[WIP] Add tool to list cloud nodes processes
Change-Id: I6e482fc7d74f80d4045416e6730ef606f5ae1c1a
This commit is contained in:
parent
9a2a8f5e0f
commit
74a370b7f0
|
@ -17,6 +17,7 @@ from tobiko.openstack.topology import _assert
|
|||
from tobiko.openstack.topology import _exception
|
||||
from tobiko.openstack.topology import _neutron
|
||||
from tobiko.openstack.topology import _topology
|
||||
from tobiko.openstack.topology import _sh
|
||||
|
||||
assert_reachable_nodes = _assert.assert_reachable_nodes
|
||||
assert_unreachable_nodes = _assert.assert_unreachable_nodes
|
||||
|
@ -24,6 +25,8 @@ assert_unreachable_nodes = _assert.assert_unreachable_nodes
|
|||
NoSuchOpenStackTopologyNodeGroup = _exception.NoSuchOpenStackTopologyNodeGroup
|
||||
NoSuchOpenStackTopologyNode = _exception.NoSuchOpenStackTopologyNode
|
||||
|
||||
list_hosts_processes = _sh.list_hosts_processes
|
||||
|
||||
UnknowOpenStackContainerNameError = _topology.UnknowOpenStackContainerNameError
|
||||
UnknowOpenStackServiceNameError = _topology.UnknowOpenStackServiceNameError
|
||||
get_agent_service_name = _topology.get_agent_service_name
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
|
||||
import typing
|
||||
|
||||
import tobiko
|
||||
from tobiko.openstack.topology import _topology
|
||||
from tobiko.shell import sh
|
||||
|
||||
|
||||
def list_hosts_processes(hostnames: typing.Iterable[str],
|
||||
command: str,
|
||||
command_line: str,
|
||||
**list_processes_params) \
|
||||
-> tobiko.Selection[sh.PsProcess]:
|
||||
processes = tobiko.Selection[sh.PsProcess]()
|
||||
for hostname in sorted(frozenset(hostnames)):
|
||||
node = _topology.get_openstack_node(hostname=hostname)
|
||||
processes += sh.list_processes(command=command,
|
||||
command_line=command_line,
|
||||
ssh_client=node.ssh_client,
|
||||
**list_processes_params)
|
||||
return processes
|
|
@ -43,7 +43,7 @@ class OpenStackTopologyTest(testtools.TestCase):
|
|||
def test_ssh_client(self):
|
||||
for node in self.topology.nodes:
|
||||
self.assertIsNotNone(node.ssh_client)
|
||||
hostname = sh.get_hostname(
|
||||
hostname = sh.ssh_hostname(
|
||||
ssh_client=node.ssh_client).split('.')[0]
|
||||
self.assertEqual(node.name, hostname)
|
||||
|
||||
|
|
Loading…
Reference in New Issue