From d1fb105db6a88d2130b938d2fd1f4691196ebf08 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 13 Mar 2020 13:49:51 -0500 Subject: [PATCH] mgr/orch: add 'unmanaged' property to ServiceSpec Signed-off-by: Sage Weil --- src/pybind/mgr/orchestrator/module.py | 28 ++++++++++++------- .../ceph/deployment/service_spec.py | 20 +++++++++---- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 50e7425aa686e..65ddc83613b1f 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -674,13 +674,15 @@ Usage: @_cli_write_command( 'orch apply', 'name=service_type,type=CephChoices,strings=mon|mgr|rbd-mirror|crash|alertmanager|grafana|node-exporter|prometheus ' - 'name=placement,type=CephString,req=false', + 'name=placement,type=CephString,req=false ' + 'name=unmanaged,type=CephBool,req=false', 'Update the size or placement for a service') - def _apply_misc(self, service_type, placement=None): + def _apply_misc(self, service_type, placement=None, unmanaged=False): placement = PlacementSpec.from_string(placement) placement.validate() - spec = ServiceSpec(service_type, placement=placement) + spec = ServiceSpec(service_type, placement=placement, + unmanaged=unmanaged) if service_type == 'mgr': completion = self.apply_mgr(spec) @@ -706,14 +708,16 @@ Usage: @_cli_write_command( 'orch apply mds', 'name=fs_name,type=CephString ' - 'name=placement,type=CephString,req=false', + 'name=placement,type=CephString,req=false ' + 'name=unmanaged,type=CephBool,req=false', 'Update the number of MDS instances for the given fs_name') - def _apply_mds(self, fs_name, placement=None): + def _apply_mds(self, fs_name, placement=None, unmanaged=False): placement = PlacementSpec.from_string(placement) placement.validate() spec = ServiceSpec( 'mds', fs_name, - placement=placement) + placement=placement, + unmanaged=unmanaged) completion = self.apply_mds(spec) self._orchestrator_wait([completion]) raise_if_exception(completion) @@ -723,13 +727,15 @@ Usage: 'orch apply rgw', 'name=realm_name,type=CephString ' 'name=zone_name,type=CephString ' - 'name=placement,type=CephString,req=false', + 'name=placement,type=CephString,req=false ' + 'name=unmanaged,type=CephBool,req=false', 'Update the number of RGW instances for the given zone') - def _apply_rgw(self, zone_name, realm_name, placement=None): + def _apply_rgw(self, zone_name, realm_name, placement=None, unmanaged=False): spec = RGWSpec( rgw_realm=realm_name, rgw_zone=zone_name, placement=PlacementSpec.from_string(placement), + unmanaged=unmanaged, ) completion = self.apply_rgw(spec) self._orchestrator_wait([completion]) @@ -739,12 +745,14 @@ Usage: @_cli_write_command( 'orch apply nfs', "name=svc_id,type=CephString " - 'name=placement,type=CephString,req=false', + 'name=placement,type=CephString,req=false ' + 'name=unmanaged,type=CephBool,req=false', 'Scale an NFS service') - def _apply_nfs(self, svc_id, placement=None): + def _apply_nfs(self, svc_id, placement=None, unmanaged=False): spec = NFSServiceSpec( svc_id, placement=PlacementSpec.from_string(placement), + unmanaged=unmanaged, ) completion = self.apply_nfs(spec) self._orchestrator_wait([completion]) diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index e65ceaf83dd3e..ae19d739fd289 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -304,15 +304,18 @@ class ServiceSpec(object): """ def __init__(self, - service_type, # type: str + service_type, # type: str service_id=None, # type: Optional[str] - placement: Optional[PlacementSpec] = None, - count: Optional[int] = None): + placement=None, # type: Optional[PlacementSpec] + count=None, # type: Optional[int] + unmanaged=False, # type: bool + ): self.placement = PlacementSpec() if placement is None else placement # type: PlacementSpec assert service_type self.service_type = service_type self.service_id = service_id + self.unmanaged = unmanaged @classmethod def from_json(cls, json_spec): @@ -384,9 +387,11 @@ def servicespec_validate_add(self: ServiceSpec): class NFSServiceSpec(ServiceSpec): def __init__(self, service_id, pool=None, namespace=None, placement=None, - service_type='nfs'): + service_type='nfs', unmanaged=False): assert service_type == 'nfs' - super(NFSServiceSpec, self).__init__('nfs', service_id=service_id, placement=placement) + super(NFSServiceSpec, self).__init__( + 'nfs', service_id=service_id, + placement=placement, unmanaged=unmanaged) #: RADOS pool where NFS client recovery data is stored. self.pool = pool @@ -413,13 +418,16 @@ class RGWSpec(ServiceSpec): placement=None, service_type='rgw', rgw_frontend_port=None, # type: Optional[int] + unmanaged=False, # type: bool ): assert service_type == 'rgw' if service_id: (rgw_realm, rgw_zone) = service_id.split('.', 1) else: service_id = '%s.%s' % (rgw_realm, rgw_zone) - super(RGWSpec, self).__init__('rgw', service_id=service_id, placement=placement) + super(RGWSpec, self).__init__( + 'rgw', service_id=service_id, + placement=placement, unmanaged=unmanaged) self.rgw_realm = rgw_realm self.rgw_zone = rgw_zone -- 2.39.5