Пример #1
0
    def parseExistingInstallation(self):
        results = {}
        if len(self.nodelist.getElementsByTagName('existing-installation')) == 0:
            raise AnswerfileError, "No existing installation specified."
        ei = getText(self.nodelist.getElementsByTagName('existing-installation')[0].childNodes)

        if ei.startswith('iscsi:'):
            # ei is a rfc4173 spec identifying a LUN in the iBFT.  
            # We should be logged into this already.  
            # Convert this spec into a disk location.
            disk = diskutil.rfc4173_to_disk(ei)
        else:
            disk = normalize_disk(ei)

        # If answerfile names a multipath replace with the master!
        master = disktools.getMpathMaster(disk)
        if master:
            disk = master

        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 AnswerfileError, "Could not locate the installation specified to be reinstalled."
        elif len(installations) > 1:
            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
Пример #2
0
    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
Пример #3
0
    def completeUpgrade(self, mounts, prev_install, target_disk,
                        backup_partnum, logs_partnum, admin_iface,
                        admin_bridge, admin_config):

        util.assertDir(os.path.join(mounts['root'], "var/lib/xcp"))
        util.assertDir(os.path.join(mounts['root'], "etc/xensource"))

        Upgrader.completeUpgrade(self, mounts, target_disk, backup_partnum)

        v = Version(prev_install.version.ver)
        f = open(os.path.join(mounts['root'], 'var/tmp/.previousVersion'), 'w')
        f.write("PLATFORM_VERSION='%s'\n" % v)
        f.close()

        state = open(
            os.path.join(mounts['root'], constants.FIRSTBOOT_DATA_DIR,
                         'host.conf'), 'w')
        print >> state, "UPGRADE=true"
        state.close()

        # The existence of the static-rules.conf is used to detect upgrade from Boston or newer
        if os.path.exists(
                os.path.join(
                    mounts['root'],
                    'etc/sysconfig/network-scripts/interface-rename-data/static-rules.conf'
                )):
            # CA-82901 - convert any old style ppn referenced to new style ppn references
            util.runCmd2([
                'sed', r's/pci\([0-9]\+p[0-9]\+\)/p\1/g', '-i',
                os.path.join(
                    mounts['root'],
                    'etc/sysconfig/network-scripts/interface-rename-data/static-rules.conf'
                )
            ])

        net_dict = util.readKeyValueFile(
            os.path.join(mounts['root'], 'etc/sysconfig/network'))
        if net_dict.get('NETWORKING_IPV6', 'no') == 'no':
            nfd = open(os.path.join(mounts['root'], 'etc/sysconfig/network'),
                       'a')
            nfd.write("NETWORKING_IPV6=no\n")
            nfd.close()
            netutil.disable_ipv6_module(mounts["root"])

        # handle the conversion of devices from aacraid to smartpqi
        primary_disk = self.source.getInventoryValue("PRIMARY_DISK")
        target_link = diskutil.idFromPartition(target_disk) or target_disk
        if primary_disk.startswith('/dev/disk/by-id/scsi-') and \
                target_link.startswith('/dev/disk/by-id/scsi-') and \
                primary_disk != target_link:
            for i in (os.path.join(constants.FIRSTBOOT_DATA_DIR,
                                   'default-storage.conf'), constants.XAPI_DB):
                util.runCmd2([
                    'sed', '-i', '-e',
                    "s#%s#%s#g" % (primary_disk, target_link),
                    os.path.join(mounts['root'], i)
                ])
Пример #4
0
    def completeUpgrade(self, mounts, prev_install, target_disk,
                        backup_partnum, admin_iface, admin_bridge,
                        admin_config):

        util.assertDir(os.path.join(mounts['root'], "var/lib/xcp"))
        util.assertDir(os.path.join(mounts['root'], "etc/xensource"))

        Upgrader.completeUpgrade(self, mounts, target_disk, backup_partnum)

        v = Version(prev_install.version.ver)
        f = open(os.path.join(mounts['root'], 'var/tmp/.previousVersion'), 'w')
        f.write("PLATFORM_VERSION='%s'\n" % v)
        f.close()

        state = open(
            os.path.join(mounts['root'], constants.FIRSTBOOT_DATA_DIR,
                         'host.conf'), 'w')
        print >> state, "UPGRADE=true"
        state.close()

        # The existence of the static-rules.conf is used to detect upgrade from Boston or newer
        if os.path.exists(
                os.path.join(
                    mounts['root'],
                    'etc/sysconfig/network-scripts/interface-rename-data/static-rules.conf'
                )):
            # CA-82901 - convert any old style ppn referenced to new style ppn references
            util.runCmd2([
                'sed', r's/pci\([0-9]\+p[0-9]\+\)/p\1/g', '-i',
                os.path.join(
                    mounts['root'],
                    'etc/sysconfig/network-scripts/interface-rename-data/static-rules.conf'
                )
            ])

        net_dict = util.readKeyValueFile(
            os.path.join(mounts['root'], 'etc/sysconfig/network'))
        if 'NETWORKING_IPV6' not in net_dict:
            nfd = open(os.path.join(mounts['root'], 'etc/sysconfig/network'),
                       'a')
            nfd.write("NETWORKING_IPV6=no\n")
            nfd.close()
            netutil.disable_ipv6_module(mounts["root"])

        # handle the conversion of HP Gen6 controllers from cciss to scsi
        primary_disk = self.source.getInventoryValue("PRIMARY_DISK")
        target_link = diskutil.idFromPartition(target_disk) or target_disk
        if 'cciss' in primary_disk and 'scsi' in target_link:
            util.runCmd2([
                'sed', '-i', '-e',
                "s#%s#%s#g" % (primary_disk, target_link),
                os.path.join(mounts['root'], constants.FIRSTBOOT_DATA_DIR,
                             'default-storage.conf')
            ])
            util.runCmd2([
                'sed', '-i', '-e',
                "s#%s#%s#g" % (primary_disk, target_link),
                os.path.join(mounts['root'], constants.XAPI_DB)
            ])

        # handle the conversion of RAID devices from /dev/md_* to /dev/disk/by-id/md-uuid-*
        if primary_disk.startswith('/dev/md_') and target_link.startswith(
                '/dev/disk/by-id/md-uuid-'):
            for i in (os.path.join(constants.FIRSTBOOT_DATA_DIR,
                                   'default-storage.conf'), constants.XAPI_DB):
                # First convert partitions from *pN to *-partN
                util.runCmd2([
                    'sed', '-i', '-e',
                    "s#\(%s\)p\([[:digit:]]\+\)#\\1-part\\2#g" % primary_disk,
                    os.path.join(mounts['root'], i)
                ])
                # Then conert from /dev/md_* to /dev/disk/by-id/md-uuid-*
                util.runCmd2([
                    'sed', '-i', '-e',
                    "s#%s#%s#g" % (primary_disk, target_link),
                    os.path.join(mounts['root'], i)
                ])

        # handle the conversion of devices from scsi-* links to ata-* links
        if primary_disk.startswith(
                '/dev/disk/by-id/scsi-') and target_link.startswith(
                    '/dev/disk/by-id/ata-'):
            for i in (os.path.join(constants.FIRSTBOOT_DATA_DIR,
                                   'default-storage.conf'), constants.XAPI_DB):
                util.runCmd2([
                    'sed', '-i', '-e',
                    "s#%s#%s#g" % (primary_disk, target_link),
                    os.path.join(mounts['root'], i)
                ])