1 ##############################################################################
2 # Copyright (c) 2017 ZTE Corporation and others.
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 ##############################################################################
9 from doctor_tests.common.utils import SSHClient
10 from doctor_tests.installer.base import BaseInstaller
13 class ApexInstaller(BaseInstaller):
14 node_user_name = 'heat-admin'
15 cm_set_script = 'set_ceilometer.py'
16 cm_restore_script = 'restore_ceilometer.py'
18 def __init__(self, conf, log):
19 super(ApexInstaller, self).__init__(conf, log)
20 self.client = SSHClient(self.conf.installer.ip,
21 self.conf.installer.username,
24 self.controllers = list()
25 self.controller_clients = list()
28 self.log.info('Setup Apex installer start......')
30 self.key_file = self.get_ssh_key_from_installer()
31 self.controllers = self.get_controller_ips()
33 self.set_apply_patches()
37 self.restore_apply_patches()
38 for server in self.servers:
41 def get_ssh_key_from_installer(self):
42 key_path = '/home/stack/.ssh/id_rsa'
43 return self._get_ssh_key(self.client, key_path)
45 def get_controller_ips(self):
46 self.log.info('Get controller ips from Apex installer......')
48 command = "source stackrc; " \
49 "nova list | grep ' overcloud-controller-[0-9] ' " \
50 "| sed -e 's/^.*ctlplane=//' |awk '{print $1}'"
51 controllers = self._run_cmd_remote(self.client, command)
52 self.log.info('Get controller_ips:%s from Apex installer'
56 def get_host_ip_from_hostname(self, hostname):
57 self.log.info('Get host ip by hostname=%s from Apex installer......'
60 hostname_in_undercloud = hostname.split('.')[0]
61 command = "source stackrc; nova show %s | awk '/ ctlplane network /{print $5}'" % (hostname_in_undercloud) # noqa
62 host_ips = self._run_cmd_remote(self.client, command)
65 def set_apply_patches(self):
66 self.log.info('Set apply patches start......')
68 restart_cm_cmd = 'sudo systemctl restart ' \
69 'openstack-ceilometer-notification.service'
71 for node_ip in self.controllers:
72 client = SSHClient(node_ip, self.node_user_name,
73 key_filename=self.key_file)
74 self.controller_clients.append(client)
75 self._run_apply_patches(client,
79 def restore_apply_patches(self):
80 self.log.info('restore apply patches start......')
82 restart_cm_cmd = 'sudo systemctl restart ' \
83 'openstack-ceilometer-notification.service'
85 for client in self.controller_clients:
86 self._run_apply_patches(client,
88 self.cm_restore_script)