Added vm_name parameter to create_vm

This commit is contained in:
M.Ravi 2017-06-21 13:13:10 +05:30
parent 2959159863
commit 385df4e069

View file

@ -239,7 +239,7 @@ class OpenNebulaManager():
)
)
def create_vm(self, template_id, specs, ssh_key=None):
def create_vm(self, template_id, specs, ssh_key=None, vm_name=None):
template = self.get_template(template_id)
vm_specs_formatter = """<TEMPLATE>
@ -287,14 +287,16 @@ class OpenNebulaManager():
image=image,
image_uname=image_uname)
if vm_name is not None:
vm_specs += """<NAME>{template_vm_name}</NAME>
""".format(template_vm_name=vm_name)
vm_specs += "<CONTEXT>"
if ssh_key:
vm_specs += """<CONTEXT>
<SSH_PUBLIC_KEY>{ssh}</SSH_PUBLIC_KEY>
<NETWORK>YES</NETWORK>
vm_specs += "<SSH_PUBLIC_KEY>{ssh}</SSH_PUBLIC_KEY>".format(ssh=ssh_key)
vm_specs += """<NETWORK>YES</NETWORK>
</CONTEXT>
</TEMPLATE>
""".format(ssh=ssh_key)
"""
vm_id = self.client.call(oca.VmTemplate.METHODS['instantiate'],
template.id,
'',