def test_nfs_rm(self):
self._orch_cmd("nfs", "rm", "service_name")
+
+ def test_host_ls(self):
+ out = self._orch_cmd("host", "ls")
+ self.assertEqual(out, "localhost\n")
+
+ def test_host_add(self):
+ self._orch_cmd("host", "add", "hostname")
+
+ def test_host_rm(self):
+ self._orch_cmd("host", "rm", "hostname")
+
+ def test_mon_update(self):
+ self._orch_cmd("mon", "update", "3")
+ self._orch_cmd("mon", "update", "3", "host1", "host2", "host3")
+ self._orch_cmd("mon", "update", "3", "host1:network", "host2:network", "host3:network")
+
+ def test_mgr_update(self):
+ self._orch_cmd("mgr", "update", "3")
raise NotImplementedError()
def update_mons(self, num, hosts):
- # type: (int, List[List[str,str]]) -> WriteCompletion
+ # type: (int, List[Tuple[str,str]]) -> WriteCompletion
"""
Update the number of cluster monitors.
:param num: requested number of monitors.
- :param hosts: list of hosts (optional)
+ :param hosts: list of hosts + network (optional)
"""
raise NotImplementedError()
InventoryNode.
"""
def __init__(self, name, devices):
+ # type: (str, List[InventoryDevice]) -> None
assert isinstance(devices, list)
self.name = name # unique within cluster. For example a hostname.
- self.devices = devices # type: List[InventoryDevice]
+ self.devices = devices
def to_json(self):
return {'name': self.name, 'devices': [d.to_json() for d in self.devices]}
def _add_host(self, host):
completion = self.add_host(host)
self._orchestrator_wait([completion])
- result = "\n".join(map(lambda r: str(r), completion.result))
- return HandleCommandResult(stdout=result)
+ return HandleCommandResult(stdout=str(completion.result))
@CLIWriteCommand('orchestrator host rm',
"name=host,type=CephString,req=true",
def _remove_host(self, host):
completion = self.remove_host(host)
self._orchestrator_wait([completion])
- result = "\n".join(map(lambda r: str(r), completion.result))
- return HandleCommandResult(stdout=result)
+ return HandleCommandResult(stdout=str(completion.result))
@CLIReadCommand('orchestrator host ls',
desc='List hosts')
"name=hosts,type=CephString,n=N,req=false",
'Update the number of manager instances')
@handle_exceptions
- def _update_mgrs(self, num, hosts):
+ def _update_mgrs(self, num, hosts=None):
hosts = hosts if hosts is not None else []
if num <= 0:
completion = self.update_mgrs(num, hosts)
self._orchestrator_wait([completion])
- result = "\n".join(map(lambda r: str(r), completion.result))
- return HandleCommandResult(stdout=result)
+ return HandleCommandResult(stdout=str(completion.result))
@CLIWriteCommand('orchestrator mon update',
"name=num,type=CephInt,req=true "
"name=hosts,type=CephString,n=N,req=false",
'Update the number of monitor instances')
@handle_exceptions
- def _update_mons(self, num, hosts):
+ def _update_mons(self, num, hosts=None):
hosts = hosts if hosts is not None else []
if num <= 0:
completion = self.update_mons(num, hosts)
self._orchestrator_wait([completion])
- result = "\n".join(map(lambda r: str(r), completion.result))
- return HandleCommandResult(stdout=result)
+ return HandleCommandResult(stdout=str(completion.result))
@CLIWriteCommand('orchestrator set backend',
"name=module_name,type=CephString,req=true",
The implementation is similar to the Rook orchestrator, but simpler.
"""
-
def _progress(self, *args, **kwargs):
try:
self.remote("progress", *args, **kwargs)
@deferred_write("remove_stateless_service")
def remove_stateless_service(self, service_type, id_):
pass
+
+ @deferred_read
+ def get_hosts(self):
+ return [orchestrator.InventoryNode('localhost', [])]
+
+ @deferred_write("add_host")
+ def add_host(self, host):
+ assert isinstance(host, str)
+
+ @deferred_write("remove_host")
+ def remove_host(self, host):
+ assert isinstance(host, str)
+
+ @deferred_write("update_mgrs")
+ def update_mgrs(self, num, hosts):
+ assert not hosts or len(hosts) == num
+ assert all([isinstance(h, str) for h in hosts])
+
+ @deferred_write("update_mons")
+ def update_mons(self, num, hosts):
+ assert not hosts or len(hosts) == num
+ assert all([isinstance(h[0], str) for h in hosts])
+ assert all([isinstance(h[1], str) or h[1] is None for h in hosts])