def check_location(self): if self._location_is_path: # We already mostly validated this return True else: # This will throw an error for us OSDistro.detectMediaDistro(location=self.location, arch=self.arch) return True
def _prepare_kernel_and_initrd(self, guest, meter): disk = None # If installing off a local path, map it through to a virtual CD/disk if (self.location is not None and self._location_is_path and not os.path.isdir(self.location)): device = VirtualDisk.DEVICE_CDROM if (self.is_xenpv() and not guest._lookup_osdict_key('pv_cdrom_install')): device = VirtualDisk.DEVICE_DISK disk = VirtualDisk(conn=guest.conn, device=device, path=self.location, readOnly=True, transient=True) # Make sure we always fetch kernel here if required if self._install_bootconfig.kernel and not self.scratchdir_required(): return disk # Need to fetch the kernel & initrd from a remote site, or # out of a loopback mounted disk image/device ignore, os_type, os_variant, media = OSDistro.acquireKernel(guest, self.location, meter, self.scratchdir, self.os_type) (kernelfn, initrdfn, args) = media if guest.get_os_autodetect(): if os_type: logging.debug("Auto detected OS type as: %s", os_type) guest.os_type = os_type if (os_variant and guest.os_type == os_type): logging.debug("Auto detected OS variant as: %s", os_variant) guest.os_variant = os_variant self._tmpfiles.append(kernelfn) if initrdfn: self._tmpfiles.append(initrdfn) if self._initrd_injections: self._perform_initrd_injections(initrdfn) # If required, upload media to an accessible guest location kernelfn, initrdfn = self._upload_media(guest, meter, kernelfn, initrdfn) self._install_bootconfig.kernel = kernelfn self._install_bootconfig.initrd = initrdfn self._install_bootconfig.kernel_args = args return disk
def detect_distro(self): try: dist_info = OSDistro.detectMediaDistro(location=self.location, arch=self.arch) except: logging.exception("Error attempting to detect distro.") return (None, None) # detectMediaDistro should only return valid values dtype, dvariant = dist_info return (dtype, dvariant)
def _prepare_kernel_and_initrd(self, guest, meter): disk = None # If installing off a local path, map it through to a virtual CD/disk if (self.location is not None and self._location_is_path and not os.path.isdir(self.location)): device = VirtualDisk.DEVICE_CDROM if (self.is_xenpv() and not guest._lookup_osdict_key('pv_cdrom_install')): device = VirtualDisk.DEVICE_DISK disk = VirtualDisk(conn=guest.conn, device=device, path=self.location, readOnly=True, transient=True) # Make sure we always fetch kernel here if required if self._install_bootconfig.kernel and not self.scratchdir_required(): return disk # Need to fetch the kernel & initrd from a remote site, or # out of a loopback mounted disk image/device ignore, os_type, os_variant, media = OSDistro.acquireKernel( guest, self.location, meter, self.scratchdir, self.os_type) (kernelfn, initrdfn, args) = media if guest.get_os_autodetect(): if os_type: logging.debug("Auto detected OS type as: %s" % os_type) guest.os_type = os_type if (os_variant and guest.os_type == os_type): logging.debug("Auto detected OS variant as: %s" % os_variant) guest.os_variant = os_variant self._tmpfiles.append(kernelfn) if initrdfn: self._tmpfiles.append(initrdfn) if self._initrd_injections: self._perform_initrd_injections(initrdfn) # If required, upload media to an accessible guest location kernelfn, initrdfn = self._upload_media(guest, meter, kernelfn, initrdfn) self._install_bootconfig.kernel = kernelfn self._install_bootconfig.initrd = initrdfn self._install_bootconfig.kernel_args = args return disk
def _prepare_cdrom(self, guest, meter): if not self._location_is_path: # Xen needs a boot.iso if its a http://, ftp://, or nfs: url (store_ignore, os_type_ignore, os_variant_ignore, media) = \ OSDistro.acquireBootDisk(guest, self.location, meter, self.scratchdir) cdrom = media self._tmpfiles.append(cdrom) else: cdrom = self.location disk = VirtualDisk(path=cdrom, conn=guest.conn, device=VirtualDisk.DEVICE_CDROM, readOnly=True, transient=True) self.install_devices.append(disk)
def _prepare_cdrom(self, guest, meter): transient = not self.livecd if not self._location_is_path: # Xen needs a boot.iso if its a http://, ftp://, or nfs: url (store_ignore, os_type_ignore, os_variant_ignore, media) = OSDistro.acquireBootDisk( guest, self.location, meter, self.scratchdir ) cdrom = media self._tmpfiles.append(cdrom) transient = True else: cdrom = self.location disk = VirtualDisk( path=cdrom, conn=guest.conn, device=VirtualDisk.DEVICE_CDROM, readOnly=True, transient=transient ) self.install_devices.append(disk)