コード例 #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
コード例 #2
0
ファイル: enter.py プロジェクト: nresare/vdisk
def action(ns):
    if not os.path.isfile(ns.path):
        raise Exception("No such file: {0}".format(ns.path))

    with entered_system(ns.path, ns.volume_group, ns.mountpoint) as d:
        path = d[2]
        exitcode, out, err = chroot(path, ns.shell, raise_on_exit=False)
        return exitcode
コード例 #3
0
ファイル: install.py プロジェクト: vzctl/vdisk
def action(ns):
    if not os.path.isfile(ns.path):
        raise Exception("Missing image file: {0}".format(ns.path))

    if ns.selections is None:
        ns.selections = os.path.join(ns.root, "selections", "default")

    if not os.path.isfile(ns.selections):
        raise Exception("Missing selections file: {0}".format(ns.selections))

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

        # find first device as soon as possible
        first_device = find_first_device(devices)
        apt_env = dict(APTITUDE_ENV)

        log.info("Configuring apt")
        configure_base_system(ns, apt_env, path)

        log.info("Install selected packages")
        if ns.download:
            download_selections(ns, apt_env, path)
        else:
            install_selections(ns, apt_env, path)

        tmp_devicemap = generate_temporary_devicemap(devices)
        log.info("Writing temporary device.map")
        write_mounted(ns.mountpoint, "boot/grub/device.map", tmp_devicemap)

        log.info("Installing grub on first device")
        chroot(path, "grub-install", "--no-floppy", first_device)

        log.info("Writing fstab")
        fstab = generate_fstab(ns)
        write_mounted(ns.mountpoint, "etc/fstab", fstab)

        log.info("Writing real device.map")
        new_devicemap = generate_devicemap(ns, logical_volumes)
        write_mounted(ns.mountpoint, "boot/grub/device.map", new_devicemap)

        manifest = ns.config.get("manifest")
        postinst = ns.config.get("postinst")

        if manifest:
            install_manifest(ns, manifest)

        if postinst:
            execute_postinst(ns, postinst)

    return 0
コード例 #4
0
ファイル: install.py プロジェクト: nresare/vdisk
def action(ns):
    if not os.path.isfile(ns.path):
        raise Exception("Missing image file: {0}".format(ns.path))

    if ns.selections is None:
        ns.selections = os.path.join(ns.root, "selections", "default")

    if not os.path.isfile(ns.selections):
        raise Exception("Missing selections file: {0}".format(ns.selections))

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

        # find first device as soon as possible
        first_device = find_first_device(devices)
        apt_env = dict(APTITUDE_ENV)

        log.info("Configuring apt")
        configure_base_system(ns, apt_env, path)

        log.info("Download selected packages (do not unpack or configure)")
        download_selections(ns, apt_env, path)

        tmp_devicemap = generate_temporary_devicemap(devices)
        log.info("Writing temporary device.map")
        write_mounted(ns.mountpoint, "boot/grub/device.map", tmp_devicemap)

        log.info("Installing grub on first device")
        chroot(path, "grub-install", "--no-floppy", first_device)

        log.info("Writing fstab")
        fstab = generate_fstab(ns)
        write_mounted(ns.mountpoint, "etc/fstab", fstab)

        log.info("Writing real device.map")
        new_devicemap = generate_devicemap(ns, logical_volumes)
        write_mounted(ns.mountpoint, "boot/grub/device.map", new_devicemap)

        manifest = ns.config.get("manifest")
        postinst = ns.config.get("postinst")

        if manifest:
            install_manifest(ns, manifest)

        if postinst:
            execute_postinst(ns, postinst)

    return 0
コード例 #5
0
 def entered_system(self, **kw):
     return entered_system(self.image_path, self.volume_group,
                           self.mountpoint, **kw)
コード例 #6
0
 def entered_system(self, **kw):
     return entered_system(
         self.image_path,
         self.volume_group,
         self.mountpoint, **kw)
コード例 #7
0
 def entered_system(self, **kw):
     return entered_system(self.image_path,
                           self.volume_group,
                           self.mountpoint,
                           extra_mounts=self._extra_mounts(),
                           **kw)
コード例 #8
0
ファイル: ec2_preset.py プロジェクト: pombredanne/vdisk
 def entered_system(self, **kw):
     return entered_system(
         self.image_path,
         self.volume_group,
         self.mountpoint,
         extra_mounts=self._extra_mounts(), **kw)