From c5c8d29dfff245071b59ceb860c67847278bf9b6 Mon Sep 17 00:00:00 2001 From: savichev Date: Wed, 30 Mar 2016 12:48:15 +0500 Subject: [PATCH 1/9] Update requirements.txt Warning! this string installing libxml2-python version 2.9.2 --- conf/requirements.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conf/requirements.txt b/conf/requirements.txt index 676876f..a9e437f 100644 --- a/conf/requirements.txt +++ b/conf/requirements.txt @@ -2,4 +2,6 @@ Django==1.8.2 websockify==0.6.0 gunicorn==19.3.0 libvirt-python==1.2.16 -http://github.com/retspen/retspen.github.io/raw/master/libxml2-python-2.9.1.tar.gz +#http://github.com/retspen/retspen.github.io/raw/master/libxml2-python-2.9.1.tar.gz +#Warning! this string installing libxml2-python version 2.9.2 +git+http://github.com/GNOME/libxml2.git#egg=subdir&subdirectory=python From 90fc5db411f4136d9d665bccc7f52a6835dec40f Mon Sep 17 00:00:00 2001 From: savichev Date: Wed, 30 Mar 2016 14:51:16 +0500 Subject: [PATCH 2/9] Update requirements.txt --- conf/requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/requirements.txt b/conf/requirements.txt index a9e437f..f4b2901 100644 --- a/conf/requirements.txt +++ b/conf/requirements.txt @@ -3,5 +3,4 @@ websockify==0.6.0 gunicorn==19.3.0 libvirt-python==1.2.16 #http://github.com/retspen/retspen.github.io/raw/master/libxml2-python-2.9.1.tar.gz -#Warning! this string installing libxml2-python version 2.9.2 -git+http://github.com/GNOME/libxml2.git#egg=subdir&subdirectory=python +git+https://git.gnome.org/browse/libxml2@v2.9.1#egg=libxml2-python&subdirectory=python From 9b5d745fb909bd651fea8f9880b2debac6d11791 Mon Sep 17 00:00:00 2001 From: savichev Date: Wed, 30 Mar 2016 18:15:35 +0500 Subject: [PATCH 3/9] Update requirements.txt --- conf/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/requirements.txt b/conf/requirements.txt index f4b2901..0dd5c0c 100644 --- a/conf/requirements.txt +++ b/conf/requirements.txt @@ -3,4 +3,4 @@ websockify==0.6.0 gunicorn==19.3.0 libvirt-python==1.2.16 #http://github.com/retspen/retspen.github.io/raw/master/libxml2-python-2.9.1.tar.gz -git+https://git.gnome.org/browse/libxml2@v2.9.1#egg=libxml2-python&subdirectory=python +"http://git.gnome.org/browse/libxml2/snapshot/libxml2-2.9.1.tar.gz#egg=libxml2-python&subdirectory=python" From 2f63d35804f1d3bb24ba1930ea2fd59910a633ef Mon Sep 17 00:00:00 2001 From: retspen Date: Wed, 30 Mar 2016 16:24:22 +0300 Subject: [PATCH 4/9] Updated Python dependencies --- conf/requirements.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/requirements.txt b/conf/requirements.txt index 0dd5c0c..e01113b 100644 --- a/conf/requirements.txt +++ b/conf/requirements.txt @@ -1,6 +1,6 @@ -Django==1.8.2 -websockify==0.6.0 +Django==1.8.11 +websockify==0.8.0 gunicorn==19.3.0 -libvirt-python==1.2.16 +libvirt-python==1.3.2 #http://github.com/retspen/retspen.github.io/raw/master/libxml2-python-2.9.1.tar.gz -"http://git.gnome.org/browse/libxml2/snapshot/libxml2-2.9.1.tar.gz#egg=libxml2-python&subdirectory=python" +http://git.gnome.org/browse/libxml2/snapshot/libxml2-2.9.1.tar.gz#egg=libxml2-python&subdirectory=python From ee2b97d62f3f77033441311631a1af4b6dae3090 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sat, 16 Apr 2016 15:04:28 +0200 Subject: [PATCH 5/9] Retreive all RBD hosts (and their port if defined) from pool definition during instance creation --- vrtManager/create.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/vrtManager/create.py b/vrtManager/create.py index 1d37300..d9f5350 100644 --- a/vrtManager/create.py +++ b/vrtManager/create.py @@ -7,9 +7,17 @@ from webvirtcloud.settings import QEMU_CONSOLE_DEFAULT_TYPE def get_rbd_storage_data(stg): xml = stg.XMLDesc(0) ceph_user = util.get_xml_path(xml, "/pool/source/auth/@username") - ceph_host = util.get_xml_path(xml, "/pool/source/host/@name") - secrt_uuid = util.get_xml_path(xml, "/pool/source/auth/secret/@uuid") - return ceph_user, secrt_uuid, ceph_host + + def get_ceph_hosts(ctx): + hosts = [] + for host in ctx.xpathEval("/pool/source/host"): + name = host.prop("name") + if name: + hosts.append({'name': name, 'port': host.prop("port")}) + return hosts + ceph_hosts = util.get_xml_path(xml, func=get_ceph_hosts) + secret_uuid = util.get_xml_path(xml, "/pool/source/auth/secret/@uuid") + return ceph_user, secret_uuid, ceph_hosts class wvmCreate(wvmConnect): @@ -162,15 +170,23 @@ class wvmCreate(wvmConnect): stg_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type") if stg_type == 'rbd': - ceph_user, secrt_uuid, ceph_host = get_rbd_storage_data(stg) + ceph_user, secret_uuid, ceph_hosts = get_rbd_storage_data(stg) xml += """ - - - """ % (img_type, ceph_user, secrt_uuid, image, ceph_host) + """ % (img_type, ceph_user, secret_uuid, image) + if isinstance(ceph_hosts, list): + for host in ceph_hosts: + if host.get('port'): + xml += """ + """ % (host.get('name'), host.get('port')) + else: + xml += """ + """ % host.get('name') + xml += """ + """ else: xml += """ From e1d3be17f1b4e66e0e1f940b4c2ee5c13a6d3a6c Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sat, 16 Apr 2016 15:06:39 +0200 Subject: [PATCH 6/9] Fix pep8 errors --- accounts/templatetags/tags_fingerprint.py | 2 +- instances/views.py | 2 +- vrtManager/instance.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/accounts/templatetags/tags_fingerprint.py b/accounts/templatetags/tags_fingerprint.py index d15c473..5688039 100644 --- a/accounts/templatetags/tags_fingerprint.py +++ b/accounts/templatetags/tags_fingerprint.py @@ -9,4 +9,4 @@ register = template.Library() def ssh_to_fingerprint(line): key = base64.b64decode(line.strip().split()[1].encode('ascii')) fp_plain = hashlib.md5(key).hexdigest() - return ':'.join(a+b for a, b in zip(fp_plain[::2], fp_plain[1::2])) + return ':'.join(a + b for a, b in zip(fp_plain[::2], fp_plain[1::2])) diff --git a/instances/views.py b/instances/views.py index 29a1a1b..8d9afd9 100644 --- a/instances/views.py +++ b/instances/views.py @@ -103,7 +103,7 @@ def instances(request): conn.start(name) addlogmsg(request.user.username, instance.name, msg) return HttpResponseRedirect(request.get_full_path()) - + if 'getvvfile' in request.POST: msg = _("Send console.vv file") addlogmsg(request.user.username, instance.name, msg) diff --git a/vrtManager/instance.py b/vrtManager/instance.py index 4218aa4..0f3b258 100644 --- a/vrtManager/instance.py +++ b/vrtManager/instance.py @@ -81,7 +81,7 @@ class wvmInstances(wvmConnect): dom = self.get_instance(name) xml = dom.XMLDesc(VIR_DOMAIN_XML_SECURE) self.wvm.defineXML(xml) - + def graphics_type(self, name): inst = self.get_instance(name) console_type = util.get_xml_path(inst.XMLDesc(0), "/domain/devices/graphics/@type") From 9520282a4b147043551e47f88334219ad5cb1f7b Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sun, 17 Apr 2016 23:41:40 +0200 Subject: [PATCH 7/9] Add possibility to configure HDD cache mode during instance creation --- create/forms.py | 1 + create/templates/create_instance.html | 20 ++++++++++++++++++++ create/views.py | 7 ++++++- vrtManager/create.py | 21 ++++++++++++++++----- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/create/forms.py b/create/forms.py index 5b9fab5..fccf944 100644 --- a/create/forms.py +++ b/create/forms.py @@ -40,6 +40,7 @@ class NewVMForm(forms.Form): storage = forms.CharField(max_length=20, required=False) template = forms.CharField(required=False) images = forms.CharField(required=False) + cache_mode = forms.CharField(error_messages={'required': _('Please select HDD cache mode')}) hdd_size = forms.IntegerField(required=False) meta_prealloc = forms.BooleanField(required=False) virtio = forms.BooleanField(required=False) diff --git a/create/templates/create_instance.html b/create/templates/create_instance.html index 37189b7..f9a0692 100644 --- a/create/templates/create_instance.html +++ b/create/templates/create_instance.html @@ -77,6 +77,16 @@ +
+ +
+ +
+
@@ -159,6 +169,16 @@
+
+ +
+ +
+
diff --git a/create/views.py b/create/views.py index 5b03f8c..c3e1139 100644 --- a/create/views.py +++ b/create/views.py @@ -42,6 +42,7 @@ def create_instance(request, compute_id): networks = sorted(conn.get_networks()) instances = conn.get_instances() get_images = sorted(conn.get_storages_images()) + cache_modes = sorted(conn.get_cache_modes().items()) mac_auto = util.randomMAC() except libvirtError as lib_err: error_messages.append(lib_err) @@ -123,11 +124,15 @@ def create_instance(request, compute_id): volumes[path] = conn.get_volume_type(path) except libvirtError as lib_err: error_messages.append(lib_err.message) + if data['cache_mode'] not in conn.get_cache_modes(): + error_msg = _("Invalid cache mode") + error_messages.append(error_msg) if not error_messages: uuid = util.randomUUID() try: conn.create_instance(data['name'], data['memory'], data['vcpu'], data['host_model'], - uuid, volumes, data['networks'], data['virtio'], data['mac']) + uuid, volumes, data['cache_mode'], data['networks'], data['virtio'], + data['mac']) create_instance = Instance(compute_id=compute_id, name=data['name'], uuid=uuid) create_instance.save() return HttpResponseRedirect(reverse('instance', args=[compute_id, data['name']])) diff --git a/vrtManager/create.py b/vrtManager/create.py index d9f5350..cc1f7f2 100644 --- a/vrtManager/create.py +++ b/vrtManager/create.py @@ -48,6 +48,17 @@ class wvmCreate(wvmConnect): """Get guest capabilities""" return util.get_xml_path(self.get_cap_xml(), "/capabilities/host/cpu/arch") + def get_cache_modes(self): + """Get cache available modes""" + return { + 'default': 'Default', + 'none': 'Disabled', + 'writethrough': 'Write through', + 'writeback': 'Write back', + 'directsync': 'Direct sync', # since libvirt 0.9.5 + 'unsafe': 'Unsafe', # since libvirt 0.9.7 + } + def create_volume(self, storage, name, size, format='qcow2', metadata=False): size = int(size) * 1073741824 stg = self.get_storage(storage) @@ -129,7 +140,7 @@ class wvmCreate(wvmConnect): vol = self.get_volume_by_path(path) vol.delete() - def create_instance(self, name, memory, vcpu, host_model, uuid, images, networks, virtio, mac=None): + def create_instance(self, name, memory, vcpu, host_model, uuid, images, cache_mode, networks, virtio, mac=None): """ Create VM function """ @@ -172,11 +183,11 @@ class wvmCreate(wvmConnect): if stg_type == 'rbd': ceph_user, secret_uuid, ceph_hosts = get_rbd_storage_data(stg) xml += """ - + - """ % (img_type, ceph_user, secret_uuid, image) + """ % (img_type, cache_mode, ceph_user, secret_uuid, image) if isinstance(ceph_hosts, list): for host in ceph_hosts: if host.get('port'): @@ -189,8 +200,8 @@ class wvmCreate(wvmConnect): """ else: xml += """ - - """ % (img_type, image) + + """ % (img_type, cache_mode, image) if virtio: xml += """""" % (disk_letters.pop(0),) From 69b955261f43ca4a393b2afa4b98208c8cf4265d Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 18 Apr 2016 00:25:46 +0200 Subject: [PATCH 8/9] Unified VNC/SPICE console interfaces with bootstrap --- console/templates/console-base.html | 127 +++++++ console/templates/console-spice.html | 481 ++++++++++----------------- console/templates/console-vnc.html | 154 +++++---- 3 files changed, 374 insertions(+), 388 deletions(-) create mode 100644 console/templates/console-base.html diff --git a/console/templates/console-base.html b/console/templates/console-base.html new file mode 100644 index 0000000..d0e0e7a --- /dev/null +++ b/console/templates/console-base.html @@ -0,0 +1,127 @@ +{% load i18n %} + + + + + + + + + + +{% block head %}{% endblock %} + + + + + +
+{% block content %}{% endblock %} +
+ + + + + +{% block foot %}{% endblock %} + + diff --git a/console/templates/console-spice.html b/console/templates/console-spice.html index 4704ef3..1a1cbf8 100644 --- a/console/templates/console-spice.html +++ b/console/templates/console-spice.html @@ -1,333 +1,194 @@ +{% extends "console-base.html" %} {% load i18n %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +{% load staticfiles %} +{% block head %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - -
-
-
+ } - - - + var password = '{{ console_passwd }}'; + log_info('Connecting ...'); + connect(uri,password); + +{% endblock %} diff --git a/console/templates/console-vnc.html b/console/templates/console-vnc.html index 59d0afa..b0a3334 100644 --- a/console/templates/console-vnc.html +++ b/console/templates/console-vnc.html @@ -1,48 +1,37 @@ +{% extends "console-base.html" %} {% load i18n %} - - - - - - - - -
-
- - - - - -
-
{% trans "Loading..." %}
-
-
- - - - - +{% load staticfiles %} +{% block head %} + - - -
-
-
+{% endblock %} + +{% block navbarmenu %} + +
  • {% trans "Show Keyboad" %}
  • +{% endblock %} + +{% block content %} +
    {% trans "Canvas not supported." %} -
    +
    + + + + + +{% endblock %} + +{% block foot %} - - +{% endblock %} From 17cb7ace8893d8a82fe9d2e64d5bb21aa3406bd8 Mon Sep 17 00:00:00 2001 From: retspen Date: Thu, 21 Apr 2016 13:14:20 +0300 Subject: [PATCH 9/9] Fixed #105 --- create/templates/create_instance.html | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/create/templates/create_instance.html b/create/templates/create_instance.html index f9a0692..9df7326 100644 --- a/create/templates/create_instance.html +++ b/create/templates/create_instance.html @@ -77,6 +77,13 @@
    +
    + +
    + +
    + +
    @@ -278,6 +285,7 @@
    +
    -
    - -
    - -
    - -
    @@ -435,4 +436,4 @@ var editor = ace.edit("editor"); editor.getSession().setMode("ace/mode/xml"); -{% endblock %} \ No newline at end of file +{% endblock %}