diff --git a/app/cli/cliapp.py b/app/cli/cliapp.py index 6a87092f..50eb1142 100644 --- a/app/cli/cliapp.py +++ b/app/cli/cliapp.py @@ -1,13 +1,13 @@ import inspect import os -import pkgutil import sys +import pkgutil import traceback from typing import List import click -from common.utils import get_logger, setup_log, Singleton, path_extend +from clap.utils import get_logger, setup_log, Singleton, path_extend if 'CLAP_PATH' not in os.environ: os.environ['CLAP_PATH'] = path_extend('~', '.clap') @@ -17,13 +17,17 @@ class Defaults(metaclass=Singleton): def __init__(self): self.verbosity: int = 0 self.clap_path: str = path_extend(os.environ.get('CLAP_PATH')) - self.configs_path: str = path_extend(os.environ.get('CLAP_PATH'), 'configs') - self.private_path: str = path_extend(os.environ.get('CLAP_PATH'), 'private') - self.storage_path: str = path_extend(os.environ.get('CLAP_PATH'), 'storage') + self.configs_path: str = path_extend( + os.environ.get('CLAP_PATH'), 'configs') + self.private_path: str = path_extend( + os.environ.get('CLAP_PATH'), 'private') + self.storage_path: str = path_extend( + os.environ.get('CLAP_PATH'), 'storage') class clap_command(click.Group): def __init__(self, group): + super().__init__() self.__dict__ = group.__dict__.copy() @@ -32,6 +36,11 @@ def __init__(self, group): def find_commands(paths: List[str] = None) -> List[clap_command]: + """ + + :param paths: + :return: + """ paths = paths or [os.path.join(os.path.dirname(__file__), 'modules')] modules = [] for importer, package_name, _ in pkgutil.iter_modules(paths): @@ -40,9 +49,8 @@ def find_commands(paths: List[str] = None) -> List[clap_command]: continue try: mod = importer.find_module(package_name).load_module(package_name) - # TODO Remove this!! modules += [obj for _, obj in inspect.getmembers( - mod, predicate=lambda x: 'clap_command' in str(type(x)))] + mod, predicate=lambda x: type(x) is clap_command)] except Exception as e: print(f'Error importing module with name `{package_name}`') raise e @@ -79,4 +87,4 @@ def main(args): if __name__ == '__main__': import sys - main(sys.argv) \ No newline at end of file + main(sys.argv) diff --git a/app/cli/modules/cluster.py b/app/cli/modules/cluster.py index 742b14d2..0896f577 100644 --- a/app/cli/modules/cluster.py +++ b/app/cli/modules/cluster.py @@ -7,13 +7,12 @@ from dataclasses import asdict from typing import List -from common.cluster_manager import ClusterManager, ClusterConfigDatabase, ClusterRepositoryController -from common.configs import ConfigurationDatabase -from common.executor import ShellInvoker, SSHCommandExecutor, AnsiblePlaybookExecutor -from common.node import NodeRepositoryController -from common.node_manager import NodeManager -from common.repository import RepositoryFactory -from common.utils import path_extend, float_time_to_string, get_logger, \ +from clap.cluster_manager import ClusterManager, ClusterConfigDatabase, ClusterRepositoryController +from clap.configs import ConfigurationDatabase +from clap.executor import ShellInvoker, SSHCommandExecutor, AnsiblePlaybookExecutor +from clap.node_manager import NodeManager, NodeRepositoryController +from clap.repository import RepositoryFactory +from clap.utils import path_extend, float_time_to_string, get_logger, \ Singleton, defaultdict_to_dict from providers.provider_ansible_aws import AnsibleAWSProvider from app.cli.cliapp import clap_command, Defaults diff --git a/app/cli/modules/node.py b/app/cli/modules/node.py index 9f38dcb7..822dafaa 100644 --- a/app/cli/modules/node.py +++ b/app/cli/modules/node.py @@ -5,12 +5,11 @@ from collections import defaultdict from dataclasses import asdict from typing import List -from common.configs import ConfigurationDatabase -from common.executor import ShellInvoker, SSHCommandExecutor, AnsiblePlaybookExecutor -from common.node import NodeRepositoryController -from common.node_manager import NodeManager -from common.repository import RepositoryFactory -from common.utils import path_extend, float_time_to_string, get_logger, \ +from clap.configs import ConfigurationDatabase +from clap.executor import ShellInvoker, SSHCommandExecutor, AnsiblePlaybookExecutor +from clap.node_manager import NodeManager, NodeRepositoryController +from clap.repository import RepositoryFactory +from clap.utils import path_extend, float_time_to_string, get_logger, \ Singleton, defaultdict_to_dict from providers.provider_ansible_aws import AnsibleAWSProvider from app.cli.cliapp import clap_command, Defaults diff --git a/app/cli/modules/role.py b/app/cli/modules/role.py index 193a8b08..63646a71 100644 --- a/app/cli/modules/role.py +++ b/app/cli/modules/role.py @@ -2,10 +2,10 @@ import yaml from collections import defaultdict from dataclasses import asdict -from common.node import NodeRepositoryController -from common.repository import RepositoryFactory -from common.role_manager import RoleManager -from common.utils import path_extend, get_logger, Singleton, defaultdict_to_dict +from clap.node_manager import NodeRepositoryController +from clap.repository import RepositoryFactory +from clap.role_manager import RoleManager +from clap.utils import path_extend, get_logger, Singleton, defaultdict_to_dict from app.cli.cliapp import clap_command, Defaults logger = get_logger(__name__) diff --git a/common/__init__.py b/clap/__init__.py similarity index 100% rename from common/__init__.py rename to clap/__init__.py diff --git a/common/abstract_provider.py b/clap/abstract_provider.py similarity index 90% rename from common/abstract_provider.py rename to clap/abstract_provider.py index a11fa430..3aafd731 100644 --- a/common/abstract_provider.py +++ b/clap/abstract_provider.py @@ -1,9 +1,9 @@ from abc import abstractmethod, ABC from typing import List, Dict -from common.node import NodeDescriptor -from common.configs import InstanceInfo -from common.utils import get_logger +from clap.node import NodeDescriptor +from clap.configs import InstanceInfo +from clap.utils import get_logger logger = get_logger(__name__) diff --git a/common/cluster_manager.py b/clap/cluster_manager.py similarity index 88% rename from common/cluster_manager.py rename to clap/cluster_manager.py index 6973a357..d984a22a 100644 --- a/common/cluster_manager.py +++ b/clap/cluster_manager.py @@ -7,12 +7,12 @@ import dacite -from common.configs import ConfigurationDatabase, InstanceInfo -from common.executor import SSHCommandExecutor, AnsiblePlaybookExecutor -from common.node_manager import NodeManager -from common.repository import Repository, InvalidEntryError -from common.role_manager import RoleManager -from common.utils import yaml_load, get_logger, get_random_object +from clap.configs import ConfigurationDatabase, InstanceInfo +from clap.executor import SSHCommandExecutor, AnsiblePlaybookExecutor +from clap.node_manager import NodeManager, NodeRepositoryController +from clap.repository import Repository, InvalidEntryError +from clap.role_manager import RoleManager +from clap.utils import yaml_load, get_logger, get_random_object logger = get_logger(__name__) @@ -557,61 +557,3 @@ def is_alive(self, cluster_id: str, retries: int = 5, nodes, retries=retries, wait_timeout=wait_timeout, update_timeout=update_timeout, max_workers=max_workers, test_command=test_command) - - -if __name__ == '__main__': - import json - from dataclasses import asdict - from common.repository import RepositoryFactory - from common.utils import setup_log - from common.node import NodeRepositoryController - from providers.provider_ansible_aws import AnsibleAWSProvider - - setup_log(verbosity_level=1) - node_repository_path = '/home/lopani/.clap/storage/nodes.db' - private_path = '/home/lopani/.clap/private' - cluster_file_path = '/home/lopani/.clap/configs/clusters/spits-cluster.yml' - cluster_repository_path = '/home/lopani/.clap/storage/clusters.db' - - config_db = ConfigurationDatabase( - providers_file='/home/lopani/.clap/configs/providers.yaml', - logins_file='/home/lopani/.clap/configs/logins.yaml', - instances_file='/home/lopani/.clap/configs/instances.yaml' - ) - - repository = RepositoryFactory().get_repository('sqlite', node_repository_path) - repository_controller = NodeRepositoryController(repository) - - ansible_aws = AnsibleAWSProvider(private_path) - node_manager = NodeManager( - repository_controller, {'aws': ansible_aws}, private_path) - - role_manager = RoleManager( - repository_controller, - '/home/lopani/.clap/groups', - '/home/lopani/.clap/groups/actions.d', - '/home/lopani/.clap/private' - ) - - cluster_db = ClusterConfigDatabase([cluster_file_path]) - print(cluster_db.clusters) - - repository = RepositoryFactory().get_repository('sqlite', cluster_repository_path) - cluster_repository_controller = ClusterRepositoryController(repository) - - cluster_manager = ClusterManager( - node_manager, role_manager, config_db, - cluster_repository_controller, private_path) - - cluster_config = cluster_db.clusters['spits-cluster'] - cluster = cluster_manager.start_cluster(cluster_config, max_workers=4) - # cluster = cluster_manager.get_all_clusters()[0] - print(f"CLUSTER: {cluster}") - all_cluster_node_types = cluster_manager.get_cluster_nodes_types(cluster.cluster_id) - print(f"All cluster node types: {all_cluster_node_types}") - all_cluster_nodes = cluster_manager.get_all_cluster_nodes(cluster.cluster_id) - print(f"All cluster nodes: {all_cluster_nodes}") - cluster_manager.setup_cluster(cluster.cluster_id, max_workers=1) - print('setup ok') - stopped_nodes = cluster_manager.stop_cluster(cluster.cluster_id) - print(f'Stopped nodes: {stopped_nodes}') diff --git a/common/configs.py b/clap/configs.py similarity index 91% rename from common/configs.py rename to clap/configs.py index 6233d371..829563de 100644 --- a/common/configs.py +++ b/clap/configs.py @@ -3,7 +3,7 @@ import dacite -from common.utils import yaml_load, get_logger +from clap.utils import yaml_load, get_logger logger = get_logger(__name__) @@ -190,20 +190,3 @@ def load_all(self): logger.debug(f"Loaded {len(self.instance_descriptors)} instance descriptors: " f"{', '.join(sorted(self.instance_descriptors.keys()))}") - - -# if __name__ == '__main__': -# from dataclasses import asdict -# from common.utils import setup_log -# setup_log(verbosity_level=4) -# -# c = ConfigurationDatabase( -# providers_file='/home/lopani/.clap/configs/providers.yaml', -# logins_file='/home/lopani/.clap/configs/logins.yaml', -# instances_file='/home/lopani/.clap/configs/instances.yaml' -# ) -# -# for iid, instance in c.instance_descriptors.items(): -# a = asdict(instance) -# x = dacite.from_dict(InstanceInfo, a) -# print(x) diff --git a/common/executor.py b/clap/executor.py similarity index 92% rename from common/executor.py rename to clap/executor.py index 1e7f26e6..90ca213d 100644 --- a/common/executor.py +++ b/clap/executor.py @@ -12,8 +12,8 @@ import paramiko import yaml -from common.node import NodeDescriptor -from common.utils import path_extend, get_logger, tmpdir, defaultdict_to_dict +from clap.node import NodeDescriptor +from clap.utils import path_extend, get_logger, tmpdir, defaultdict_to_dict logger = get_logger(__name__) @@ -288,25 +288,3 @@ def run(self): except subprocess.CalledProcessError: logger.error(f"Invalid connection ip: {self.node.ip}. " f"Check if `{self.node.node_id}` is alive first...") - - -# if __name__ == '__main__': - # import os - # import common.config - # import common.node - # import common.repository - # import json - # config = common.config.Config() - # rpath = os.path.join(config.storage_path, 'nodes.db') - # repository = common.repository.SQLiteRepository(rpath) - # node_controller = common.node.NodeRepositoryController(repository) - # node = node_controller.get_nodes_by_id(['node-5'])[0] - # print(node) - - # c = SSHCommandExecutor('ls -lha ~', [node], config.private_path) - # results = c.run() - # print(json.dumps(results, sort_keys=True, indent=4)) - - # p = AnsiblePlaybookExecutor('/home/lopani/.clap/groups/debug.yaml', config.private_path, hosts_node_map=[node]) - # results = p.run() - # print(json.dumps(results, sort_keys=True, indent=4)) diff --git a/clap/node.py b/clap/node.py new file mode 100644 index 00000000..49fd33fb --- /dev/null +++ b/clap/node.py @@ -0,0 +1,44 @@ +from dataclasses import dataclass, field + +from typing import List, Any, Dict, Optional + +from clap.configs import InstanceInfo +from clap.utils import get_logger + +logger = get_logger(__name__) + + +class NodeStatus: + UNKNOWN = 'unknown' + STARTED = 'started' + UNREACHABLE = 'unreachable' + REACHABLE = 'reachable' + PAUSED = 'paused' + STOPPED = 'stopped' + + +class NodeType: + TYPE_CLOUD = 'cloud' + TYPE_LOCAL = 'local' + + +class NodeLifecycle: + NORMAL = 'normal' + PREEMPTIBLE = 'preemptible' + + +@dataclass +class NodeDescriptor: + node_id: str + configuration: InstanceInfo + nickname: Optional[str] = '' + ip: Optional[str] = '' + type: Optional[str] = NodeType.TYPE_CLOUD + cloud_instance_id: Optional[str] = '' + cloud_lifecycle: Optional[str] = NodeLifecycle.NORMAL + status: Optional[str] = NodeStatus.UNKNOWN + creation_time: Optional[float] = 0.0 + update_time: Optional[float] = 0.0 + roles: List[str] = field(default_factory=list) + tags: Dict[str, str] = field(default_factory=dict) + extra: Dict[str, Any] = field(default_factory=dict) diff --git a/common/node_manager.py b/clap/node_manager.py similarity index 86% rename from common/node_manager.py rename to clap/node_manager.py index ca0d5d15..61d94b0d 100644 --- a/common/node_manager.py +++ b/clap/node_manager.py @@ -1,12 +1,16 @@ import time +from dataclasses import asdict from multiprocessing.pool import ThreadPool from typing import Dict, List, Tuple, Callable -from common.abstract_provider import AbstractInstanceProvider -from common.configs import InstanceInfo -from common.executor import SSHCommandExecutor -from common.node import NodeRepositoryController, NodeDescriptor, NodeStatus -from common.utils import get_logger, sorted_groupby +import dacite + +from clap.abstract_provider import AbstractInstanceProvider +from clap.configs import InstanceInfo +from clap.executor import SSHCommandExecutor +from clap.node import NodeDescriptor, NodeStatus +from clap.repository import Repository, InvalidEntryError +from clap.utils import get_logger, sorted_groupby logger = get_logger(__name__) @@ -17,6 +21,7 @@ class InvalidProvider(Exception): class UnhandledProviderError(Exception): def __init__(self, provider: str): + self.provider = provider super().__init__(f'Unhandled provider {provider}') @@ -24,6 +29,53 @@ class DeploymentError(Exception): pass +class InvalidNodeError(Exception): + def __init__(self, node_id: str): + self.node_id = node_id + super().__init__(f"Invalid node with id: {node_id}") + + +class NodeRepositoryController: + def __init__(self, repository: Repository): + self.repository = repository + + def upsert_node(self, node: NodeDescriptor): + node.update_time = time.time() + with self.repository.connect('node') as db: + node_dict = asdict(node) + db.upsert(node.node_id, node_dict) + + def remove_node(self, node_id: str): + with self.repository.connect('node') as db: + db.remove(node_id) + + def remove_nodes(self, node_ids: List[str]): + with self.repository.connect('node') as db: + db.remove_multiple(node_ids) + + def get_nodes_by_id(self, node_ids: List[str]) -> List[NodeDescriptor]: + with self.repository.connect('node') as db: + try: + nodes = [ + dacite.from_dict(data_class=NodeDescriptor, data=node) + for nid, node in db.get_multiple(node_ids).items() + ] + return nodes + except InvalidEntryError as e: + raise InvalidNodeError(e.entry) from e + + def get_all_nodes(self) -> List[NodeDescriptor]: + with self.repository.connect('node') as db: + return [ + dacite.from_dict(data_class=NodeDescriptor, data=node) + for nid, node in db.get_all().items() + ] + + def get_nodes_filter(self, filter_func: Callable[[NodeDescriptor], bool]) -> \ + List[NodeDescriptor]: + return [node for node in self.get_all_nodes() if filter_func(node)] + + class NodeManager: def __init__(self, node_repository_controller: NodeRepositoryController, providers: Dict[str, AbstractInstanceProvider], @@ -393,59 +445,3 @@ def upsert_node(self, node: NodeDescriptor): def remove_node(self, node_id: str): self.node_repository.remove_node(node_id) - - -if __name__ == '__main__': - import json - from common.configs import ConfigurationDatabase - from common.node import NodeRepositoryController - from common.repository import RepositoryFactory - from common.utils import setup_log - from providers.provider_ansible_aws import AnsibleAWSProvider - setup_log(verbosity_level=1) - - c = ConfigurationDatabase( - providers_file='/home/lopani/.clap/configs/providers.yaml', - logins_file='/home/lopani/.clap/configs/logins.yaml', - instances_file='/home/lopani/.clap/configs/instances.yaml' - ) - - type_a_instance = c.instance_descriptors['type-a'] - type_b_instance = c.instance_descriptors['type-b'] - print(type_a_instance) - print(type_b_instance) - - node_repository_path = '/home/lopani/.clap/storage/nodes.db' - private_path = '/home/lopani/.clap/private' - repository = RepositoryFactory().get_repository('sqlite', node_repository_path) - repository_controller = NodeRepositoryController(repository) - ansible_aws = AnsibleAWSProvider(private_path) - node_manager = NodeManager( - repository_controller, {'aws': ansible_aws}, private_path) - - # node_manager.start_nodes( - # [(type_a_instance, 1), (type_b_instance, 1)], max_workers=4) - - node_ids = [node.node_id for node in node_manager.get_all_nodes()] - print(f'Get {len(node_ids)} nodes: {node_ids}') - res = node_manager.is_alive(node_ids) - print(f'Result ({len(res)} nodes): {res}') - - x = SSHCommandExecutor('env', node_manager.get_nodes_by_id(node_ids), - private_path) - res = x.run() - - for node_id, result in res.items(): - print(node_id) - print(json.dumps(result, indent=4, sort_keys=True)) - - # res = node_manager.stop_nodes(node_ids) - # print(f'Stopped {len(res)} nodes: {res}') - - # node_ids = node_manager.start_nodes( - # [(type_a_instance, 1), (type_b_instance, 1)], max_workers=4) - # nodes = node_manager.get_all_nodes() - # x = SSHCommandExecutor('ls -lha ~', nodes, private_path) - # res = x.run() - # print(res) - # node_manager.pause_nodes(node_ids) \ No newline at end of file diff --git a/common/repository.py b/clap/repository.py similarity index 97% rename from common/repository.py rename to clap/repository.py index 69358274..da70e4e5 100644 --- a/common/repository.py +++ b/clap/repository.py @@ -12,7 +12,9 @@ class RepositoryError(Exception): class InvalidEntryError(RepositoryError): - pass + def __init__(self, entry): + self.entry = entry + super().__init__(f"Invalid entry {entry}") class Repository(ABC): diff --git a/common/role_manager.py b/clap/role_manager.py similarity index 88% rename from common/role_manager.py rename to clap/role_manager.py index 7fd7e0a8..64546748 100644 --- a/common/role_manager.py +++ b/clap/role_manager.py @@ -5,9 +5,10 @@ import dacite -from common.executor import AnsiblePlaybookExecutor -from common.node import NodeRepositoryController, NodeDescriptor -from common.utils import yaml_load, path_extend, get_logger +from clap.executor import AnsiblePlaybookExecutor +from clap.node import NodeDescriptor +from clap.node_manager import NodeRepositoryController +from clap.utils import yaml_load, path_extend, get_logger logger = get_logger(__name__) @@ -294,48 +295,3 @@ def remove_role(self, role_name: str, hosts_node_map: Union[List[str], Dict[str, List[str]]]) -> \ List[str]: pass - - -if __name__ == '__main__': - from dataclasses import asdict - from common.repository import RepositoryFactory - from common.utils import setup_log - - setup_log(verbosity_level=3) - node_repository_path = '/home/lopani/.clap/storage/nodes.db' - private_path = '/home/lopani/.clap/private' - repository = RepositoryFactory().get_repository('sqlite', node_repository_path) - repository_controller = NodeRepositoryController(repository) - - role_manager = RoleManager( - repository_controller, - '/home/lopani/.clap/groups', - '/home/lopani/.clap/groups/actions.d', - '/home/lopani/.clap/private' - ) - - for rid, r in role_manager.roles.items(): - print(f"------ {rid} -------") - print(r) - - all_nodes = repository_controller.get_all_nodes() - print("**** Nodes ****") - for node in all_nodes: - print(asdict(node)) - - # added_nodes = role_manager.add_role( - # 'commands-common', [n.node_id for n in all_nodes]) - # print(f"Added nodes: {added_nodes}") - # # - # all_nodes = repository_controller.get_all_nodes() - # print("**** Nodes ****") - # for node in all_nodes: - # print(asdict(node)) - - nodes = role_manager.get_role_nodes('commands-common') - - result = role_manager.perform_action( - 'commands-common', 'install-packages', nodes, - extra_args={'packages': 'gcc'} - ) - print(f"RESULT: {result}") diff --git a/common/utils.py b/clap/utils.py similarity index 94% rename from common/utils.py rename to clap/utils.py index f453f286..8d8d12af 100644 --- a/common/utils.py +++ b/clap/utils.py @@ -121,15 +121,3 @@ def sorted_groupby(iterable: Iterable, key=None) -> dict: def get_logger(name): return logging.getLogger(f'{APP_NAME}.{name}') - - -class Dictable: - @staticmethod - @abstractmethod - def from_dict(d: dict): - raise NotImplementedError() - - @abstractmethod - def to_dict(self): - pass - diff --git a/common/node.py b/common/node.py deleted file mode 100644 index c807f068..00000000 --- a/common/node.py +++ /dev/null @@ -1,87 +0,0 @@ -import time - -from dataclasses import dataclass, field, asdict - -from typing import List, Any, Dict, Callable, Optional - -import dacite - -from common.repository import Repository -from common.configs import InstanceInfo -from common.utils import get_logger - -logger = get_logger(__name__) - - -class NodeStatus: - UNKNOWN = 'unknown' - STARTED = 'started' - UNREACHABLE = 'unreachable' - REACHABLE = 'reachable' - PAUSED = 'paused' - STOPPED = 'stopped' - - -class NodeType: - TYPE_CLOUD = 'cloud' - TYPE_LOCAL = 'local' - - -class NodeLifecycle: - NORMAL = 'normal' - PREEMPTIBLE = 'preemptible' - - -@dataclass -class NodeDescriptor: - node_id: str - configuration: InstanceInfo - nickname: Optional[str] = '' - ip: Optional[str] = '' - type: Optional[str] = NodeType.TYPE_CLOUD - cloud_instance_id: Optional[str] = '' - cloud_lifecycle: Optional[str] = NodeLifecycle.NORMAL - status: Optional[str] = NodeStatus.UNKNOWN - creation_time: Optional[float] = 0.0 - update_time: Optional[float] = 0.0 - roles: List[str] = field(default_factory=list) - tags: Dict[str, str] = field(default_factory=dict) - extra: Dict[str, Any] = field(default_factory=dict) - - -class NodeRepositoryController: - def __init__(self, repository: Repository): - self.repository = repository - - def upsert_node(self, node: NodeDescriptor): - node.update_time = time.time() - with self.repository.connect('node') as db: - node_dict = asdict(node) - db.upsert(node.node_id, node_dict) - - def remove_node(self, node_id: str): - with self.repository.connect('node') as db: - db.remove(node_id) - - def remove_nodes(self, node_ids: List[str]): - with self.repository.connect('node') as db: - db.remove_multiple(node_ids) - - def get_nodes_by_id(self, node_ids: List[str]) -> List[NodeDescriptor]: - with self.repository.connect('node') as db: - nodes = [ - dacite.from_dict(data_class=NodeDescriptor, data=node) - for nid, node in db.get_multiple(node_ids).items() - ] - return nodes - - def get_all_nodes(self) -> List[NodeDescriptor]: - with self.repository.connect('node') as db: - return [ - dacite.from_dict(data_class=NodeDescriptor, data=node) - for nid, node in db.get_all().items() - ] - - def get_nodes_filter(self, filter_func: Callable[[NodeDescriptor], bool]) -> \ - List[NodeDescriptor]: - return [node for node in self.get_all_nodes() if filter_func(node)] diff --git a/providers/provider_ansible_aws.py b/providers/provider_ansible_aws.py index ccd4d549..19a25f86 100644 --- a/providers/provider_ansible_aws.py +++ b/providers/provider_ansible_aws.py @@ -7,11 +7,11 @@ from typing import List, Dict -from common.executor import AnsiblePlaybookExecutor -from common.node import NodeDescriptor, NodeStatus, NodeLifecycle, NodeType -from common.abstract_provider import AbstractInstanceProvider, InstanceDeploymentError -from common.configs import InstanceInfo, ProviderConfigAWS -from common.utils import path_extend, tmpdir, get_logger, get_random_name, \ +from clap.executor import AnsiblePlaybookExecutor +from clap.node import NodeDescriptor, NodeStatus, NodeLifecycle, NodeType +from clap.abstract_provider import AbstractInstanceProvider, InstanceDeploymentError +from clap.configs import InstanceInfo, ProviderConfigAWS +from clap.utils import path_extend, tmpdir, get_logger, get_random_name, \ sorted_groupby logger = get_logger(__name__) @@ -420,10 +420,11 @@ def update_instance_info(self, nodes_to_check: List[NodeDescriptor], if __name__ == '__main__': - from common.configs import ConfigurationDatabase - from common.utils import setup_log - from common.node import NodeDescriptor, NodeRepositoryController - from common.repository import RepositoryFactory + from clap.configs import ConfigurationDatabase + from clap.utils import setup_log + from clap.node import NodeDescriptor + from clap.node_manager import NodeRepositoryController + from clap.repository import RepositoryFactory setup_log(verbosity_level=3) c = ConfigurationDatabase( diff --git a/share/configs/clusters/simple-cluster.yml b/share/configs/clusters/simple-cluster.yml index bc8653e1..5a6905b5 100755 --- a/share/configs/clusters/simple-cluster.yml +++ b/share/configs/clusters/simple-cluster.yml @@ -1,10 +1,10 @@ setups: setup-initial: roles: - - name: commands-common + - name: commands-clap actions: - - role: commands-common + - role: commands-clap action: update-packages # - command: "ls -lha" @@ -12,7 +12,7 @@ setups: setup-install-gcc: actions: - - role: commands-common + - role: commands-clap action: install-packages extra: packages: gcc diff --git a/version.txt b/version.txt index 0ea3a944..0c62199f 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.2.0 +0.2.1