for a, d in self.args_dict.items():
if 'req' in d and d['req'] == "false" and a not in cmd_dict:
continue
- if kwargs_switch or (isinstance(cmd_dict[a], str) and '=' in cmd_dict[a]):
- mgr.log.debug('found kwarg, assuming all following args are kw style')
- kwargs_switch = True
+
+ if isinstance(cmd_dict[a], str) and '=' in cmd_dict[a]:
+ k, arg = cmd_dict[a].split('=', 1)
+ if k in self.args_dict:
+ kwargs_switch = True
+
+ if kwargs_switch:
try:
- k, arg = cmd_dict[a].split('=')
+ k, arg = cmd_dict[a].split('=', 1)
except ValueError as e:
mgr.log.error('found positional arg after switching to kwarg parsing')
return -errno.EINVAL, '', 'Error EINVAL: postitional arg not allowed after kwarg'
from ceph.deployment.service_spec import ServiceSpec
from ceph.deployment import inventory
+from mgr_module import HandleCommandResult
from test_orchestrator import TestOrchestrator as _TestOrchestrator
from tests import mock
from orchestrator import raise_if_exception, Completion, ProgressReference
from orchestrator import InventoryHost, DaemonDescription, ServiceDescription
from orchestrator import OrchestratorValidationError
-from orchestrator.module import to_format
+from orchestrator.module import to_format, OrchestratorCli
def _test_resource(data, resource_class, extra=None):
e = OrchestratorEvent(datetime.datetime.utcnow(), 'service',
'subject', 'ERROR', 'multiline\nmessage')
assert OrchestratorEvent.from_json(e.to_json()) == e
+
+
+def test_handle_command():
+ cmd = {
+ 'prefix': 'orch daemon add',
+ 'daemon_type': 'mon',
+ 'placement': 'smithi044:[v2:172.21.15.44:3301,v1:172.21.15.44:6790]=c',
+ }
+ m = OrchestratorCli('orchestrator', 0, 0)
+ r = m._handle_command(None, cmd)
+ assert r == HandleCommandResult(
+ retval=-2, stdout='', stderr='No orchestrator configured (try `ceph orch set backend`)')