Пример #1
0
    def unsetup(self):
        super(RPMOSTreePayload, self).unsetup()

        for mount in reversed(self._internal_mounts):
            try:
                umount(mount)
            except CalledProcessError as e:
                log.debug("unmounting %s failed: %s", mount, str(e))
Пример #2
0
    def unsetup(self):
        super(RPMOSTreePayload, self).unsetup()

        for mount in reversed(self._internal_mounts):
            try:
                umount(mount)
            except CalledProcessError as e:
                log.debug("unmounting %s failed: %s", mount, str(e))
Пример #3
0
def _find_existing_installations(devicetree):
    """Find existing GNU/Linux installations on devices from the device tree.

    :param devicetree: a device tree to find existing installations in
    :return: roots of all found installations
    """
    if not os.path.exists(util.getTargetPhysicalRoot()):
        blivet_util.makedirs(util.getTargetPhysicalRoot())

    sysroot = util.getSysroot()
    roots = []
    direct_devices = (dev for dev in devicetree.devices if dev.direct)
    for device in direct_devices:
        if not device.format.linux_native or not device.format.mountable or \
           not device.controllable:
            continue

        try:
            device.setup()
        except Exception:  # pylint: disable=broad-except
            log_exception_info(log.warning, "setup of %s failed", [device.name])
            continue

        options = device.format.options + ",ro"
        try:
            device.format.mount(options=options, mountpoint=sysroot)
        except Exception:  # pylint: disable=broad-except
            log_exception_info(log.warning, "mount of %s as %s failed", [device.name, device.format.type])
            blivet_util.umount(mountpoint=sysroot)
            continue

        if not os.access(sysroot + "/etc/fstab", os.R_OK):
            blivet_util.umount(mountpoint=sysroot)
            device.teardown()
            continue

        try:
            (architecture, product, version) = get_release_string()
        except ValueError:
            name = _("Linux on %s") % device.name
        else:
            # I'd like to make this finer grained, but it'd be very difficult
            # to translate.
            if not product or not version or not architecture:
                name = _("Unknown Linux")
            elif "linux" in product.lower():
                name = _("%(product)s %(version)s for %(arch)s") % \
                    {"product": product, "version": version, "arch": architecture}
            else:
                name = _("%(product)s Linux %(version)s for %(arch)s") % \
                    {"product": product, "version": version, "arch": architecture}

        (mounts, swaps) = _parse_fstab(devicetree, chroot=sysroot)
        blivet_util.umount(mountpoint=sysroot)
        if not mounts and not swaps:
            # empty /etc/fstab. weird, but I've seen it happen.
            continue
        roots.append(Root(mounts=mounts, swaps=swaps, name=name))

    return roots
Пример #4
0
def _find_existing_installations(devicetree):
    """Find existing GNU/Linux installations on devices from the device tree.

    :param devicetree: a device tree to find existing installations in
    :return: roots of all found installations
    """
    if not os.path.exists(conf.target.physical_root):
        blivet_util.makedirs(conf.target.physical_root)

    sysroot = conf.target.physical_root
    roots = []
    direct_devices = (dev for dev in devicetree.devices if dev.direct)
    for device in direct_devices:
        if not device.format.linux_native or not device.format.mountable or \
           not device.controllable:
            continue

        try:
            device.setup()
        except Exception:  # pylint: disable=broad-except
            log_exception_info(log.warning, "setup of %s failed", [device.name])
            continue

        options = device.format.options + ",ro"
        try:
            device.format.mount(options=options, mountpoint=sysroot)
        except Exception:  # pylint: disable=broad-except
            log_exception_info(log.warning, "mount of %s as %s failed", [device.name, device.format.type])
            blivet_util.umount(mountpoint=sysroot)
            continue

        if not os.access(sysroot + "/etc/fstab", os.R_OK):
            blivet_util.umount(mountpoint=sysroot)
            device.teardown()
            continue

        try:
            (architecture, product, version) = get_release_string(chroot=sysroot)
        except ValueError:
            name = _("Linux on %s") % device.name
        else:
            # I'd like to make this finer grained, but it'd be very difficult
            # to translate.
            if not product or not version or not architecture:
                name = _("Unknown Linux")
            elif "linux" in product.lower():
                name = _("%(product)s %(version)s for %(arch)s") % \
                    {"product": product, "version": version, "arch": architecture}
            else:
                name = _("%(product)s Linux %(version)s for %(arch)s") % \
                    {"product": product, "version": version, "arch": architecture}

        (mounts, swaps) = _parse_fstab(devicetree, chroot=sysroot)
        blivet_util.umount(mountpoint=sysroot)
        if not mounts and not swaps:
            # empty /etc/fstab. weird, but I've seen it happen.
            continue
        roots.append(Root(mounts=mounts, swaps=swaps, name=name))

    return roots
Пример #5
0
def _find_existing_installations(devicetree):
    """Find existing GNU/Linux installations on devices from the device tree.

    :param devicetree: a device tree to find existing installations in
    :return: roots of all found installations
    """
    if not os.path.exists(conf.target.physical_root):
        blivet_util.makedirs(conf.target.physical_root)

    sysroot = conf.target.physical_root
    roots = []
    direct_devices = (dev for dev in devicetree.devices if dev.direct)
    for device in direct_devices:
        if not device.format.linux_native or not device.format.mountable or \
           not device.controllable or not device.format.exists:
            continue

        try:
            device.setup()
        except Exception:  # pylint: disable=broad-except
            log_exception_info(log.warning, "setup of %s failed",
                               [device.name])
            continue

        options = device.format.options + ",ro"
        try:
            device.format.mount(options=options, mountpoint=sysroot)
        except Exception:  # pylint: disable=broad-except
            log_exception_info(log.warning, "mount of %s as %s failed",
                               [device.name, device.format.type])
            blivet_util.umount(mountpoint=sysroot)
            continue

        if not os.access(sysroot + "/etc/fstab", os.R_OK):
            blivet_util.umount(mountpoint=sysroot)
            device.teardown()
            continue

        architecture, product, version = get_release_string(chroot=sysroot)
        (mounts, swaps) = _parse_fstab(devicetree, chroot=sysroot)
        blivet_util.umount(mountpoint=sysroot)

        if not mounts and not swaps:
            # empty /etc/fstab. weird, but I've seen it happen.
            continue

        roots.append(
            Root(product=product,
                 version=version,
                 arch=architecture,
                 mounts=mounts,
                 swaps=swaps))

    return roots
Пример #6
0
    def unsetup(self):
        super(RPMOSTreePayload, self).unsetup()

        for mount in reversed(self._internal_mounts):
            umount(mount)
Пример #7
0
    def unsetup(self):
        super(RPMOSTreePayload, self).unsetup()

        for mount in reversed(self._internal_mounts):
            umount(mount)
Пример #8
0
    def execute(self, storage, ksdata, instclass, users):
        """
        Post install activities, first copy the answer file
        from location given in kickstart. Second copy cirrios
        image and rabbitmq public key (both needed for offline packstack run)
        """
        # Create Answers file from given URL TODO:Copy the answer file to host
        if self.state == "True" and self.env == "anaconda":
            os.mkdir(ROOT_PATH + ADDON_DIRECTORY)
            # if (self.lines is not None) and not (self.lines == "") :
            #     answer_file = os.path.normpath(ROOT_PATH + ADDON_DIRECTORY + "answer-file.txt")
            #     with open(answer_file, "w") as fobj:
            #         fobj.write("%s\n" % self.lines)

            # Copying repodata, cirrios image & rabbitmq public key to Host system from media
            tmpdirectory = tempfile.mkdtemp()
            util.mount(device="/dev/disk/by-label/CentOS\\x207\\x20x86_64", mountpoint=tmpdirectory, fstype="auto")
            copy_tree(tmpdirectory + "/Packages/RDO", os.path.normcase(ROOT_PATH + ADDON_DIRECTORY))
            util.umount(tmpdirectory)
            shutil.rmtree(tmpdirectory)
            with open(ROOT_PATH + '/etc/hosts', 'a') as file:
                file.write('127.0.0.1 www.rabbitmq.com\n')
            file.close()
            # Copy Addon itself to /usr/share/anaconda/addons
            #TODO: Once Packaged remove this step
            if os.path.exists(ROOT_PATH + "/usr/share/anaconda/addons/org_centos_cloud"):
                os.mkdir(ROOT_PATH + "/usr/share/anaconda/addons/org_centos_cloud")
            shutil.copytree("/usr/share/anaconda/addons/org_centos_cloud",
                            os.path.normcase(ROOT_PATH + "/usr/share/anaconda/addons/org_centos_cloud"))

            # Enabling initial-setup-text service,
            # TODO: Check if Graphical OR Text Service to Enable
            #initial-setup-text.service: Adding $HOME=/root ENV Variable & Enabling
            for line in fileinput.input(ROOT_PATH + '/usr/lib/systemd/system/initial-setup-text.service', inplace=1):
                if line.startswith('Type'):
                    print 'Environment=HOME=/root'
                print line,
            rc = iutil.execInSysroot("ln", ["-s", "usr/lib/systemd/system/initial-setup-text.service",
                                            "etc/systemd/system/multi-user.target.wants/initial-setup-text.service"])
            if rc:
                msg = "Initializing initial-setup-text service failed"
                raise KickstartValueError(msg)
            # NetworkManager: Disable
            rc = iutil.execInSysroot("rm", ["-rf", "etc/systemd/system/multi-user.target.wants/NetworkManager.service",
                                            "etc/systemd/system/dbus-org.freedesktop.NetworkManager.service",
                                            "etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service"])
            if rc:
                msg = "Disabling Network Failed"
                raise KickstartValueError(msg)

        elif (self.env == "firstboot") and (self.state == "True"):

            rc = iutil._run_systemctl("enable", "network")
            if rc:
                print ("Network start failed")
            ret = self.run_packstack()
            if ret:
                if (self.cleanup()):
                    raw_input("OpenStack Successfully Setup! Press Any Key To Continue...")
                else:
                    raw_input(
                        "Warning! OpenStack Successfully Setup But System Cleanup failed. Press Any Key To Continue...")
        else:
            pass
Пример #9
0
    def execute(self, storage, ksdata, instclass, users):
        """
        Post install activities, first copy the answer file
        from location given in kickstart. Second copy cirrios
        image and rabbitmq public key (both needed for offline packstack run)
        """
        # Create Answers file from given URL TODO:Copy the answer file to host
        if self.state == "True" and self.env == "anaconda":
            os.mkdir(ROOT_PATH + ADDON_DIRECTORY)
            # if (self.lines is not None) and not (self.lines == "") :
            #     answer_file = os.path.normpath(ROOT_PATH + ADDON_DIRECTORY + "answer-file.txt")
            #     with open(answer_file, "w") as fobj:
            #         fobj.write("%s\n" % self.lines)

            # Copying repodata, cirrios image & rabbitmq public key to Host system from media
            tmpdirectory = tempfile.mkdtemp()
            util.mount(device="/dev/disk/by-label/CentOS\\x207\\x20x86_64",
                       mountpoint=tmpdirectory,
                       fstype="auto")
            copy_tree(tmpdirectory + "/Packages/RDO",
                      os.path.normcase(ROOT_PATH + ADDON_DIRECTORY))
            util.umount(tmpdirectory)
            shutil.rmtree(tmpdirectory)
            with open(ROOT_PATH + '/etc/hosts', 'a') as file:
                file.write('127.0.0.1 www.rabbitmq.com\n')
            file.close()
            # Copy Addon itself to /usr/share/anaconda/addons
            #TODO: Once Packaged remove this step
            if os.path.exists(ROOT_PATH +
                              "/usr/share/anaconda/addons/org_centos_cloud"):
                os.mkdir(ROOT_PATH +
                         "/usr/share/anaconda/addons/org_centos_cloud")
            shutil.copytree(
                "/usr/share/anaconda/addons/org_centos_cloud",
                os.path.normcase(
                    ROOT_PATH + "/usr/share/anaconda/addons/org_centos_cloud"))

            # Enabling initial-setup-text service,
            # TODO: Check if Graphical OR Text Service to Enable
            #initial-setup-text.service: Adding $HOME=/root ENV Variable & Enabling
            for line in fileinput.input(
                    ROOT_PATH +
                    '/usr/lib/systemd/system/initial-setup-text.service',
                    inplace=1):
                if line.startswith('Type'):
                    print 'Environment=HOME=/root'
                print line,
            rc = iutil.execInSysroot("ln", [
                "-s", "usr/lib/systemd/system/initial-setup-text.service",
                "etc/systemd/system/multi-user.target.wants/initial-setup-text.service"
            ])
            if rc:
                msg = "Initializing initial-setup-text service failed"
                raise KickstartValueError(msg)
            # NetworkManager: Disable
            rc = iutil.execInSysroot("rm", [
                "-rf",
                "etc/systemd/system/multi-user.target.wants/NetworkManager.service",
                "etc/systemd/system/dbus-org.freedesktop.NetworkManager.service",
                "etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service"
            ])
            if rc:
                msg = "Disabling Network Failed"
                raise KickstartValueError(msg)

        elif (self.env == "firstboot") and (self.state == "True"):

            rc = iutil._run_systemctl("enable", "network")
            if rc:
                print("Network start failed")
            ret = self.run_packstack()
            if ret:
                if (self.cleanup()):
                    raw_input(
                        "OpenStack Successfully Setup! Press Any Key To Continue..."
                    )
                else:
                    raw_input(
                        "Warning! OpenStack Successfully Setup But System Cleanup failed. Press Any Key To Continue..."
                    )
        else:
            pass