summaryrefslogtreecommitdiffstats
path: root/doctor_tests/installer
diff options
context:
space:
mode:
Diffstat (limited to 'doctor_tests/installer')
-rw-r--r--doctor_tests/installer/apex.py50
-rw-r--r--doctor_tests/installer/base.py1
-rw-r--r--doctor_tests/installer/common/congress.py12
-rw-r--r--doctor_tests/installer/common/set_ceilometer.py3
-rw-r--r--doctor_tests/installer/common/vitrage.py11
-rw-r--r--doctor_tests/installer/local.py12
6 files changed, 59 insertions, 30 deletions
diff --git a/doctor_tests/installer/apex.py b/doctor_tests/installer/apex.py
index 16f0376e..aaacb385 100644
--- a/doctor_tests/installer/apex.py
+++ b/doctor_tests/installer/apex.py
@@ -72,9 +72,11 @@ class ApexInstaller(BaseInstaller):
"| sed -e 's/^.*ctlplane=//' |awk '{print $1}'"
ret, controllers = self.client.ssh(command)
if ret:
- raise Exception('Exec command to get controller ips in Apex installer failed'
- 'ret=%s, output=%s' % (ret, controllers))
- self.log.info('Get controller_ips:%s from Apex installer' % controllers)
+ raise Exception('Exec command to get controller ips'
+ 'in Apex installer failed, ret=%s, output=%s'
+ % (ret, controllers))
+ self.log.info('Get controller_ips:%s from Apex installer'
+ % controllers)
self.controllers = controllers
def get_host_ip_from_hostname(self, hostname):
@@ -82,20 +84,31 @@ class ApexInstaller(BaseInstaller):
hostname_in_undercloud = hostname.split('.')[0]
- command = "source stackrc; nova show %s | awk '/ ctlplane network /{print $5}'" % (hostname_in_undercloud)
+ command = "source stackrc; nova show %s | awk '/ ctlplane network /{print $5}'" % (hostname_in_undercloud) # noqa
ret, host_ip = self.client.ssh(command)
if ret:
- raise Exception('Exec command to get host ip from hostname(%s) in Apex installer failed'
- 'ret=%s, output=%s' % (hostname, ret, host_ip))
- self.log.info('Get host_ip:%s from host_name:%s in Apex installer' % (host_ip, hostname))
+ raise Exception('Exec command to get host ip from hostname(%s)'
+ 'in Apex installer failed, ret=%s, output=%s'
+ % (hostname, ret, host_ip))
+ self.log.info('Get host_ip:%s from host_name:%s in Apex installer'
+ % (host_ip, hostname))
return host_ip[0]
def setup_stunnel(self):
- self.log.info('Setup ssh stunnel in controller nodes in Apex installer......')
+ self.log.info('Setup ssh stunnel in controller nodes'
+ ' in Apex installer......')
for node_ip in self.controllers:
- cmd = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i %s %s@%s -R %s:localhost:%s sleep 600 > ssh_tunnel.%s.log 2>&1 < /dev/null &" \
- % (self.key_file, self.node_user_name, node_ip,
- self.conf.consumer.port, self.conf.consumer.port, node_ip)
+ cmd = ("ssh -o UserKnownHostsFile=/dev/null"
+ "-o StrictHostKeyChecking=no"
+ "-i %s %s@%s -R %s:localhost:%s"
+ "sleep 600 > ssh_tunnel.%s.log"
+ "2>&1 < /dev/null &"
+ % (self.key_file,
+ self.node_user_name,
+ node_ip,
+ self.conf.consumer.port,
+ self.conf.consumer.port,
+ node_ip))
server = subprocess.Popen(cmd, shell=True)
self.servers.append(server)
server.communicate()
@@ -104,7 +117,8 @@ class ApexInstaller(BaseInstaller):
self.log.info('Set apply patches start......')
for node_ip in self.controllers:
- client = SSHClient(node_ip, self.node_user_name, key_filename=self.key_file)
+ client = SSHClient(node_ip, self.node_user_name,
+ key_filename=self.key_file)
self.controller_clients.append(client)
self._ceilometer_apply_patches(client, self.cm_set_script)
@@ -116,13 +130,15 @@ class ApexInstaller(BaseInstaller):
def _ceilometer_apply_patches(self, ssh_client, script_name):
installer_dir = os.path.dirname(os.path.realpath(__file__))
- script_abs_path = '{0}/{1}/{2}'.format(installer_dir, 'common', script_name)
+ script_abs_path = '{0}/{1}/{2}'.format(installer_dir,
+ 'common', script_name)
ssh_client.scp(script_abs_path, script_name)
cmd = 'sudo python %s' % script_name
ret, output = ssh_client.ssh(cmd)
if ret:
- raise Exception('Do the ceilometer command in controller node failed....'
- 'ret=%s, cmd=%s, output=%s' % (ret, cmd, output))
- ssh_client.ssh('sudo systemctl restart openstack-ceilometer-notification.service')
-
+ raise Exception('Do the ceilometer command in controller'
+ ' node failed, ret=%s, cmd=%s, output=%s'
+ % (ret, cmd, output))
+ ssh_client.ssh('sudo systemctl restart '
+ 'openstack-ceilometer-notification.service')
diff --git a/doctor_tests/installer/base.py b/doctor_tests/installer/base.py
index fa39816a..dcb5b1d8 100644
--- a/doctor_tests/installer/base.py
+++ b/doctor_tests/installer/base.py
@@ -9,6 +9,7 @@
import abc
import six
+
@six.add_metaclass(abc.ABCMeta)
class BaseInstaller(object):
def __init__(self, conf, log):
diff --git a/doctor_tests/installer/common/congress.py b/doctor_tests/installer/common/congress.py
index db882de2..cc58c390 100644
--- a/doctor_tests/installer/common/congress.py
+++ b/doctor_tests/installer/common/congress.py
@@ -6,6 +6,8 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+
+
def set_doctor_driver_conf(ssh_client, restart_cmd):
cg_set_cmd = '''#!/bin/bash
co_conf=/etc/congress/congress.conf
@@ -23,8 +25,9 @@ fi
ret, output = ssh_client.ssh(cg_set_cmd)
if ret:
- raise Exception('Do the congress command in controller node failed....'
- 'ret=%s, cmd=%s, output=%s' % (ret, cg_set_cmd, output))
+ raise Exception('Do the congress command in controller node failed...'
+ 'ret=%s, cmd=%s, output=%s'
+ % (ret, cg_set_cmd, output))
def restore_doctor_driver_conf(ssh_client, restart_cmd):
@@ -43,5 +46,6 @@ fi
ret, output = ssh_client.ssh(cg_restore_cmd)
if ret:
- raise Exception('Do the congress command in controller node failed....'
- 'ret=%s, cmd=%s, output=%s' % (ret, cg_restore_cmd, output))
+ raise Exception('Do the congress command in controller node failed...'
+ 'ret=%s, cmd=%s, output=%s'
+ % (ret, cg_restore_cmd, output))
diff --git a/doctor_tests/installer/common/set_ceilometer.py b/doctor_tests/installer/common/set_ceilometer.py
index f5946cb2..4050aaef 100644
--- a/doctor_tests/installer/common/set_ceilometer.py
+++ b/doctor_tests/installer/common/set_ceilometer.py
@@ -33,7 +33,8 @@ def set_notifier_topic():
publishers.append(event_notifier_topic)
config_modified = True
else:
- print('NOTE: event notifier is configured in ceilometer as we needed')
+ print('NOTE: event notifier is configured'
+ 'in ceilometer as we needed')
if config_modified:
shutil.copyfile(ep_file, ep_file_bak)
diff --git a/doctor_tests/installer/common/vitrage.py b/doctor_tests/installer/common/vitrage.py
index 9ea32271..30a73f5d 100644
--- a/doctor_tests/installer/common/vitrage.py
+++ b/doctor_tests/installer/common/vitrage.py
@@ -9,7 +9,8 @@
import os
-vitrage_template_file = '/etc/vitrage/templates/vitrage_host_down_scenarios.yaml'
+vitrage_template_file = \
+ '/etc/vitrage/templates/vitrage_host_down_scenarios.yaml'
template = """
metadata:
@@ -86,13 +87,15 @@ scenarios:
action_type: mark_down
action_target:
target: instance
-"""
+""" # noqa
def set_vitrage_host_down_template():
if os.path.isfile(vitrage_template_file):
- print('Vitrage host_down template file: %s already exists.' % vitrage_template_file)
+ print('Vitrage host_down template file: %s already exists.'
+ % vitrage_template_file)
else:
- print('Create Vitrage host_down template file:%s.' % vitrage_template_file)
+ print('Create Vitrage host_down template file:%s.'
+ % vitrage_template_file)
with open(vitrage_template_file, 'w') as file:
file.write(template)
diff --git a/doctor_tests/installer/local.py b/doctor_tests/installer/local.py
index 453755c2..fee14f33 100644
--- a/doctor_tests/installer/local.py
+++ b/doctor_tests/installer/local.py
@@ -11,7 +11,8 @@ import shutil
import subprocess
from doctor_tests.installer.base import BaseInstaller
-from doctor_tests.installer.common.vitrage import set_vitrage_host_down_template
+from doctor_tests.installer.common.vitrage import \
+ set_vitrage_host_down_template
from doctor_tests.common.constants import Inspector
from doctor_tests.common.utils import load_json_file
from doctor_tests.common.utils import write_json_file
@@ -36,7 +37,8 @@ class LocalInstaller(BaseInstaller):
self.restore_apply_patches()
def get_ssh_key_from_installer(self):
- self.log.info('Assuming SSH keys already exchanged with computer for local installer type')
+ self.log.info('Assuming SSH keys already exchanged with computer'
+ 'for local installer type')
return None
def get_host_ip_from_hostname(self, hostname):
@@ -47,7 +49,8 @@ class LocalInstaller(BaseInstaller):
stdout, stderr = server.communicate()
host_ip = stdout.strip().decode("utf-8")
- self.log.info('Get host_ip:%s from host_name:%s in local installer' % (host_ip, hostname))
+ self.log.info('Get host_ip:%s from host_name:%s in local installer'
+ % (host_ip, hostname))
return host_ip
def set_apply_patches(self):
@@ -103,7 +106,8 @@ class LocalInstaller(BaseInstaller):
def _restore_nova_policy(self):
if self.policy_modified:
- shutil.copyfile(self.nova_policy_file_backup, self.nova_policy_file)
+ shutil.copyfile(self.nova_policy_file_backup,
+ self.nova_policy_file)
os.remove(self.nova_policy_file_backup)
elif self.add_policy_file:
os.remove(self.nova_policy_file)