diff options
author | Shubham Mishra <shivam828787@gmail.com> | 2020-09-01 23:10:14 +0530 |
---|---|---|
committer | Shubham Mishra <shivam828787@gmail.com> | 2020-09-10 11:04:19 +0530 |
commit | 7794bb28352a9f8140fa756c6d8ec7289aefbfc5 (patch) | |
tree | 0ff9344fbb2d696c08df382a465a42ba7b13daf9 /hdv/redfish/hdv_redfish.py | |
parent | dcdd46fe975c13c56a246ba0a6c79516a6afda77 (diff) |
add tests for HPE ILO 4 server
some servers sends '/' at the end of resources URI, while some doesn't. change the code to adapt both.
Change-Id: I383513f30b3d41513c0ca38b65614413788f0d4e
Signed-off-by: Shubham Mishra <shivam828787@gmail.com>
Diffstat (limited to 'hdv/redfish/hdv_redfish.py')
-rw-r--r-- | hdv/redfish/hdv_redfish.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/hdv/redfish/hdv_redfish.py b/hdv/redfish/hdv_redfish.py index f0aaa4b..306c93b 100644 --- a/hdv/redfish/hdv_redfish.py +++ b/hdv/redfish/hdv_redfish.py @@ -95,7 +95,7 @@ def parse_data(exp_value, act_value): case 2: list,dict type, then return updated exp_value ERROR_CODE for unexpected case. ''' - if isinstance(exp_value, (str, int)) and isinstance(act_value, (str, int)): + if isinstance(exp_value, (str, int, type(None))) and isinstance(act_value, (str, int, type(None))): return (exp_value, act_value) if isinstance(exp_value, list): if not isinstance(act_value, list): @@ -112,6 +112,7 @@ def parse_data(exp_value, act_value): if key in act_value: exp_value[key] = parse_data(val, act_value[key]) else: + exp_value[key] = (val, "Can't find key {} in return value".format(key)) LOGGER.error("%s,%s", ERROR_CODE['E500001'], key) else: LOGGER.error("%s,expected: %s , actual: %s", @@ -127,6 +128,9 @@ def compare_data(value, flag): compare value content ''' if isinstance(value, tuple): + if value[1] is None: + if value[0] == 'N/A' or value[0] == None: + return "Success", flag if value[1] is not None or value[1]: if value[0] == 'N/A': return "Success", flag @@ -182,7 +186,6 @@ def create_real_url(url_value, id_dict, key_flag_dict, http_handler, bmc_ip): pattern = re.compile(regexp, DT) LOGGER.info("url_value %s", url_value) matches = list(pattern.finditer(url_value)) - for match in matches: value = match.groupdict() # stripping out value['var'] from end of the URL @@ -198,6 +201,9 @@ def create_real_url(url_value, id_dict, key_flag_dict, http_handler, bmc_ip): url_list.append(parent_url) else: for index in range(len(url_list)): + #Make sure link will not have merged with '//' two forward slashes + if parent_url[0] == '/' and url_list[index][-1] == '/': + parent_url = parent_url[1:] url_list[index] = url_list[index] + parent_url response_list = handle_depend_url( @@ -224,7 +230,11 @@ def create_real_url(url_value, id_dict, key_flag_dict, http_handler, bmc_ip): url_list.append(url_value) for index in range(len(url_list)): - url_list[index] = url_list[index] + url_value.split('}')[-1] + #Make sure link will not have merged with '//' two forward slashes + if(url_value.split('}')[-1][0] == '/' and url_list[index][-1] == '/'): + url_list[index] = url_list[index] + url_value.split('}')[-1][1:] + else: + url_list[index] = url_list[index] + url_value.split('}')[-1] LOGGER.debug("created real url list is %s", url_list) return url_list @@ -540,7 +550,7 @@ def run(conf_file): ACCOUNT_INFO.update({"UserName": bmc_user}) ACCOUNT_INFO.update({"Password": bmc_pwd}) - url = "{0}/redfish/v1/SessionService/Sessions".format(bmc_ip) + url = "{0}/redfish/v1/SessionService/Sessions/".format(bmc_ip) x_auth_token = get_token(http_handler, url) LOGGER.info("x_auth_token: %s", x_auth_token) |