def guest_from_installer(self): """ Return a L{Guest} instance wrapping the current installer. If all the appropriate values are present in the installer (conn, type, os_type, arch, machine), we have everything we need to determine what L{Guest} class is expected and what default values to pass it. This is a convenience method to save the API user from having to enter all these known details twice. """ if not self.conn: raise ValueError(_("A connection must be specified.")) guest, domain = CapabilitiesParser.guest_lookup(conn=self.conn, caps=self._get_caps(), os_type=self.os_type, typ=self.type, arch=self.arch, machine=self.machine) gobj = virtinst.Guest(installer=self, conn=self.conn) gobj.arch = guest.arch gobj.emulator = domain.emulator self.loader = domain.loader return gobj
def _pygrub_path(conn=None): # FIXME: This should be removed/deprecated when capabilities are # fixed to provide bootloader info if conn: cap = CapabilitiesParser.parse(conn.getCapabilities()) if (cap.host.arch == "i86pc"): return "/usr/lib/xen/bin/pygrub" else: return "/usr/bin/pygrub" if platform.system() == "SunOS": return "/usr/lib/xen/bin/pygrub" return "/usr/bin/pygrub"
def host(conn=None): """ Return the host, as seen in platform.system(), but possibly from a hypervisor connection. Note: use default_arch() in almost all cases, unless you need to detect the OS. In particular, this value gives no indication of 32 vs 64 bitness. """ if conn: cap = CapabilitiesParser.parse(conn.getCapabilities()) if cap.host.arch == "i86pc": return "SunOS" else: # or Linux-alike. Hmm. return "Linux" return platform.system()
def __init__(self, type="xen", location=None, boot=None, extraargs=None, os_type=None, conn=None): self._type = None self._location = None self._initrd_injections = [] self._cdrom = False # XXX: We should set this default based on capabilities? self._os_type = "xen" self._conn = conn self._scratchdir = None self._caps = None self._arch = None self._install_bootconfig = Boot(self.conn) self._bootconfig = Boot(self.conn) # Devices created/added during the prepare() stage self.install_devices = [] if self.conn: self._caps = CapabilitiesParser.parse(self.conn.getCapabilities()) # FIXME: Better solution? Skip validating this since we may not be # able to install a VM of the host arch self._arch = self._caps.host.arch if type is None: type = "xen" self.type = type if not os_type is None: self.os_type = os_type if not location is None: self.location = location if not boot is None: self.boot = boot self.extraargs = extraargs self._tmpfiles = []
def guest_from_installer(self): """ Return a L{Guest} instance wrapping the current installer. If all the appropriate values are present in the installer (conn, type, os_type, arch), we have everything we need to determine what L{Guest} class is expected and what default values to pass it. This is a convenience method to save the API user from having to enter all these known details twice. """ if not self.conn: raise ValueError(_("A connection must be specified.")) guest, domain = CapabilitiesParser.guest_lookup(conn=self.conn, caps=self._caps, os_type=self.os_type, type=self.type, arch=self.arch) if self.os_type == "xen": gobj = virtinst.ParaVirtGuest(installer=self, connection=self.conn) gobj.arch = guest.arch elif self.os_type == "hvm": gobj = virtinst.FullVirtGuest(installer=self, connection=self.conn, emulator=domain.emulator, arch=guest.arch) gobj.loader = domain.loader if self.type == "openvz": gobj = virtinst.FullVirtGuest(installer=self, connection=self.conn, emulator=domain.emulator, arch=guest.arch) gobj.loader = domain.loader else: raise ValueError( _("No 'Guest' class for virtualization type '%s'" % self.type)) return gobj
def _get_caps(self): if not self.__caps and self.conn: self.__caps = CapabilitiesParser.parse(self.conn.getCapabilities()) return self.__caps
def _buildCaps(self, filename): path = os.path.join("tests/capabilities-xml", filename) xml = file(path).read() return capabilities.Capabilities(xml)
def _buildCaps(self, filename): path = os.path.join("tests/capabilities-xml", filename) xml = file(path).read() return capabilities.parse(xml)