]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orchestrator_cli: rgw add: optionally take count and node names
authorSage Weil <sage@redhat.com>
Thu, 31 Oct 2019 16:15:20 +0000 (11:15 -0500)
committerSage Weil <sage@redhat.com>
Tue, 5 Nov 2019 14:46:00 +0000 (08:46 -0600)
This avoids the need for JSON in the common case.

Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/orchestrator.py
src/pybind/mgr/orchestrator_cli/module.py

index c7e3e69d5629b8d332ba8d6c4579cfd7fd98c2ee..d27ca55ad4f15cbc02ed5752aa33a5cb97e40be5 100644 (file)
@@ -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
index d4c58bcb75dd5d4a68122463e020c4cfe57c4361..982fdcfd8d0f3f33895929970955904291c6a5bf 100644 (file)
@@ -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 <rgw_spec> 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 <json_file>
@@ -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)