Esempio n. 1
0
def main():
    args = parse_arguments()
    if not args.config_file:
        args.config_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'config',
            'default.yaml')
    config = load_config(args.config_file)

    vcluster = VCluster(config, args.label_name, args.zookeeper_server,
                        args.respool_path, args.peloton_apps_config_path)

    command = args.command

    if command == 'mesos':
        agent_number = args.agent_number
        vcluster.start_mesos(agent_number)

    elif command == 'mesos-slave':
        agent_number = args.agent_number
        zk = args.zk.split(':')
        if len(zk) != 2:
            raise Exception("Invalid zk")
        vcluster.start_mesos_slave(args.zk, agent_number)

    elif command == 'mesos-master':
        zk = args.zk.split(':')
        if len(zk) != 2:
            raise Exception("Invalid zk")
        vcluster.start_mesos_master(args.zk)

    elif command == 'peloton':
        zk = args.zk.split(':')
        if len(zk) != 2:
            raise Exception("Invalid zk")
        vcluster.start_peloton(args.zk,
                               args.agent_number,
                               args.peloton_version,
                               peloton_image=args.peloton_image)

    elif command == 'setup':
        agent_number = args.agent_number
        peloton_version = args.peloton_version
        if args.clean_setup:
            vcluster.teardown()
        vcluster.start_all(agent_number,
                           peloton_version,
                           skip_respool=args.skip_respool,
                           peloton_image=args.peloton_image)

    elif command == 'teardown':
        option = args.option
        if option == 'slave':
            vcluster.teardown_slave(remove=args.remove)
        elif option == 'peloton':
            vcluster.teardown_peloton(remove=args.remove)
        else:
            vcluster.teardown(remove=args.remove)
Esempio n. 2
0
def main():
    args = parse_arguments()
    if not args.config_file:
        args.config_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            "config",
            "default.yaml",
        )
    config = load_config(args.config_file)

    vcluster = VCluster(
        config,
        args.label_name,
        args.zookeeper_server,
        args.respool_path,
        auth_type=args.auth_type,
        auth_file=args.auth_config_file,
    )

    command = args.command

    if command == "mesos":
        agent_number = args.agent_number
        vcluster.start_mesos(agent_number)

    elif command == "mesos-slave":
        agent_number = args.agent_number
        zk = args.zk.split(":")
        if len(zk) != 2:
            raise Exception("Invalid zk")
        vcluster.start_mesos_slave(args.zk, agent_number)

    elif command == "mesos-master":
        zk = args.zk.split(":")
        if len(zk) != 2:
            raise Exception("Invalid zk")
        vcluster.start_mesos_master(args.zk)

    elif command == "peloton":
        zk = args.zk.split(":")
        if len(zk) != 2:
            raise Exception("Invalid zk")
        vcluster.start_peloton(
            args.zk,
            args.agent_number,
            args.peloton_version,
            skip_respool=args.skip_respool,
            peloton_image=args.peloton_image,
            peloton_apps_config=args.peloton_apps_config_path,
        )

    elif command == "setup":
        agent_number = args.agent_number
        peloton_version = args.peloton_version
        if args.clean_setup:
            vcluster.teardown()
        vcluster.start_all(
            agent_number,
            peloton_version,
            skip_respool=args.skip_respool,
            peloton_image=args.peloton_image,
            peloton_apps_config=args.peloton_apps_config_path,
        )

    elif command == "teardown":
        option = args.option
        if option == "slave":
            vcluster.teardown_slave(remove=args.remove)
        elif option == "peloton":
            vcluster.teardown_peloton(remove=args.remove)
        else:
            vcluster.teardown(remove=args.remove)