Exemplo n.º 1
0
def action(ns):
    if not os.path.isfile(ns.path):
        raise Exception("No such file: {0}".format(ns.path))

    puppet_env = dict()

    if ns.facts:
        for fact in ns.facts:
            try:
                key, value = fact.split("=", 2)
            except:
                raise Exception("Invalid fact: {0}".format(fact))

            puppet_env["FACTER_{0}".format(key)] = value

    with entered_system(ns.path, ns.volume_group, ns.mountpoint) as d:
        devices, logical_volumes, path = d

        puppetpath = "{0}/puppet".format(ns.mountpoint)

        if not os.path.isdir(puppetpath):
            os.makedirs(puppetpath)

        with mounted_device(ns.puppetpath, puppetpath, mount_bind=True):
            chroot(path, "puppet", *ns.puppetargs, env=puppet_env)

    return 0
Exemplo n.º 2
0
def action(ns):
    """
    Invoke debootstrap on an already created image.
    """
    if not os.path.isfile(ns.path):
        raise Exception("No such file: {0}".format(ns.path))

    if not os.path.isdir(ns.mountpoint):
        log.info("Creating mountpoint: {0}".format(ns.mountpoint))
        os.makedirs(ns.mountpoint)

    with mounted_loopback(ns.path):
        with available_lvm(ns.volume_group) as logical_volumes:
            with mounted_device(logical_volumes[0], ns.mountpoint):
                log.info("Installing on {0}".format(ns.mountpoint))
                debootstrap("--arch", ns.arch, ns.suite, ns.mountpoint,
                            ns.mirror)

    return 0
Exemplo n.º 3
0
def action(ns):
    """
    Invoke debootstrap on an already created image.
    """
    if not os.path.isfile(ns.path):
        raise Exception("No such file: {0}".format(ns.path))

    if not os.path.isdir(ns.mountpoint):
        log.info("Creating mountpoint: {0}".format(ns.mountpoint))
        os.makedirs(ns.mountpoint)

    with mounted_loopback(ns.path):
        with available_lvm(ns.volume_group) as logical_volumes:
            with mounted_device(logical_volumes[0], ns.mountpoint):
                log.info("Installing on {0}".format(ns.mountpoint))
                debootstrap("--arch", ns.arch, ns.suite,
                            ns.mountpoint, ns.mirror)

    return 0
Exemplo n.º 4
0
        def __ec2_extra_mounts(devices, logical_volumes):
            first_device, partitions = find_first_device(devices)

            return mounted_device(partitions[0],
                                  "{0}/boot".format(self.mountpoint))
Exemplo n.º 5
0
        def __ec2_extra_mounts(devices, logical_volumes):
            first_device, partitions = find_first_device(devices)

            return mounted_device(
                partitions[0], "{0}/boot".format(self.mountpoint))