virt-manager/virtman-show-suse-install-repos.patch
Charles Arnold 6de106691e - Update to virt-manager 3.0.0 (fate#326786)
virt-manager-3.0.0.tar.bz2
  * virt-install –cloud-init support (Athina Plaskasoviti, Cole
    Robinson)
  * The virt-convert tool has been removed. Please use virt-v2v
    instead
  * A handful of UI XML configuration options have been removed.
    The XML editor can be used instead. For a larger discussion see
    this thread: https://www.redhat.com/archives/virt-tools-list/
    2019-June/msg00117.html
  * The ‘New VM’ UI now has a ‘Manual Install’ option which creates
    a VM without any required install media
  * In the ‘New VM’ UI, the network/pxe install option has been
    removed. If you need network boot, choose ‘Manual Install’ and
    set the boot device after initial VM creation
  * ‘Clone VM’ UI has been reworked and simplified
  * ‘Migrate VM’ UI now has an XML editor for the destination VM
  * Global and per-vm option to disable graphical console
    autoconnect. This makes it easier to use virt-manager alongside
    another client like virt-viewer
  * virt-manager: set guest time after VM restore (Michael Weiser)
  * virt-manager: option to delete storage when removing disk
    device (Lily Nie)
  * virt-manager: show warnings if snapshot operation is unsafe
    (Michael Weiser)
  * Unattended install improvements (Fabiano Fidêncio)
  * cli: new –xml XPATH=VAL option for making direct XML changes
  * virt-install: new –reinstall=DOMAIN option
  * virt-install: new –autoconsole text|graphical|none option
  * virt-install: new –os-variant detect=on,require=on suboptions

OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=509
2020-09-16 17:23:41 +00:00

94 lines
3.2 KiB
Diff

Enhancement that gets installation repos from zypper.
These locations are then presented as potential installation
sources when creating a VM.
Index: virt-manager-3.0.0/virtManager/createvm.py
===================================================================
--- virt-manager-3.0.0.orig/virtManager/createvm.py
+++ virt-manager-3.0.0/virtManager/createvm.py
@@ -164,6 +164,70 @@ class _GuestData:
return guest
+################################################
+# Helpers for using SUSE installation location #
+################################################
+
+import subprocess
+from subprocess import Popen, PIPE
+
+_host_repo_url = None
+
+def getHostInstallSource():
+ global _host_repo_url
+ if _host_repo_url is not None:
+ return _host_repo_url
+ if os.geteuid() != 0:
+ return None
+
+ (_,zypper_output) = lookupZypperRepos()
+ if len(zypper_output):
+ _host_repo_url = zypper_output[0]
+ return _host_repo_url
+ return None
+
+def lookupZypperRepos(dom0_inst_source=None):
+ try:
+ env = os.environ.copy()
+ env['LC_ALL'] = 'C'
+ cmd = ['/usr/bin/zypper', 'lr', '-u', '-P', '-E']
+ p = subprocess.Popen(cmd, stdout=PIPE, stderr=PIPE, env=env)
+ stdout, stderr = p.communicate()
+ zypper_output = stdout.decode()
+ zypper_list = zypper_output.split("\n")
+ zypper_header = [x.strip(' ') for x in zypper_list[0].split("|")]
+ uri_index = zypper_header.index("URI")
+ except:
+ inst_source = []
+ if dom0_inst_source:
+ inst_source = [dom0_inst_source]
+ return (0, inst_source)
+
+ index_dom0 = -1
+ number_of_sources = 0
+ zypper_output = []
+ for repo in zypper_list:
+ repo = [x.strip(' ') for x in repo.split("|")]
+ if len(repo) >= uri_index:
+ str = repo[uri_index]
+ if str.startswith('ftp://') or str.startswith('http://') or str.startswith('nfs://') or str.startswith('smb://'):
+ if str not in zypper_output:
+ zypper_output.append(str)
+ if dom0_inst_source is not None and str == dom0_inst_source:
+ index_dom0 = number_of_sources
+ number_of_sources += 1
+
+ if index_dom0 == -1 and dom0_inst_source:
+ index_dom0 = 0
+ zypper_output.insert(0, dom0_inst_source)
+ return (index_dom0, zypper_output)
+
+def getInstallRepos():
+ if os.geteuid() != 0:
+ return (0, [])
+ return lookupZypperRepos(getHostInstallSource())
+
+
##############
# Main class #
##############
@@ -422,7 +486,13 @@ class vmmCreateVM(vmmGObjectUI):
self.widget("install-url-entry").set_text("")
self.widget("install-url-options").set_expanded(False)
urlmodel = self.widget("install-url-combo").get_model()
- _populate_media_model(urlmodel, self.config.get_media_urls())
+ urllist = self.config.get_media_urls()
+ (index, inst_repos) = getInstallRepos()
+ for u in urllist:
+ if u in inst_repos:
+ inst_repos.remove(u)
+ media_urllist = urllist + inst_repos
+ _populate_media_model(urlmodel, media_urllist)
# Install import
self.widget("install-import-entry").set_text("")