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
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
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))
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))
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