##
import asyncio
-from typing import Any, Dict
+from typing import Any, Dict, List
import yaml
import logging
import logging.handlers
nsd: Dict[str, Any],
vca: DeployedVCA,
cached_vnfds: Dict[str, Any],
- ):
+ ) -> List[Relation]:
relations = []
db_ns_relations = get_ns_configuration_relation_list(nsd)
for r in db_ns_relations:
+ provider_dict = None
+ requirer_dict = None
+ if all(key in r for key in ("provider", "requirer")):
+ provider_dict = r["provider"]
+ requirer_dict = r["requirer"]
+ elif "entities" in r:
+ provider_id = r["entities"][0]["id"]
+ provider_dict = {
+ "nsr-id": nsr_id,
+ "endpoint": r["entities"][0]["endpoint"],
+ }
+ if provider_id != nsd["id"]:
+ provider_dict["vnf-profile-id"] = provider_id
+ requirer_id = r["entities"][1]["id"]
+ requirer_dict = {
+ "nsr-id": nsr_id,
+ "endpoint": r["entities"][1]["endpoint"],
+ }
+ if requirer_id != nsd["id"]:
+ requirer_dict["vnf-profile-id"] = requirer_id
+ else:
+ raise Exception("provider/requirer or entities must be included in the relation.")
relation_provider = self._update_ee_relation_data_with_implicit_data(
- nsr_id, nsd, r["provider"], cached_vnfds
+ nsr_id, nsd, provider_dict, cached_vnfds
)
relation_requirer = self._update_ee_relation_data_with_implicit_data(
- nsr_id, nsd, r["requirer"], cached_vnfds
+ nsr_id, nsd, requirer_dict, cached_vnfds
)
provider = EERelation(relation_provider)
requirer = EERelation(relation_requirer)
nsd: Dict[str, Any],
vca: DeployedVCA,
cached_vnfds: Dict[str, Any],
- ):
+ ) -> List[Relation]:
relations = []
vnf_profile = get_vnf_profile(nsd, vca.vnf_profile_id)
vnf_profile_id = vnf_profile["id"]
db_vnfd = self._get_vnfd(vnfd_id, cached_vnfds)
db_vnf_relations = get_relation_list(db_vnfd, vnfd_id)
for r in db_vnf_relations:
+ provider_dict = None
+ requirer_dict = None
+ if all(key in r for key in ("provider", "requirer")):
+ provider_dict = r["provider"]
+ requirer_dict = r["requirer"]
+ elif "entities" in r:
+ provider_id = r["entities"][0]["id"]
+ provider_dict = {
+ "nsr-id": nsr_id,
+ "vnf-profile-id": vnf_profile_id,
+ "endpoint": r["entities"][0]["endpoint"],
+ }
+ if provider_id != vnfd_id:
+ provider_dict["vdu-profile-id"] = provider_id
+ requirer_id = r["entities"][1]["id"]
+ requirer_dict = {
+ "nsr-id": nsr_id,
+ "vnf-profile-id": vnf_profile_id,
+ "endpoint": r["entities"][1]["endpoint"],
+ }
+ if requirer_id != vnfd_id:
+ requirer_dict["vdu-profile-id"] = requirer_id
+ else:
+ raise Exception("provider/requirer or entities must be included in the relation.")
relation_provider = self._update_ee_relation_data_with_implicit_data(
- nsr_id, nsd, r["provider"], cached_vnfds, vnf_profile_id=vnf_profile_id
+ nsr_id, nsd, provider_dict, cached_vnfds, vnf_profile_id=vnf_profile_id
)
relation_requirer = self._update_ee_relation_data_with_implicit_data(
- nsr_id, nsd, r["requirer"], cached_vnfds, vnf_profile_id=vnf_profile_id
+ nsr_id, nsd, requirer_dict, cached_vnfds, vnf_profile_id=vnf_profile_id
)
provider = EERelation(relation_provider)
requirer = EERelation(relation_requirer)