X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Futils.py;h=a661e050289721aa352b85311474f91e15e508aa;hp=0dbd71ef1d7c8db567f56e5fbd633abbcf414537;hb=582b923b8f3f7104411c39ebdba63949d606ecd1;hpb=7114f65ca3ba581281fa03639f21db61a111b53e diff --git a/n2vc/utils.py b/n2vc/utils.py index 0dbd71e..a661e05 100644 --- a/n2vc/utils.py +++ b/n2vc/utils.py @@ -22,6 +22,7 @@ from juju.application import Application from juju.action import Action from juju.unit import Unit from n2vc.exceptions import N2VCInvalidCertificate +from typing import Tuple def base64_to_cacert(b64string): @@ -147,3 +148,18 @@ def obj_to_dict(obj: object) -> dict: yaml_text = obj_to_yaml(obj) # parse to dict return yaml.load(yaml_text, Loader=yaml.Loader) + + +def get_ee_id_components(ee_id: str) -> Tuple[str, str, str]: + """ + Get model, application and machine components from an execution environment id + :param ee_id: + :return: model_name, application_name, machine_id + """ + parts = ee_id.split(".") + if len(parts) != 3: + raise Exception("invalid ee id.") + model_name = parts[0] + application_name = parts[1] + machine_id = parts[2] + return model_name, application_name, machine_id