From 13dc4ff51070fb488b6882d9d38bd8b6a742111b Mon Sep 17 00:00:00 2001 From: catborise Date: Fri, 14 Sep 2018 23:02:07 +0300 Subject: [PATCH] console password random and empty options modified. --- create/views.py | 2 +- vrtManager/create.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/create/views.py b/create/views.py index 51280c4..3da8d17 100644 --- a/create/views.py +++ b/create/views.py @@ -139,7 +139,7 @@ def create_instance(request, compute_id): try: conn.create_instance(data['name'], data['memory'], data['vcpu'], data['host_model'], uuid, volumes, data['cache_mode'], data['networks'], data['virtio'], - data["console_pass"], data["listener_addr"], None, data["video"], + data["listener_addr"], None, data["video"], data["console_pass"], data['mac']) create_instance = Instance(compute_id=compute_id, name=data['name'], uuid=uuid) create_instance.save() diff --git a/vrtManager/create.py b/vrtManager/create.py index 58c2c82..1770c8a 100644 --- a/vrtManager/create.py +++ b/vrtManager/create.py @@ -149,7 +149,7 @@ class wvmCreate(wvmConnect): vol = self.get_volume_by_path(path) vol.delete() - def create_instance(self, name, memory, vcpu, host_model, uuid, images, cache_mode, networks, virtio, console_pass, listen_addr, nwfilter=None, video="cirrus", mac=None ): + def create_instance(self, name, memory, vcpu, host_model, uuid, images, cache_mode, networks, virtio, listen_addr, nwfilter=None, video="cirrus", console_pass="random", mac=None): """ Create VM function """ @@ -236,8 +236,11 @@ class wvmCreate(wvmConnect): xml += """""" xml += """""" - if console_pass is None: console_pass = "passwd='" + util.randomPasswd() + "'" - else: console_pass = "passwd='" + console_pass + "'" + if console_pass == "random": + console_pass = "passwd='" + util.randomPasswd() + "'" + else: + if not console_pass == "": + console_pass = "passwd='" + console_pass + "'" xml += """