[virt-tools-list] [PATCH v4 2/5] Add GUI to create wizard for virtuozzo containers

Mikhail Feoktistov mfeoktistov at virtuozzo.com
Mon Mar 13 12:01:51 UTC 2017


Add virtuozzo hypervisor to connection list.
Add radio buttons for choosing VM or container virtualization type.
New wizard window for setting template name for containers.
---
 ui/create.ui              | 149 +++++++++++++++++++++++++++++++++++++++++++++-
 virtManager/connect.py    |   8 ++-
 virtManager/connection.py |   1 +
 virtManager/create.py     |  58 +++++++++++++++++-
 virtinst/connection.py    |   3 +
 5 files changed, 212 insertions(+), 7 deletions(-)

diff --git a/ui/create.ui b/ui/create.ui
index d271e0d..c197a97 100644
--- a/ui/create.ui
+++ b/ui/create.ui
@@ -143,6 +143,85 @@
                             <property name="vexpand">False</property>
                             <property name="row_spacing">12</property>
                             <child>
+                              <object class="GtkVBox" id="vz-install-box">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">8</property>
+                                <child>
+                                  <object class="GtkLabel" id="label39">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Choose virtualization type</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkAlignment" id="alignment3">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="left_padding">15</property>
+                                    <child>
+                                      <object class="GtkVBox" id="vbox5">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="spacing">3</property>
+                                        <child>
+                                          <object class="GtkRadioButton" id="vz-virt-type-hvm">
+                                            <property name="label" translatable="yes">_Virtual machine</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="use_underline">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="active">True</property>
+                                            <property name="draw_indicator">True</property>
+                                            <signal name="toggled" handler="on_vz_virt_type_changed" swapped="no"/>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkRadioButton" id="vz-virt-type-exe">
+                                            <property name="label" translatable="yes">_Container</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="use_underline">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="draw_indicator">True</property>
+                                            <property name="group">vz-virt-type-hvm</property>
+                                            <signal name="toggled" handler="on_vz_virt_type_changed" swapped="no"/>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">0</property>
+                              </packing>
+                            </child>
+                            <child>
                               <object class="GtkVBox" id="virt-install-box">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
@@ -255,7 +334,7 @@
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
-                                <property name="top_attach">0</property>
+                                <property name="top_attach">1</property>
                               </packing>
                             </child>
                             <child>
@@ -334,7 +413,7 @@
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
-                                <property name="top_attach">1</property>
+                                <property name="top_attach">2</property>
                               </packing>
                             </child>
                           </object>
@@ -1620,6 +1699,72 @@ is not yet supported.</small></property>
                                 <property name="tab_fill">False</property>
                               </packing>
                             </child>
+                            <child>
+                              <object class="GtkVBox" id="vbox67">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkLabel" id="label53">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Select _container template:</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="mnemonic_widget">install-container-template</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkAlignment" id="alignment4">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="left_padding">12</property>
+                                    <child>
+                                      <object class="GtkHBox" id="hbox6">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="spacing">6</property>
+                                        <child>
+                                          <object class="GtkEntry" id="install-container-template">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">True</property>
+                                            <property name="fill">True</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="position">6</property>
+                              </packing>
+                            </child>
+                            <child type="tab">
+                              <object class="GtkLabel" id="label52">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">VZ templates</property>
+                              </object>
+                              <packing>
+                                <property name="position">6</property>
+                                <property name="tab_fill">False</property>
+                              </packing>
+                            </child>
                           </object>
                           <packing>
                             <property name="expand">True</property>
diff --git a/virtManager/connect.py b/virtManager/connect.py
index 30add14..4cec8ca 100644
--- a/virtManager/connect.py
+++ b/virtManager/connect.py
@@ -34,7 +34,8 @@ from .baseclass import vmmGObjectUI
 HV_XEN,
 HV_LXC,
 HV_QEMU_SESSION,
-HV_BHYVE) = range(5)
+HV_BHYVE,
+HV_VZ) = range(6)
 
 (CONN_SSH,
 CONN_TCP,
@@ -169,6 +170,7 @@ class vmmConnect(vmmGObjectUI):
         _add_hv_row(HV_XEN, "xen", "Xen")
         _add_hv_row(HV_LXC, "lxc", "LXC (" + _("Linux Containers") + ")")
         _add_hv_row(HV_BHYVE, "bhyve", "Bhyve")
+        _add_hv_row(HV_VZ, "vz", "Virtuozzo")
         combo.set_model(model)
         uiutil.init_combo_text_column(combo, 1)
 
@@ -384,6 +386,8 @@ class vmmConnect(vmmGObjectUI):
             hvstr = "qemu"
         elif hv == HV_BHYVE:
             hvstr = "bhyve"
+        elif hv == HV_VZ:
+            hvstr = "vz"
         else:
             hvstr = "lxc"
 
@@ -408,7 +412,7 @@ class vmmConnect(vmmGObjectUI):
             hoststr += addrstr + "/"
 
         uri = hvstr + hoststr
-        if hv in (HV_QEMU, HV_BHYVE):
+        if hv in (HV_QEMU, HV_BHYVE, HV_VZ):
             uri += "system"
         elif hv == HV_QEMU_SESSION:
             uri += "session"
diff --git a/virtManager/connection.py b/virtManager/connection.py
index 4997918..96c6a7b 100644
--- a/virtManager/connection.py
+++ b/virtManager/connection.py
@@ -348,6 +348,7 @@ class vmmConnection(vmmGObject):
     is_container = property(lambda s: getattr(s, "_backend").is_container)
     is_lxc = property(lambda s: getattr(s, "_backend").is_lxc)
     is_openvz = property(lambda s: getattr(s, "_backend").is_openvz)
+    is_vz = property(lambda s: getattr(s, "_backend").is_vz)
     is_xen = property(lambda s: getattr(s, "_backend").is_xen)
     is_remote = property(lambda s: getattr(s, "_backend").is_remote)
     is_qemu = property(lambda s: getattr(s, "_backend").is_qemu)
diff --git a/virtManager/create.py b/virtManager/create.py
index 7d53110..603dd7c 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -56,7 +56,8 @@ DEFAULT_MEM = 1024
  INSTALL_PAGE_PXE,
  INSTALL_PAGE_IMPORT,
  INSTALL_PAGE_CONTAINER_APP,
- INSTALL_PAGE_CONTAINER_OS) = range(6)
+ INSTALL_PAGE_CONTAINER_OS,
+ INSTALL_PAGE_VZ_TEMPLATE) = range(7)
 
 # Column numbers for os type/version list models
 (OS_COL_ID,
@@ -156,6 +157,7 @@ class vmmCreate(vmmGObjectUI):
             "on_arch_changed": self._arch_changed,
             "on_virt_type_changed": self._virt_type_changed,
             "on_machine_changed": self._machine_changed,
+            "on_vz_virt_type_changed": self._vz_virt_type_changed,
 
             "on_install_cdrom_radio_toggled": self._local_media_toggled,
             "on_install_iso_entry_changed": self._iso_changed,
@@ -375,6 +377,7 @@ class vmmCreate(vmmGObjectUI):
         self.widget("create-conn").set_active(-1)
         activeconn = self._populate_conn_list(urihint)
         self.widget("arch-expander").set_expanded(False)
+        self.widget("vz-virt-type-hvm").set_active(True)
 
         if self._set_conn(activeconn) is False:
             return False
@@ -418,6 +421,9 @@ class vmmCreate(vmmGObjectUI):
         # Install container OS
         self.widget("install-oscontainer-fs").set_text("")
 
+        # Install VZ container from template
+        self.widget("install-container-template").set_text("centos-7-x86_64")
+
         # Storage
         self.widget("enable-storage").set_active(True)
         self._addstorage.reset_state()
@@ -441,6 +447,7 @@ class vmmCreate(vmmGObjectUI):
         can_storage = (is_local or is_storage_capable)
         is_pv = (self._capsinfo.os_type == "xen")
         is_container = self.conn.is_container()
+        is_vz = self.conn.is_vz()
         can_remote_url = self.conn.get_backend().support_remote_url_install()
 
         installable_arch = (self._capsinfo.arch in
@@ -522,6 +529,7 @@ class vmmCreate(vmmGObjectUI):
         method_container_app.set_active(True)
         self.widget("virt-install-box").set_visible(not is_container)
         self.widget("container-install-box").set_visible(is_container)
+        self.widget("vz-install-box").set_visible(is_vz)
 
         show_dtb = ("arm" in self._capsinfo.arch or
                     "microblaze" in self._capsinfo.arch or
@@ -585,6 +593,21 @@ class vmmCreate(vmmGObjectUI):
                  "are not loaded. Your virtual machines may perform poorly.")
                 self._show_startup_warning(error)
 
+        elif self.conn.is_vz():
+            has_hvm_guests = False
+            has_exe_guests = False
+            for g in self.conn.caps.guests:
+                if g.os_type == "hvm":
+                    has_hvm_guests = True
+                if g.os_type == "exe":
+                    has_exe_guests = True
+
+            self.widget("vz-virt-type-hvm").set_sensitive(has_hvm_guests)
+            self.widget("virt-install-box").set_sensitive(has_hvm_guests)
+            self.widget("vz-virt-type-exe").set_sensitive(has_exe_guests)
+            if not has_hvm_guests and has_exe_guests:
+                self.widget("vz-virt-type-exe").set_active(True)
+
         # Install local
         iso_option = self.widget("install-iso-radio")
         cdrom_option = self.widget("install-cdrom-radio")
@@ -1073,6 +1096,8 @@ class vmmCreate(vmmGObjectUI):
             install = _("Application container")
         elif instmethod == INSTALL_PAGE_CONTAINER_OS:
             install = _("Operating system container")
+        elif instmethod == INSTALL_PAGE_VZ_TEMPLATE:
+            install = _("Virtuozzo container")
 
         osstr = ""
         have_os = True
@@ -1109,6 +1134,9 @@ class vmmCreate(vmmGObjectUI):
             check_visible=True)
 
     def _get_config_install_page(self):
+        if self.widget("vz-install-box").get_visible():
+            if self.widget("vz-virt-type-exe").get_active():
+                return INSTALL_PAGE_VZ_TEMPLATE
         if self.widget("virt-install-box").get_visible():
             if self.widget("method-local").get_active():
                 return INSTALL_PAGE_ISO
@@ -1126,11 +1154,13 @@ class vmmCreate(vmmGObjectUI):
 
     def _is_container_install(self):
         return self._get_config_install_page() in [INSTALL_PAGE_CONTAINER_APP,
-                                                   INSTALL_PAGE_CONTAINER_OS]
+                                                   INSTALL_PAGE_CONTAINER_OS,
+                                                   INSTALL_PAGE_VZ_TEMPLATE]
     def _should_skip_disk_page(self):
         return self._get_config_install_page() in [INSTALL_PAGE_IMPORT,
                                                    INSTALL_PAGE_CONTAINER_APP,
-                                                   INSTALL_PAGE_CONTAINER_OS]
+                                                   INSTALL_PAGE_CONTAINER_OS,
+                                                   INSTALL_PAGE_VZ_TEMPLATE]
 
     def _get_config_os_info(self):
         drow = uiutil.get_list_selected_row(self.widget("install-os-type"))
@@ -1293,6 +1323,13 @@ class vmmCreate(vmmGObjectUI):
 
         self._change_caps(self._capsinfo.os_type, self._capsinfo.arch, domtype)
 
+    def _vz_virt_type_changed(self, ignore):
+        is_hvm = self.widget("vz-virt-type-hvm").get_active()
+        self.widget("virt-install-box").set_sensitive(is_hvm)
+        if is_hvm:
+            self._change_caps("hvm")
+        else:
+            self._change_caps("exe")
 
     # Install page listeners
     def _detectable_media_widget_changed(self, widget, checkfocus=True):
@@ -1745,6 +1782,7 @@ class vmmCreate(vmmGObjectUI):
         is_import = False
         init = None
         fs = None
+        template = None
         distro, variant, valid, ignore1, ignore2 = self._get_config_os_info()
 
         if not valid:
@@ -1802,6 +1840,12 @@ class vmmCreate(vmmGObjectUI):
             if not fs:
                 return self.err.val_err(_("An OS directory path is required."))
 
+        elif instmethod == INSTALL_PAGE_VZ_TEMPLATE:
+            instclass = virtinst.ContainerInstaller
+            template = self.widget("install-container-template").get_text()
+            if not template:
+                return self.err.val_err(_("A template name is required."))
+
         # Build the installer and Guest instance
         try:
             # Overwrite the guest
@@ -1832,6 +1876,14 @@ class vmmCreate(vmmGObjectUI):
                 fsdev.target = "/"
                 fsdev.source = fs
                 self._guest.add_device(fsdev)
+
+            if template:
+                fsdev = virtinst.VirtualFilesystem(self._guest.conn)
+                fsdev.target = "/"
+                fsdev.type = "template"
+                fsdev.source = template
+                self._guest.add_device(fsdev)
+
         except Exception, e:
             return self.err.val_err(
                                 _("Error setting install media location."), e)
diff --git a/virtinst/connection.py b/virtinst/connection.py
index e8d2378..bdf1717 100644
--- a/virtinst/connection.py
+++ b/virtinst/connection.py
@@ -387,6 +387,9 @@ class VirtualConnection(object):
         return self._uriobj.scheme.startswith("openvz")
     def is_container(self):
         return self.is_lxc() or self.is_openvz()
+    def is_vz(self):
+        return (self._uriobj.scheme.startswith("vz") or
+                self._uriobj.scheme.startswith("parallels"))
 
 
     #########################
-- 
2.9.3




More information about the virt-tools-list mailing list