Пример #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_case_sensitive():
  c = DeployConfig("muchos", '../../conf/muchos.props.example', '../../conf/hosts/example/example_cluster', 'mycluster')
  assert c.has_option('ec2', 'aws_secret_key') == True
  assert c.has_option('ec2', 'Aws_secret_key') == False
  c.set('nodes', 'CamelCaseWorker', 'worker,fluo')
  c.init_nodes()
  assert c.get_node('CamelCaseWorker') == ['worker', 'fluo']
Пример #3
0
def test_case_sensitive():
    c = DeployConfig("muchos", '../conf/muchos.props.example', '../conf/hosts/example/example_cluster',
                     '../conf/checksums', '../conf/templates', 'mycluster')
    assert c.has_option('ec2', 'default_instance_type') == True
    assert c.has_option('ec2', 'Default_instance_type') == False
    c.set('nodes', 'CamelCaseWorker', 'worker,fluo')
    c.init_nodes()
    assert c.get_node('CamelCaseWorker') == ['worker', 'fluo']
Пример #4
0
def test_existing_cluster():
    c = DeployConfig("muchos", '../conf/muchos.props.example', '../conf/hosts/example/example_cluster',
                     '../conf/checksums', '../conf/templates', 'mycluster')
    c.cluster_type = 'existing'
    assert c.get_cluster_type() == 'existing'
    assert c.node_type_map() == {}
    assert c.mount_root() == '/var/data'
    assert c.fstype() is None
    assert c.force_format() == 'no'
    assert c.worker_data_dirs() == ['/var/data1', '/var/data2', '/var/data3']
    assert c.default_data_dirs() == ['/var/data1', '/var/data2', '/var/data3']
    assert c.metrics_drive_ids() == ['var-data1', 'var-data2', 'var-data3']
    assert c.shutdown_delay_minutes() == '0'
Пример #5
0
def test_defaults():
  c = DeployConfig("muchos", '../../conf/muchos.props.example', '../../conf/hosts/example/example_cluster', 'mycluster')
  assert c.get('ec2', 'default_instance_type') == 'm3.large'
  assert c.get('ec2', 'worker_instance_type') == 'm3.large'
  assert c.num_ephemeral('worker1') == 1
  assert c.num_ephemeral('worker1') == c.worker_num_ephemeral()
  assert c.max_ephemeral() == 1
  assert c.mounts(2) == ['/media/ephemeral0', '/media/ephemeral1']
  assert c.devices(2) == ['/dev/xvdb', '/dev/xvdc']
  assert c.node_type_map() == {'default': {'mounts': ['/media/ephemeral0',], 'devices': ['/dev/xvdb',]}, 'worker': {'mounts': ['/media/ephemeral0',], 'devices': ['/dev/xvdb',]}}
  assert c.node_type('worker1') == 'worker'
  assert c.node_type('leader1') == 'default'
  assert c.get('ec2', 'region') == 'us-east-1'
  assert c.has_option('ec2', 'vpc_id') == False
  assert c.has_option('ec2', 'subnet_id') == False
  assert c.get('ec2', 'key_name') == 'my_aws_key'
  assert c.instance_tags() == {}
  assert len(c.nodes()) == 7
  assert c.get_node('leader1') == ['namenode', 'zookeeper', 'fluo']
  assert c.get_node('worker1') == ['worker']
  assert c.get_node('worker2') == ['worker']
  assert c.get_node('worker3') == ['worker']
  assert c.has_service('fluo')
  assert c.get_service_hostnames('worker') == ['worker1', 'worker2', 'worker3']
  assert c.get_service_hostnames('zookeeper') == ['leader1', 'leader2', 'leader3']
  assert c.get_hosts() == {'leader2': ('10.0.0.1', None), 'leader3': ('10.0.0.2', None), 'leader1': ('10.0.0.0', '23.0.0.0'),
                           'worker1': ('10.0.0.3', None), 'worker3': ('10.0.0.5', None), 'worker2': ('10.0.0.4', None)}
  assert c.get_public_ip('leader1') == '23.0.0.0'
  assert c.get_private_ip('leader1') == '10.0.0.0'
  assert c.cluster_name == 'mycluster'
  assert c.version("accumulo").startswith('1.')
  assert c.version("fluo").startswith('1.')
  assert c.version("hadoop").startswith('2.')
  assert c.version("zookeeper").startswith('3.')
  assert c.get_service_private_ips("worker") == ['10.0.0.3', '10.0.0.4', '10.0.0.5']
  assert c.get('general', 'proxy_hostname') == "leader1"
  assert c.proxy_public_ip() == "23.0.0.0"
  assert c.proxy_private_ip() == "10.0.0.0"
  assert c.get('general', 'cluster_basedir') == "/home/centos"
  assert c.get('general', 'cluster_user') == "centos"
  assert c.get_non_proxy() == [('10.0.0.1', 'leader2'), ('10.0.0.2', 'leader3'), ('10.0.0.3', 'worker1'), ('10.0.0.4', 'worker2'), ('10.0.0.5', 'worker3')]
  assert c.get_host_services() == [('leader1', 'namenode zookeeper fluo'), ('leader2', 'resourcemanager zookeeper'), ('leader3', 'accumulomaster zookeeper'),
                                   ('metrics', 'metrics'), ('worker1', 'worker'), ('worker2', 'worker'), ('worker3', 'worker')]
  assert c.get_image_id('m3.large') == 'ami-6d1c2007'
  assert c.get('ec2', 'aws_access_key') == 'access_key'
  assert c.get('ec2', 'aws_secret_key') == 'secret_key'
Пример #6
0
def test_defaults():
    c = DeployConfig("muchos", '../conf/muchos.props.example',
                     '../conf/hosts/example/example_cluster',
                     '../conf/checksums', 'mycluster')
    assert c.checksum_ver(
        'accumulo', '1.9.0'
    ) == 'f68a6145029a9ea843b0305c90a7f5f0334d8a8ceeea94734267ec36421fe7fe'
    assert c.checksum(
        'accumulo'
    ) == 'baa5e0929248ff0d96355bc7fb42a5b75d183a83364519296e07b0adbb089180'
    assert c.get('ec2', 'default_instance_type') == 'm5d.large'
    assert c.get('ec2', 'worker_instance_type') == 'm5d.large'
    assert c.get('ec2', 'aws_ami') == 'ami-9887c6e7'
    assert c.max_ephemeral() == 1
    assert c.mounts(2) == ['/media/ephemeral0', '/media/ephemeral1']
    assert c.node_type_map() == {
        'default': {
            'mounts': [
                '/media/ephemeral0',
            ],
            'devices': [
                '/dev/nvme1n1',
            ]
        },
        'worker': {
            'mounts': [
                '/media/ephemeral0',
            ],
            'devices': [
                '/dev/nvme1n1',
            ]
        }
    }
    assert c.node_type('worker1') == 'worker'
    assert c.node_type('leader1') == 'default'
    assert not c.has_option('ec2', 'vpc_id')
    assert not c.has_option('ec2', 'subnet_id')
    assert c.get('ec2', 'key_name') == 'my_aws_key'
    assert c.instance_tags() == {}
    assert len(c.nodes()) == 6
    assert c.get_node('leader1') == [
        'namenode', 'resourcemanager', 'accumulomaster', 'zookeeper'
    ]
    assert c.get_node('worker1') == ['worker', 'swarmmanager']
    assert c.get_node('worker2') == ['worker']
    assert c.get_node('worker3') == ['worker']
    assert c.has_service('accumulomaster')
    assert not c.has_service('fluo')
    assert c.get_service_hostnames('worker') == [
        'worker1', 'worker2', 'worker3', 'worker4'
    ]
    assert c.get_service_hostnames('zookeeper') == ['leader1']
    assert c.get_hosts() == {
        'leader2': ('10.0.0.1', None),
        'leader1': ('10.0.0.0', '23.0.0.0'),
        'worker1': ('10.0.0.2', None),
        'worker3': ('10.0.0.4', None),
        'worker2': ('10.0.0.3', None),
        'worker4': ('10.0.0.5', None)
    }
    assert c.get_public_ip('leader1') == '23.0.0.0'
    assert c.get_private_ip('leader1') == '10.0.0.0'
    assert c.cluster_name == 'mycluster'
    assert c.version("accumulo").startswith('2.')
    assert c.version("fluo").startswith('1.')
    assert c.version("hadoop").startswith('3.')
    assert c.version("zookeeper").startswith('3.')
    assert c.get_service_private_ips("worker") == [
        '10.0.0.2', '10.0.0.3', '10.0.0.4', '10.0.0.5'
    ]
    assert c.get('general', 'proxy_hostname') == "leader1"
    assert c.proxy_public_ip() == "23.0.0.0"
    assert c.proxy_private_ip() == "10.0.0.0"
    assert c.get('general', 'cluster_basedir') == "/home/centos"
    assert c.get('general', 'cluster_user') == "centos"
    assert c.get_non_proxy() == [('10.0.0.1', 'leader2'),
                                 ('10.0.0.2', 'worker1'),
                                 ('10.0.0.3', 'worker2'),
                                 ('10.0.0.4', 'worker3'),
                                 ('10.0.0.5', 'worker4')]
    assert c.get_host_services() == [
        ('leader1', 'namenode resourcemanager accumulomaster zookeeper'),
        ('leader2', 'metrics'), ('worker1', 'worker swarmmanager'),
        ('worker2', 'worker'), ('worker3', 'worker'), ('worker4', 'worker')
    ]
Пример #7
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)
Пример #8
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)