]
)
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(
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)])
+ 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)