mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
create: Add support for OS tree creation
Allow container bootstrap when connected to local Libvirt LXC driver and if virtBootstrap module is available.
This commit is contained in:
parent
550770626f
commit
bb2e5c0899
200
ui/create.ui
200
ui/create.ui
@ -1652,7 +1652,7 @@ User shouldn't see this.</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="hbox16">
|
||||
<object class="GtkBox" id="install-oscontainer-notsupport">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
@ -1673,8 +1673,8 @@ User shouldn't see this.</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes"><small>The OS directory tree must already exist. Creating an OS directory tree
|
||||
is not yet supported.</small></property>
|
||||
<property name="label" translatable="yes"><small>The OS directory tree must already exist. To enable OS directory tree creation,
|
||||
please install <a href="https://github.com/virt-manager/virt-bootstrap">virt-bootrap</a></small></property>
|
||||
<property name="use_markup">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -1690,6 +1690,200 @@ is not yet supported.</small></property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="install-oscontainer-notsupport-conn">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image8">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-dialog-warning</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes"><small>The OS directory tree must already exist. Creating an OS directory tree for remote
|
||||
connections is not yet supported.</small></property>
|
||||
<property name="use_markup">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="install-oscontainer-bootstrap">
|
||||
<property name="label" translatable="yes">Create OS directory tree from container image</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<signal name="toggled" handler="on_install_container_source_toggle" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="install-oscontainer-source">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">10</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Source URI:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="install-oscontainer-source-url-combo">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="has_entry">True</property>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry" id="install-oscontainer-source-url-entry">
|
||||
<property name="can_focus">True</property>
|
||||
<property name="placeholder_text" translatable="yes">docker://fedora</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="install-oscontainer-source-insecure">
|
||||
<property name="label" translatable="yes">Do not verify TLS certificates of registry</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkExpander" id="install-oscontainer-auth-options">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_right">10</property>
|
||||
<property name="label" translatable="yes">Username:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_right">10</property>
|
||||
<property name="label" translatable="yes">Password:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="install-oscontainer-source-user">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="install-oscontainer-source-passwd">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="visibility">False</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="input_purpose">password</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Credentials for accessing the source registry</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -19,6 +19,7 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
import pkgutil
|
||||
import threading
|
||||
import time
|
||||
|
||||
@ -104,6 +105,10 @@ def _remove_vmm_device(guest, devkey):
|
||||
guest.remove_device(dev)
|
||||
|
||||
|
||||
def is_virt_bootstrap_installed():
|
||||
return pkgutil.find_loader('virtBootstrap') is not None
|
||||
|
||||
|
||||
##############
|
||||
# Main class #
|
||||
##############
|
||||
@ -168,6 +173,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
"on_install_import_browse_clicked": self._browse_import,
|
||||
"on_install_app_browse_clicked": self._browse_app,
|
||||
"on_install_oscontainer_browse_clicked": self._browse_oscontainer,
|
||||
"on_install_container_source_toggle": self._container_source_toggle,
|
||||
|
||||
"on_install_detect_os_toggled": self._toggle_detect_os,
|
||||
"on_install_os_type_changed": self._change_os_type,
|
||||
@ -427,6 +433,12 @@ class vmmCreate(vmmGObjectUI):
|
||||
|
||||
# Install container OS
|
||||
self.widget("install-oscontainer-fs").set_text("")
|
||||
self.widget("install-oscontainer-source-url-entry").set_text("")
|
||||
self.widget("install-oscontainer-source-user").set_text("")
|
||||
self.widget("install-oscontainer-source-passwd").set_text("")
|
||||
self.widget("install-oscontainer-source-insecure").set_active(False)
|
||||
self.widget("install-oscontainer-bootstrap").set_active(False)
|
||||
self.widget("install-oscontainer-auth-options").set_expanded(False)
|
||||
|
||||
# Install VZ container from template
|
||||
self.widget("install-container-template").set_text("centos-7-x86_64")
|
||||
@ -651,6 +663,20 @@ class vmmCreate(vmmGObjectUI):
|
||||
|
||||
self._local_media_toggled(cdrom_option)
|
||||
|
||||
# Allow container bootstrap only for local connection and
|
||||
# only if virt-bootstrap is installed. Otherwise, show message.
|
||||
vb_installed = is_virt_bootstrap_installed()
|
||||
vb_enabled = is_local and vb_installed
|
||||
|
||||
oscontainer_widget_conf = {
|
||||
"install-oscontainer-notsupport-conn": not is_local,
|
||||
"install-oscontainer-notsupport": not vb_installed,
|
||||
"install-oscontainer-bootstrap": vb_enabled,
|
||||
"install-oscontainer-source": vb_enabled
|
||||
}
|
||||
for w in oscontainer_widget_conf:
|
||||
self.widget(w).set_visible(oscontainer_widget_conf[w])
|
||||
|
||||
# Memory
|
||||
memory = int(self.conn.host_memory_size())
|
||||
mem_label = (_("Up to %(maxmem)s available on the host") %
|
||||
@ -1585,6 +1611,12 @@ class vmmCreate(vmmGObjectUI):
|
||||
_show_netdev_warn(_("Network selection does not support PXE"))
|
||||
|
||||
|
||||
# Enable/Disable container source URL entry on checkbox click
|
||||
def _container_source_toggle(self, ignore):
|
||||
enable_src = self.widget("install-oscontainer-bootstrap").get_active()
|
||||
self.widget("install-oscontainer-source").set_sensitive(enable_src)
|
||||
|
||||
|
||||
########################
|
||||
# Misc helper routines #
|
||||
########################
|
||||
|
Loading…
Reference in New Issue
Block a user