X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Fn2vc_juju_conn.py;h=7c55af73045ceee4d43226b0bbdc37ad2b710051;hp=aba88eebb99866459fc939fce04d3d082e71160d;hb=ad3a05447418afef1d7b1998f9d7e351ccf9fe40;hpb=43c2e79e783aa65dba1234ae4c299944c5f1702e diff --git a/n2vc/n2vc_juju_conn.py b/n2vc/n2vc_juju_conn.py index aba88ee..7c55af7 100644 --- a/n2vc/n2vc_juju_conn.py +++ b/n2vc/n2vc_juju_conn.py @@ -266,11 +266,11 @@ class N2VCJujuConnector(N2VCConnector): if credentials is None: raise N2VCBadArgumentsException(message='credentials are mandatory', bad_args=['credentials']) - if 'hostname' in credentials: + if credentials.get('hostname'): hostname = credentials['hostname'] else: raise N2VCBadArgumentsException(message='hostname is mandatory', bad_args=['credentials.hostname']) - if 'username' in credentials: + if credentials.get('username'): username = credentials['username'] else: raise N2VCBadArgumentsException(message='username is mandatory', bad_args=['credentials.username']) @@ -439,7 +439,7 @@ class N2VCJujuConnector(N2VCConnector): raise e # return public key if exists - return output + return output["pubkey"] if "pubkey" in output else output async def add_relation( self, @@ -706,18 +706,22 @@ class N2VCJujuConnector(N2VCConnector): :return: app-vnf--vdu--cnt- """ + # TODO: Enforce the Juju 50-character application limit + # split namespace components _, _, vnf_id, vdu_id, vdu_count = self._get_namespace_components(namespace=namespace) if vnf_id is None or len(vnf_id) == 0: vnf_id = '' else: - vnf_id = 'vnf-' + vnf_id + # Shorten the vnf_id to its last twelve characters + vnf_id = 'vnf-' + vnf_id[-12:] if vdu_id is None or len(vdu_id) == 0: vdu_id = '' else: - vdu_id = '-vdu-' + vdu_id + # Shorten the vdu_id to its last twelve characters + vdu_id = '-vdu-' + vdu_id[-12:] if vdu_count is None or len(vdu_count) == 0: vdu_count = '' @@ -1021,9 +1025,6 @@ class N2VCJujuConnector(N2VCConnector): total_timeout: float = None ): - # get juju model - model = await self._juju_get_model(model_name=model_name) - # get the application application = await self._juju_get_application(model_name=model_name, application_name=application_name) @@ -1042,10 +1043,11 @@ class N2VCJujuConnector(N2VCConnector): ) # check if 'verify-ssh-credentials' action exists - unit = application.units[0] + # unit = application.units[0] actions = await application.get_actions() if 'verify-ssh-credentials' not in actions: msg = 'Action verify-ssh-credentials does not exist in application {}'.format(application_name) + self.debug(msg=msg) return False # execute verify-credentials