def base_url(persistent_environment): """ When --base-url is not provided - set up an environment and get a OZ host. Assume, that protocol is always HTTPS, so return base_url: https://<oz_host> """ set_dns(persistent_environment) oz_host = re.match(r'worker@node\d*\.(.*)', persistent_environment["oz_worker_nodes"][0]).groups(0)[0] return "https://{oz_host}".format(oz_host=oz_host)
def register_users(users, passwords, context, onedata_environment, request): set_dns(onedata_environment) users = list_parser(users) passwords = list_parser(passwords) onepanel = onedata_environment['onepanel_nodes'][0].split('@')[1] if not hasattr(context, "users"): context.users = {} for user_name, password in zip(users, passwords): user = create_user(user_name, password, onepanel) user.set_oz_domain(onedata_environment) context.users[user_name] = user def fin(): for user_name in users: user = context.get_user(user_name) for space in user.created_spaces.keys(): delete_space(user, space) delete_user(user_name, onepanel) del context.users[user_name] request.addfinalizer(fin) return users
def mount_users(request, environment, context, client_dockers, env_description_file, providers, user_names=[], client_instances=[], mount_paths=[], client_hosts=[], tokens=[]): # current version is for environment with one OZ oz_node = environment['oz_worker_nodes'][0] set_dns(environment) client_data = environment['client_data'] clients = create_clients(user_names, client_hosts, mount_paths, client_dockers) parameters = zip(user_names, clients, client_instances, mount_paths, client_hosts, tokens) for user_name, client, client_instance, mount_path, client_host, token_arg in parameters: data = client_data[client_host][client_instance] oz_domain = data['zone_domain'] # get OZ cookie from env description file cookie = get_oz_cookie(env_description_file, oz_domain, node_name=False) user = context.get_user(user_name) if not user: provider_id = data['op_domain'].split('.')[0] user = User(user_name, id=user_name, oz_domain=oz_domain, provider=providers[provider_id]) # get token for user if token_arg != 'bad_token': token = get_token(token_arg, user.id, oz_node, cookie) client.set_timeout(data.get('default_timeout', 0)) print "User {user} mounts oneclient using token: {token}"\ .format(user=user_name, token=token) # /root has to be accessible for gdb to access /root/bin/oneclient assert run_cmd('root', client, 'chmod +x /root') == 0 client.start_rpyc(user.name) client.token = token client.user_cert = data['user_cert'] client.user_key = data['user_key'] ret = client.mount(user) user.update_clients(client_instance, client) if not context.has_user(user): context.add_user(user) if ret != 0 and token_arg != "bad token": # if token was different than "bad token" and mounting failed clean_mount_path(user_name, client) pytest.fail("Error mounting oneclient") # todo without this sleep protocol error occurs more often during cleaning spaces time.sleep(3) if token != 'bad_token': try: clean_spaces(client) except AssertionError: pytest.fail("Failed to clean spaces") if ret == 0: user.mark_last_operation_succeeded() else: user.mark_last_operation_failed() def fin(): params = zip(user_names, clients) for user_name, client in params: time.sleep(5) for opened_file in client.opened_files.keys(): close_file(client, opened_file) client.opened_files.clear() clean_mount_path(user_name, client) for user_name in user_names: user = context.get_user(user_name) for client in user.clients.values(): client.stop_rpyc_server() user.clients.clear() request.addfinalizer(fin)