else:
resp = ctx.obj.vnfd.list()
# print(yaml.safe_dump(resp))
- fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__
- if fullclassname == "osmclient.sol005.client.Client":
+ if long:
+ table = PrettyTable(
+ [
+ "nfpkg name",
+ "id",
+ "desc type",
+ "vendor",
+ "version",
+ "onboarding state",
+ "operational state",
+ "usage state",
+ "date",
+ "last update",
+ ]
+ )
+ else:
+ table = PrettyTable(["nfpkg name", "id", "desc type"])
+ for vnfd in resp:
+ name = vnfd.get("id", vnfd.get("name", "-"))
+ descriptor_type = "sol006" if "product-name" in vnfd else "rel8"
if long:
- table = PrettyTable(
+ onb_state = vnfd["_admin"].get("onboardingState", "-")
+ op_state = vnfd["_admin"].get("operationalState", "-")
+ vendor = vnfd.get("provider", vnfd.get("vendor"))
+ version = vnfd.get("version")
+ usage_state = vnfd["_admin"].get("usageState", "-")
+ date = datetime.fromtimestamp(vnfd["_admin"]["created"]).strftime(
+ "%Y-%m-%dT%H:%M:%S"
+ )
+ last_update = datetime.fromtimestamp(vnfd["_admin"]["modified"]).strftime(
+ "%Y-%m-%dT%H:%M:%S"
+ )
+ table.add_row(
[
- "nfpkg name",
- "id",
- "desc type",
- "vendor",
- "version",
- "onboarding state",
- "operational state",
- "usage state",
- "date",
- "last update",
+ name,
+ vnfd["_id"],
+ descriptor_type,
+ vendor,
+ version,
+ onb_state,
+ op_state,
+ usage_state,
+ date,
+ last_update,
]
)
else:
- table = PrettyTable(["nfpkg name", "id", "desc type"])
- for vnfd in resp:
- name = vnfd.get("id", vnfd.get("name", "-"))
- descriptor_type = "sol006" if "product-name" in vnfd else "rel8"
- if long:
- onb_state = vnfd["_admin"].get("onboardingState", "-")
- op_state = vnfd["_admin"].get("operationalState", "-")
- vendor = vnfd.get("provider", vnfd.get("vendor"))
- version = vnfd.get("version")
- usage_state = vnfd["_admin"].get("usageState", "-")
- date = datetime.fromtimestamp(vnfd["_admin"]["created"]).strftime(
- "%Y-%m-%dT%H:%M:%S"
- )
- last_update = datetime.fromtimestamp(
- vnfd["_admin"]["modified"]
- ).strftime("%Y-%m-%dT%H:%M:%S")
- table.add_row(
- [
- name,
- vnfd["_id"],
- descriptor_type,
- vendor,
- version,
- onb_state,
- op_state,
- usage_state,
- date,
- last_update,
- ]
- )
- else:
- table.add_row([name, vnfd["_id"], descriptor_type])
- else:
- table = PrettyTable(["nfpkg name", "id"])
- for vnfd in resp:
- table.add_row([vnfd["name"], vnfd["id"]])
+ table.add_row([name, vnfd["_id"], descriptor_type])
table.align = "l"
print(table)
]
)
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)
else:
resp = ctx.obj.nsd.list()
# print(yaml.safe_dump(resp))
- fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__
- if fullclassname == "osmclient.sol005.client.Client":
+ if long:
+ table = PrettyTable(
+ [
+ "nsd name",
+ "id",
+ "onboarding state",
+ "operational state",
+ "usage state",
+ "date",
+ "last update",
+ ]
+ )
+ else:
+ table = PrettyTable(["nsd name", "id"])
+ for nsd in resp:
+ name = nsd.get("id", "-")
if long:
- table = PrettyTable(
+ onb_state = nsd["_admin"].get("onboardingState", "-")
+ op_state = nsd["_admin"].get("operationalState", "-")
+ usage_state = nsd["_admin"].get("usageState", "-")
+ date = datetime.fromtimestamp(nsd["_admin"]["created"]).strftime(
+ "%Y-%m-%dT%H:%M:%S"
+ )
+ last_update = datetime.fromtimestamp(nsd["_admin"]["modified"]).strftime(
+ "%Y-%m-%dT%H:%M:%S"
+ )
+ table.add_row(
[
- "nsd name",
- "id",
- "onboarding state",
- "operational state",
- "usage state",
- "date",
- "last update",
+ name,
+ nsd["_id"],
+ onb_state,
+ op_state,
+ usage_state,
+ date,
+ last_update,
]
)
else:
- table = PrettyTable(["nsd name", "id"])
- for nsd in resp:
- name = nsd.get("id", "-")
- if long:
- onb_state = nsd["_admin"].get("onboardingState", "-")
- op_state = nsd["_admin"].get("operationalState", "-")
- usage_state = nsd["_admin"].get("usageState", "-")
- date = datetime.fromtimestamp(nsd["_admin"]["created"]).strftime(
- "%Y-%m-%dT%H:%M:%S"
- )
- last_update = datetime.fromtimestamp(
- nsd["_admin"]["modified"]
- ).strftime("%Y-%m-%dT%H:%M:%S")
- table.add_row(
- [
- name,
- nsd["_id"],
- onb_state,
- op_state,
- usage_state,
- date,
- last_update,
- ]
- )
- else:
- table.add_row([name, nsd["_id"]])
- else:
- table = PrettyTable(["nsd name", "id"])
- for nsd in resp:
- table.add_row([nsd["name"], nsd["id"]])
+ table.add_row([name, nsd["_id"]])
table.align = "l"
print(table)
"""
logger.debug("")
ctx.obj.package.upload(filename, skip_charm_build=skip_charm_build)
- fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__
- if fullclassname != "osmclient.sol005.client.Client":
- ctx.obj.package.wait_for_upload(filename)
:raises ClientError: if the specified version does not match the client version
"""
logger.debug("")
+ if version == "sol005":
+ message = f"The following commands or options are only supported with the version v1 of OSM SOL005': {what}"
+ elif version == "sol005_v2":
+ message = f"The following commands or options are only supported with the version v2 of OSM SOL005': {what}"
fullclassname = obj.__module__ + "." + obj.__class__.__name__
- message = 'The following commands or options are only supported with the option "--sol005": {}'.format(
- what
- )
- if version == "v1":
- message = 'The following commands or options are not supported when using option "--sol005": {}'.format(
- what
- )
if fullclassname != "osmclient.{}.client.Client".format(version):
raise ClientException(message)
return
if filter:
filter = "&".join(filter)
utils.check_client_version(ctx.obj, "--filter")
- fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__
- if fullclassname == "osmclient.sol005.client.Client":
- resp = ctx.obj.vim.list(filter)
+ resp = ctx.obj.vim.list(filter)
if long:
table = PrettyTable(
["vim name", "uuid", "project", "operational state", "error details"]
resp = ctx.obj.vnf.list(ns, filter)
else:
resp = ctx.obj.vnf.list()
- fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__
- if fullclassname == "osmclient.sol005.client.Client":
+ field_names = [
+ "vnf id",
+ "name",
+ "ns id",
+ "vnf member index",
+ "vnfd name",
+ "vim account id",
+ "ip address",
+ ]
+ if long:
field_names = [
"vnf id",
"name",
"vnfd name",
"vim account id",
"ip address",
+ "date",
+ "last update",
+ ]
+ table = PrettyTable(field_names)
+ for vnfr in resp:
+ name = vnfr["name"] if "name" in vnfr else "-"
+ new_row = [
+ vnfr["_id"],
+ name,
+ vnfr["nsr-id-ref"],
+ vnfr["member-vnf-index-ref"],
+ vnfr["vnfd-ref"],
+ vnfr["vim-account-id"],
+ vnfr["ip-address"],
]
if long:
- field_names = [
- "vnf id",
- "name",
- "ns id",
- "vnf member index",
- "vnfd name",
- "vim account id",
- "ip address",
- "date",
- "last update",
- ]
- table = PrettyTable(field_names)
- for vnfr in resp:
- name = vnfr["name"] if "name" in vnfr else "-"
- new_row = [
- vnfr["_id"],
- name,
- vnfr["nsr-id-ref"],
- vnfr["member-vnf-index-ref"],
- vnfr["vnfd-ref"],
- vnfr["vim-account-id"],
- vnfr["ip-address"],
- ]
- if long:
- date = datetime.fromtimestamp(vnfr["_admin"]["created"]).strftime(
- "%Y-%m-%dT%H:%M:%S"
- )
- last_update = datetime.fromtimestamp(
- vnfr["_admin"]["modified"]
- ).strftime("%Y-%m-%dT%H:%M:%S")
- new_row.extend([date, last_update])
- table.add_row(new_row)
- else:
- table = PrettyTable(["vnf name", "id", "operational status", "config status"])
- for vnfr in resp:
- if "mgmt-interface" not in vnfr:
- vnfr["mgmt-interface"] = {}
- vnfr["mgmt-interface"]["ip-address"] = None
- table.add_row(
- [
- vnfr["name"],
- vnfr["id"],
- vnfr["operational-status"],
- vnfr["config-status"],
- ]
+ date = datetime.fromtimestamp(vnfr["_admin"]["created"]).strftime(
+ "%Y-%m-%dT%H:%M:%S"
+ )
+ last_update = datetime.fromtimestamp(vnfr["_admin"]["modified"]).strftime(
+ "%Y-%m-%dT%H:%M:%S"
)
+ new_row.extend([date, last_update])
+ table.add_row(new_row)
print_output.print_output(output, table.field_names, table._rows)