1 ##############################################################################
2 # Copyright (c) 2017 Ericsson AB and others.
3 # Author: Jose Lausuch (jose.lausuch@ericsson.com)
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
12 from opnfv.deployment import manager
13 from opnfv.utils import opnfv_logger as logger
14 from opnfv.utils import ssh_utils
16 logger = logger.Logger(__name__).getLogger()
19 class ApexAdapter(manager.DeploymentHandler):
21 def __init__(self, installer_ip, installer_user, pkey_file):
22 super(ApexAdapter, self).__init__(installer='apex',
23 installer_ip=installer_ip,
24 installer_user=installer_user,
30 cmd = "source /home/stack/stackrc;openstack server list"
31 output = self.installer_node.run_cmd(cmd)
32 lines = output.rsplit('\n')
34 logger.info("No nodes found in the deployment.")
38 if 'controller' in line:
40 elif 'compute' in line:
44 if 'Daylight' in line:
45 roles += ", OpenDaylight"
46 fields = line.split('|')
47 id = re.sub('[!| ]', '', fields[1]).encode()
48 name = re.sub('[!| ]', '', fields[2]).encode()
49 status_node = re.sub('[!| ]', '', fields[3]).encode()
50 ip = re.sub('[!| ctlplane=]', '', fields[4]).encode()
52 if status_node.lower() == 'active':
53 status = manager.Node.STATUS_OK
54 ssh_client = ssh_utils.get_ssh_client(hostname=ip,
55 username='heat-admin',
56 pkey_file=self.pkey_file)
58 status = manager.Node.STATUS_INACTIVE
61 node = manager.Node(id, ip, name, status, roles, ssh_client)
66 def get_openstack_version(self):
67 cmd = 'source overcloudrc;sudo nova-manage version'
68 result = self.installer_node.run_cmd(cmd)
71 def get_sdn_version(self):
72 cmd_descr = ("sudo yum info opendaylight 2>/dev/null|"
73 "grep Description|sed 's/^.*\: //'")
74 cmd_ver = ("sudo yum info opendaylight 2>/dev/null|"
75 "grep Version|sed 's/^.*\: //'")
76 for node in self.nodes:
77 if 'controller' in node.get_attribute('roles'):
78 description = node.run_cmd(cmd_descr)
79 version = node.run_cmd(cmd_ver)
82 if description is None:
85 return description + ':' + version
87 def get_deployment_status(self):
88 cmd = 'source stackrc;openstack stack list|grep CREATE_COMPLETE'
89 result = self.installer_node.run_cmd(cmd)
90 if result is None or len(result) == 0: