예제 #1
0
def run_health(api):
    config = scaffold.get_config()
    try:
        exe('ping -c 1 -w 1 {}'.format(config['mgmt_ip']))
    except EnvironmentError:
        print('Could not ping mgmt_ip:', config['mgmt_ip'])
        return False
    try:
        api.app_instances.list()
    except Exception as e:
        print("Could not connect to cluster", e)
        return False
    npass = True
    av = api.system.network.access_vip.get()
    for np in av['network_paths']:
        ip = np.get('ip')
        if ip:
            try:
                exe('ping -c 1 -w 1 {}'.format(ip))
            except EnvironmentError:
                print('Could not ping: {} {}'.format(np.get('name'), ip))
                npass = False
    if not npass:
        return False
    print("Health Check Completed Successfully")
    return True
예제 #2
0
파일: common.py 프로젝트: sscargal/ddct
def get_config():
    api = scaffold.get_api(strict=False)
    config = scaffold.get_config()
    config['api'] = api
    access_paths = api.system.network.access_vip.get()['network_paths']
    config['vip1_ip'] = access_paths[0]['ip']
    if len(access_paths) > 1:
        config['vip2_ip'] = access_paths[1]['ip']
    return config
예제 #3
0
def check_install(host):
    try:
        exe_remote(host, 'test -d ~/dbmp')
    except EnvironmentError:
        exe_remote(host, 'git clone {} && ~/dbmp/install.py'.format(DBMP_REPO))
    with tempfile.NamedTemporaryFile() as tf:
        config = scaffold.get_config()
        tf.write(json.dumps(config))
        tf.flush()
        user, _, _ = get_topology(host)
        putf_remote(host, tf.name,
                    '/home/{}/datera-config.json'.format(user))
예제 #4
0
def main(args):
    global VERBOSE
    VERBOSE = args.verbose
    if args.tenant:
        set_conf_tenant(args.tenant)
        restart_cvol()
    api = scaffold.get_api()
    config = scaffold.get_config()
    print("Using Config")
    scaffold.print_config()
    # Tests
    ptests = set(_TESTS)
    tests = set()
    if args.filter:
        for f in args.filter:
            tests.update(
                filter(lambda x: f in x.__name__ or f == x.__name__, ptests))
    else:
        tests = ptests
    if args.list_tests:
        print("TESTS")
        print("-----")
        for test in sorted(tests):
            print(test.__name__)
        sys.exit(0)
    for test in sorted(tests):
        if args.stop_on_failure and len(_FAIL) > 0:
            print("Detected failure, stopping tests")
            sys.exit(1)
        test(api)

    print()
    print("----------")
    print("| REPORT |")
    print("----------")
    print("Tenant:", config['tenant'])
    print("PASSED:", len(_PASS))
    print("FAILED:", len(_FAIL))
    for name, e in _FAIL:
        print(name)
        print(e)
    print("XFAILED:", len(_XFAIL))
    for name, e in _XFAIL:
        print(name)
        print(e)
    print("SKIPPED:", len(_SKIP))
예제 #5
0
def get_topology(host):
    global _TOPOLOGY
    if host == 'local':
        return 'local'
    if not _TOPOLOGY:
        config = scaffold.get_config()
        if 'topology' in config:
            _TOPOLOGY = config['topology']
        elif host != 'local':
            _TOPOLOGY = read_topology_file(TFILE)
    if host != 'local' and not _TOPOLOGY:
        raise EnvironmentError(
            "Non-local host specified, but no topology file found")
    if host not in _TOPOLOGY:
        raise EnvironmentError(
            "Unrecognized host: {}.  Check topology file".format(host))
    top = _TOPOLOGY[host]
    user, back = top.split('@')
    ip, creds = back.split(':')
    return user, ip, creds