Example #1
0
def auto_install(ops: command.Operations,
                 authorized_key=None,
                 persistent: bool = False,
                 cdrom_install: bool = False,
                 debug_qemu: bool = False):
    "complete cluster installation and launch"
    if authorized_key is None:
        if "HOME" not in os.environ:
            command.fail(
                "expected $HOME to be set for authorized_key autodetect")
        authorized_key = os.path.join(os.getenv("HOME"), ".ssh/id_rsa.pub")
    project, config = configuration.get_project(), configuration.get_config()
    iso_path = os.path.join(project, "cluster-%d.iso" % os.getpid())
    ops.add_operation("check nested virtualization", qemu_check_nested_virt)
    ops.add_operation("update known hosts", access.update_known_hosts)
    ops.add_operation("generate ISO",
                      lambda: iso.gen_iso(iso_path, authorized_key, "serial"))
    with ops.context("networking", net_context()):
        with ops.context("termination", TerminationContext()) as tc:
            with ops.context("debug shell", DebugContext(persistent)):
                ops.add_subcommand(auto_install_supervisor,
                                   tc,
                                   config.keyserver,
                                   iso_path,
                                   cdrom_install=cdrom_install,
                                   debug_qemu=debug_qemu)
                ops.add_subcommand(auto_launch_supervisor,
                                   tc,
                                   config.keyserver,
                                   debug_qemu=debug_qemu)
                ops.add_subcommand(seq.sequence_supervisor)

                other_nodes = [
                    n for n in config.nodes if n != config.keyserver
                ]
                ops.add_subcommand(auto_install_nodes,
                                   tc,
                                   other_nodes,
                                   iso_path,
                                   cdrom_install=cdrom_install,
                                   debug_qemu=debug_qemu)
                ops.add_subcommand(auto_launch_nodes,
                                   tc,
                                   other_nodes,
                                   debug_qemu=debug_qemu)

                ops.add_subcommand(seq.sequence_cluster)
Example #2
0
def auto_launch(ops: command.Operations, debug_qemu: bool = False):
    "launch installed cluster"
    config = configuration.get_config()
    with ops.context("networking", net_context()):
        with ops.context("termination", TerminationContext()) as tc:
            with ops.context("debug shell", DebugContext(True)):
                ops.add_subcommand(auto_launch_supervisor,
                                   tc,
                                   config.keyserver,
                                   debug_qemu=debug_qemu)
                other_nodes = [
                    n for n in config.nodes if n != config.keyserver
                ]
                ops.add_subcommand(auto_launch_nodes,
                                   tc,
                                   other_nodes,
                                   debug_qemu=debug_qemu)