Coverage for n2vc/vca/connection_data.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-05-07 06:04 +0000

1# Copyright 2021 Canonical Ltd. 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14 

15from n2vc.utils import base64_to_cacert 

16 

17 

18class ConnectionData: 

19 def __init__(self, **kwargs): 

20 """ 

21 Constructor 

22 

23 :param: kwargs: 

24 endpoints (list): Endpoints of all the Juju controller units 

25 user (str): Username for authenticating to the controller 

26 secret (str): Secret for authenticating to the controller 

27 cacert (str): Base64 encoded CA certificate for authenticating to the controller 

28 (optional) pubkey (str): Public key to insert to the charm. 

29 This is useful to do `juju ssh`. 

30 It is not very useful though. 

31 TODO: Test it. 

32 (optional) lxd-cloud (str): Name of the cloud to use for lxd proxy charms 

33 (optional) lxd-credentials (str): Name of the lxd-cloud credentials 

34 (optional) k8s-cloud (str): Name of the cloud to use for k8s proxy charms 

35 (optional) k8s-credentials (str): Name of the k8s-cloud credentials 

36 (optional) model-config (n2vc.config.ModelConfig): Config to apply in all Juju models 

37 (deprecated, optional) api-proxy (str): Proxy IP to reach the controller. 

38 Used in case native charms cannot react the controller. 

39 """ 

40 self.endpoints = kwargs["endpoints"] 

41 self.user = kwargs["user"] 

42 self.secret = kwargs["secret"] 

43 self.cacert = base64_to_cacert(kwargs["cacert"]) 

44 self.pubkey = kwargs.get("pubkey", "") 

45 self.lxd_cloud = kwargs.get("lxd-cloud", None) 

46 self.lxd_credentials = kwargs.get("lxd-credentials", None) 

47 self.k8s_cloud = kwargs.get("k8s-cloud", None) 

48 self.k8s_credentials = kwargs.get("k8s-credentials", None) 

49 self.model_config = kwargs.get("model-config", {}) 

50 self.model_config.update({"authorized-keys": self.pubkey}) 

51 self.api_proxy = kwargs.get("api-proxy", None)