Example #1
0
def bootstrap_client():
    parser = argparse.ArgumentParser(description="heaverc, the heaver client")

    # actions
    parser.add_argument("-S", "--start", action="store_true", help="Start container")
    parser.add_argument("-C", "--create", action="store_true", help="Create container")
    parser.add_argument("-T", "--stop", action="store_true", help="Stop container")
    parser.add_argument("-D", "--destroy", action="store_true", help="Destroy container")
    parser.add_argument("-L", "--list", action="store_true", help="List containers")
    parser.add_argument("-H", "--list-hosts", action="store_true", help="List hosts")
    parser.add_argument("-I", "--info", action="store_true", help="Show container info")
    parser.add_argument("--tarball", help="Get container's root tarball")
    parser.add_argument("--sync-images", action="store_true",
                        help="Syncronize image given by -i (or all images if none given)")

    # parameters
    parser.add_argument("-n", "--name", help="Name of container")
    parser.add_argument("-i", "--image", action="append", help="Image(s) for container")
    parser.add_argument("--host", help="Host to operate on")
    parser.add_argument("-k", "--key",
            help="Public ssh key (will be added to root's authorized keys)")
    parser.add_argument("--raw-key",
            help="Public ssh key as string (will be added to root's authorized keys)")

    parser.add_argument("--net", action="append", help=("Network definition for container."
        " Take name of configured network and, optionally, number of ips from given net"
        " (separated by semicolon), i.e. --net br0 --net br1:2. Distinct virtual interfaces will be"
        " created for each argument"))

    parser.add_argument("--limit", action="append", help=("Set container limits. Overrides "
        "default values (from config). Format: option=value, available options: cpu, memory"))

    # raw network disabled for client
    #parser.add_argument("--raw-net", action="append", help=("Raw bridged network definition "
    #    "in form hostbr[/hwaddr]:ip.add.r.ess/mask, i.e. br0:192.168.2.22/24 "
    #    "br0/02.de.ad.be.ef.01:192.168.2.23/24. hostbr must be set up manually"))

    # maintenance
    parser.add_argument("--dryrun", action="store_true",
        help="Don't touch anything, report what will be done")
    parser.add_argument("--config", help="Config file to use", default="/etc/heaver/client.yml")

    args = parser.parse_args()

    report.format = report.format_pretty
    report.die = report.die_pretty

    config = must_read_config(args.config)
    must_set_up_logging(config, "pretty")

    import heaver.cli.client as main
    main.main(args, config)
Example #2
0
def bootstrap_daemon():
    parser = argparse.ArgumentParser(description="heaverd, the heaver daemon")

    # parameters
    parser.add_argument("--config", help="Config file to use", default="/etc/heaver/daemon.yml")

    args = parser.parse_args()

    report.format = report.format_pretty
    report.die = report.die_pretty

    config = must_read_config(args.config)
    must_set_up_logging(config, "pretty")

    import heaver.cli.daemon as main
    main.main(args, config)
Example #3
0
def bootstrap_daemon():
    parser = argparse.ArgumentParser(description="heaverd, the heaver daemon")

    # parameters
    parser.add_argument("--config",
                        help="Config file to use",
                        default="/etc/heaver/daemon.yml")

    args = parser.parse_args()

    report.format = report.format_pretty
    report.die = report.die_pretty

    config = must_read_config(args.config)
    must_set_up_logging(config, "pretty")

    import heaver.cli.daemon as main
    main.main(args, config)
Example #4
0
def bootstrap():
    parser = argparse.ArgumentParser(description="heaver, the lxc container manager")

    # actions
    parser.add_argument("-S", "--start", action="store_true", help="Start container")
    parser.add_argument("-C", "--create", action="store_true", help="Create container")
    parser.add_argument("-T", "--stop", action="store_true", help="Stop container")
    parser.add_argument("-D", "--destroy", action="store_true", help="Destroy container")
    parser.add_argument("-L", "--list", action="store_true", help="List containers")
    # tarball can haz optional path to tarball
    parser.add_argument("--tarball", nargs="?", const="<generated>",
                        help="Create tarball of container's root")
    parser.add_argument("--send-status", action="store_true", help="Send host status to daemon")
    parser.add_argument("--status", action="store_true", help="Show host status")

    # maintenance actions
    parser.add_argument("--startup", action="store_true",
                        help="Start all containers that should be running")
    parser.add_argument("--shutdown", action="store_true",
                        help="Stop all containers running containers before shutdown")

    # parameters
    parser.add_argument("-n", "--name", help="Name of container")
    parser.add_argument("-k", "--key",
            help="Public ssh key file (will be added to root's authorized keys)")
    parser.add_argument("--raw-key",
            help="Public ssh key as string (will be added to root's authorized keys)")

    root_src = parser.add_mutually_exclusive_group()
    root_src.add_argument("-i", "--image", action="append", help="Image for container")
    root_src.add_argument("-r", "--root", help="Root of container fs")

    parser.add_argument("--net", action="append", help=("Network definition for container."
        " Take name of configured network and, optionally, number of ips from given net"
        " (separated by semicolon), i.e. --net br0 --net br1:2. Distinct virtual interfaces will be"
        " created for each argument"))
    parser.add_argument("--raw-net", action="append", help=("Raw bridged network definition "
        "in form hostbr[/hwaddr]:ip.add.r.ess/mask, i.e. br0:192.168.2.22/24 "
        "br0/02.de.ad.be.ef.01:192.168.2.23/24. hostbr must be set up manually"))

    parser.add_argument("--limit", action="append", help=("Set container limits. Overrides "
        "default values (from config). Format: option=value, available options: cpu, memory"))

    # special modificators
    parser.add_argument("--all", action="store_true",
        help="Operate on all current instances instead of one given")
    parser.add_argument("--force", help="Dont doubt, do what I say")

    # appearance
    parser.add_argument("--format", choices=["pretty", "json"], default="pretty",
        help="Format messages human-readable or machine-readable")
    # parser.add_argument("-v", "--verbose", action="count", help="Set verbosity level")

    # maintenance
    parser.add_argument("--dryrun", action="store_true",
        help="Don't touch anything, report what will be done")
    parser.add_argument("--config", help="Config file to use", default="/etc/heaver/worker.yml")


    args = parser.parse_args()

    if args.format == "pretty":
        report.format = report.format_pretty
        report.die = report.die_pretty
    elif args.format == "json":
        report.format = report.format_json
        report.die = report.die_json

    config = must_read_config(args.config)
    must_set_up_logging(config, args.format)
    must_validate_config(config, args)

    import heaver.cli.main as main
    main.main(args, config)
Example #5
0
def bootstrap():
    parser = argparse.ArgumentParser(
        description="heaver, the lxc container manager")

    # actions
    parser.add_argument("-S",
                        "--start",
                        action="store_true",
                        help="Start container")
    parser.add_argument("-C",
                        "--create",
                        action="store_true",
                        help="Create container")
    parser.add_argument("-T",
                        "--stop",
                        action="store_true",
                        help="Stop container")
    parser.add_argument("-D",
                        "--destroy",
                        action="store_true",
                        help="Destroy container")
    parser.add_argument("-L",
                        "--list",
                        action="store_true",
                        help="List containers")
    # tarball can haz optional path to tarball
    parser.add_argument("--tarball",
                        nargs="?",
                        const="<generated>",
                        help="Create tarball of container's root")
    parser.add_argument("--send-status",
                        action="store_true",
                        help="Send host status to daemon")
    parser.add_argument("--status",
                        action="store_true",
                        help="Show host status")

    # maintenance actions
    parser.add_argument("--startup",
                        action="store_true",
                        help="Start all containers that should be running")
    parser.add_argument(
        "--shutdown",
        action="store_true",
        help="Stop all containers running containers before shutdown")

    # parameters
    parser.add_argument("-n", "--name", help="Name of container")
    parser.add_argument(
        "-k",
        "--key",
        help="Public ssh key file (will be added to root's authorized keys)")
    parser.add_argument(
        "--raw-key",
        help=
        "Public ssh key as string (will be added to root's authorized keys)")

    root_src = parser.add_mutually_exclusive_group()
    root_src.add_argument("-i",
                          "--image",
                          action="append",
                          help="Image for container")
    root_src.add_argument("-r", "--root", help="Root of container fs")

    parser.add_argument(
        "--net",
        action="append",
        help=
        ("Network definition for container."
         " Take name of configured network and, optionally, number of ips from given net"
         " (separated by semicolon), i.e. --net br0 --net br1:2. Distinct virtual interfaces will be"
         " created for each argument"))
    parser.add_argument(
        "--raw-net",
        action="append",
        help=
        ("Raw bridged network definition "
         "in form hostbr[/hwaddr]:ip.add.r.ess/mask, i.e. br0:192.168.2.22/24 "
         "br0/02.de.ad.be.ef.01:192.168.2.23/24. hostbr must be set up manually"
         ))

    parser.add_argument(
        "--limit",
        action="append",
        help=
        ("Set container limits. Overrides "
         "default values (from config). Format: option=value, available options: cpu, memory"
         ))

    # special modificators
    parser.add_argument(
        "--all",
        action="store_true",
        help="Operate on all current instances instead of one given")
    parser.add_argument("--force", help="Dont doubt, do what I say")

    # appearance
    parser.add_argument(
        "--format",
        choices=["pretty", "json"],
        default="pretty",
        help="Format messages human-readable or machine-readable")
    # parser.add_argument("-v", "--verbose", action="count", help="Set verbosity level")

    # maintenance
    parser.add_argument("--dryrun",
                        action="store_true",
                        help="Don't touch anything, report what will be done")
    parser.add_argument("--config",
                        help="Config file to use",
                        default="/etc/heaver/worker.yml")

    args = parser.parse_args()

    if args.format == "pretty":
        report.format = report.format_pretty
        report.die = report.die_pretty
    elif args.format == "json":
        report.format = report.format_json
        report.die = report.die_json

    config = must_read_config(args.config)
    must_set_up_logging(config, args.format)
    must_validate_config(config, args)

    import heaver.cli.main as main
    main.main(args, config)
Example #6
0
def bootstrap_client():
    parser = argparse.ArgumentParser(description="heaverc, the heaver client")

    # actions
    parser.add_argument("-S",
                        "--start",
                        action="store_true",
                        help="Start container")
    parser.add_argument("-C",
                        "--create",
                        action="store_true",
                        help="Create container")
    parser.add_argument("-T",
                        "--stop",
                        action="store_true",
                        help="Stop container")
    parser.add_argument("-D",
                        "--destroy",
                        action="store_true",
                        help="Destroy container")
    parser.add_argument("-L",
                        "--list",
                        action="store_true",
                        help="List containers")
    parser.add_argument("-H",
                        "--list-hosts",
                        action="store_true",
                        help="List hosts")
    parser.add_argument("-I",
                        "--info",
                        action="store_true",
                        help="Show container info")
    parser.add_argument("--tarball", help="Get container's root tarball")
    parser.add_argument(
        "--sync-images",
        action="store_true",
        help="Syncronize image given by -i (or all images if none given)")

    # parameters
    parser.add_argument("-n", "--name", help="Name of container")
    parser.add_argument("-i",
                        "--image",
                        action="append",
                        help="Image(s) for container")
    parser.add_argument("--host", help="Host to operate on")
    parser.add_argument(
        "-k",
        "--key",
        help="Public ssh key (will be added to root's authorized keys)")
    parser.add_argument(
        "--raw-key",
        help=
        "Public ssh key as string (will be added to root's authorized keys)")

    parser.add_argument(
        "--net",
        action="append",
        help=
        ("Network definition for container."
         " Take name of configured network and, optionally, number of ips from given net"
         " (separated by semicolon), i.e. --net br0 --net br1:2. Distinct virtual interfaces will be"
         " created for each argument"))

    parser.add_argument(
        "--limit",
        action="append",
        help=
        ("Set container limits. Overrides "
         "default values (from config). Format: option=value, available options: cpu, memory"
         ))

    # raw network disabled for client
    #parser.add_argument("--raw-net", action="append", help=("Raw bridged network definition "
    #    "in form hostbr[/hwaddr]:ip.add.r.ess/mask, i.e. br0:192.168.2.22/24 "
    #    "br0/02.de.ad.be.ef.01:192.168.2.23/24. hostbr must be set up manually"))

    # maintenance
    parser.add_argument("--dryrun",
                        action="store_true",
                        help="Don't touch anything, report what will be done")
    parser.add_argument("--config",
                        help="Config file to use",
                        default="/etc/heaver/client.yml")

    args = parser.parse_args()

    report.format = report.format_pretty
    report.die = report.die_pretty

    config = must_read_config(args.config)
    must_set_up_logging(config, "pretty")

    import heaver.cli.client as main
    main.main(args, config)