From ec0b6245f856d34845b36d0b1b5c2cd63c86b03b Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Wed, 4 Oct 2017 18:11:17 +0200 Subject: Do not use capital letters to refer to osa As agreed with the releng-xci, we should stop using OSA and start using osa to refer to openstack-ansible Change-Id: I201b360654b9a52a3387c5e473a3e448a900bb9f Signed-off-by: Manuel Buil --- modules/opnfv/deployment/OSA/__init__.py | 0 modules/opnfv/deployment/OSA/adapter.py | 76 -------------------------------- modules/opnfv/deployment/factory.py | 4 +- modules/opnfv/deployment/osa/__init__.py | 0 modules/opnfv/deployment/osa/adapter.py | 76 ++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 78 deletions(-) delete mode 100644 modules/opnfv/deployment/OSA/__init__.py delete mode 100644 modules/opnfv/deployment/OSA/adapter.py create mode 100644 modules/opnfv/deployment/osa/__init__.py create mode 100644 modules/opnfv/deployment/osa/adapter.py (limited to 'modules/opnfv') diff --git a/modules/opnfv/deployment/OSA/__init__.py b/modules/opnfv/deployment/OSA/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/opnfv/deployment/OSA/adapter.py b/modules/opnfv/deployment/OSA/adapter.py deleted file mode 100644 index e98526cad..000000000 --- a/modules/opnfv/deployment/OSA/adapter.py +++ /dev/null @@ -1,76 +0,0 @@ -############################################################################## -# Copyright (c) 2017 SUSE Linux GmbH -# Author: Manuel Buil (mbuil@suse.com) -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from opnfv.deployment import manager -from opnfv.utils import opnfv_logger as logger -from opnfv.utils import ssh_utils -import yaml - -logger = logger.Logger(__name__).getLogger() - - -class OSAAdapter(manager.DeploymentHandler): - - def __init__(self, installer_ip, installer_user, pkey_file): - self.SOURCE_PATH_UC = "/etc/openstack_deploy/openstack_user_config.yml" - self.DEST_PATH_UC = "/tmp/openstack_user_config.yml" - super(OSAAdapter, self).__init__(installer='osa', - installer_ip=installer_ip, - installer_user=installer_user, - installer_pwd=None, - pkey_file=pkey_file) - - def _find_nodes(self, file): - nodes = file['compute_hosts'] - controllers = file['haproxy_hosts'] - for controller in controllers: - nodes[controller] = controllers[controller] - return nodes - - def _process_nodes(self, raw_nodes): - nodes = [] - - for node in raw_nodes: - name = node - ip = raw_nodes[node]['ip'] - # TODO when xci provides status and id of nodes add logic - status = 'active' - id = None - if 'controller' in node: - roles = 'controller' - elif 'compute' in node: - roles = 'compute' - ssh_client = ssh_utils.get_ssh_client(hostname=ip, - username=self.installer_user, - pkey_file=self.pkey_file) - node = manager.Node(id, ip, name, status, roles, ssh_client) - nodes.append(node) - - return nodes - - def get_nodes(self, options=None): - try: - # if we have retrieved previously all the nodes, don't do it again - # This fails the first time when the constructor calls this method - # therefore the try/except - if len(self.nodes) > 0: - return self.nodes - except: - pass - - self.installer_node.get_file(self.SOURCE_PATH_UC, self.DEST_PATH_UC) - with open(self.DEST_PATH_UC, 'r') as stream: - try: - file = yaml.load(stream) - raw_nodes = self._find_nodes(file) - except yaml.YAMLError as exc: - logger.error(exc) - nodes = self._process_nodes(raw_nodes) - return nodes diff --git a/modules/opnfv/deployment/factory.py b/modules/opnfv/deployment/factory.py index 55fb2e2e3..e14783fe2 100644 --- a/modules/opnfv/deployment/factory.py +++ b/modules/opnfv/deployment/factory.py @@ -11,7 +11,7 @@ from opnfv.deployment.apex import adapter as apex_adapter from opnfv.deployment.compass import adapter as compass_adapter from opnfv.deployment.fuel import adapter as fuel_adapter -from opnfv.deployment.OSA import adapter as osa_adapter +from opnfv.deployment.osa import adapter as osa_adapter from opnfv.utils import opnfv_logger as logger logger = logger.Logger(__name__).getLogger() @@ -19,7 +19,7 @@ logger = logger.Logger(__name__).getLogger() class Factory(object): - INSTALLERS = ["fuel", "apex", "compass", "joid", "daisy", "OSA"] + INSTALLERS = ["fuel", "apex", "compass", "joid", "daisy", "osa"] def __init__(self): pass diff --git a/modules/opnfv/deployment/osa/__init__.py b/modules/opnfv/deployment/osa/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/modules/opnfv/deployment/osa/adapter.py b/modules/opnfv/deployment/osa/adapter.py new file mode 100644 index 000000000..e98526cad --- /dev/null +++ b/modules/opnfv/deployment/osa/adapter.py @@ -0,0 +1,76 @@ +############################################################################## +# Copyright (c) 2017 SUSE Linux GmbH +# Author: Manuel Buil (mbuil@suse.com) +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from opnfv.deployment import manager +from opnfv.utils import opnfv_logger as logger +from opnfv.utils import ssh_utils +import yaml + +logger = logger.Logger(__name__).getLogger() + + +class OSAAdapter(manager.DeploymentHandler): + + def __init__(self, installer_ip, installer_user, pkey_file): + self.SOURCE_PATH_UC = "/etc/openstack_deploy/openstack_user_config.yml" + self.DEST_PATH_UC = "/tmp/openstack_user_config.yml" + super(OSAAdapter, self).__init__(installer='osa', + installer_ip=installer_ip, + installer_user=installer_user, + installer_pwd=None, + pkey_file=pkey_file) + + def _find_nodes(self, file): + nodes = file['compute_hosts'] + controllers = file['haproxy_hosts'] + for controller in controllers: + nodes[controller] = controllers[controller] + return nodes + + def _process_nodes(self, raw_nodes): + nodes = [] + + for node in raw_nodes: + name = node + ip = raw_nodes[node]['ip'] + # TODO when xci provides status and id of nodes add logic + status = 'active' + id = None + if 'controller' in node: + roles = 'controller' + elif 'compute' in node: + roles = 'compute' + ssh_client = ssh_utils.get_ssh_client(hostname=ip, + username=self.installer_user, + pkey_file=self.pkey_file) + node = manager.Node(id, ip, name, status, roles, ssh_client) + nodes.append(node) + + return nodes + + def get_nodes(self, options=None): + try: + # if we have retrieved previously all the nodes, don't do it again + # This fails the first time when the constructor calls this method + # therefore the try/except + if len(self.nodes) > 0: + return self.nodes + except: + pass + + self.installer_node.get_file(self.SOURCE_PATH_UC, self.DEST_PATH_UC) + with open(self.DEST_PATH_UC, 'r') as stream: + try: + file = yaml.load(stream) + raw_nodes = self._find_nodes(file) + except yaml.YAMLError as exc: + logger.error(exc) + nodes = self._process_nodes(raw_nodes) + return nodes -- cgit 1.2.3-korg