]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orchestrator: name rgw by client.rgw.$realm.$zone[.$id] 31890/head
authorSage Weil <sage@redhat.com>
Tue, 26 Nov 2019 16:26:25 +0000 (10:26 -0600)
committerSage Weil <sage@redhat.com>
Tue, 26 Nov 2019 16:26:25 +0000 (10:26 -0600)
Specify both the realm and zone when provisioning rgws.

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

index 1bdc7fec178064652b33058883b742625589d902..9b6452d216d9fd34b346a02e22794561de987b6c 100644 (file)
@@ -851,6 +851,7 @@ class RGWSpec(StatelessServiceSpec):
 
     """
     def __init__(self,
+                 rgw_realm, # type: str
                  rgw_zone,  # type: str
                  placement=None,
                  hosts=None,  # type: Optional[List[str]]
@@ -861,7 +862,6 @@ class RGWSpec(StatelessServiceSpec):
                  rgw_frontend_port=None,  # type: Optional[int]
                  rgw_zonegroup=None,  # type: Optional[str]
                  rgw_zone_user=None,  # type: Optional[str]
-                 rgw_realm=None,  # type: Optional[str]
                  system_access_key=None,  # type: Optional[str]
                  system_secret_key=None,  # type: Optional[str]
                  count=None  # type: Optional[int]
@@ -870,7 +870,8 @@ 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_realm + '.' + rgw_zone,
+                                      count=count,
                                       placement=placement)
 
         #: List of hosts where RGWs should run. Not for Rook.
@@ -884,9 +885,10 @@ class RGWSpec(StatelessServiceSpec):
         self.rgw_multisite_proto = rgw_multisite_proto
         self.rgw_frontend_port = rgw_frontend_port
 
+        self.rgw_realm = rgw_realm
+        self.rgw_zone = rgw_zone
         self.rgw_zonegroup = rgw_zonegroup
         self.rgw_zone_user = rgw_zone_user
-        self.rgw_realm = rgw_realm
 
         self.system_access_key = system_access_key
         self.system_secret_key = system_secret_key
index cf4734118c3b4a7d4792892764acdb81d33615e5..18519f76e5be66853a5e32149d0f231fcae9873f 100644 (file)
@@ -426,31 +426,29 @@ Usage:
 
     @orchestrator._cli_write_command(
         'orchestrator rgw add',
-        'name=zone_name,type=CephString,req=false '
+        'name=realm_name,type=CephString '
+        'name=zone_name,type=CephString '
         '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, num, hosts, inbuf=None):
+    def _rgw_add(self, realm_name, zone_name, num=1, hosts=None, inbuf=None):
         usage = """
 Usage:
   ceph orchestrator rgw add -i <json_file>
-  ceph orchestrator rgw add <zone_name>
+  ceph orchestrator rgw add <realm_name> <zone_name>
         """
-
         if inbuf:
             try:
                 rgw_spec = orchestrator.RGWSpec.from_json(json.loads(inbuf))
             except ValueError as e:
                 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,
-                placement=orchestrator.PlacementSpec(nodes=hosts),
-                count=num or 1)
-        else:
-            return HandleCommandResult(-errno.EINVAL, stderr=usage)
+        rgw_spec = orchestrator.RGWSpec(
+            rgw_realm=realm_name,
+            rgw_zone=zone_name,
+            placement=orchestrator.PlacementSpec(nodes=hosts),
+            count=num or 1)
 
         completion = self.add_rgw(rgw_spec)
         self._orchestrator_wait([completion])
@@ -459,12 +457,14 @@ Usage:
 
     @orchestrator._cli_write_command(
         'orchestrator rgw update',
-        "name=zone_name,type=CephString "
-        "name=num,type=CephInt "
+        'name=realm_name,type=CephString '
+        'name=zone_name,type=CephString '
+        "name=num,type=CephInt,req=False "
         "name=hosts,type=CephString,n=N,req=false",
         'Update the number of RGW instances for the given zone')
-    def _rgw_update(self, zone_name, num, hosts=None):
+    def _rgw_update(self, realm_name, zone_name, num, hosts=None):
         spec = orchestrator.RGWSpec(
+            rgw_realm=realm_name,
             rgw_zone=zone_name,
             placement=orchestrator.PlacementSpec(nodes=hosts),
             count=num or 1)
index 2f6eb445307c6974de452e38ce4d2005e95a679d..a86649d4f9e4861fd798ad23f0e24ddbfe87c2f9 100644 (file)
@@ -1164,12 +1164,18 @@ class SSHOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
     def add_rgw(self, spec):
         if not spec.placement.nodes or len(spec.placement.nodes) < spec.count:
             raise RuntimeError("must specify at least %d hosts" % spec.count)
-        # ensure rgw_zone is set for these daemons
+        # ensure rgw_realm and rgw_zone is set for these daemons
         ret, out, err = self.mon_command({
             'prefix': 'config set',
             'who': 'client.rgw.' + spec.name,
             'name': 'rgw_zone',
-            'value': spec.name,
+            'value': spec.rgw_zone,
+        })
+        ret, out, err = self.mon_command({
+            'prefix': 'config set',
+            'who': 'client.rgw.' + spec.rgw_realm,
+            'name': 'rgw_realm',
+            'value': spec.rgw_realm,
         })
         daemons = self._get_services('rgw')
         results = []