virt-manager/virtman-show-suse-install-repos.patch
Charles Arnold 674d49879e - Update to virt-manager 2.0.0 (bsc#1027942)
virt-manager-2.0.0.tar.bz2
  * Finish port to Python 3 (Radostin Stoyanov, Cole Robinson)
  * Improved VM defaults for supported OS: q35 PCIe, usb3, CPU host-model
  * Search based OS selection UI for new VMs (Daniel P. Berrangé, Cole Robinson)
  * Track OS name for lifetime of domain in XML
  * Host interface management UI has been completely removed
  * Show domain IP on interface details page (Lin Ma, Cole Robinson)
  * More efficient stats polling with AllDomainStats (Simon Kobyda, Cole Robinson)
  * TPM device model and backend UI (Marc-André Lureau, Stefan Berger)
  * Show connection state in UI (Lin Ma)
  * Show attached devices in UI (Lin Ma)
  * UI option to plug/unplug VM nic link (Simon Kobyda)
  * UI support for disk discard and detect_zeroes (Povilas Kanapickas, Lin Ma)
  * Improved SUSE –location URL/ISO detection (Charles Arnold)
  * cli and UI support for SCSI persistent reservations (Lin Ma)
  * cli: Add –network mtu.size= option (Anya Harter)
  * cli: Add –disk driver.copy_on_read (Anya Harter)
  * cli: Add –disk geometry support (Anya Harter)
  * cli: Add –sound codec support (Anya Harter)
  * cli: Add –hostdev net/char/block for LXC (Lubomir Rintel)
  * cli: Add –memorybacking access_mode and source_type (Marc-André Lureau)
  * cli: Add –boot rebootTimout (Yossi Ovadia)
  * cli: Add –boot bootloader=
  * cli: Add –destroy-on-exit
- Drop patches contained in new tarball or not required
  0004-virtinst-python3-use-binary-mode-for-kernel.patch
  27d4b167-virtinst-update-location-for-opensuse.patch
  5a7698c7-fix-select-network-vol.patch
  d15b78ab-virtinst-read-CPU-model-from-domain-capabilities.patch

OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=437
2018-10-30 22:00:52 +00:00

98 lines
3.4 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-2.0.0/virtManager/create.py
===================================================================
--- virt-manager-2.0.0.orig/virtManager/create.py
+++ virt-manager-2.0.0/virtManager/create.py
@@ -371,7 +371,13 @@ class vmmCreate(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) = util.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("")
Index: virt-manager-2.0.0/virtinst/util.py
===================================================================
--- virt-manager-2.0.0.orig/virtinst/util.py
+++ virt-manager-2.0.0/virtinst/util.py
@@ -11,9 +11,12 @@ import os
import random
import re
import sys
+import subprocess
+from subprocess import Popen, PIPE
import libvirt
+_host_repo_url = None
def listify(l):
if l is None:
@@ -292,3 +295,57 @@ def make_meter(quiet):
if quiet:
return progress.BaseMeter()
return progress.TextMeter(fo=sys.stdout)
+
+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://'):
+ 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())
+