raise LcmException("Error parsing Jinja2 to cloud-init content at vnfd[id={}]:vdu[id={}]: {}".
format(vnfd["id"], vdu["id"], e))
- def _ns_params_2_RO(self, ns_params, nsd, vnfd_dict, n2vc_key_list):
+ def _ns_params_2_RO(self, ns_params, nsd, vnfd_dict, db_vnfrs, n2vc_key_list):
"""
Creates a RO ns descriptor from OSM ns_instantiate params
:param ns_params: OSM instantiate params
+ :param vnfd_dict: database content of vnfds, indexed by id (not _id). {id: {vnfd_object}, ...}
+ :param db_vnfrs: database content of vnfrs, indexed by member-vnf-index. {member-vnf-index: {vnfr_object}, ...}
:return: The RO ns descriptor
"""
vim_2_RO = {}
"wim_account": wim_account_2_RO(ns_params.get("wimAccountId")),
# "scenario": ns_params["nsdId"],
}
+ # set vim_account of each vnf if different from general vim_account.
+ # Get this information from <vnfr> database content, key vim-account-id
+ # Vim account can be set by placement_engine and it may be different from
+ # the instantiate parameters (vnfs.member-vnf-index.datacenter).
+ for vnf_index, vnfr in db_vnfrs.items():
+ if vnfr.get("vim-account-id") and vnfr["vim-account-id"] != ns_params["vimAccountId"]:
+ populate_dict(RO_ns_params, ("vnfs", vnf_index, "datacenter"), vim_account_2_RO(vnfr["vim-account-id"]))
n2vc_key_list = n2vc_key_list or []
for vnfd_ref, vnfd in vnfd_dict.items():
else:
raise LcmException("Invalid instantiate parameter vnf:member-vnf-index={} is not present at nsd:"
"constituent-vnfd".format(vnf_params["member-vnf-index"]))
- if vnf_params.get("vimAccountId"):
- populate_dict(RO_ns_params, ("vnfs", vnf_params["member-vnf-index"], "datacenter"),
- vim_account_2_RO(vnf_params["vimAccountId"]))
for vdu_params in get_iterable(vnf_params, "vdu"):
# TODO feature 1417: check that this VDU exist and it is not a PDU
async def instantiate_RO(self, logging_text, nsr_id, nsd, db_nsr, db_nslcmop, db_vnfrs, db_vnfds_ref,
n2vc_key_list, stage):
+ """
+ Instantiate at RO
+ :param logging_text: preffix text to use at logging
+ :param nsr_id: nsr identity
+ :param nsd: database content of ns descriptor
+ :param db_nsr: database content of ns record
+ :param db_nslcmop: database content of ns operation, in this case, 'instantiate'
+ :param db_vnfrs:
+ :param db_vnfds_ref: database content of vnfds, indexed by id (not _id). {id: {vnfd_object}, ...}
+ :param n2vc_key_list: ssh-public-key list to be inserted to management vdus via cloud-init
+ :param stage: list with 3 items: [general stage, tasks, vim_specific]. This task will write over vim_specific
+ :return: None or exception
+ """
try:
db_nsr_update = {}
RO_descriptor_number = 0 # number of descriptors created at RO
await asyncio.wait(task_dependency, timeout=3600)
stage[2] = "Checking instantiation parameters."
- RO_ns_params = self._ns_params_2_RO(ns_params, nsd, db_vnfds_ref, n2vc_key_list)
+ RO_ns_params = self._ns_params_2_RO(ns_params, nsd, db_vnfds_ref, db_vnfrs, n2vc_key_list)
stage[2] = "Deploying ns at VIM."
db_nsr_update["detailed-status"] = " ".join(stage)
self.update_db_2("nsrs", nsr_id, db_nsr_update)
projects_write:
- 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
_id: ea958ba5-4e58-4405-bf42-6e3be15d4c3a
- description: Openstack site 2, based on Mirantis, also called DSS9000-1, with
- tenant tid
- name: ost2-mrt-tid
+ description: some description here
+ name: vim1
schema_version: '1.1'
vim_password: 5g0yGX86qIhprX86YTMcpg==
vim_tenant_name: osm
vim_type: openstack
vim_url: http://10.95.87.162:5000/v2.0
vim_user: osm
+- _admin:
+ created: 1566818150.3024442
+ current_operation: 0
+ deployed:
+ RO: 9ac17c0d-4265-4333-843b-c3cbd1f93f88
+ RO-account: 011895dc-ab34-4c9f-b06f-401a8ffb073b
+ detailed-status: Done
+ modified: 1566818150.3024442
+ operationalState: ENABLED
+ operations:
+ - detailed-status: Done
+ lcmOperationType: create
+ operationParams: null
+ operationState: COMPLETED
+ startTime: 1566818150.3025382
+ statusEnteredTime: 1566818150.3025382
+ worker: 86434c2948e2
+ projects_read:
+ - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
+ projects_write:
+ - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
+ _id: 05357241-1a01-416f-9e02-af20f65f51cd
+ description: No description
+ name: vim2
+ schema_version: '1.1'
+ vim_password: 5g0yGX86qIhprX86YTMcpg==
+ vim_tenant_name: osm
+ vim_type: dumy
+ vim_url: http://10.95.88.162:5000/v2.0
+ vim_user: osm
"""
db_k8sclusters_text = """
# TODO add a terminate
def test_ns_params_2_RO(self):
- vim = self.db.get_list("vim_accounts")[0]
- vim_id = vim["_id"]
- ro_vim_id = vim["_admin"]["deployed"]["RO"]
+ vims = self.db.get_list("vim_accounts")
+ vim_id = vims[0]["_id"]
+ ro_vim_id = vims[0]["_admin"]["deployed"]["RO"]
+ vim_id2 = vims[1]["_id"]
+ ro_vim_id2 = vims[1]["_admin"]["deployed"]["RO"]
+
ns_params = {"vimAccountId": vim_id}
mgmt_interface = {"cp": "cp"}
vdu = [{"id": "vdu_id", "interface": [{"external-connection-point-ref": "cp"}]}]
"vnf-configuration": {"config-access": {"ssh-access": {"required": True, "default_user": "U"}}}},
}
nsd = {"constituent-vnfd": []}
+ db_vnfrs = {}
for k in vnfd_dict.keys():
- nsd["constituent-vnfd"].append({"vnfd-id-ref": k, "member-vnf-index": k})
+ nsd["constituent-vnfd"].append({"vnfd-id-ref": k, "member-vnf-index": "member " + k})
+ db_vnfrs["member " + k] = {"vim-account-id": vim_id2 if k == "1" else vim_id}
n2vc_key_list = ["key"]
- ro_ns_params = self.my_ns._ns_params_2_RO(ns_params, nsd, vnfd_dict, n2vc_key_list)
+ ro_ns_params = self.my_ns._ns_params_2_RO(ns_params, nsd, vnfd_dict, db_vnfrs, n2vc_key_list)
ro_params_expected = {'wim_account': None, "datacenter": ro_vim_id,
- "vnfs": {"5": {"vdus": {"vdu_id": {"mgmt_keys": n2vc_key_list}}}}}
+ "vnfs": {
+ "member 5": {"vdus": {"vdu_id": {"mgmt_keys": n2vc_key_list}}},
+ "member 1": {"datacenter": ro_vim_id2}
+ }}
self.assertEqual(ro_ns_params, ro_params_expected)
# Test scale() and related methods