X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fcli_commands%2Fns.py;h=a21c49205db31067c1f7f79b5756d5fa9ccce297;hb=9cdadd6be32877f088455074101483194b1f5bf8;hp=75054fe9f14393793a6a92871c1a436ccb581817;hpb=cd7cd5eba8cfbb5f1941744ff90cf45e0ebcf422;p=osm%2Fosmclient.git diff --git a/osmclient/cli_commands/ns.py b/osmclient/cli_commands/ns.py index 75054fe..a21c492 100755 --- a/osmclient/cli_commands/ns.py +++ b/osmclient/cli_commands/ns.py @@ -210,65 +210,41 @@ def ns_list(ctx, filter, long, output): ] ) for ns in resp: - fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ - if fullclassname == "osmclient.sol005.client.Client": - nsr = ns - logger.debug("NS info: {}".format(nsr)) - nsr_name = nsr["name"] - nsr_id = nsr["_id"] - date = datetime.fromtimestamp(nsr["create-time"]).strftime( - "%Y-%m-%dT%H:%M:%S" - ) - ns_state = nsr.get("nsState", nsr["_admin"]["nsState"]) - if long: - deployment_status = summarize_deployment_status( - nsr.get("deploymentStatus") - ) - config_status = summarize_config_status(nsr.get("configurationStatus")) - project_id, project_name = utils.get_project(project_list, nsr) - # project = '{} ({})'.format(project_name, project_id) - project = project_name - vim_id = nsr.get("datacenter") - vim_name = utils.get_vim_name(vim_list, vim_id) + nsr = ns + logger.debug("NS info: {}".format(nsr)) + nsr_name = nsr["name"] + nsr_id = nsr["_id"] + date = datetime.fromtimestamp(nsr["create-time"]).strftime("%Y-%m-%dT%H:%M:%S") + ns_state = nsr.get("nsState", nsr["_admin"]["nsState"]) + if long: + deployment_status = summarize_deployment_status(nsr.get("deploymentStatus")) + config_status = summarize_config_status(nsr.get("configurationStatus")) + project_id, project_name = utils.get_project(project_list, nsr) + # project = '{} ({})'.format(project_name, project_id) + project = project_name + vim_id = nsr.get("datacenter") + vim_name = utils.get_vim_name(vim_list, vim_id) - # vim = '{} ({})'.format(vim_name, vim_id) - vim = vim_name - if "currentOperation" in nsr: - current_operation = "{} ({})".format( - nsr["currentOperation"], nsr["currentOperationID"] - ) - else: - current_operation = "{} ({})".format( - nsr["_admin"].get("current-operation", "-"), - nsr["_admin"]["nslcmop"], - ) - error_details = "N/A" - if ( - ns_state == "BROKEN" - or ns_state == "DEGRADED" - or ("currentOperation" not in nsr and nsr.get("errorDescription")) - ): - error_details = "{}\nDetail: {}".format( - nsr["errorDescription"], nsr["errorDetail"] - ) + # vim = '{} ({})'.format(vim_name, vim_id) + vim = vim_name + if "currentOperation" in nsr: + current_operation = "{} ({})".format( + nsr["currentOperation"], nsr["currentOperationID"] + ) else: - nsopdata = ctx.obj.ns.get_opdata(ns["id"]) - nsr = nsopdata["nsr:nsr"] - nsr_name = nsr["name-ref"] - nsr_id = nsr["ns-instance-config-ref"] - date = "-" - project = "-" - deployment_status = ( - nsr["operational-status"] - if "operational-status" in nsr - else "Not found" + current_operation = "{} ({})".format( + nsr["_admin"].get("current-operation", "-"), + nsr["_admin"]["nslcmop"], + ) + error_details = "N/A" + if ( + ns_state == "BROKEN" + or ns_state == "DEGRADED" + or ("currentOperation" not in nsr and nsr.get("errorDescription")) + ): + error_details = "{}\nDetail: {}".format( + nsr["errorDescription"], nsr["errorDetail"] ) - ns_state = deployment_status - config_status = nsr.get("config-status", "Not found") - current_operation = "Unknown" - error_details = nsr.get("detailed-status", "Not found") - if config_status == "config_not_needed": - config_status = "configured (no charms)" if long: table.add_row( @@ -331,13 +307,6 @@ def ns_show(ctx, name, literal, filter, output): if not filter or k in filter: table.add_row([k, utils.wrap_text(text=json.dumps(v, indent=2), width=100)]) - fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ - if fullclassname != "osmclient.sol005.client.Client": - nsopdata = ctx.obj.ns.get_opdata(ns["id"]) - nsr_optdata = nsopdata["nsr:nsr"] - for k, v in list(nsr_optdata.items()): - if not filter or k in filter: - table.add_row([k, utils.wrap_text(json.dumps(v, indent=2), width=100)]) print_output.print_output(output, table.field_names, table._rows)