]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/ssh: implement 'rgw add'
authorSage Weil <sage@redhat.com>
Thu, 31 Oct 2019 18:36:32 +0000 (13:36 -0500)
committerSage Weil <sage@redhat.com>
Tue, 5 Nov 2019 14:46:00 +0000 (08:46 -0600)
Note that this doesn't correctly confine a daemon to a zone.

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

index 1d8212eb03dc49028dde1c73c828ecd5bad8435d..1c7732e256ca9253862d2b13e010f92b6ecf44e2 100644 (file)
@@ -310,7 +310,7 @@ This is an overview of the current implementation status of the orchestrators.
  rbd-mirror add                      ⚪         ⚪       ⚪         ⚪
  rbd-mirror rm                       ⚪         ⚪       ⚪         ⚪
  rbd-mirror update                   ⚪         ⚪       ⚪         ⚪
- rgw add                             â\9c\94         â\9c\94       â\9aª         â\9aª
+ rgw add                             â\9c\94         â\9c\94       â\9aª         â\9c\94
  rgw rm                              ✔         ✔       ⚪         ⚪
  rgw update                          ⚪         ⚪       ⚪         ⚪
 =================================== ========= ====== ========= =====
index 76dfc02d62d197fddfe7f6aec0b3803affa8538c..83fce83802ca42a40bd9ba73e5bfe53236ffeb5b 100644 (file)
@@ -361,6 +361,8 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
 
         try:
             # get container image
+            if entity.startswith('rgw.'):
+                entity = 'client.' + entity
             ret, image, err = self.mon_command({
                 'prefix': 'config get',
                 'who': entity,
@@ -492,7 +494,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
 
     def describe_service(self, service_type=None, service_id=None,
                          node_name=None, refresh=False):
-        if service_type not in ("mds", "osd", "mgr", "mon", "nfs", None):
+        if service_type not in ("mds", "osd", "mgr", "mon", 'rgw', "nfs", None):
             raise orchestrator.OrchestratorValidationError(
                 service_type + " unsupported")
         result = self._get_services(service_type,
@@ -968,3 +970,36 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
             ['--name', name])
         self.log.debug('remove_mds code %s out %s' % (code, out))
         return "Removed {} from host '{}'".format(name, host)
+
+    def add_rgw(self, spec):
+        if len(spec.placement.nodes) < spec.count:
+            raise RuntimeError("must specify at least %d hosts" % spec.count)
+        daemons = self._get_services('rgw')
+        results = []
+        num_added = 0
+        for host in spec.placement.nodes:
+            if num_added >= spec.count:
+                break
+            rgw_id = self.get_unique_name(daemons, spec.name)
+            self.log.debug('placing rgw.%s on host %s' % (rgw_id, host))
+            results.append(
+                self._worker_pool.apply_async(self._create_rgw, (rgw_id, host))
+            )
+            # add to daemon list so next name(s) will also be unique
+            sd = orchestrator.ServiceDescription()
+            sd.service_instance = rgw_id
+            sd.service_type = 'rgw'
+            sd.nodename = host
+            daemons.append(sd)
+            num_added += 1
+        return SSHWriteCompletion(results)
+
+    def _create_rgw(self, rgw_id, host):
+        ret, keyring, err = self.mon_command({
+            'prefix': 'auth get-or-create',
+            'entity': 'client.rgw.' + rgw_id,
+            'caps': ['mon', 'allow rw',
+                     'mgr', 'allow rw',
+                     'osd', 'allow rwx'],
+        })
+        return self._create_daemon('rgw', rgw_id, host, keyring)