[ansible][fedora] Update package name
[barometer.git] / baro_tests / config_server.py
index 71d4f15..a6849f0 100644 (file)
@@ -1,16 +1,19 @@
 # -*- coding: utf-8 -*-
 #
+# Copyright(c) 2017-2019 Intel Corporation and OPNFV. All rights reserved.
+#
 # Licensed under the Apache License, Version 2.0 (the "License"); you may
 # not use this file except in compliance with the License. You may obtain
 # a copy of the License at
 #
-#      http://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 # License for the specific language governing permissions and limitations
 # under the License.
+#
 
 """Classes used by collectd.py"""
 
@@ -35,6 +38,8 @@ APEX_IP = os.getenv("INSTALLER_IP").rstrip('\n')
 APEX_USER = 'root'
 APEX_USER_STACK = 'stack'
 APEX_PKEY = '/root/.ssh/id_rsa'
+TEST_VM_IMAGE = 'cirros-0.4.0-x86_64-disk.img'
+TEST_VM_IMAGE_PATH = '/home/opnfv/functest/images/' + TEST_VM_IMAGE
 
 
 class Node(object):
@@ -320,68 +325,68 @@ class ConfigServer(object):
              compute_name))
         return False
 
-    def is_localagent_server_running(self, compute):
-        """Check whether LocalAgent server is running on compute"""
+    def is_dma_server_running(self, compute):
+        """Check whether DMA server is running on compute"""
         compute_name = compute.get_name()
         nodes = get_apex_nodes()
         for node in nodes:
             if compute_name == node.get_dict()['name']:
                 stdout = node.run_cmd('sudo systemctl status docker'
                                       '&& sudo docker ps'
-                                      '| grep opnfv/barometer-localagent')
+                                      '| grep opnfv/barometer-dma')
                 if stdout and '/server' in stdout:
                     self.__logger.info(
-                        'LocalAgent Server is running in node {}'.format(
+                        'DMA Server is running in node {}'.format(
                          compute_name))
                     return True
         self.__logger.info(
-            'LocalAgent Server is *not* running in node {}'.format(
+            'DMA Server is *not* running in node {}'.format(
              compute_name))
         return False
 
-    def is_localagent_infofetch_running(self, compute):
-        """Check whether LocalAgent infofetch is running on compute"""
+    def is_dma_infofetch_running(self, compute):
+        """Check whether DMA infofetch is running on compute"""
         compute_name = compute.get_name()
         nodes = get_apex_nodes()
         for node in nodes:
             if compute_name == node.get_dict()['name']:
                 stdout = node.run_cmd('sudo systemctl status docker'
                                       '&& sudo docker ps'
-                                      '| grep opnfv/barometer-localagent')
+                                      '| grep opnfv/barometer-dma')
                 if stdout and '/infofetch' in stdout:
                     self.__logger.info(
-                        'LocalAgent InfoFetch is running in node {}'.format(
+                        'DMA InfoFetch is running in node {}'.format(
                          compute_name))
                     return True
         self.__logger.info(
-            'LocalAgent InfoFetch is *not* running in node {}'.format(
+            'DMA InfoFetch is *not* running in node {}'.format(
              compute_name))
         return False
 
-    def get_localagent_config(self, compute):
-        """Get config values of LocalAgent"""
+    def get_dma_config(self, compute):
+        """Get config values of DMA"""
         compute_name = compute.get_name()
         nodes = get_apex_nodes()
         for node in nodes:
             if compute_name == node.get_dict()['name']:
                 # We use following after functest accept python-toml
                 #     stdout = node.run_cmd(
-                #         'cat /etc/barometer-localagent/config.toml')
+                #         'cat /etc/barometer-dma/config.toml')
                 #     try:
                 #         agent_conf = toml.loads(stdout)
                 #     except (TypeError, TomlDecodeError) as e:
                 #         self.__logger.error(
-                #             'LocalAgent config error: {}'.format(e))
+                #             'DMA config error: {}'.format(e))
                 #         agent_conf = None
                 #     finally:
                 #         return agent_conf
                 readcmd = (
                     'egrep "listen_port|amqp_"'
-                    ' /etc/barometer-localagent/config.toml'
+                    ' /etc/barometer-dma/config.toml'
                     '| sed -e "s/#.*$//" | sed -e "s/=/:/"'
                     )
                 stdout = node.run_cmd(readcmd)
-                agent_conf = {"server": yaml.load(stdout)}
+                agent_conf = {"server": yaml.safe_load(stdout)}
 
                 pingcmd = (
                     'ping -n -c1 ' + agent_conf["server"]["amqp_host"] +
@@ -753,8 +758,8 @@ class ConfigServer(object):
         else:
             return False
 
-    def check_localagent_dummy_included(self, compute, name):
-        """Check if dummy collectd config by LocalAgent
+    def check_dma_dummy_included(self, compute, name):
+        """Check if dummy collectd config by DMA
            is included in collectd.conf file.
 
         Keyword arguments:
@@ -793,18 +798,13 @@ class ConfigServer(object):
         self.__logger.debug('Create command is executed in {}' .format(
             (controller_node.get_dict()['name'])))
 
-        image_filename = 'cirros-0.4.0-x86_64-disk.img'
-        controller_node.run_cmd(
-            'curl -sO '
-            'http://download.cirros-cloud.net/0.4.0/'
-            + image_filename)
-
         node.put_file(constants.ENV_FILE, 'overcloudrc.v3')
+        node.put_file(TEST_VM_IMAGE_PATH, TEST_VM_IMAGE)
         image = controller_node.run_cmd(
             'source overcloudrc.v3;'
             'openstack image create -f value -c id'
             ' --disk-format qcow2 --file {0} {1}'
-            .format(image_filename, test_name))
+            .format(TEST_VM_IMAGE, test_name))
         flavor = controller_node.run_cmd(
             'source overcloudrc.v3;'
             'openstack flavor create -f value -c id {}'
@@ -860,13 +860,13 @@ class ConfigServer(object):
 
         self.__logger.debug('VM and other OpenStack resources deleted')
 
-    def test_localagent_infofetch_get_data(self, compute, test_name):
+    def test_dma_infofetch_get_data(self, compute, test_name):
         compute_name = compute.get_name()
         nodes = get_apex_nodes()
         for node in nodes:
             if compute_name == node.get_dict()['name']:
                 stdout = node.run_cmd(
-                    'redis-cli keys "barometer-localagent/vm/*/vminfo"'
+                    'redis-cli keys "barometer-dma/vm/*/vminfo"'
                     ' | while read k; do redis-cli get $k; done'
                     ' | grep {}'.format(test_name))
                 self.__logger.debug('InfoFetch data: {}'.format(stdout))