X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2Fhoneycomb%2FHoneycombSetup.py;h=04af9a5a8b66535530f11d00ce420a1c1f2ce85a;hp=1c232f08a5f390c644af39225dba634f171a8f32;hb=bff480ceb6e7dd9f624f3c8e39f7d7ece1f9248e;hpb=313dd6b6a2eac04a6dd686a1407e35ac2424913f diff --git a/resources/libraries/python/honeycomb/HoneycombSetup.py b/resources/libraries/python/honeycomb/HoneycombSetup.py index 1c232f08a5..04af9a5a8b 100644 --- a/resources/libraries/python/honeycomb/HoneycombSetup.py +++ b/resources/libraries/python/honeycomb/HoneycombSetup.py @@ -53,6 +53,9 @@ class HoneycombSetup(object): :type nodes: list :raises HoneycombError: If Honeycomb fails to start. """ + + HoneycombSetup.print_environment(nodes) + logger.console("\nStarting Honeycomb service ...") cmd = "{0}/bin/start".format(Const.REMOTE_HC_DIR) @@ -123,6 +126,7 @@ class HoneycombSetup(object): for node in nodes: if node['type'] == NodeType.DUT: + HoneycombSetup.print_ports(node) status_code, _ = HTTPRequest.get(node, path, timeout=10, enable_logging=False) if status_code == HTTPCodes.OK: @@ -185,3 +189,53 @@ class HoneycombSetup(object): logger.info("Honeycomb on node {0} has stopped". format(node['host'])) return True + + @staticmethod + def print_environment(nodes): + """Print information about the nodes to log. The information is defined + by commands in cmds tuple at the beginning of this method. + + :param nodes: List of DUT nodes to get information about. + :type nodes: list + """ + + # TODO: When everything is set and running in VIRL env, transform this + # method to a keyword checking the environment. + + cmds = ("uname -a", + "df -lh", + "echo $JAVA_HOME", + "echo $PATH", + "which java", + "java -version", + "dpkg --list | grep openjdk", + "ls -la /opt/honeycomb", + "ls -la /opt/honeycomb/v3po-karaf-1.0.0-SNAPSHOT") + + for node in nodes: + if node['type'] == NodeType.DUT: + logger.info("Checking node {} ...".format(node['host'])) + for cmd in cmds: + logger.info("Command: {}".format(cmd)) + ssh = SSH() + ssh.connect(node) + ssh.exec_command_sudo(cmd) + + @staticmethod + def print_ports(node): + """Uses "sudo netstat -anp | grep java" to print port where a java + application listens. + + :param node: Honeycomb node where we want to print the ports. + :type node: dict + """ + + cmds = ("netstat -anp | grep java", + "ps -ef | grep karaf") + + logger.info("Checking node {} ...".format(node['host'])) + for cmd in cmds: + logger.info("Command: {}".format(cmd)) + ssh = SSH() + ssh.connect(node) + ssh.exec_command_sudo(cmd)