From c0803f8f271ea6b2c653b3a443f7807185303912 Mon Sep 17 00:00:00 2001 From: Daniel Pivonka Date: Fri, 9 Apr 2021 15:25:21 -0400 Subject: [PATCH] mgr/orchestractor: rgw realm and zone flags must both be provided Signed-off-by: Daniel Pivonka --- src/pybind/mgr/orchestrator/module.py | 7 +++++++ src/python-common/ceph/deployment/service_spec.py | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 2e9e1f2574a3f..036bf1d71ef9e 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -1083,6 +1083,13 @@ Usage: if inbuf: raise OrchestratorValidationError('unrecognized command -i; -h or --help for usage') + if realm and not zone: + raise OrchestratorValidationError( + 'Cannot add RGW: Realm specified but no zone specified') + if zone and not realm: + raise OrchestratorValidationError( + 'Cannot add RGW: Zone specified but no realm specified') + spec = RGWSpec( service_id=svc_id, rgw_realm=realm, diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index b42c6addbdbaa..7d413af515022 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -760,6 +760,16 @@ class RGWSpec(ServiceSpec): else: return 80 + def validate(self) -> None: + super(RGWSpec, self).validate() + + if self.rgw_realm and not self.rgw_zone: + raise ServiceSpecValidationError( + 'Cannot add RGW: Realm specified but no zone specified') + if self.rgw_zone and not self.rgw_realm: + raise ServiceSpecValidationError( + 'Cannot add RGW: Zone specified but no realm specified') + yaml.add_representer(RGWSpec, ServiceSpec.yaml_representer) -- 2.39.5