virt-manager/virtman-default-guest-from-host-os.patch
Charles Arnold a0ee59eff0 - Default to virt-install when installation icon is selected
- Allow virt-install to install Xen PV guests from ISO media
  virtman-allow-pv-iso-install.patch
- Detect SUSE installation sources and use as default when found
  virtman-default-guest-from-host-os.patch
- Use 'Autoyast' instead of 'Kickstart' if installing SUSE distro
  virtman-autoyast-label.patch

OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=118
2013-07-03 21:44:06 +00:00

70 lines
2.3 KiB
Diff

Index: virt-manager-0.9.5/src/virtManager/create.py
===================================================================
--- virt-manager-0.9.5.orig/src/virtManager/create.py
+++ virt-manager-0.9.5/src/virtManager/create.py
@@ -20,6 +20,8 @@
import threading
import logging
+import sys
+import os
import gtk
@@ -1159,6 +1161,47 @@ class vmmCreate(vmmGObjectUI):
return
self.start_detection(forward=forward)
+ def _lookup_host_os(self):
+ if sys.platform == 'linux2':
+ if os.path.exists('/etc/issue'):
+ f = open('/etc/issue')
+ lines = f.readlines()
+ f.close()
+ for line in lines:
+ if "openSUSE" in line:
+ return 'linux', 'opensuse12'
+ if "SUSE Linux Enterprise Server" in line:
+ return 'linux', 'sles11'
+ if "Fedora" in line:
+ return 'linux', 'fedora17'
+ if "Red Hat Enterprise Linux Server" in line:
+ return 'linux', 'rhel6'
+ return None, None
+
+ def detect_host_os(self):
+ box = self.widget('install-os-type')
+ if box.get_active() <= 0:
+ os_type, os_variant = self._lookup_host_os()
+ if os_type is None:
+ return
+ model = box.get_model()
+ index = 0
+ for row in model:
+ if row[0] == 'linux':
+ box.set_active(index)
+ break
+ index += 1
+ if os_variant is None:
+ return
+ box = self.widget('install-os-version')
+ model = box.get_model()
+ index = 0
+ for row in model:
+ if row[0] == os_variant:
+ box.set_active(index)
+ break
+ index += 1
+
def toggle_detect_os(self, src):
dodetect = src.get_active()
@@ -1174,6 +1217,7 @@ class vmmCreate(vmmGObjectUI):
self.widget("install-os-version-label").hide()
self.widget("install-os-type").show()
self.widget("install-os-version").show()
+ self.detect_host_os()
def _selected_os_row(self):
box = self.widget("install-os-type")