Code Coverage

Cobertura Coverage Report > n2vc.vca >

connection_data.py

Trend

File Coverage summary

NameClassesLinesConditionals
connection_data.py
100%
1/1
100%
15/15
100%
0/0

Coverage Breakdown by Class

NameLinesConditionals
connection_data.py
100%
15/15
N/A

Source

n2vc/vca/connection_data.py
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
15 1 from n2vc.utils import base64_to_cacert
16
17
18 1 class ConnectionData:
19 1     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 1         self.endpoints = kwargs["endpoints"]
41 1         self.user = kwargs["user"]
42 1         self.secret = kwargs["secret"]
43 1         self.cacert = base64_to_cacert(kwargs["cacert"])
44 1         self.pubkey = kwargs.get("pubkey", "")
45 1         self.lxd_cloud = kwargs.get("lxd-cloud", None)
46 1         self.lxd_credentials = kwargs.get("lxd-credentials", None)
47 1         self.k8s_cloud = kwargs.get("k8s-cloud", None)
48 1         self.k8s_credentials = kwargs.get("k8s-credentials", None)
49 1         self.model_config = kwargs.get("model-config", {})
50 1         self.model_config.update({"authorized-keys": self.pubkey})
51 1         self.api_proxy = kwargs.get("api-proxy", None)