+ @staticmethod
+ def load_docker_image_on_node(node, image_path):
+ """Load Docker container image from file on node.
+
+ :param node: DUT node.
+ :param image_path: Container image path.
+ :type node: dict
+ :type image_path: str
+ :raises RuntimeError: If loading image failed on node.
+ """
+ command = 'docker load -i {image_path}'.\
+ format(image_path=image_path)
+ message = 'Failed to load Docker image on {node}.'.\
+ format(node=node['host'])
+ exec_cmd_no_error(node, command, timeout=240, sudo=True,
+ message=message)
+
+ command = "docker rmi $(sudo docker images -f 'dangling=true' -q)".\
+ format(image_path=image_path)
+ message = 'Failed to clean Docker images on {node}.'.\
+ format(node=node['host'])
+ try:
+ exec_cmd_no_error(node, command, timeout=240, sudo=True,
+ message=message)
+ except RuntimeError:
+ pass
+
+ @staticmethod
+ def load_docker_image_on_all_duts(nodes, image_path):
+ """Load Docker container image from file on all DUTs.
+
+ :param nodes: Topology nodes.
+ :param image_path: Container image path.
+ :type nodes: dict
+ :type image_path: str
+ """
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ KubernetesUtils.load_docker_image_on_node(node, image_path)
+