aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/KubernetesUtils.py34
-rw-r--r--resources/tools/scripts/topo_container_copy.py9
2 files changed, 40 insertions, 3 deletions
diff --git a/resources/libraries/python/KubernetesUtils.py b/resources/libraries/python/KubernetesUtils.py
index 5faa056ddc..77628b64d8 100644
--- a/resources/libraries/python/KubernetesUtils.py
+++ b/resources/libraries/python/KubernetesUtils.py
@@ -244,6 +244,36 @@ class KubernetesUtils(object):
rtype)
@staticmethod
+ def get_kubernetes_logs_on_node(node, namespace='csit'):
+ """Get Kubernetes logs on node.
+
+ :param node: DUT node.
+ :param namespace: Kubernetes namespace.
+ :type node: dict
+ :type namespace: str
+ """
+ ssh = SSH()
+ ssh.connect(node)
+
+ cmd = "for p in $(kubectl get pods -n {namespace} --no-headers"\
+ " | cut -f 1 -d ' '); do echo $p; kubectl logs -n {namespace} $p; "\
+ "done".format(namespace=namespace)
+ ssh.exec_command(cmd, timeout=120)
+
+ @staticmethod
+ def get_kubernetes_logs_on_all_duts(nodes, namespace='csit'):
+ """Get Kubernetes logs on all DUTs.
+
+ :param nodes: Topology nodes.
+ :param namespace: Kubernetes namespace.
+ :type nodes: dict
+ :type namespace: str
+ """
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ KubernetesUtils.get_kubernetes_logs_on_node(node, namespace)
+
+ @staticmethod
def reset_kubernetes_on_node(node):
"""Reset Kubernetes on node.
@@ -288,7 +318,9 @@ class KubernetesUtils(object):
if int(ret_code) == 0:
ready = True
for line in stdout.splitlines():
- if 'Running' not in line:
+ if 'Running' in line and '1/1' in line:
+ ready = True
+ else:
ready = False
if ready:
break
diff --git a/resources/tools/scripts/topo_container_copy.py b/resources/tools/scripts/topo_container_copy.py
index d243182236..088b7a4386 100644
--- a/resources/tools/scripts/topo_container_copy.py
+++ b/resources/tools/scripts/topo_container_copy.py
@@ -122,11 +122,16 @@ def main():
ssh.scp(local_path=image, remote_path=directory)
# Load image to Docker.
- cmd = "for f in {directory}/*.tar.gz; do zcat $f | "\
- "sudo docker load; done".format(directory=directory)
+ cmd = "for f in {directory}/*.tar.gz; do "\
+ "sudo docker load -i $f; done".format(directory=directory)
stdout = ssh_no_error(ssh, cmd)
print("###TI {}".format(stdout))
+ # Remove <none> images from Docker.
+ cmd = "docker rmi $(sudo docker images -f 'dangling=true' -q)"
+ stdout = ssh_no_error(ssh, cmd, sudo=True)
+ print("###TI {}".format(stdout))
+
if __name__ == "__main__":
sys.exit(main())