From: David Garcia Date: Wed, 29 Apr 2020 10:34:23 +0000 (+0200) Subject: Check if cloud is built-in cloud when adding a model X-Git-Tag: v7.1.0rc1~5 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=b4e41a0de84eea615a8a80cc191a34032b679b55;p=osm%2FN2VC.git Check if cloud is built-in cloud when adding a model Change-Id: Iad5f8e8f614898b2be38c6c40f97d6bbe97964cd Signed-off-by: David Garcia --- diff --git a/n2vc/n2vc_juju_conn.py b/n2vc/n2vc_juju_conn.py index 40f46f1..f48838d 100644 --- a/n2vc/n2vc_juju_conn.py +++ b/n2vc/n2vc_juju_conn.py @@ -54,6 +54,8 @@ class N2VCJujuConnector(N2VCConnector): ################################################################################################## """ + BUILT_IN_CLOUDS = ["localhost", "microk8s"] + def __init__( self, db: object, @@ -1177,12 +1179,19 @@ class N2VCJujuConnector(N2VCConnector): if not self.enable_os_upgrade: config_dict['enable-os-refresh-update'] = False config_dict['enable-os-upgrade'] = False - - model = await self.controller.add_model( - model_name=model_name, - config=config_dict, - cloud_name=self.cloud, - ) + if self.cloud in self.BUILT_IN_CLOUDS: + model = await self.controller.add_model( + model_name=model_name, + config=config_dict, + cloud_name=self.cloud, + ) + else: + model = await self.controller.add_model( + model_name=model_name, + config=config_dict, + cloud_name=self.cloud, + credential_name="admin" + ) self.log.info('New model created, name={}'.format(model_name)) else: self.log.debug('Model already exists in juju. Getting model {}'.format(model_name))