def list_branches(dlpx_obj): """ List all branches on a given engine :param dlpx_obj: Virtualization Engine session object """ try: header = '\nBranch Name, Data Layout, Reference, End Time' js_data_layout = '' js_branches = branch.get_all(dlpx_obj.server_session) print header for js_branch in js_branches: js_end_time = operation.get(dlpx_obj.server_session, js_branch.first_operation).end_time if re.search('TEMPLATE', js_branch.data_layout): js_data_layout = find_obj_name(dlpx_obj.server_session, template, js_branch.data_layout) elif re.search('CONTAINER', js_branch.data_layout): js_data_layout = find_obj_name(dlpx_obj.server_session, container, js_branch.data_layout) print_info('{} {}, {}, {}'.format(js_branch._name[0], js_data_layout, js_branch.reference, js_end_time)) except (DlpxException, HttpError, RequestError) as e: print_exception('\nERROR: JS Branches could not be listed. The ' 'error was:\n\n{}'.format(e))
def list_env(dlpx_obj): """ List all environments for a given engine """ engine_name = dlpx_obj.dlpx_engines.keys()[0] all_envs = environment.get_all(dlpx_obj.server_session) for env in all_envs: env_user = find_obj_name(dlpx_obj.server_session, environment.user, env.primary_user) try: env_host = find_obj_name(dlpx_obj.server_session, host, env.host) except AttributeError: pass if env.type == "WindowsHostEnvironment": print("Environment Name: {}, Username: {}, Host: {}," "Enabled: {}, ".format(env.name, env_user, env_host, env.enabled)) elif env.type == "WindowsCluster" or env.type == "OracleCluster": print("Environment Name: {}, Username: {}" "Enabled: {}, ".format(env.name, env_user, env.enabled)) else: print("Environment Name: {}, Username: {}, Host: {}, Enabled: {}," " ASE Environment Params: {}".format( env.name, env_user, env_host, env.enabled, env.ase_host_environment_parameters if isinstance( env.ase_host_environment_parameters, ASEHostEnvironmentParameters) else "Undefined", ))
def list_env(dlpx_obj): """ List all environments for a given engine """ engine_name = dlpx_obj.dlpx_engines.keys()[0] all_envs = environment.get_all(dlpx_obj.server_session) for env in all_envs: env_user = find_obj_name(dlpx_obj.server_session, environment.user, env.primary_user) try: env_host = find_obj_name(dlpx_obj.server_session, host, env.host) except AttributeError: pass if env.type == 'WindowsHostEnvironment': print('Environment Name: {}, Username: {}, Host: {},' 'Enabled: {}, '.format(env.name, env_user, env_host, env.enabled)) elif env.type == 'WindowsCluster' or env.type == 'OracleCluster': print('Environment Name: {}, Username: {}' \ 'Enabled: {}, '.format(env.name, env_user, env.enabled)) else: print 'Environment Name: {}, Username: {}, Host: {}, Enabled: {},'\ ' ASE Environment Params: {}'.format( env.name, env_user, env_host, env.enabled, env.ase_host_environment_parameters if isinstance(env.ase_host_environment_parameters, ASEHostEnvironmentParameters) else 'Undefined')
def list_bookmarks(dlpx_obj, tag_filter=None): """ List all bookmarks on a given engine :param dlpx_obj: Virtualization Engine session object :param tag_filter: Only list bookmarks with given tag """ header = '\nName, Reference, Branch Name, Template Name, Tags' try: js_bookmarks = bookmark.get_all(dlpx_obj.server_session) print header for js_bookmark in js_bookmarks: branch_name = find_obj_name(dlpx_obj.server_session, branch, js_bookmark.branch) if tag_filter in js_bookmark.tags: print '{}, {}, {}, {}, {}'.format( js_bookmark.name, js_bookmark.reference, branch_name, js_bookmark.template_name, ", ".join(tag for tag in js_bookmark.tags)) elif tag_filter is None: tag = js_bookmark.tags if js_bookmark.tags else None if tag: tag = ", ".join(tag for tag in js_bookmark.tags) print '{}, {}, {}, {}, {}'.format(js_bookmark.name, js_bookmark.reference, branch_name, js_bookmark.template_name, tag) print '\n' except (DlpxException, HttpError, RequestError) as e: print_exception('\nERROR: The bookmarks on could not be listed. The ' 'error was:\n\n{}'.format(e))
def list_env(dlpx_obj): """ List all environments for a given engine """ engine_name = dlpx_obj.dlpx_engines.keys()[0] all_envs = environment.get_all(dlpx_obj.server_session) for env in all_envs: env_user = find_obj_name(dlpx_obj.server_session, environment.user, env.primary_user) env_host = find_obj_name(dlpx_obj.server_session, host, env.host) #ORACLE CLUSTER does not have env.host #Windows does not have ASE instances print 'Environment Name: {}, Username: {}, Host: {}, Enabled: {}, ' \ 'ASE Environment Params: {}'.format( env.name, env_user, env_host, env.enabled, env.ase_host_environment_parameters if isinstance(env.ase_host_environment_parameters, ASEHostEnvironmentParameters) else 'Undefined')
def list_bookmarks(dlpx_obj, tags=None): """ List all bookmarks on a given engine :param dlpx_obj: Virtualization Engine session object :param tag_filter: Only list bookmarks with given tag """ header = "\nName, Reference, Branch Name, Template Name, Tags" try: js_bookmarks = bookmark.get_all(dlpx_obj.server_session) print(header) for js_bookmark in js_bookmarks: branch_name = find_obj_name(dlpx_obj.server_session, branch, js_bookmark.branch) tag_filter = [ x.strip() for x in tags.decode("utf-8", "ignore").split(",") ] if all(tag in js_bookmark.tags for tag in tag_filter): print("{}, {}, {}, {}, {}".format( js_bookmark.name, js_bookmark.reference, branch_name, js_bookmark.template_name, ", ".join(tag for tag in js_bookmark.tags), )) elif tag_filter is None: tag = js_bookmark.tags if js_bookmark.tags else None if tag: tag = ", ".join(tag for tag in js_bookmark.tags) print("{}, {}, {}, {}, {}".format( js_bookmark.name, js_bookmark.reference, branch_name, js_bookmark.template_name, tag, )) print("\n") except (DlpxException, HttpError, RequestError) as e: print_exception("\nERROR: The bookmarks on could not be listed. The " "error was:\n\n{}".format(e))
def list_bookmarks(dlpx_obj, tags=None): """ List all bookmarks on a given engine :param dlpx_obj: Virtualization Engine session object :param tag_filter: Only list bookmarks with given tag """ header = '\nName, Reference, Branch Name, Template Name, Tags' try: js_bookmarks = bookmark.get_all(dlpx_obj.server_session) print header for js_bookmark in js_bookmarks: branch_name = find_obj_name(dlpx_obj.server_session, branch, js_bookmark.branch) tag_filter = [x.strip() for x in tags.decode('utf-8','ignore').split(',')] if all(tag in js_bookmark.tags for tag in tag_filter): print '{}, {}, {}, {}, {}'.format(js_bookmark.name, js_bookmark.reference, branch_name, js_bookmark.template_name, ", ".join(tag for tag in js_bookmark.tags)) elif tag_filter is None: tag = js_bookmark.tags if js_bookmark.tags else None if tag: tag = ", ".join(tag for tag in js_bookmark.tags) print '{}, {}, {}, {}, {}'.format(js_bookmark.name, js_bookmark.reference, branch_name, js_bookmark.template_name, tag) print '\n' except (DlpxException, HttpError, RequestError) as e: print_exception('\nERROR: The bookmarks on could not be listed. The ' 'error was:\n\n{}'.format(e))
def list_hierarchy(dlpx_obj, container_name): """ Filter container listing. dlpx_obj: Virtualization Engine session object container_name: Name of the container to list child VDBs. """ database_dct = {} layout_ref = find_obj_by_name(dlpx_obj.server_session, container, container_name).reference for ds in datasource.get_all(dlpx_obj.server_session, data_layout=layout_ref): db_name = find_obj_name(dlpx_obj.server_session, database, ds.container) if hasattr(ds.runtime, "jdbc_strings"): database_dct[db_name] = ds.runtime.jdbc_strings else: database_dct[db_name] = "None" try: print_info("Container: {}\nRelated VDBs: {}\n".format( container_name, convert_dct_str(database_dct))) except (AttributeError, DlpxException) as e: print_exception(e)