[virt-tools-list] [virt-manager] [PATCH 3/9] create: Refactor OS container to enable bootstrap
Cole Robinson
crobinso at redhat.com
Fri Jun 23 17:22:58 UTC 2017
On 06/22/2017 10:54 AM, Radostin Stoyanov wrote:
> ---
> ui/create.ui | 2 ++
> virtManager/create.py | 42 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 44 insertions(+)
>
> diff --git a/ui/create.ui b/ui/create.ui
> index ae4227b..c9d2637 100644
> --- a/ui/create.ui
> +++ b/ui/create.ui
> @@ -1736,6 +1736,7 @@ connections is not yet supported.</small></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>
> @@ -1746,6 +1747,7 @@ connections is not yet supported.</small></property>
> <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="orientation">vertical</property>
> <child>
> diff --git a/virtManager/create.py b/virtManager/create.py
> index 275b6f3..658135c 100644
> --- a/virtManager/create.py
> +++ b/virtManager/create.py
> @@ -21,6 +21,11 @@
> import logging
> import threading
> import time
> +import subprocess
> +try:
> + import commands # Python2 only
> +except Exception:
> + pass
>
> from gi.repository import GObject
> from gi.repository import Gtk
> @@ -104,6 +109,17 @@ def _remove_vmm_device(guest, devkey):
> guest.remove_device(dev)
>
>
> +def is_virt_bootstrap_installed():
> + ''' Returns True if virt-bootstrap is installed '''
> + cmd = "virt-bootstrap --help"
> + # pylint: disable=E1101
Please do disable=$string instead, easier for readability. You can grab it
from pylint --list-msgs | grep E1101. In this case it's disable=no-member
> + try:
> + status, ignore = subprocess.getstatusoutput(cmd) # Python3
> + except:
> + status, ignore = commands.getstatusoutput(cmd) # Python2
> + return status == 0
> +
> +
There's distutils.spawn.find_executable which just searches $PATH. Saves
constantly spawning a binary
Also because this function is called from set_conn_state it may potentially
get hit a bunch which is redundant. I say have the function cache the result
in a global variable, but refresh the cache from vmmCreate.reset_state().
Limits the amount of checking, but allows the user to close the wizard and
reopen it to notice a newly installed virt-bootstrap. Or if you wanted to be
nicer about it, only do the check when we switch to the app container install page
Thanks,
Cole
More information about the virt-tools-list
mailing list