From 47c5d3c8b6ecda2172da0d864469aa94d29972b7 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 31 Oct 2019 11:15:20 -0500 Subject: [PATCH] mgr/orchestrator_cli: rgw add: optionally take count and node names This avoids the need for JSON in the common case. Signed-off-by: Sage Weil --- src/pybind/mgr/orchestrator.py | 7 +++++-- src/pybind/mgr/orchestrator_cli/module.py | 11 ++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index c7e3e69d562..d27ca55ad4f 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -717,6 +717,7 @@ class RGWSpec(StatelessServiceSpec): """ def __init__(self, rgw_zone, # type: str + placement=None, hosts=None, # type: Optional[List[str]] rgw_multisite=None, # type: Optional[bool] rgw_zonemaster=None, # type: Optional[bool] @@ -734,10 +735,12 @@ class RGWSpec(StatelessServiceSpec): # default values that makes sense for Ansible. Rook has default values implemented # in Rook itself. Thus we don't set any defaults here in this class. - super(RGWSpec, self).__init__(name=rgw_zone, count=count) + super(RGWSpec, self).__init__(name=rgw_zone, count=count, + placement=placement) #: List of hosts where RGWs should run. Not for Rook. - self.hosts = hosts + if hosts: + self.placement.hosts = hosts #: is multisite self.rgw_multisite = rgw_multisite diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index d4c58bcb75d..982fdcfd8d0 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -267,10 +267,12 @@ Usage: return HandleCommandResult(stdout=completion.result_str()) @_write_cli('orchestrator rgw add', - 'name=zone_name,type=CephString,req=false', + 'name=zone_name,type=CephString,req=false ' + 'name=num,type=CephInt,req=false ' + "name=hosts,type=CephString,n=N,req=false", 'Create an RGW service. A complete can be provided'\ ' using <-i> to customize completelly the RGW service') - def _rgw_add(self, zone_name=None, inbuf=None): + def _rgw_add(self, zone_name, num, hosts, inbuf=None): usage = """ Usage: ceph orchestrator rgw add -i @@ -284,7 +286,10 @@ Usage: msg = 'Failed to read JSON input: {}'.format(str(e)) + usage return HandleCommandResult(-errno.EINVAL, stderr=msg) elif zone_name: - rgw_spec = orchestrator.RGWSpec(rgw_zone=zone_name) + rgw_spec = orchestrator.RGWSpec( + rgw_zone=zone_name, + placement=orchestrator.PlacementSpec(nodes=hosts), + count=num or 1) else: return HandleCommandResult(-errno.EINVAL, stderr=usage) -- 2.39.5