From 347aae6ea48b962db7ab868cb0533edf7b450349 Mon Sep 17 00:00:00 2001 From: David Garcia Date: Wed, 29 Apr 2020 12:34:23 +0200 Subject: [PATCH] Check if cloud is built-in cloud when adding a model Change-Id: Iad5f8e8f614898b2be38c6c40f97d6bbe97964cd Signed-off-by: David Garcia --- n2vc/n2vc_juju_conn.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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)) -- 2.25.1