X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Flibjuju.py;h=a00fa58aaa0bc1b2535bc5aa16707fb59e594f67;hp=0fa42f804d1d8b57e62f34f192a4fca529c4c7f1;hb=7077e2601a209a87f7fe397b35586e7701ca759a;hpb=e22c72017d4756571ea04760ce5059c7ba7cd295 diff --git a/n2vc/libjuju.py b/n2vc/libjuju.py index 0fa42f8..a00fa58 100644 --- a/n2vc/libjuju.py +++ b/n2vc/libjuju.py @@ -1025,16 +1025,21 @@ class Libjuju: await self.disconnect_controller(controller) async def add_k8s( - self, name: str, configuration: Configuration, storage_class: str + self, + name: str, + configuration: Configuration, + storage_class: str, + credential_name: str = None, ): """ Add a Kubernetes cloud to the controller Similar to the `juju add-k8s` command in the CLI - :param: name: Name for the K8s cloud - :param: configuration: Kubernetes configuration object - :param: storage_class: Storage Class to use in the cloud + :param: name: Name for the K8s cloud + :param: configuration: Kubernetes configuration object + :param: storage_class: Storage Class to use in the cloud + :param: credential_name: Storage Class to use in the cloud """ if not storage_class: @@ -1062,7 +1067,9 @@ class Libjuju: }, ) - return await self.add_cloud(name, cloud, credential) + return await self.add_cloud( + name, cloud, credential, credential_name=credential_name + ) def get_k8s_cloud_credential( self, configuration: Configuration, @@ -1119,20 +1126,28 @@ class Libjuju: return client.CloudCredential(auth_type=auth_type, attrs=attrs,) async def add_cloud( - self, name: str, cloud: Cloud, credential: CloudCredential = None + self, + name: str, + cloud: Cloud, + credential: CloudCredential = None, + credential_name: str = None, ) -> Cloud: """ Add cloud to the controller - :param: name: Name of the cloud to be added - :param: cloud: Cloud object - :param: credential: CloudCredentials object for the cloud + :param: name: Name of the cloud to be added + :param: cloud: Cloud object + :param: credential: CloudCredentials object for the cloud + :param: credential_name: Credential name. + If not defined, cloud of the name will be used. """ controller = await self.get_controller() try: _ = await controller.add_cloud(name, cloud) if credential: - await controller.add_credential(name, credential=credential, cloud=name) + await controller.add_credential( + credential_name or name, credential=credential, cloud=name + ) # Need to return the object returned by the controller.add_cloud() function # I'm returning the original value now until this bug is fixed: # https://github.com/juju/python-libjuju/issues/443