)
return application_name
+ @staticmethod
+ def _get_vca_record(search_key: str, vca_records: list, vdu_id: str) -> dict:
+ """Get the correct VCA record dict depending on the search key
+
+ Args:
+ search_key (str): keyword to find the correct VCA record
+ vca_records (list): All VCA records as list
+ vdu_id (str): VDU ID
+
+ Returns:
+ vca_record (dict): Dictionary which includes the correct VCA record
+
+ """
+ return next(
+ filter(lambda record: record[search_key] == vdu_id, vca_records), {}
+ )
+
@staticmethod
def _generate_application_name(
charm_level: str,
# to first 12 characters.
if not vdu_id:
raise N2VCException(message="vdu-id should be provided.")
- vca_record = next(
- filter(lambda record: record["vdu_id"] == vdu_id, vca_records), {}
+
+ vca_record = N2VCJujuConnector._get_vca_record(
+ "vdu_id", vca_records, vdu_id
)
+
+ if not vca_record:
+ vca_record = N2VCJujuConnector._get_vca_record(
+ "kdu_name", vca_records, vdu_id
+ )
+
application_name = (
vca_record["ee_descriptor_id"][:12]
+ "-"