csit-validate-pylint-master/3731 for build 3731 04/6504/5
authorjan.hradil <jan.hradil@pantheon.tech>
Thu, 27 Apr 2017 12:47:16 +0000 (14:47 +0200)
committerTibor Frank <tifrank@cisco.com>
Tue, 2 May 2017 06:24:18 +0000 (06:24 +0000)
pylint repairs
deleted duplicated method from HcPersistence.py

Change-Id: I426e6c15957c995ea10bd11ae2deac75b1cab922
Signed-off-by: jan.hradil <jan.hradil@pantheon.tech>
resources/libraries/python/QemuUtils.py
resources/libraries/python/VatHistory.py
resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
resources/libraries/python/honeycomb/HcPersistence.py
resources/libraries/python/honeycomb/HoneycombSetup.py
resources/libraries/python/honeycomb/proxyARP.py
resources/libraries/python/parsers/JsonParser.py
resources/libraries/python/ssh.py

index 1664b0b..eeca320 100644 (file)
@@ -592,6 +592,11 @@ class QemuUtils(object):
         self._ssh.exec_command_sudo(cmd)
 
     def qemu_kill_all(self, node=None):
+        """Kill all qemu processes on DUT node if specified.
+
+        :param node: Node to kill all QEMU processes on.
+        :type node: dict
+        """
         if node:
             self.qemu_set_node(node)
         self._ssh.exec_command_sudo('pkill -SIGKILL qemu')
index e46a737..e273746 100644 (file)
@@ -17,10 +17,15 @@ from robot.api import logger
 
 from resources.libraries.python.topology import NodeType, DICT__nodes
 
-__all__ = ["DICT__duts_vat_history", "VatHistory"]
+__all__ = ["DICT__DUTS_VAT_HISTORY", "VatHistory"]
 
 
 def setup_vat_history(nodes):
+    """Setup VAT history for DUT nodes.
+
+    :param nodes: DUT nodes to setup VAT history for.
+    :type nodes: dict
+    """
     duts_vat_history = {}
     try:
         for node in nodes.values():
@@ -31,7 +36,7 @@ def setup_vat_history(nodes):
         # Necessary for the generation of source code documentation.
         pass
 
-DICT__duts_vat_history = setup_vat_history(DICT__nodes)
+DICT__DUTS_VAT_HISTORY = setup_vat_history(DICT__nodes)
 
 
 class VatHistory(object):
@@ -45,7 +50,7 @@ class VatHistory(object):
         :type node: dict
         """
         if node['type'] == NodeType.DUT:
-            DICT__duts_vat_history[node['host']] = []
+            DICT__DUTS_VAT_HISTORY[node['host']] = []
 
     @staticmethod
     def reset_vat_history_on_all_duts(nodes):
@@ -67,9 +72,9 @@ class VatHistory(object):
         """
         if node['type'] == NodeType.DUT:
             sequence = "\nno VAT command executed"\
-                if len(DICT__duts_vat_history[node['host']]) == 0\
+                if len(DICT__DUTS_VAT_HISTORY[node['host']]) == 0\
                 else "".join("\n{}".format(cmd)
-                             for cmd in DICT__duts_vat_history[node['host']])
+                             for cmd in DICT__DUTS_VAT_HISTORY[node['host']])
             logger.trace("{0} VAT command history:{1}\n".
                          format(node['host'], sequence))
 
@@ -94,4 +99,4 @@ class VatHistory(object):
         :type cmd: str
         """
         if node['type'] == NodeType.DUT:
-            DICT__duts_vat_history[node['host']].append(cmd)
+            DICT__DUTS_VAT_HISTORY[node['host']].append(cmd)
index d57f939..dc24858 100644 (file)
@@ -1531,10 +1531,10 @@ class InterfaceKeywords(object):
         interface = interface.replace("/", "%2F")
 
         data = {
-                    "interface-policer:policer": {
-                        "ip4-table": table_name
-                    }
+            "interface-policer:policer": {
+                "ip4-table": table_name
                 }
+            }
 
         path = "/interface/" + interface + "/interface-policer:policer"
         status_code, resp = HcUtil.\
@@ -1725,7 +1725,7 @@ class InterfaceKeywords(object):
             for src_interface in src_interfaces:
                 src_interface["iface-ref"] = Topology.\
                     convert_interface_reference(
-                    node, src_interface["iface-ref"], "name")
+                        node, src_interface["iface-ref"], "name")
             data = {
                 "span": {
                     "mirrored-interfaces": {
index dae84bd..e1b827f 100644 (file)
@@ -100,9 +100,7 @@ class HcPersistence(object):
         ssh = SSH()
         ssh.connect(node)
         for command in commands:
-            (_, stdout, _) = ssh.exec_command_sudo(command)
-            logger.info(stdout)
-
+            (_, _, _) = ssh.exec_command_sudo(command)
 
     @staticmethod
     def configure_persistence(node, state):
@@ -142,19 +140,3 @@ class HcPersistence(object):
             if ret_code != 0:
                 raise HoneycombError("Failed to modify configuration on "
                                      "node {0}, {1}".format(node, stderr))
-
-    @staticmethod
-    def log_persisted_configuration(node):
-        """Read contents of Honeycomb persistence files and print to Robot log.
-
-        :param node: Honeycomb node.
-        :type node: dict
-        """
-
-        command = "cat /var/lib/honeycomb/persist/{0}/data.json"
-
-        ssh = SSH()
-        ssh.connect(node)
-
-        ssh.exec_command_sudo(command.format("config"))
-        ssh.exec_command_sudo(command.format("context"))
index 871ade6..551d44b 100644 (file)
@@ -400,7 +400,7 @@ class HoneycombSetup(object):
                 Const.REMOTE_HC_DIR, artifact_id, version)
             cmd = "sudo mkdir -p {0}; " \
                   "sudo cp /usr/share/java/{1} {0}/{2}-{3}.jar".format(
-                    directory, item, artifact_id, version)
+                      directory, item, artifact_id, version)
 
             (ret_code, _, stderr) = ssh.exec_command(cmd)
             if ret_code != 0:
index c9d9040..9696bf4 100644 (file)
@@ -122,11 +122,11 @@ class ProxyARPKeywords(object):
         path = "/interface/{0}/proxy-arp".format(interface)
 
         if state == "disable":
-            status_code, resp = HcUtil.delete_honeycomb_data(
+            status_code, _ = HcUtil.delete_honeycomb_data(
                 node, "config_vpp_interfaces", path)
         elif state == "enable":
             data = {"proxy-arp": {}}
-            status_code, resp = HcUtil.put_honeycomb_data(
+            status_code, _ = HcUtil.put_honeycomb_data(
                 node, "config_vpp_interfaces", data, path)
         else:
             raise ValueError("State argument has to be enable or disable.")
index ad6e189..0e78679 100644 (file)
@@ -44,7 +44,7 @@ class JsonParser(object):
                             "lisp_map_resolver_dump error: Misc",
                             "show_lisp_pitr error: Misc",
                             "snat_static_mapping_dump error: Misc",
-                            ]
+                           ]
             for item in known_errors:
                 if item in json_data:
                     json_data = json_data.replace(item, "")
index 0009bde..f59bd02 100644 (file)
@@ -90,7 +90,8 @@ class SSH(object):
 
             logger.debug('Connect peer: {0}'.
                          format(self._ssh.get_transport().getpeername()))
-            logger.debug('Connections: {0}'.format(str(SSH.__existing_connections)))
+            logger.debug('Connections: {0}'.
+                         format(str(SSH.__existing_connections)))
         except:
             if attempts > 0:
                 self._reconnect(attempts-1)
@@ -271,8 +272,8 @@ class SSH(object):
             except socket.timeout:
                 raise Exception('Socket timeout: {0}'.format(buf))
         tmp = buf.replace(cmd.replace('\n', ''), '')
-        for p in prompt:
-            tmp.replace(p, '')
+        for item in prompt:
+            tmp.replace(item, '')
         return tmp
 
     @staticmethod