def gather_sosreport_from_node(node: Node, destination_dir: str): try: node.upload_file(SOSREPORT_SCRIPT, "/tmp/man_sosreport.sh") node.run_command("chmod a+x /tmp/man_sosreport.sh") node.run_command("sudo /tmp/man_sosreport.sh") node.download_file( "/tmp/sosreport.tar.bz2", os.path.join(destination_dir, f"sosreport-{node.name}.tar.bz2")) except (TimeoutError, RuntimeError, SSHException, SCPException): log.exception("Failed accessing node %s for sosreport data gathering", node)
def list_nodes_with_name_filter(self, name_filter) -> List[Node]: log.info("Listing current hosts with name filter %s", name_filter) nodes = list() domains = self.libvirt_connection.listAllDomains() for domain in domains: domain_name = domain.name() if name_filter and name_filter not in domain_name: continue if (consts.NodeRoles.MASTER in domain_name) or (consts.NodeRoles.WORKER in domain_name): nodes.append(Node(domain_name, self, self.private_ssh_key_path)) log.info("Found domains %s", [node.name for node in nodes]) return nodes
def vsphere_vm_to_node(terraform_vm_state): return Node( name=terraform_vm_state["attributes"]["name"], private_ssh_key_path=self._config.private_ssh_key_path, node_controller=self, )