def parseRestore(self): results = {} results['install-type'] = INSTALL_TYPE_RESTORE backups = product.findXenSourceBackups() if len(backups) == 0: raise AnswerfileException("Could not locate exsisting backup.") results['backups'] = backups logger.log("Backup list: %s" % ", ".join(str(b) for b in backups)) nodes = getElementsByTagName(self.top_node, ['backup-disk']) if len(nodes) == 1: disk = normalize_disk(getText(nodes[0])) disk = disktools.getMpathMasterOrDisk(disk) logger.log("Filtering backup list for disk %s" % disk) backups = filter(lambda x: x.root_disk == disk, backups) logger.log("Backup list filtered: %s" % ", ".join(str(b) for b in backups)) if len(backups) > 1: logger.log("Multiple backups found. Aborting...") raise AnswerfileException("Multiple backups were found. Unable to deduce which backup to restore from.") elif len(backups) == 0: logger.log("Unable to find a backup to restore. Aborting...") raise AnswerfileException("Unable to find a backup to restore.") logger.log("Restoring backup %s." % str(backups[0])) results['backup-to-restore'] = backups[0] return results
def fixMpathResults(results): # update primary disk primary_disk = None if 'primary-disk' in results: primary_disk = disktools.getMpathMasterOrDisk(results['primary-disk']) results['primary-disk'] = primary_disk # update all other disks if 'guest-disks' in results: disks = [] for disk in results['guest-disks']: master = disktools.getMpathMaster(disk) if master: # CA-38329: disallow device mapper nodes (except primary disk) as these won't exist # at XenServer boot and therefore cannot be added as physical volumes to Local SR. # Also, since the DM nodes are multipathed SANs it doesn't make sense to include them # in the "Local" SR. if master != primary_disk: raise Exception( "Non-local disk %s specified to be added to Local SR" % disk) disk = master disks.append(disk) results['guest-disks'] = disks return results
def parseExistingInstallation(self): results = {} inst = getElementsByTagName(self.top_node, ['existing-installation'], mandatory=True) disk = normalize_disk(getText(inst[0])) xelogging.log("Normalized disk: %s" % disk) disk = disktools.getMpathMasterOrDisk(disk) xelogging.log('Primary disk: ' + disk) results['primary-disk'] = disk installations = product.findXenSourceProducts() installations = filter( lambda x: x.primary_disk == disk or diskutil.idFromPartition( x.primary_disk) == disk, installations) if len(installations) == 0: raise AnswerfileException, "Could not locate the installation specified to be reinstalled." elif len(installations) > 1: # FIXME non-multipath case? xelogging.log( "Warning: multiple paths detected - recommend use of --device_mapper_multipath=yes" ) xelogging.log("Warning: selecting 1st path from %s" % str(map(lambda x: x.primary_disk, installations))) results['installation-to-overwrite'] = installations[0] return results