X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2Flcm_utils.py;h=5817b16a701d8d8cedbb4dcce69f65d87701bfdb;hb=4c0e6805c44f9ed1d0bb35161bf69645f5b84151;hp=956e44f70de2b34e5a9700e7bb1261e9c42a48c6;hpb=1dda84cafdeeb4a6affb443e65102a0c8149ec5c;p=osm%2FLCM.git diff --git a/osm_lcm/lcm_utils.py b/osm_lcm/lcm_utils.py index 956e44f..5817b16 100644 --- a/osm_lcm/lcm_utils.py +++ b/osm_lcm/lcm_utils.py @@ -40,10 +40,6 @@ class LcmException(Exception): pass -class LcmExceptionNoMgmtIP(LcmException): - pass - - class LcmExceptionExit(LcmException): pass @@ -173,6 +169,35 @@ def get_ee_id_parts(ee_id): return version, namespace, helm_id +def vld_to_ro_ip_profile(source_data): + if source_data: + return { + "ip_version": "IPv4" + if "v4" in source_data.get("ip-version", "ipv4") + else "IPv6", + "subnet_address": source_data.get("cidr") + or source_data.get("subnet-address"), + "gateway_address": source_data.get("gateway-ip") + or source_data.get("gateway-address"), + "dns_address": ";".join( + [v["address"] for v in source_data["dns-server"] if v.get("address")] + ) + if source_data.get("dns-server") + else None, + "dhcp_enabled": source_data.get("dhcp-params", {}).get("enabled", False) + or source_data.get("dhcp-enabled", False), + "dhcp_start_address": source_data["dhcp-params"].get("start-address") + if source_data.get("dhcp-params") + else None, + "dhcp_count": source_data["dhcp-params"].get("count") + if source_data.get("dhcp-params") + else None, + "ipv6_address_mode": source_data["ipv6-address-mode"] + if "ipv6-address-mode" in source_data + else None, + } + + class LcmBase: def __init__(self, msg, logger): """ @@ -211,7 +236,7 @@ class LcmBase: Returns: hex digest (str): The hash of the charm file """ - filehash = hashlib.md5() + filehash = hashlib.sha256() with open(zipped_file, mode="rb") as file: contents = file.read() filehash.update(contents) @@ -269,7 +294,6 @@ class LcmBase: target_charm = self.fs.path + target_charm_path if os.path.exists(current_charm) and os.path.exists(target_charm): - # Compare the hash of .charm files if current_charm.endswith(".charm"): return LcmBase.compare_charm_hash(current_charm, target_charm) @@ -383,7 +407,6 @@ class LcmBase: # Get the NSD package path if revision: - nsd_package_path = db_nsr["nsd-id"] + ":" + str(revision) db_nsd = self.db.get_one("nsds_revisions", {"_id": nsd_package_path})