Changed VM name format for create vm when user is already logged in

This commit is contained in:
PCoder 2017-09-10 14:52:06 +05:30
parent 1836d315cd
commit 56a8ad2edf

View file

@ -59,19 +59,21 @@ def create_vm_task(self, vm_template_id, user, specs, template,
password=user.get('pass')) password=user.get('pass'))
logger.debug("Using user {user} to create VM".format( logger.debug("Using user {user} to create VM".format(
user=user.get('email'))) user=user.get('email')))
vm_name = None
else: else:
manager = OpenNebulaManager(email=settings.OPENNEBULA_USERNAME, manager = OpenNebulaManager(email=settings.OPENNEBULA_USERNAME,
password=settings.OPENNEBULA_PASSWORD) password=settings.OPENNEBULA_PASSWORD)
logger.debug("Using OpenNebula admin user to create VM") logger.debug("Using OpenNebula admin user to create VM")
vm_name = "{email}-{template_name}-{date}".format(
email=user.get('email'),
template_name=template.get('name'),
date=int(datetime.now().strftime("%s")))
vm_id = manager.create_vm( vm_id = manager.create_vm(
template_id=vm_template_id, template_id=vm_template_id,
specs=specs, specs=specs,
ssh_key=settings.ONEADMIN_USER_SSH_PUBLIC_KEY, ssh_key=settings.ONEADMIN_USER_SSH_PUBLIC_KEY,
vm_name="{email}-{template_name}-{date}".format( vm_name=vm_name
email=user.get('email'),
template_name=template.get('name'),
date=int(datetime.now().strftime("%s")))
) )
if vm_id is None: if vm_id is None: