def listMappings( ServiceName: str, Application: str, DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", ResilienceTimeout: int = None ) -> namedtuple("listMappingsResult", ["retcode", 'stdout', 'stderr']): """ list all mappings under the application if retcode equals 0, then stdout returns a list of mappings else: stderr will return the error message :param ServiceName: Data Integration Service :param Application: :param DomainName: :param UserName: :param Password: :param SecurityDomain: :param ResilienceTimeout: :return: namedtuple("listMappingsResult", ["retcode", 'stdout', 'stderr']) """ subcmd = "ListMappings" options = [ "DomainName", "UserName", "Password", "SecurityDomain", "ResilienceTimeout", "ServiceName", "Application", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout # type: str stderr = res.stderr # type: str if res.retcode == 0: # format the stdout stdout = strip_ignored_cmd_messages(stdout) stdout = stdout.split("\n")[:-1] else: stderr += stdout ret = namedtuple("ListMappingsResult", ["retcode", 'stdout', 'stderr']) return ret(res.retcode, stdout, stderr)
def listNodes( DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", Gateway: str = None, ResilienceTimeout: int = None, NodeRole: str = "Service_compute", ) -> namedtuple("ListNodesResult", ['retcode', 'stdout', 'stderr']): """ list nodes of specified NodeRole retcode is int, 0 represents success, otherwise failure if retcode requals 0, the stdout will a list of nodes, and it must have one node, like [node1, node2]. otherwise, the stderr will show the details of error :param DomainName: :param UserName: :param Password: :param SecurityDomain: :param Gateway: :param ResilienceTimeout: :param NodeRole: (Service_compute|Service|Compute) default is Service_compute :return: namedtuple("ListNodesResult", ['retcode', 'stdout', 'stderr']) """ subcmd = "ListNodes " options = [ "DomainName", "UserName", "Password", "SecurityDomain", "Gateway", "ResilienceTimeout", "NodeRole", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout stderr = res.stderr if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) stdout = stdout.splitlines() else: stderr += stdout listNodesResult = namedtuple("ListNodesResult", ['retcode', 'stdout', 'stderr']) return listNodesResult(res.retcode, stdout, stderr)
def listConnectionOptions( ConnectionName: str, DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", ResilienceTimeout: int = None, ) -> namedtuple("ListConnectionOptionsResult", ['retcode', 'stdout', 'stderr' ]): subcmd = "ListConnectionOptions" options = [ "DomainName", "UserName", "Password", "SecurityDomain", "ResilienceTimeout", "ConnectionName", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout # type: str stderr = res.stderr if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) conn_options = stdout.split("\n") # type: list stdout = dict() for option in conn_options: # type: str option_name_value = option.split(":", maxsplit=1) option_name = option_name_value[0] option_value = option_name_value[1].lstrip().rstrip() if option_value.startswith("[") and option_value.endswith("]"): option_value = option_value[1:-1] stdout.setdefault(option_name, option_value) else: stderr += stdout listConnectionOptionsResult = namedtuple("ListConnectionOptionsResult", ['retcode', 'stdout', 'stderr']) return listConnectionOptionsResult(res.retcode, stdout, stderr)
def listServiceLevels( DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", Gateway: str = None, ResilienceTimeout: int = None, ) -> namedtuple("ListServiceLevelsResult", ['retcode', 'stdout', 'stderr']): subcmd = "ListServiceLevels" options = [ "DomainName", "UserName", "Password", "SecurityDomain", "Gateway", "ResilienceTimeout", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout stderr = res.stderr if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) serviceLevels = stdout.split("\n\n") listServiceLevels_list = list() for serviceLevel in serviceLevels: stdout = serviceLevel.split("\n") listServiceLevels_dict = dict() for item in stdout: # type: str a = re.split("[:=]", item, maxsplit=1) listServiceLevels_dict.setdefault( a[0].lstrip().rstrip(), a[1].lstrip().rstrip().rstrip(":")) listServiceLevels_list.append(listServiceLevels_dict) stdout = listServiceLevels_list else: stderr += stdout listServiceLevelsResult = namedtuple("ListServiceLevelsResult", ['retcode', 'stdout', 'stderr']) return listServiceLevelsResult(res.retcode, stdout, stderr)
def listLicenses( DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", Gateway: str = None, ResilienceTimeout: int = None, ) -> namedtuple("ListLicensesResult", ['retcode', 'stdout', 'stderr']): subcmd = "ListLicenses" options = [ "DomainName", "UserName", "Password", "SecurityDomain", "Gateway", "ResilienceTimeout", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout stderr = res.stderr if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) mainLogger.info(stdout) licenses = stdout.split("\n") stdout = list() for license in licenses: name_sid = license.split(" ") licenseResult = namedtuple("LicenseResult", ["Name", "SerialNumber"]) stdout.append( licenseResult(name_sid[0], name_sid[1].lstrip("(").rstrip(")"))) else: stderr += stdout listLicensesResult = namedtuple("ListLicensesResult", ['retcode', 'stdout', 'stderr']) return listLicensesResult(res.retcode, stdout, stderr)
def ping( ServiceName: str, NodeName: str = None, DomainName: str = None, GatewayAddress: str = None, ResilienceTimeout: int = None, ) -> namedtuple("PingResult", ['retcode', 'stdout', 'stderr']): """ :param ServiceName: :param NodeName: :param DomainName: :param GatewayAddress: :param ResilienceTimeout: :return: """ subcmd = "Ping" options = [ "DomainName", "ServiceName", "GatewayAddress", "NodeName", "ResilienceTimeout", ] cmd = _checking_infacmd_env_and_ret_base_cmd( domainname=DomainName, username=None, password=None, cmd=base_cmd, subcmd=subcmd, verify_username_password=False) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout stderr = res.stderr if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) else: stderr += stdout pingResult = namedtuple("PingResult", ['retcode', 'stdout', 'stderr']) return pingResult(res.retcode, stdout, stderr)
def backupContents( ServiceName: str, OutputFileName: str, DomainName: str = None, SecurityDomain: str = "Native", UserName: str = None, Password: str = None, OverwriteFile: False = None, Description: str = None, BackupSearchIndices: str = None, ResilienceTimeout: int = None, ) -> namedtuple("BackupContentsResult", ['retcode', 'stdout', 'stderr']): subcmd = "BackupContents" options = [ "DomainName", "SecurityDomain", "UserName", "Password", "ServiceName", "OutputFileName", "OverwriteFile", "Description", "BackupSearchIndices", "ResilienceTimeout", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout # type: str stderr = res.stderr # type: str if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) else: stderr += stdout backupContentsResult = namedtuple("BackupContentsResult", ['retcode', 'stdout', 'stderr']) return backupContentsResult(res.retcode, stdout, stderr)
def listUserPrivileges( ServiceName: str, ExistingUserName: str, ExistingUserSecurityDomain: str = "Native", DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", Gateway: str = None, ResilienceTimeout: int = None, ) -> namedtuple("ListUserPrivilegesResult", ['retcode', 'stdout', 'stderr']): subcmd = "ListUserPrivileges" options = [ "DomainName", "UserName", "Password", "SecurityDomain", "Gateway", "ResilienceTimeout", "ExistingUserName", "ExistingUserSecurityDomain", "ServiceName", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout # type: str stderr = res.stderr # type: str if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) stdout = stdout.splitlines() else: stderr += stdout listUserPrivilegesResult = namedtuple("ListUserPrivilegesResult", ['retcode', 'stdout', 'stderr']) return listUserPrivilegesResult(res.retcode, stdout, stderr)
def listUserPermissions( ExistingUserName: str, ExistingUserSecurityDomain: str = "Native", ObjectType: str = None, DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", Gateway: str = None, ResilienceTimeout: int = None, ) -> namedtuple("ListUserPermissionsResult", ['retcode', 'stdout', 'stderr']): """ list user's permissions on these Object types if retcode equals 0, then stdout returns a dict with Object Types and its list of values. dict(list) otherwise, stderr will show the error messages. here is a sample of success: { 'Folder': ['/System_Services', '/'], 'Grid': ['INFA210_GRID'], 'License': ['dd', 'EndApr1'], 'Node': ['ND_NoExisting', 'ND_INFA210'], 'OS Profile': ['BDM_OS_Profile'], 'Service': [ 'Scheduler_Service', 'Email_Service', 'Resource_Manager_Service', 'IS_ASCII', 'D102_INFA210', 'M102_INFA210', 'R102_PRD_INFA210', 'IS_UNICODE', 'R102_INFA210'] } :param ExistingUserName: :param ExistingUserSecurityDomain: :param ObjectType: (Service|License|Node|Grid|Folder|OSProfile) default is None which represents all :param DomainName: :param UserName: :param Password: :param SecurityDomain: :param Gateway: :param ResilienceTimeout: :return: """ subcmd = "ListUserPermissions" options = [ "DomainName", "UserName", "Password", "SecurityDomain", "Gateway", "ResilienceTimeout", "ExistingUserName", "ExistingUserSecurityDomain", "ObjectType", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout # type: str stderr = res.stderr # type: str if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) userPermissionsList = stdout.splitlines() userPermissionsList.reverse() stdout = dict() everyPermissionList = list() for entry in userPermissionsList: # type: str if not entry.endswith(":"): entry = entry.strip(" ") if entry: everyPermissionList.append(entry) continue else: stdout.setdefault( entry.rstrip(":").rstrip(" "), everyPermissionList) everyPermissionList = list() else: stderr += stdout listUserPermissionsResult = namedtuple("ListUserPermissionsResult", ['retcode', 'stdout', 'stderr']) return listUserPermissionsResult(res.retcode, stdout, stderr)
def listNodeResources( NodeName: str, DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", Gateway: str = None, ResilienceTimeout: int = None, ResourceCategory: str = "PCIS", ) -> namedtuple("ListNodeResourcesResult", ['retcode', 'stdout', 'stderr']): """ list the resources of the node if :param NodeName: :param DomainName: :param UserName: :param Password: :param SecurityDomain: :param Gateway: :param ResilienceTimeout: :param ResourceCategory: :return: """ subcmd = "ListNodeResources" options = [ "DomainName", "UserName", "Password", "SecurityDomain", "Gateway", "ResilienceTimeout", "NodeName", "ResourceCategory", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout stderr = res.stderr if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) entrys = stdout.splitlines() stdout = list() for entry in entrys: # type: str entry_dict = dict() entry_list = entry.split(";") name = entry_list[0] name = name[name.index("[") + 1:-1] entry_dict.setdefault("name", name) type = entry_list[1] type = type[type.index("[") + 1:-1] entry_dict.setdefault("type", type) available = entry_list[2] available = available[available.index("[") + 1:-2] entry_dict.setdefault( "available", True if available.upper() == "TRUE" else False) stdout.append(entry_dict) else: stderr += stdout listNodeResourcesResult = namedtuple("ListNodeResourcesResult", ['retcode', 'stdout', 'stderr']) return listNodeResourcesResult(res.retcode, stdout, stderr)
def listServices( DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", Gateway: str = None, ResilienceTimeout: int = None, ServiceType: str = None, ) -> namedtuple("ListServicesResult", ['retcode', 'stdout', 'stderr']): """ list all services or services of specified Service Type retcode: 0 stands for success, otherwise failure stdout: list(str) like [service_name1, service_name2, .....] if retcode equals 0 stderr: str :param DomainName: :param UserName: :param Password: :param SecurityDomain: :param Gateway: :param ResilienceTimeout: :param ServiceType: refer to the octopus.infa.infacmd.servicetype_namedtupe :return: namedtuple("ListServicesResult", ['retcode', 'stdout', 'stderr']) """ subcmd = "ListServices" options = [ "DomainName", "UserName", "Password", "SecurityDomain", "Gateway", "ResilienceTimeout", "ServiceType", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout # type: str stderr = res.stderr if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) stdout = stdout.split("\n") else: stderr += stdout listServicesResult = namedtuple("ListServicesResult", ['retcode', 'stdout', 'stderr']) return listServicesResult(res.retcode, stdout, stderr)
def listConnections( DomainName: str = None, UserName: str = None, Password: str = None, ConnectionType: str = None, SecurityDomain: str = "Native", ResilienceTimeout: int = None, ) -> namedtuple("ListConnectionsResult", ['retcode', 'stdout', 'stderr']): """ list all connections (Administrator Console) if retcode requals 0, then stdout returns a dict which contains Connection_Type and its list of connection(id: name) like, {CONN_TYPE_1: [{id: CONN_1_ID, name: CONN_1_NAME}, {id: CONN_2_ID, name: CONN_2_NAME}, ....], CONN_TYPE_2: [], .....} :param DomainName: :param UserName: :param Password: :param ConnectionType: refer to the octopus.infa.infacmd.connectiontype_namedtupe :param SecurityDomain: :param ResilienceTimeout: :return: namedtuple("ListConnectionsResult", ['retcode', 'stdout', 'stderr']) """ subcmd = "ListConnections " options = [ "DomainName", "UserName", "Password", "ConnectionType", "SecurityDomain", "ResilienceTimeout", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout # type: str stderr = res.stderr if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) stdout = stdout.split("\n") # type: list stdout.reverse() conns_dict = dict() conns_list = list() for conn_val in stdout: if not conn_val.startswith("\t"): if len(conns_list) > 0: conns_dict.setdefault(conn_val, conns_list) conns_list = list() else: # '\tINFA_102_DIS_PWD_210 - [ID: INFA_102_DIS_PWD_210 conn_val = conn_val.lstrip("\t").rstrip("]").split(" - [ID: ") conns_list.append({"id": conn_val[1], "name": conn_val[0]}) continue stdout = conns_dict else: stderr += stdout listConnectionsResult = namedtuple("ListConnectionsResult", ['retcode', 'stdout', 'stderr']) return listConnectionsResult(res.retcode, stdout, stderr)
def listAllUsers( DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", Gateway: str = None, ResilienceTimeout: int = None, ) -> namedtuple("ListAllUsersResult", ['retcode', 'stdout', 'stderr']): """ list all users if retcode is 0, then stdout returns a list of users' dict, like [{securityDomain: securityDomainName_1, userName: userName_1}, ....] for example: [{'securityDomain': 'Native', 'userName': '******'}] else: return the stderr :param DomainName: :param UserName: :param Password: :param SecurityDomain: :param Gateway: :param ResilienceTimeout: :return: namedtuple("ListAllUsersResult", ['retcode', 'stdout', 'stderr']) """ subcmd = "ListAllUsers " options = [ "DomainName", "UserName", "Password", "SecurityDomain", "Gateway", "ResilienceTimeout", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout stderr = res.stderr if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) usersList = stdout.split("\n") stdout = list() for user in usersList: userinfo = user.split("/") user_dict = dict() user_dict.setdefault("securityDomain", userinfo[0]) user_dict.setdefault("userName", userinfo[1]) stdout.append(user_dict) else: stderr += stdout listAllUsersResult = namedtuple("ListAllUsersResult", ['retcode', 'stdout', 'stderr']) return listAllUsersResult(res.retcode, stdout, stderr)
def listGroupsForUser( ExistingUserName: str, ExistingUserSecurityDomain: str = "Native", DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", Gateway: str = None, ResilienceTimeout: int = None, ) -> namedtuple("ListGroupsForUserResult", ['retcode', 'stdout', 'stderr']): """ list group for the user if retcode equals 0, then stdout returns a list of dict which contains securityDomain and groupName else: stderr will show error messages for instance: [{'securityDomain': 'Native', 'groupName': 'Administrator'}, {'securityDomain': 'Native', 'groupName': 'Everyone'}] :param ExistingUserName: :param ExistingUserSecurityDomain: :param DomainName: :param UserName: :param Password: :param SecurityDomain: :param Gateway: :param ResilienceTimeout: :return: namedtuple("ListGroupsForUserResult", ['retcode', 'stdout', 'stderr']) """ subcmd = "ListGroupsForUser" options = [ "DomainName", "UserName", "Password", "SecurityDomain", "Gateway", "ResilienceTimeout", "ExistingUserName", "ExistingUserSecurityDomain", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout # type: str stderr = res.stderr # type: str if res.retcode == 0: stdout = strip_ignored_cmd_messages(stdout) groups_list = stdout.splitlines() stdout = list() for group in groups_list: temp_dict = dict() group_info = group.split("/") temp_dict.setdefault("securityDomain", group_info[0]) temp_dict.setdefault("groupName", group_info[1]) stdout.append(temp_dict) else: stderr += stdout listGroupsForUserResult = namedtuple("ListGroupsForUserResult", ['retcode', 'stdout', 'stderr']) return listGroupsForUserResult(res.retcode, stdout, stderr)
def getMappingStatus( ServiceName: str, JobId: str, DomainName: str = None, UserName: str = None, Password: str = None, SecurityDomain: str = "Native", ResilienceTimeout: int = None, ) -> namedtuple("GetMappingStatusResult", ['retcode', 'stdout', 'stderr']): """ for example: GetMappingStatusResult(retcode=0, stdout={'JobID': ' TA-1CRxxEei_oNrsW-zrpQ', 'StartTime': ' 02/28/2018 18','OnNode': ' ND_INFA210', 'JobState': ' RUNNING', 'LogFile': ' /opt/infa/pwc/1020/logs/ND_INFA210/services/DataIntegrationService/disLogs/ms/DEPLOYED_MAPPING_app_wf_ cuttlefish_hive2hive_failure-m_cuttlefish_single_triple_20180116_20180228_182236_130.log'}, stderr='') :param DomainName: :param ServiceName: :param JobId: :param UserName: optional :param Password: optional :param SecurityDomain: default is Native :param ResilienceTimeout: int :return: namedtuple("GetMappingStatusResult", ['retcode', 'stdout', 'stderr']) """ subcmd = "GetMappingStatus" options = [ "DomainName", "UserName", "Password", "SecurityDomain", "ServiceName", "JobId", "ResilienceTimeout", ] cmd = _checking_infacmd_env_and_ret_base_cmd(domainname=DomainName, username=UserName, password=Password, cmd=base_cmd, subcmd=subcmd) options_value_dict = locals() for option in options: cmd = _assemble_command_options(cmd, option, options_value_dict.get(option)) mainLogger.debug(cmd) res = run_cmd(cmd, env=os.environ) mainLogger.info(res) stdout = res.stdout # type: str stderr = res.stderr if res.retcode == 0: # format the stdout stdout = strip_ignored_cmd_messages(stdout) stdout = stdout.split("\n") format_stdout_dict = dict() for item in stdout: split_item = item.split(":") k = split_item[0].replace(" ", "") format_stdout_dict.setdefault(k, split_item[1]) stdout = format_stdout_dict else: stderr += stdout getMappingStatusResult = namedtuple("GetMappingStatusResult", ['retcode', 'stdout', 'stderr']) return getMappingStatusResult(res.retcode, stdout, stderr)