blob: 337821ba92eb193f3f4b3b5c35b328a63a042e89 [file] [log] [blame]
Alex0989ecf2022-03-29 13:43:21 -05001# Author: Alex Savatieiev (osavatieiev@mirantis.com; a.savex@gmail.com)
2# Copyright 2019-2022 Mirantis, Inc.
Alex Savatieiev5118de02019-02-20 15:50:42 -06003from cfg_checker.common import logger
Alex3ebc5632019-04-18 16:47:18 -05004from cfg_checker.common.salt_utils import SaltRemote
Alex9a4ad212020-10-01 18:04:25 -05005from cfg_checker.common.kube_utils import KubeRemote
6
Alex Savatieiev5118de02019-02-20 15:50:42 -06007
8# instance of the salt client
9salt = None
Alex9a4ad212020-10-01 18:04:25 -050010kube = None
Alex Savatieiev5118de02019-02-20 15:50:42 -060011
12
13def get_salt_remote(config):
14 """Singleton-like creation of instance
15
16 Arguments:
17 config {base_config} -- an instance to base_config
18 with creds and params
19
20 Returns:
21 SaltRemote -- instance of salt client
22 """
23
24 global salt
25 logger.info("Creating salt remote instance")
26 # create it once
27 if salt is None:
Alex9a4ad212020-10-01 18:04:25 -050028 salt = SaltRemote(config)
Alex Savatieiev5118de02019-02-20 15:50:42 -060029 # return once required
30 return salt
Alex9a4ad212020-10-01 18:04:25 -050031
32
33def get_kube_remote(config):
34 """Singleton-like creation of instance
35
36 Arguments:
37 config {base_config} -- an instance to base_config
38 with creds and params
39
40 Returns:
41 KubeRemote -- instance of kube client
42 """
43 global kube
44 logger.info("Creating kube remote client instance")
45 # Create it once
46 if kube is None:
47 kube = KubeRemote(config)
48 return kube