From 1aea7baadaf431cc02d8039e55d1b96b6d32fb51 Mon Sep 17 00:00:00 2001 From: catborise Date: Thu, 3 Jan 2019 13:56:07 +0300 Subject: [PATCH 01/11] update requirements --- conf/requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/requirements.txt b/conf/requirements.txt index 49903c0..d8c5a5f 100644 --- a/conf/requirements.txt +++ b/conf/requirements.txt @@ -1,7 +1,7 @@ -Django==1.11.14 +Django==1.11.17 websockify==0.8.0 gunicorn==19.9.0 -lxml==4.2.3 -libvirt-python==4.4.0 +lxml==4.2.5 +libvirt-python==4.10.0 pytz From fc6761aabcf189c91d58b410153bcc3637106188 Mon Sep 17 00:00:00 2001 From: catborise Date: Wed, 9 Jan 2019 14:16:51 +0300 Subject: [PATCH 02/11] Add destination storage option for instance creation from a template. --- create/templates/create_instance.html | 19 ++++++++++++++++++- create/views.py | 2 +- vrtManager/create.py | 8 ++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/create/templates/create_instance.html b/create/templates/create_instance.html index 34ee73c..bb3b0a2 100644 --- a/create/templates/create_instance.html +++ b/create/templates/create_instance.html @@ -441,7 +441,7 @@
- {% if storages %} {% for storage in storages %} @@ -458,6 +458,20 @@
+
+ +
+ +
+
@@ -697,6 +711,9 @@ }); }); $("#template").removeAttr("disabled"); + $("#storage").val(pool).change(); + $("#storage").removeAttr("disabled"); + } function get_disk_bus_choices(compute_id, dev_idx, disk_type){ diff --git a/create/views.py b/create/views.py index 0bb2133..9bd881a 100644 --- a/create/views.py +++ b/create/views.py @@ -134,7 +134,7 @@ def create_instance(request, compute_id): error_msg = _("Image has already exist. Please check volumes or change instance name") error_messages.append(error_msg) else: - clone_path = conn.clone_from_template(data['name'], templ_path, metadata=meta_prealloc) + clone_path = conn.clone_from_template(data['name'], templ_path, data['storage'], metadata=meta_prealloc) volume = dict() volume['path'] = clone_path volume['type'] = conn.get_volume_type(clone_path) diff --git a/vrtManager/create.py b/vrtManager/create.py index 5a41a6a..fd3203a 100644 --- a/vrtManager/create.py +++ b/vrtManager/create.py @@ -118,9 +118,13 @@ class wvmCreate(wvmConnect): vol = self.get_volume_by_path(vol_path) return vol.storagePoolLookupByVolume() - def clone_from_template(self, clone, template, metadata=False, owner=default_owner): + def clone_from_template(self, clone, template, storage=None, metadata=False, owner=default_owner): vol = self.get_volume_by_path(template) - stg = vol.storagePoolLookupByVolume() + if not storage: + stg = vol.storagePoolLookupByVolume() + else: + stg = self.get_storage(storage) + storage_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type") format = util.get_xml_path(vol.XMLDesc(0), "/volume/target/format/@type") if storage_type == 'dir': From 6b06ed25ff44d604d109f6f9235c458923537f4b Mon Sep 17 00:00:00 2001 From: catborise Date: Wed, 9 Jan 2019 15:31:42 +0300 Subject: [PATCH 03/11] Add disk cache info for instance --- instances/templates/instance.html | 4 ++- vrtManager/instance.py | 43 ++++++++++++------------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/instances/templates/instance.html b/instances/templates/instance.html index f0a6388..4413b51 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -685,7 +685,9 @@ data-trigger="focus" data-toggle="popover" data-html="true" - data-content="Bus: {{ disk.bus }}
Format: {{ disk.format }}"> + data-content="Bus: {{ disk.bus }}
+ Format: {{ disk.format }}
+ Cache: {{ disk.cache }}"> {{ disk.dev }} diff --git a/vrtManager/instance.py b/vrtManager/instance.py index 6ebb5c8..c0c53af 100644 --- a/vrtManager/instance.py +++ b/vrtManager/instance.py @@ -201,7 +201,6 @@ class wvmInstance(wvmConnect): return util.get_xml_path(self._XMLDesc(0), func=filterrefs) - def get_description(self): description = util.get_xml_path(self._XMLDesc(0), "/domain/description") return description if description else '' @@ -248,13 +247,8 @@ class wvmInstance(wvmConnect): def get_disk_devices(self): def disks(doc): result = [] - dev = None - volume = None - storage = None - src_fl = None - disk_format = None - used_size = None - disk_size = None + dev = volume = storage = src_file = None + disk_format = used_size = disk_size = None for disk in doc.xpath('/domain/devices/disk'): device = disk.xpath('@device')[0] @@ -262,13 +256,14 @@ class wvmInstance(wvmConnect): try: dev = disk.xpath('target/@dev')[0] bus = disk.xpath('target/@bus')[0] - src_fl = disk.xpath('source/@file|source/@dev|source/@name|source/@volume')[0] + src_file = disk.xpath('source/@file|source/@dev|source/@name|source/@volume')[0] try: disk_format = disk.xpath('driver/@type')[0] + disk_cache = disk.xpath('driver/@cache')[0] except: pass try: - vol = self.get_volume_by_path(src_fl) + vol = self.get_volume_by_path(src_file) volume = vol.name() disk_size = vol.info()[1] @@ -276,13 +271,13 @@ class wvmInstance(wvmConnect): stg = vol.storagePoolLookupByVolume() storage = stg.name() except libvirtError: - volume = src_fl + volume = src_file except: pass finally: result.append( - {'dev': dev, 'bus': bus, 'image': volume, 'storage': storage, 'path': src_fl, - 'format': disk_format, 'size': disk_size, 'used': used_size}) + {'dev': dev, 'bus': bus, 'image': volume, 'storage': storage, 'path': src_file, + 'format': disk_format, 'size': disk_size, 'used': used_size, 'cache': disk_cache}) return result return util.get_xml_path(self._XMLDesc(0), func=disks) @@ -290,10 +285,8 @@ class wvmInstance(wvmConnect): def get_media_devices(self): def disks(doc): result = [] - dev = None - volume = None - storage = None - src_fl = None + dev = volume = storage = None + src_file = None for media in doc.xpath('/domain/devices/disk'): device = media.xpath('@device')[0] if device == 'cdrom': @@ -301,18 +294,18 @@ class wvmInstance(wvmConnect): dev = media.xpath('target/@dev')[0] bus = media.xpath('target/@bus')[0] try: - src_fl = media.xpath('source/@file')[0] - vol = self.get_volume_by_path(src_fl) + src_file = media.xpath('source/@file')[0] + vol = self.get_volume_by_path(src_file) volume = vol.name() stg = vol.storagePoolLookupByVolume() storage = stg.name() except: - src_fl = None - volume = src_fl + src_file = None + volume = src_file except: pass finally: - result.append({'dev': dev, 'image': volume, 'storage': storage, 'path': src_fl, 'bus': bus}) + result.append({'dev': dev, 'image': volume, 'storage': storage, 'path': src_file, 'bus': bus}) return result return util.get_xml_path(self._XMLDesc(0), func=disks) @@ -490,11 +483,9 @@ class wvmInstance(wvmConnect): return telnet_port def get_console_listen_addr(self): - listen_addr = util.get_xml_path(self._XMLDesc(0), - "/domain/devices/graphics/@listen") + listen_addr = util.get_xml_path(self._XMLDesc(0), "/domain/devices/graphics/@listen") if listen_addr is None: - listen_addr = util.get_xml_path(self._XMLDesc(0), - "/domain/devices/graphics/listen/@address") + listen_addr = util.get_xml_path(self._XMLDesc(0), "/domain/devices/graphics/listen/@address") if listen_addr is None: return "127.0.0.1" return listen_addr From 96efde814a00b9289b2b697dd29fb246b6d44209 Mon Sep 17 00:00:00 2001 From: catborise Date: Tue, 15 Jan 2019 15:55:05 +0300 Subject: [PATCH 04/11] Add boot menu/order functionality. Minor improvements. Some bug fixes --- instances/templates/add_instance_volume.html | 2 +- instances/templates/instance.html | 659 +++++++++++-------- instances/views.py | 38 +- static/css/webvirtcloud.css | 18 + vrtManager/instance.py | 120 +++- 5 files changed, 553 insertions(+), 284 deletions(-) diff --git a/instances/templates/add_instance_volume.html b/instances/templates/add_instance_volume.html index 9cea2fc..6b0fed3 100644 --- a/instances/templates/add_instance_volume.html +++ b/instances/templates/add_instance_volume.html @@ -1,6 +1,6 @@ {% load i18n %} {% if request.user.is_superuser %} - + diff --git a/instances/templates/instance.html b/instances/templates/instance.html index 4413b51..21d1531 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -526,8 +526,8 @@
-
- {% if request.user.is_superuser and status == 5 %} -
{% csrf_token %} -
-
- -
-
-
- {% endif %} - {% for cd in media %} + {% if request.user.is_superuser %} +
+

{% trans 'Autostart' %}

{% csrf_token %}
- - {% trans "CDROM" %} {{ forloop.counter }} - - {% if not cd.image %} -
- -
-
- {% if media_iso and allow_admin_or_not_template %} - - {% if status == 5 %} - - {% endif %} - {% else %} - - {% endif %} -
+
+

{% trans "Autostart your instance when host server is power on " %} + {% ifequal autostart 0 %} + {% else %} -

- -
-
- - {% if allow_admin_or_not_template %} - - {% else %} - - {% endif %} -
- {% endif %} + + {% endifequal %} +

+
- {% endfor %} -
-
-
-

- {% trans "Instance Volumes" %} - {% include 'add_instance_volume.html' %} -

-
+

{% trans 'Boot Order' %}

+
{% csrf_token %} +
+
+ {% ifequal status 5 %} +

{% trans "Enable Boot Menu for your instance when it starts up " %} + {% ifequal bootmenu 0 %} + + {% else %} + + {% endifequal %} + {% else %} +

{% trans "**** Please shutdown instance to modify boot menu ****" %} + {% endifequal %} +

+
+
+
+ {% ifequal bootmenu 1 %} +
+
+ {% for idx, val in boot_order.items %} + + {% endfor %} +
+
+
{% csrf_token %} + +
+
+
+ {% for disk in disks %} + + {% endfor %} + {% for cd in media %} + + {% endfor %} + {% for net in networks %} + + {% endfor %} +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ {% endifequal %} +
+
+ +
+ {% if status == 5 %} +
{% csrf_token %} +

+ {% trans "Instance Media" %} + +

+
+ {% endif %} + {% for cd in media %} +
{% csrf_token %} +
+ + {% trans "CDROM" %} {{ forloop.counter }} + + {% if not cd.image %} +
+ +
+
+ {% if media_iso and allow_admin_or_not_template %} + + {% if status == 5 %} + + {% endif %} + {% else %} + + {% endif %} +
+ {% else %} +
+ +
+
+ + {% if allow_admin_or_not_template %} + + {% else %} + + {% endif %} +
+ {% endif %} +
+
+ {% endfor %} + +

+ {% trans "Instance Volume" %} + {% include 'add_instance_volume.html' %} +

+ +
@@ -726,21 +793,167 @@
{% trans "Device" %}
-
-
+
+
+
+

+ {% trans "Assign network device to bridge" %} + {% include 'add_instance_network_block.html' %} +

+

{% trans "Network devices" %}

+
+
{% csrf_token %} + {% for network in networks %} +
+
+ +
+
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
- {% if request.user.is_superuser %} -
-

{% trans "Autostart your instance when host server is power on" %}

- {% csrf_token %} - {% ifequal autostart 0 %} - + +
+ {% endfor %} + +
+
+ +
+
+

{% trans "For migration both host servers must have equal settings and OS type" %}

+
{% csrf_token %} +
+ +
+

{{ compute.name }}

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ {% if computes_count != 1 %} + {% else %} - + + {% endif %} +
+

+
+
+

{% trans "If you need to edit xml please Power Off the instance" %}

+
{% csrf_token %} +
+ +
+ {% ifequal status 5 %} + + + {% else %} + {% endifequal %}
+
+
+

+ {% trans "Instance owners" %} + {% include 'add_instance_owner_block.html' %} +

+
+
+ + + {% for userinstance in userinstances %} + + + + + {% endfor %} + +
{{ userinstance.user }} +
{% csrf_token %} + + +
+
+
+
+
{% endif %} {% if request.user.is_superuser or userinstance.is_vnc %}
@@ -857,65 +1070,6 @@
{% endif %} - {% if request.user.is_superuser %} -
-

- {% trans "Assign network device to bridge" %} - {% include 'add_instance_network_block.html' %} -

-

{% trans "Network devices" %}

-
-
{% csrf_token %} - {% for network in networks %} -
-
- -
-
-
- - - - -
-
- - - - -
-
- - - - -
-
- - -
- {% endfor %} -
-
-
- -
- {% endif %} {% if request.user.is_superuser or request.user.userattributes.can_clone_instances %}

{% trans "Create a clone" %}

@@ -923,25 +1077,25 @@
{% if request.user.is_superuser %} -
- -
-
- -
+
+ +
+
+ +
{% elif clone_instance_auto_name %} -
- -
+
+ +
{% else %} -
- -
+
+ +
{% endif %}
{% if request.user.is_superuser %} @@ -1006,84 +1160,6 @@
- {% endif %} - {% if request.user.is_superuser %} -
-

{% trans "For migration both host servers must have equal settings and OS type" %}

-
{% csrf_token %} -
- -
-

{{ compute.name }}

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- {% if computes_count != 1 %} - - {% else %} - - {% endif %} -
-

-
-
-

{% trans "If you need to edit xml please Power Off the instance" %}

-
{% csrf_token %} -
- -
- {% ifequal status 5 %} - - - {% else %} - - {% endifequal %} -
-
-
- {% endif %} - {% if request.user.is_superuser or request.user.userattributes.can_clone_instances %}
{% csrf_token %}
@@ -1113,36 +1189,6 @@
{% endif %} - {% if request.user.is_superuser %} -
-
-

- {% trans "Instance owners" %} - {% include 'add_instance_owner_block.html' %} -

-
-
- - - {% for userinstance in userinstances %} - - - - - {% endfor %} - -
{{ userinstance.user }} - {% csrf_token %} - - - -
-
-
-
- {% endif %}
@@ -1217,7 +1263,7 @@ - None ... + {% trans 'None' %}...
@@ -1271,8 +1317,6 @@ @@ -1415,7 +1457,6 @@ }); $(document).ready(function () { // set vdi url - $.get("{% url 'vdi_url' vname %}", function(data) { $("#vdi_url_input").attr("value", data); $("#vdi_url").attr("href", data); @@ -1444,6 +1485,72 @@ $(document).ready(function(){ placement : 'top' }); }); + +