From: Sage Weil Date: Tue, 26 Nov 2019 16:26:25 +0000 (-0600) Subject: mgr/orchestrator: name rgw by client.rgw.$realm.$zone[.$id] X-Git-Tag: v15.1.0~685^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F31890%2Fhead;p=ceph.git mgr/orchestrator: name rgw by client.rgw.$realm.$zone[.$id] Specify both the realm and zone when provisioning rgws. Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 1bdc7fec178..9b6452d216d 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -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 diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index cf4734118c3..18519f76e5b 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -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 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 - ceph orchestrator rgw add + ceph orchestrator rgw add """ - 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) diff --git a/src/pybind/mgr/ssh/module.py b/src/pybind/mgr/ssh/module.py index 2f6eb445307..a86649d4f9e 100644 --- a/src/pybind/mgr/ssh/module.py +++ b/src/pybind/mgr/ssh/module.py @@ -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 = []