blob: 4969e6e9a0499f908bf3caaa6373e652ece74b82 [file] [log] [blame]
Dennis Dmitriev010f4cd2016-11-01 20:43:51 +02001# Copyright 2016 Mirantis, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
Tatyana Leontovich53bd1f92017-09-08 13:04:42 +030014import os
Dennis Dmitriev010f4cd2016-11-01 20:43:51 +020015
Dmitry Tyzhnenko2b730a02017-04-07 19:31:32 +030016from tcp_tests.managers.execute_commands import ExecuteCommandsMixin
Tatyana Leontovich53bd1f92017-09-08 13:04:42 +030017from tcp_tests import logger
18
19LOG = logger.logger
Dmitry Tyzhnenko2b730a02017-04-07 19:31:32 +030020
21
22class OpenstackManager(ExecuteCommandsMixin):
Dennis Dmitriev010f4cd2016-11-01 20:43:51 +020023 """docstring for OpenstackManager"""
24
Dmitry Tyzhnenkobc0f8262017-04-28 15:39:26 +030025 __config = None
26 __underlay = None
Dennis Dmitriev010f4cd2016-11-01 20:43:51 +020027
Dmitry Tyzhnenko2b730a02017-04-07 19:31:32 +030028 def __init__(self, config, underlay, salt):
Dmitry Tyzhnenkobc0f8262017-04-28 15:39:26 +030029 self.__config = config
30 self.__underlay = underlay
Dmitry Tyzhnenko2b730a02017-04-07 19:31:32 +030031 self._salt = salt
Dmitry Tyzhnenkobc0f8262017-04-28 15:39:26 +030032 super(OpenstackManager, self).__init__(
33 config=config, underlay=underlay)
Dennis Dmitriev010f4cd2016-11-01 20:43:51 +020034
35 def install(self, commands):
Dmitry Tyzhnenko2b730a02017-04-07 19:31:32 +030036 self.execute_commands(commands,
37 label='Install OpenStack services')
vrovachev700a7b02017-05-23 18:36:48 +040038 self.__config.openstack.openstack_installed = True
Tatyana Leontovich53bd1f92017-09-08 13:04:42 +030039
40 def run_tempest(
41 self,
42 image_name='rally-tempest:with_designate',
43 target='gtw01', pattern=None,
44 conf_name='lvm_mcp.conf',
45 registry='docker-sandbox.sandbox.mirantis.net/rally-tempest/'):
46 target_name = [node_name for node_name
47 in self.__underlay.node_names() if target in node_name]
48
49 if pattern:
50 cmd = ("docker run --rm --net=host "
51 "-e TEMPEST_CONF={0} "
52 "-e SKIP_LIST=mcp_skip.list "
53 "-e SOURCE_FILE=keystonercv3 "
54 "-e CUSTOM='--pattern {1}' "
55 "-v /root/:/home/rally {2}{3} "
Dina Belovae6fdffb2017-09-19 13:58:34 -070056 "-v /etc/ssl/certs/:/etc/ssl/certs/ >> image.output"
57 .format(conf_name, pattern, registry, image_name))
Tatyana Leontovich53bd1f92017-09-08 13:04:42 +030058 else:
59 cmd = ("docker run --rm --net=host "
60 "-e TEMPEST_CONF={0} "
61 "-e SKIP_LIST=mcp_skip.list "
62 "-e SOURCE_FILE=keystonercv3 "
63 "-v /root/:/home/rally {2}{3} "
Dina Belovae6fdffb2017-09-19 13:58:34 -070064 "-v /etc/ssl/certs/:/etc/ssl/certs/ >> image.output"
65 .format(conf_name, pattern, registry, image_name))
Tatyana Leontovich53bd1f92017-09-08 13:04:42 +030066 with self.__underlay.remote(node_name=target_name[0]) as node_remote:
67 result = node_remote.execute(cmd)
68 LOG.debug("Test execution result is {}".format(result))
69 return result
70
71 def download_tempest_report(self, file_fromat='xml', stored_node='gtw01'):
72 target_node_name = [node_name for node_name
73 in self.__underlay.node_names()
74 if stored_node in node_name]
75 with self.__underlay.remote(node_name=target_node_name[0]) as r:
76 result = r.execute('find /root -name "report_*.{}"'.format(
77 file_fromat))
78 LOG.debug("Find result {0}".format(result))
79 file_name = result['stdout'][0].rstrip()
80 LOG.debug("Founded files {0}".format(file_name))
81 r.download(destination=file_name, target=os.getcwd())