X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2Fhoneycomb%2FHoneycombSetup.py;h=32992c03defa3af0d0e1a6ebeca450e51890eb9f;hp=13b8b971b6d36efb69392e91435242b02bb62790;hb=dc0288317e241f6cb18b0978993a1e2f396c793c;hpb=d32194f3afb0ec725d178effe6ae589571287602 diff --git a/resources/libraries/python/honeycomb/HoneycombSetup.py b/resources/libraries/python/honeycomb/HoneycombSetup.py index 13b8b971b6..32992c03de 100644 --- a/resources/libraries/python/honeycomb/HoneycombSetup.py +++ b/resources/libraries/python/honeycomb/HoneycombSetup.py @@ -163,7 +163,11 @@ class HoneycombSetup(object): except HTTPRequestError: ssh = SSH() ssh.connect(node) - ssh.exec_command("tail -n 100 /var/log/syslog") + ret_code, _, _ = ssh.exec_command_sudo( + "tail -n 100 /var/log/syslog") + if ret_code != 0: + # It's probably Centos + ssh.exec_command_sudo("tail -n 100 /var/log/messages") raise if status_code == HTTPCodes.OK: logger.info("Honeycomb on node {0} is up and running". @@ -251,7 +255,7 @@ class HoneycombSetup(object): replace = '\\"restconf-binding-address\\": \\"0.0.0.0\\",' argument = '"/{0}/c\\ {1}"'.format(find, replace) - path = "{0}/config/honeycomb.json".format(Const.REMOTE_HC_DIR) + path = "{0}/config/restconf.json".format(Const.REMOTE_HC_DIR) command = "sed -i {0} {1}".format(argument, path) ssh = SSH() @@ -460,7 +464,7 @@ class HoneycombSetup(object): cmd = "cp -r {src}/*karaf_{odl_name}* {dst}".format( src=src_path, odl_name=odl_name, dst=dst_path) - ret_code, _, _ = ssh.exec_command(cmd, timeout=30) + ret_code, _, _ = ssh.exec_command(cmd, timeout=60) if int(ret_code) != 0: raise HoneycombError( "Failed to copy ODL client on node {0}".format(node["host"])) @@ -553,6 +557,35 @@ class HoneycombSetup(object): format(status_code)) return True + @staticmethod + def check_odl_shutdown_state(node): + """Check the status of ODL client shutdown. + + :param node: Honeycomb node. + :type node: dict + :returns: True when ODL is stopped. + :rtype: bool + :raises HoneycombError: When the response is not code 200: OK. + """ + + cmd = "pgrep -f karaf" + path = HcUtil.read_path_from_url_file( + "odl_client/odl_netconf_connector") + + try: + status_code, _ = HTTPRequest.get(node, path, timeout=10, + enable_logging=False) + raise HoneycombError("ODL client is still running.") + except HTTPRequestError: + logger.debug("Connection refused, checking process state....") + ssh = SSH() + ssh.connect(node) + ret_code, _, _ = ssh.exec_command(cmd) + if ret_code == 0: + raise HoneycombError("ODL client is still running.") + + return True + @staticmethod def mount_honeycomb_on_odl(node): """Tell ODL client to mount Honeycomb instance over netconf. @@ -602,7 +635,7 @@ class HoneycombSetup(object): ssh.connect(node) ret_code, _, _ = ssh.exec_command_sudo(cmd) if int(ret_code) != 0: - logger.warn("ODL Client refused to shut down.") + logger.debug("ODL Client refused to shut down.") cmd = "pkill -f 'karaf'" (ret_code, _, _) = ssh.exec_command_sudo(cmd) if int(ret_code) != 0: @@ -625,9 +658,7 @@ class HoneycombSetup(object): cmd = "service vpp stop" ret_code, _, _ = ssh.exec_command_sudo(cmd, timeout=80) if int(ret_code) != 0: - raise RuntimeError("Could not stop VPP service on node {0}".format( - node['host'])) - + logger.debug("VPP service refused to shut down.") class HoneycombStartupConfig(object): """Generator for Honeycomb startup configuration.