def get_disk_names(self): """ Returns a list of physical target disk names (e.g., 'sdb') which will be created. """ if self._disk_names: return self._disk_names #get partition info from ks handler parts = self._get_parts() for i in range(len(parts)): if parts[i].disk: disk_name = parts[i].disk else: raise CreatorError("Failed to create disks, no --ondisk " "specified in partition line of ks file") if parts[i].mountpoint and not parts[i].fstype: raise CreatorError("Failed to create disks, no --fstype " "specified for partition with mountpoint " "'%s' in the ks file") self._disk_names.append(disk_name) return self._disk_names
def __ensure_builddir(self): if not self.__builddir is None: return try: self.workdir = os.path.join(self.tmpdir, "build") if not os.path.exists(self.workdir): os.makedirs(self.workdir) self.__builddir = tempfile.mkdtemp(dir=self.workdir, prefix="imgcreate-") except OSError, (err, msg): raise CreatorError("Failed create build directory in %s: %s" % (self.tmpdir, msg))
def _get_parts(self): if not self.ks: raise CreatorError("Failed to get partition info, " "please check your kickstart setting.") # Set a default partition if no partition is given out if not self.ks.partitions: partstr = "part / --size 1900 --ondisk sda --fstype=ext3" args = partstr.split() part = self.ks.parse(args[1:]) if part not in self.ks.partitions: self.ks.partitions.append(part) # partitions list from kickstart file return self.ks.partitions