summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-03-21 12:36:11 +0000
committerGerrit Code Review <review@openstack.org>2017-03-21 12:36:11 +0000
commiteb0b1fdc2b35bbe59168abfa46398e417cd590c4 (patch)
tree946d060d26e63228ce0faec384abb253167d8604
parent49fc7e54acd4316a974d7e82d4869a359b9a4b28 (diff)
parenteeee1e1ffd3b69082379064195f05e3513e605f1 (diff)
Merge "Devops client for fuelweb"
-rw-r--r--fuelweb_test/models/environment.py73
-rw-r--r--fuelweb_test/models/fuel_web_client.py27
-rw-r--r--fuelweb_test/tests/base_test_case.py2
3 files changed, 51 insertions, 51 deletions
diff --git a/fuelweb_test/models/environment.py b/fuelweb_test/models/environment.py
index 4649522..08dd32f 100644
--- a/fuelweb_test/models/environment.py
+++ b/fuelweb_test/models/environment.py
@@ -21,7 +21,6 @@ from devops.helpers.helpers import tcp_ping_
21from devops.helpers.helpers import wait_pass 21from devops.helpers.helpers import wait_pass
22from devops.helpers.helpers import wait 22from devops.helpers.helpers import wait
23from devops.helpers.metaclasses import SingletonMeta 23from devops.helpers.metaclasses import SingletonMeta
24from devops.models import Environment
25from keystoneauth1 import exceptions 24from keystoneauth1 import exceptions
26from proboscis.asserts import assert_equal 25from proboscis.asserts import assert_equal
27from proboscis.asserts import assert_true 26from proboscis.asserts import assert_true
@@ -104,7 +103,7 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
104 @logwrap 103 @logwrap
105 def add_syslog_server(self, cluster_id, port=5514): 104 def add_syslog_server(self, cluster_id, port=5514):
106 self.fuel_web.add_syslog_server( 105 self.fuel_web.add_syslog_server(
107 cluster_id, self.d_env.router(), port) 106 cluster_id, self.d_env.get_default_gw(), port)
108 107
109 def bootstrap_nodes(self, devops_nodes, timeout=settings.BOOTSTRAP_TIMEOUT, 108 def bootstrap_nodes(self, devops_nodes, timeout=settings.BOOTSTRAP_TIMEOUT,
110 skip_timesync=False): 109 skip_timesync=False):
@@ -147,8 +146,8 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
147 logger.info("Please wait while time on nodes: {0} " 146 logger.info("Please wait while time on nodes: {0} "
148 "will be synchronized" 147 "will be synchronized"
149 .format(', '.join(sorted(nodes_names)))) 148 .format(', '.join(sorted(nodes_names))))
150 denv = DevopsClient().get_env(self.d_env.name) 149 new_time = self.d_env.sync_time(node_names=nodes_names,
151 new_time = denv.sync_time(node_names=nodes_names, skip_sync=skip_sync) 150 skip_sync=skip_sync)
152 for name in sorted(new_time): 151 for name in sorted(new_time):
153 logger.info("New time on '{0}' = {1}".format(name, new_time[name])) 152 logger.info("New time on '{0}' = {1}".format(name, new_time[name]))
154 153
@@ -169,7 +168,7 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
169 'iface': iface_alias('eth0'), 168 'iface': iface_alias('eth0'),
170 'ip': node.get_ip_address_by_network_name('admin'), 169 'ip': node.get_ip_address_by_network_name('admin'),
171 'mask': self.d_env.get_network(name='admin').ip.netmask, 170 'mask': self.d_env.get_network(name='admin').ip.netmask,
172 'gw': self.d_env.router(), 171 'gw': self.d_env.get_default_gw(),
173 'hostname': ''.join((settings.FUEL_MASTER_HOSTNAME, 172 'hostname': ''.join((settings.FUEL_MASTER_HOSTNAME,
174 settings.DNS_SUFFIX)), 173 settings.DNS_SUFFIX)),
175 'nat_interface': '', 174 'nat_interface': '',
@@ -229,20 +228,21 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
229 from devops.error import DevopsObjNotFound 228 from devops.error import DevopsObjNotFound
230 EnvDoesNotExist = DevopsObjNotFound 229 EnvDoesNotExist = DevopsObjNotFound
231 except ImportError: 230 except ImportError:
231 from devops.models import Environment
232 # pylint: disable=no-member 232 # pylint: disable=no-member
233 EnvDoesNotExist = Environment.DoesNotExist 233 EnvDoesNotExist = Environment.DoesNotExist
234 # pylint: enable=no-member 234 # pylint: enable=no-member
235 235
236 try: 236 try:
237 logger.info("Try to find environment '{0}'".format(env_name)) 237 logger.info("Try to find environment '{0}'".format(env_name))
238 self._virt_env = Environment.get(name=env_name) 238 self._virt_env = DevopsClient().get_env(env_name)
239 except EnvDoesNotExist: 239 except EnvDoesNotExist:
240 logger.info("Try to create environment '{0}'".format(env_name)) 240 logger.info("Try to create environment '{0}'".format(env_name))
241 if self._config: 241 if self._config:
242 self._virt_env = Environment.create_environment( 242 self._virt_env = DevopsClient().create_env_from_config(
243 full_config=self._config) 243 config=self._config)
244 else: 244 else:
245 self._virt_env = Environment.describe_environment( 245 self._virt_env = DevopsClient().create_env(
246 boot_from=settings.ADMIN_BOOT_DEVICE) 246 boot_from=settings.ADMIN_BOOT_DEVICE)
247 self._virt_env.define() 247 self._virt_env.define()
248 logger.info("New environment '{0}' was defined".format(env_name)) 248 logger.info("New environment '{0}' was defined".format(env_name))
@@ -348,9 +348,9 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
348 new_login = settings.SSH_FUEL_CREDENTIALS['login'] 348 new_login = settings.SSH_FUEL_CREDENTIALS['login']
349 new_password = settings.SSH_FUEL_CREDENTIALS['password'] 349 new_password = settings.SSH_FUEL_CREDENTIALS['password']
350 try: 350 try:
351 self.ssh_manager.execute_on_remote( 351 self.ssh_manager.check_call(
352 ip=self.ssh_manager.admin_ip, 352 ip=self.ssh_manager.admin_ip,
353 cmd='date' 353 command='date'
354 ) 354 )
355 logger.debug('Accessing admin node using SSH: SUCCESS') 355 logger.debug('Accessing admin node using SSH: SUCCESS')
356 except Exception: 356 except Exception:
@@ -363,10 +363,10 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
363 slave_login=settings.SSH_SLAVE_CREDENTIALS['login'], 363 slave_login=settings.SSH_SLAVE_CREDENTIALS['login'],
364 slave_password=settings.SSH_SLAVE_CREDENTIALS['password'] 364 slave_password=settings.SSH_SLAVE_CREDENTIALS['password']
365 ) 365 )
366 self.ssh_manager.execute_on_remote( 366 self.ssh_manager.check_call(
367 ip=self.ssh_manager.admin_ip, 367 ip=self.ssh_manager.admin_ip,
368 cmd='echo -e "{1}\\n{1}" | passwd {0}'.format(new_login, 368 command='echo -e "{1}\\n{1}" | passwd {0}'.format(new_login,
369 new_password) 369 new_password)
370 ) 370 )
371 self.ssh_manager.initialize( 371 self.ssh_manager.initialize(
372 admin_ip=self.ssh_manager.admin_ip, 372 admin_ip=self.ssh_manager.admin_ip,
@@ -389,14 +389,15 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
389 self.fuel_web.client.get_releases() 389 self.fuel_web.client.get_releases()
390 # TODO(akostrikov) CENTOS7 except exceptions.Unauthorized: 390 # TODO(akostrikov) CENTOS7 except exceptions.Unauthorized:
391 except: 391 except:
392 self.ssh_manager.execute_on_remote( 392 self.ssh_manager.check_call(
393 ip=self.ssh_manager.admin_ip, 393 ip=self.ssh_manager.admin_ip,
394 cmd='fuel user --newpass {0} --change-password'.format( 394 command='fuel user --newpass {0} --change-password'.format(
395 settings.KEYSTONE_CREDS['password']) 395 settings.KEYSTONE_CREDS['password'])
396 ) 396 )
397 config_file = self.ssh_manager.execute_on_remote( 397 config_file_path = 'ls -1 $HOME/.config/fuel/fuel_client.yaml'
398 config_file = self.ssh_manager.check_call(
398 ip=self.ssh_manager.admin_ip, 399 ip=self.ssh_manager.admin_ip,
399 cmd='ls -1 $HOME/.config/fuel/fuel_client.yaml')['stdout_str'] 400 command=config_file_path)['stdout_str']
400 401
401 with YamlEditor(config_file, ip=self.admin_node_ip) as editor: 402 with YamlEditor(config_file, ip=self.admin_node_ip) as editor:
402 editor.content["OS_USERNAME"] = \ 403 editor.content["OS_USERNAME"] = \
@@ -458,7 +459,7 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
458 nessus_node.start() 459 nessus_node.start()
459 # wait while installation complete 460 # wait while installation complete
460 461
461 self.admin_actions.modify_configs(self.d_env.router()) 462 self.admin_actions.modify_configs(self.d_env.get_default_gw())
462 if CUSTOM_FUEL_SETTING_YAML: 463 if CUSTOM_FUEL_SETTING_YAML:
463 self.admin_actions.update_fuel_setting_yaml( 464 self.admin_actions.update_fuel_setting_yaml(
464 CUSTOM_FUEL_SETTING_YAML) 465 CUSTOM_FUEL_SETTING_YAML)
@@ -471,19 +472,19 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
471 cmd = """ 472 cmd = """
472 echo -e '"SSL":\n "force_https": "true"' >> /etc/fuel/astute.yaml 473 echo -e '"SSL":\n "force_https": "true"' >> /etc/fuel/astute.yaml
473 """ 474 """
474 self.ssh_manager.execute_on_remote(admin_node_ip, cmd) 475 self.ssh_manager.check_call(admin_node_ip, cmd)
475 cmd = "find / -name \"nginx_services.pp\"" 476 cmd = "find / -name \"nginx_services.pp\""
476 puppet_manifest = \ 477 puppet_manifest = \
477 self.ssh_manager.execute_on_remote( 478 self.ssh_manager.check_call(
478 admin_node_ip, cmd)['stdout'][0].strip() 479 admin_node_ip, cmd)['stdout'][0].strip()
479 cmd = 'puppet apply {0}'.format(puppet_manifest) 480 cmd = 'puppet apply {0}'.format(puppet_manifest)
480 self.ssh_manager.execute_on_remote(admin_node_ip, cmd) 481 self.ssh_manager.check_call(admin_node_ip, cmd)
481 cmd = """ 482 cmd = """
482 systemctl status nginx.service | 483 systemctl status nginx.service |
483 awk 'match($0, /\s+Active:.*\((\w+)\)/, a) {print a[1]}' 484 awk 'match($0, /\s+Active:.*\((\w+)\)/, a) {print a[1]}'
484 """ 485 """
485 wait(lambda: ( 486 wait(lambda: (
486 self.ssh_manager.execute_on_remote( 487 self.ssh_manager.check_call(
487 admin_node_ip, cmd)['stdout'][0] != 'dead'), interval=10, 488 admin_node_ip, cmd)['stdout'][0] != 'dead'), interval=10,
488 timeout=30, 489 timeout=30,
489 timeout_msg='Nginx service is dead after trying to enable ' 490 timeout_msg='Nginx service is dead after trying to enable '
@@ -550,13 +551,13 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
550 def kill_wait_for_external_config(self): 551 def kill_wait_for_external_config(self):
551 kill_cmd = 'pkill -f "^wait_for_external_config"' 552 kill_cmd = 'pkill -f "^wait_for_external_config"'
552 check_cmd = 'pkill -0 -f "^wait_for_external_config"; [[ $? -eq 1 ]]' 553 check_cmd = 'pkill -0 -f "^wait_for_external_config"; [[ $? -eq 1 ]]'
553 self.ssh_manager.execute_on_remote( 554 self.ssh_manager.check_call(
554 ip=self.ssh_manager.admin_ip, 555 ip=self.ssh_manager.admin_ip,
555 cmd=kill_cmd 556 command=kill_cmd
556 ) 557 )
557 self.ssh_manager.execute_on_remote( 558 self.ssh_manager.check_call(
558 ip=self.ssh_manager.admin_ip, 559 ip=self.ssh_manager.admin_ip,
559 cmd=check_cmd 560 command=check_cmd
560 ) 561 )
561 562
562 def wait_bootstrap(self): 563 def wait_bootstrap(self):
@@ -606,9 +607,9 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
606 'is not based on Ubuntu!') 607 'is not based on Ubuntu!')
607 return 608 return
608 609
609 bootstrap_images = self.ssh_manager.execute_on_remote( 610 bootstrap_images = self.ssh_manager.check_call(
610 ip=self.ssh_manager.admin_ip, 611 ip=self.ssh_manager.admin_ip,
611 cmd='fuel-bootstrap --quiet list' 612 command='fuel-bootstrap --quiet list'
612 )['stdout'] 613 )['stdout']
613 assert_true(any('active' in line for line in bootstrap_images), 614 assert_true(any('active' in line for line in bootstrap_images),
614 'Ubuntu bootstrap image wasn\'t built and activated! ' 615 'Ubuntu bootstrap image wasn\'t built and activated! '
@@ -662,10 +663,10 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
662 'yum update -y 2>>/var/log/yum-update-error.log' 663 'yum update -y 2>>/var/log/yum-update-error.log'
663 664
664 logger.info('Performing yum clean and update commands') 665 logger.info('Performing yum clean and update commands')
665 update_result = self.ssh_manager.execute_on_remote( 666 update_result = self.ssh_manager.check_call(
666 ip=self.ssh_manager.admin_ip, 667 ip=self.ssh_manager.admin_ip,
667 cmd=update_command, 668 command=update_command,
668 err_msg='Packages update failed, inspect logs for details') 669 error_info='Packages update failed, inspect logs for details')
669 670
670 logger.info('Packages were updated successfully') 671 logger.info('Packages were updated successfully')
671 672
@@ -702,10 +703,10 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
702 # ssh connection hanging on massive output from puppet run. 703 # ssh connection hanging on massive output from puppet run.
703 cmd = '/usr/share/fuel-utils/update-master-node.sh > /dev/null 2>&1' 704 cmd = '/usr/share/fuel-utils/update-master-node.sh > /dev/null 2>&1'
704 705
705 self.ssh_manager.execute_on_remote( 706 self.ssh_manager.check_call(
706 ip=self.ssh_manager.admin_ip, 707 ip=self.ssh_manager.admin_ip,
707 cmd=cmd, 708 command=cmd,
708 err_msg='Update failed, inspect logs for details', 709 error_info='Update failed, inspect logs for details',
709 ) 710 )
710 logger.info('Update successful') 711 logger.info('Update successful')
711 712
diff --git a/fuelweb_test/models/fuel_web_client.py b/fuelweb_test/models/fuel_web_client.py
index 298adb5..acfa931 100644
--- a/fuelweb_test/models/fuel_web_client.py
+++ b/fuelweb_test/models/fuel_web_client.py
@@ -63,7 +63,6 @@ from fuelweb_test.helpers.decorators import retry
63from fuelweb_test.helpers.decorators import update_fuel 63from fuelweb_test.helpers.decorators import update_fuel
64from fuelweb_test.helpers.decorators import upload_manifests 64from fuelweb_test.helpers.decorators import upload_manifests
65from fuelweb_test.helpers.security import SecurityChecks 65from fuelweb_test.helpers.security import SecurityChecks
66from fuelweb_test.helpers.ssh_manager import SSHManager
67from fuelweb_test.helpers.ssl_helpers import change_cluster_ssl_config 66from fuelweb_test.helpers.ssl_helpers import change_cluster_ssl_config
68from fuelweb_test.helpers.ssl_helpers import copy_cert_from_master 67from fuelweb_test.helpers.ssl_helpers import copy_cert_from_master
69from fuelweb_test.helpers.uca import change_cluster_uca_config 68from fuelweb_test.helpers.uca import change_cluster_uca_config
@@ -105,9 +104,9 @@ class FuelWebClient29(object):
105 """FuelWebClient.""" # TODO documentation 104 """FuelWebClient.""" # TODO documentation
106 105
107 def __init__(self, environment): 106 def __init__(self, environment):
108 self.ssh_manager = SSHManager()
109 self.admin_node_ip = self.ssh_manager.admin_ip
110 self._environment = environment 107 self._environment = environment
108 self.ssh_manager = environment.ssh_manager
109 self.admin_node_ip = self.ssh_manager.admin_ip
111 110
112 keystone_url = "http://{0}:5000/v2.0".format(self.admin_node_ip) 111 keystone_url = "http://{0}:5000/v2.0".format(self.admin_node_ip)
113 112
@@ -655,7 +654,7 @@ class FuelWebClient29(object):
655 if help_data.FUEL_USE_LOCAL_NTPD\ 654 if help_data.FUEL_USE_LOCAL_NTPD\
656 and ('ntp_list' not in settings)\ 655 and ('ntp_list' not in settings)\
657 and checkers.is_ntpd_active( 656 and checkers.is_ntpd_active(
658 self.ssh_manager.admin_ip, public_gw): 657 self.admin_node_ip, public_gw):
659 attributes['editable']['external_ntp']['ntp_list']['value'] =\ 658 attributes['editable']['external_ntp']['ntp_list']['value'] =\
660 [public_gw] 659 [public_gw]
661 logger.info("Configuring cluster #{0}" 660 logger.info("Configuring cluster #{0}"
@@ -1259,8 +1258,7 @@ class FuelWebClient29(object):
1259 1258
1260 @logwrap 1259 @logwrap
1261 def get_ssh_for_node(self, node_name): 1260 def get_ssh_for_node(self, node_name):
1262 return self.environment.d_env.get_ssh_to_remote( 1261 return self.environment.d_env.get_node_remote(node_name)
1263 self.get_node_ip_by_devops_name(node_name))
1264 1262
1265 @logwrap 1263 @logwrap
1266 def get_ssh_for_role(self, nodes_dict, role): 1264 def get_ssh_for_role(self, nodes_dict, role):
@@ -1269,8 +1267,12 @@ class FuelWebClient29(object):
1269 return self.get_ssh_for_node(node_name) 1267 return self.get_ssh_for_node(node_name)
1270 1268
1271 @logwrap 1269 @logwrap
1270 def get_ssh_for_ip(self, ip):
1271 return self.ssh_manager.get_remote(ip)
1272
1273 @logwrap
1272 def get_ssh_for_nailgun_node(self, nailgun_node): 1274 def get_ssh_for_nailgun_node(self, nailgun_node):
1273 return self.environment.d_env.get_ssh_to_remote(nailgun_node['ip']) 1275 return self.get_ssh_for_ip(nailgun_node['ip'])
1274 1276
1275 @logwrap 1277 @logwrap
1276 def is_node_discovered(self, nailgun_node): 1278 def is_node_discovered(self, nailgun_node):
@@ -2290,7 +2292,7 @@ class FuelWebClient29(object):
2290 self.client.list_cluster_nodes(cluster_id)]) 2292 self.client.list_cluster_nodes(cluster_id)])
2291 # 'mco find' returns '1' exit code if rabbitmq is not ready 2293 # 'mco find' returns '1' exit code if rabbitmq is not ready
2292 out = self.ssh_manager.execute_on_remote( 2294 out = self.ssh_manager.execute_on_remote(
2293 ip=self.ssh_manager.admin_ip, 2295 ip=self.admin_node_ip,
2294 cmd='mco find', assert_ec_equal=[0, 1])['stdout_str'] 2296 cmd='mco find', assert_ec_equal=[0, 1])['stdout_str']
2295 ready_nodes_uids = set(out.split('\n')) 2297 ready_nodes_uids = set(out.split('\n'))
2296 unavailable_nodes = nodes_uids - ready_nodes_uids 2298 unavailable_nodes = nodes_uids - ready_nodes_uids
@@ -2369,8 +2371,7 @@ class FuelWebClient29(object):
2369 # Let's find nodes where are a time skew. It can be checked on 2371 # Let's find nodes where are a time skew. It can be checked on
2370 # an arbitrary one. 2372 # an arbitrary one.
2371 logger.debug("Looking up nodes with a time skew and try to fix them") 2373 logger.debug("Looking up nodes with a time skew and try to fix them")
2372 with self.environment.d_env.get_ssh_to_remote( 2374 with self.get_ssh_for_nailgun_node(online_ceph_nodes[0]) as remote:
2373 online_ceph_nodes[0]['ip']) as remote:
2374 if ceph.is_clock_skew(remote): 2375 if ceph.is_clock_skew(remote):
2375 skewed = ceph.get_node_fqdns_w_clock_skew(remote) 2376 skewed = ceph.get_node_fqdns_w_clock_skew(remote)
2376 logger.warning("Time on nodes {0} are to be " 2377 logger.warning("Time on nodes {0} are to be "
@@ -2413,9 +2414,7 @@ class FuelWebClient29(object):
2413 2414
2414 logger.info('Waiting until Ceph service become up...') 2415 logger.info('Waiting until Ceph service become up...')
2415 for node in online_ceph_nodes: 2416 for node in online_ceph_nodes:
2416 with self.environment.d_env\ 2417 with self.get_ssh_for_nailgun_node(node) as remote:
2417 .get_ssh_to_remote(node['ip']) as remote:
2418
2419 wait(lambda: ceph.check_service_ready(remote) is True, 2418 wait(lambda: ceph.check_service_ready(remote) is True,
2420 interval=20, timeout=600, 2419 interval=20, timeout=600,
2421 timeout_msg='Ceph service is not properly started' 2420 timeout_msg='Ceph service is not properly started'
@@ -2425,7 +2424,7 @@ class FuelWebClient29(object):
2425 self.check_ceph_time_skew(cluster_id, offline_nodes) 2424 self.check_ceph_time_skew(cluster_id, offline_nodes)
2426 2425
2427 node = online_ceph_nodes[0] 2426 node = online_ceph_nodes[0]
2428 with self.environment.d_env.get_ssh_to_remote(node['ip']) as remote: 2427 with self.get_ssh_for_nailgun_node(node) as remote:
2429 if not ceph.is_health_ok(remote): 2428 if not ceph.is_health_ok(remote):
2430 if ceph.is_pgs_recovering(remote) and len(offline_nodes) > 0: 2429 if ceph.is_pgs_recovering(remote) and len(offline_nodes) > 0:
2431 logger.info('Ceph is being recovered after osd node(s)' 2430 logger.info('Ceph is being recovered after osd node(s)'
diff --git a/fuelweb_test/tests/base_test_case.py b/fuelweb_test/tests/base_test_case.py
index 650e3ae..071bb45 100644
--- a/fuelweb_test/tests/base_test_case.py
+++ b/fuelweb_test/tests/base_test_case.py
@@ -280,7 +280,7 @@ class TestBasic(object):
280 ssh.execute_on_remote(ssh.admin_ip, cmd=cmd) 280 ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)
281 281
282 self.env.wait_for_external_config() 282 self.env.wait_for_external_config()
283 self.env.admin_actions.modify_configs(self.env.d_env.router()) 283 self.env.admin_actions.modify_configs(self.env.d_env.get_default_gw())
284 if CUSTOM_FUEL_SETTING_YAML: 284 if CUSTOM_FUEL_SETTING_YAML:
285 self.env.admin_actions.update_fuel_setting_yaml( 285 self.env.admin_actions.update_fuel_setting_yaml(
286 CUSTOM_FUEL_SETTING_YAML) 286 CUSTOM_FUEL_SETTING_YAML)