def check(self): """ @return: True if the computer can be archived, else False @rtype: bool """ # Get computer folder and boot menu self.cfolder = os.path.join( self.config.imaging_api['base_folder'], self.config.imaging_api['computers_folder'], self.computerUUID) self.bootmenu = os.path.join( self.config.imaging_api['base_folder'], self.config.imaging_api['bootmenus_folder'], reduceMACAddress(self.macAddress)) if not os.path.exists(self.cfolder): self.logger.error( "Looks like computer %s is not registered, so it can't be archived" % self.computerUUID) return False # Build valid image list for image in self.imageList: ifolder = os.path.join(self.config.imaging_api['base_folder'], self.config.imaging_api['masters_folder'], image) if isPulse2Image(ifolder): self.images.append(ifolder) else: self.logger.error("Invalid image, won't be archived: %s" % image) return True
def __init__(self, config, imageUUID, size, title): """ @param imageUUID: UUID of the Pulse 2 image to convert to an ISO @type imageUUID: str @param size: media size, in bytes @type size: int @param title: title of the image, in UTF-8 @type title: str """ self.logger = logging.getLogger('imaging') self.config = config self.source = os.path.join(self.config.imaging_api['base_folder'], self.config.imaging_api['masters_folder'], imageUUID) if not isPulse2Image(self.source): raise ValueError('Image %s is not a valid image' % imageUUID) self.imageUUID = imageUUID if not title: raise ValueError('Image ISO title is empty') self.title = title targetdir = self.config.imaging_api['isos_folder'] if not os.path.isdir(targetdir): raise Exception("Target directory %s for ISO image doesn't exist" % targetdir) self.target = os.path.join(targetdir, title) if os.path.exists('%s-1.iso' % self.target): # ISO file already exists, find another file name. i = 1 while True: if not os.path.exists('%s-%d-1.iso' % (self.target, i)): self.target += '-' + str(i) break i += 1 self.size = int(size) # size is given as string, and we need it in B self.tempdir = tempfile.mkdtemp('pulse2-iso') self.medialist = {}
def check(self): """ @return: True if the computer can be archived, else False @rtype: bool """ # Get computer folder and boot menu self.cfolder = os.path.join(self.config.imaging_api['base_folder'], self.config.imaging_api['computers_folder'], self.computerUUID) self.bootmenu = os.path.join(self.config.imaging_api['base_folder'], self.config.imaging_api['bootmenus_folder'], reduceMACAddress(self.macAddress)) if not os.path.exists(self.cfolder): self.logger.error("Looks like computer %s is not registered, so it can't be archived" % self.computerUUID) return False # Build valid image list for image in self.imageList: ifolder = os.path.join(self.config.imaging_api['base_folder'], self.config.imaging_api['masters_folder'], image) if isPulse2Image(ifolder): self.images.append(ifolder) else: self.logger.error("Invalid image, won't be archived: %s" % image) return True