+
+ @staticmethod
+ def get_service_logs(node, service):
+ """Get specific service unit logs by journalctl from node.
+
+ :param node: Node in the topology.
+ :param service: Service unit name.
+ :type node: dict
+ :type service: str
+ """
+ ssh = SSH()
+ ssh.connect(node)
+ ret_code, _, _ = \
+ ssh.exec_command_sudo('journalctl --no-pager --unit={name} '
+ '--since="$(echo `systemctl show -p '
+ 'ActiveEnterTimestamp {name}` | '
+ 'awk \'{{print $2 $3}}\')"'.
+ format(name=service))
+ if int(ret_code) != 0:
+ raise RuntimeError('DUT {host} failed to get logs from unit {name}'.
+ format(host=node['host'], name=service))
+
+ @staticmethod
+ def get_service_logs_on_all_duts(nodes, service):
+ """Get specific service unit logs by journalctl from all DUTs.
+
+ :param nodes: Nodes in the topology.
+ :param service: Service unit name.
+ :type nodes: dict
+ :type service: str
+ """
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ DUTSetup.get_service_logs(node, service)
+
+ @staticmethod
+ def start_service(node, service):
+ """Start up the named service on node.
+
+ :param node: Node in the topology.
+ :param service: Service unit name.
+ :type node: dict
+ :type service: str
+ """
+ ssh = SSH()
+ ssh.connect(node)
+ # We are doing restart. With this we do not care if service
+ # was running or not.
+ ret_code, _, _ = \
+ ssh.exec_command_sudo('service {name} restart'.
+ format(name=service), timeout=120)
+ if int(ret_code) != 0:
+ raise RuntimeError('DUT {host} failed to start service {name}'.
+ format(host=node['host'], name=service))
+
+ DUTSetup.get_service_logs(node, service)
+