示例#1
0
def main():
    deploy_path = os.environ.get('MUCHOS_HOME')
    if not deploy_path:
        exit('ERROR - MUCHOS_HOME env variable must be set!')
    if not os.path.isdir(deploy_path):
        exit('ERROR - Directory set by MUCHOS_HOME does not exist: ' +
             deploy_path)

    config_path = join(deploy_path, "conf/muchos.props")
    if not isfile(config_path):
        exit('ERROR - A config file does not exist at ' + config_path)
    checksums_path = join(deploy_path, "conf/checksums")
    if not isfile(checksums_path):
        exit('ERROR - A checksums file does not exist at ' + checksums_path)

    hosts_dir = join(deploy_path, "conf/hosts/")

    # parse command line args
    retval = parse_args(hosts_dir)
    if not retval:
        print("Invalid command line arguments. For help, use 'muchos -h'")
        sys.exit(1)
    (opts, action, args) = retval

    hosts_path = join(hosts_dir, opts.cluster)

    templates_path = join(deploy_path, "conf/templates/")

    config = DeployConfig(deploy_path, config_path, hosts_path, checksums_path,
                          templates_path, opts.cluster)
    config.verify_config(action)

    if action == 'config':
        if opts.property == 'all':
            config.print_all()
        else:
            config.print_property(opts.property)
    else:
        cluster_type = config.get('general', 'cluster_type')
        if cluster_type == 'existing':
            from muchos.existing import ExistingCluster
            cluster = ExistingCluster(config)
            cluster.perform(action)
        elif cluster_type == 'ec2':
            from muchos.ec2 import Ec2Cluster, Ec2ClusterTemplate
            if config.has_option('ec2', 'cluster_template'):
                cluster = Ec2ClusterTemplate(config)
            else:
                cluster = Ec2Cluster(config)
            cluster.perform(action)
        elif cluster_type == 'azure':
            from muchos.azure import VmssCluster
            cluster = VmssCluster(config)
            cluster.perform(action)
        else:
            exit('Unknown cluster_type: ' + cluster_type)
示例#2
0
def test_util():
  assert get_arch('m1.large') == 'pvm'
  assert get_arch('m3.large') == 'hvm'

  assert get_ami('m3.large', 'us-east-1') == 'ami-6d1c2007'
  assert get_ami('m1.large', 'us-east-1') == None

  hosts_dir = '../../conf/hosts'
  assert parse_args(hosts_dir, ['launch']) == None
  assert parse_args(hosts_dir, ['launch', 'mycluster']) == None
  assert parse_args(hosts_dir, ['-c', 'mycluster', 'launch']) != None

  hosts_dir = '../../conf/hosts/example'
  assert parse_args(hosts_dir, ['setup']) != None
  assert parse_args(hosts_dir, ['config']) == None
  assert parse_args(hosts_dir, ['-p', 'all', 'config']) != None
示例#3
0
def test_util():
    assert set(get_ephemeral_devices('m3.large')) == set(['/dev/xvdb'])
    assert set(get_ephemeral_devices('m3.xlarge')) == set(['/dev/xvdb', '/dev/xvdc'])

    assert set(get_ephemeral_devices('i3.xlarge')) == set(['/dev/nvme0n1'])
    assert set(get_ephemeral_devices('i3.4xlarge')) == set(['/dev/nvme0n1','/dev/nvme1n1'])

    assert get_arch('m1.large') == 'pvm'
    assert get_arch('m3.large') == 'hvm'

    hosts_dir = '../conf/hosts'
    assert parse_args(hosts_dir, ['launch']) is None
    assert parse_args(hosts_dir, ['launch', 'mycluster']) is None
    assert parse_args(hosts_dir, ['-c', 'mycluster', 'launch']) is not None

    hosts_dir = '../conf/hosts/example'
    assert parse_args(hosts_dir, ['setup']) is not None
    assert parse_args(hosts_dir, ['config']) is None
    assert parse_args(hosts_dir, ['-p', 'all', 'config']) is not None
示例#4
0
def test_util():
    assert set(get_ephemeral_devices("m3.large")) == set(["/dev/xvdb"])
    assert set(get_ephemeral_devices("m3.xlarge")) == set(
        ["/dev/xvdb", "/dev/xvdc"]
    )

    assert set(get_ephemeral_devices("i3.xlarge")) == set(["/dev/nvme0n1"])
    assert set(get_ephemeral_devices("i3.4xlarge")) == set(
        ["/dev/nvme0n1", "/dev/nvme1n1"]
    )

    assert get_arch("m1.large") == "pvm"
    assert get_arch("m3.large") == "hvm"

    hosts_dir = "../conf/hosts"
    assert parse_args(hosts_dir, ["launch"]) is None
    assert parse_args(hosts_dir, ["launch", "mycluster"]) is None
    assert parse_args(hosts_dir, ["-c", "mycluster", "launch"]) is not None

    hosts_dir = "../conf/hosts/example"
    assert parse_args(hosts_dir, ["setup"]) is not None
    assert parse_args(hosts_dir, ["config"]) is None
    assert parse_args(hosts_dir, ["-p", "all", "config"]) is not None
示例#5
0
def main():
    deploy_path = environ.get("MUCHOS_HOME")
    if not deploy_path:
        exit("ERROR - MUCHOS_HOME env variable must be set!")
    if not path.isdir(deploy_path):
        exit("ERROR - Directory set by MUCHOS_HOME does not exist: " +
             deploy_path)

    config_path = path.join(deploy_path, "conf/muchos.props")
    if not path.isfile(config_path):
        exit("ERROR - A config file does not exist at " + config_path)
    checksums_path = path.join(deploy_path, "conf/checksums")
    if not path.isfile(checksums_path):
        exit("ERROR - A checksums file does not exist at " + checksums_path)

    hosts_dir = path.join(deploy_path, "conf/hosts/")

    # parse command line args
    retval = parse_args(hosts_dir)
    if not retval:
        print("Invalid command line arguments. For help, use 'muchos -h'")
        exit(1)
    (opts, action, args) = retval

    hosts_path = path.join(hosts_dir, opts.cluster)

    templates_path = path.join(deploy_path, "conf/templates/")

    config = DeployConfig(
        deploy_path,
        config_path,
        hosts_path,
        checksums_path,
        templates_path,
        opts.cluster,
    )
    config.verify_config(action)

    if action == "config":
        if opts.property == "all":
            config.print_all()
        else:
            config.print_property(opts.property)
    else:
        cluster_type = config.get("general", "cluster_type")
        if cluster_type == "existing":
            from muchos.existing import ExistingCluster

            cluster = ExistingCluster(config)
            cluster.perform(action)
        elif cluster_type == "ec2":
            from muchos.ec2 import Ec2Cluster, Ec2ClusterTemplate

            if config.has_option("ec2", "cluster_template"):
                cluster = Ec2ClusterTemplate(config)
            else:
                cluster = Ec2Cluster(config)
            cluster.perform(action)
        elif cluster_type == "azure":
            from muchos.azure import VmssCluster

            cluster = VmssCluster(config)
            cluster.perform(action)
        else:
            exit("Unknown cluster_type: " + cluster_type)
示例#6
0
def main():
    deploy_path = os.environ.get('MUCHOS_HOME')
    if not deploy_path:
        exit('ERROR - MUCHOS_HOME env variable must be set!')
    if not os.path.isdir(deploy_path):
        exit('ERROR - Directory set by MUCHOS_HOME does not exist: ' +
             deploy_path)

    config_path = join(deploy_path, "conf/muchos.props")
    if not isfile(config_path):
        exit('ERROR - A config file does not exist at ' + config_path)
    checksums_path = join(deploy_path, "conf/checksums")
    if not isfile(checksums_path):
        exit('ERROR - A checksums file does not exist at ' + checksums_path)

    hosts_dir = join(deploy_path, "conf/hosts/")

    # parse command line args
    retval = parse_args(hosts_dir)
    if not retval:
        print("Invalid command line arguments. For help, use 'muchos -h'")
        sys.exit(1)
    (opts, action, args) = retval

    hosts_path = join(hosts_dir, opts.cluster)

    config = DeployConfig(deploy_path, config_path, hosts_path, checksums_path,
                          opts.cluster)
    config.verify_config(action)

    cluster = MuchosCluster(config)

    if action == 'launch':
        cluster.launch()
    elif action == 'status':
        nodes = cluster.status(['running'])
        print("Found {0} nodes in {1} cluster".format(len(nodes),
                                                      config.cluster_name))
        cluster.print_nodes(nodes)
    elif action == 'sync':
        cluster.sync()
    elif action == 'setup':
        cluster.setup()
    elif action == 'config':
        if opts.property == 'all':
            config.print_all()
        else:
            config.print_property(opts.property)
    elif action == 'ssh':
        cluster.ssh()
    elif action in ('wipe', 'kill', 'cancel_shutdown'):
        if not isfile(hosts_path):
            exit("Hosts file does not exist for cluster: " + hosts_path)
        if action == 'wipe':
            print("Killing all processes started by Muchos and wiping Muchos data from {0} cluster"\
                .format(config.cluster_name))
        elif action == 'kill':
            print("Killing all processes started by Muchos on {0} cluster".
                  format(config.cluster_name))
        elif action == 'cancel_shutdown':
            print("Cancelling automatic shutdown of {0} cluster".format(
                config.cluster_name))
        cluster.execute_playbook(action + ".yml")
    elif action == 'terminate':
        cluster.terminate(hosts_path)
    else:
        print('ERROR - Unknown action:', action)