From 1ddfb6e84e64fc52defac017ad536c9341177c08 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 (cherry picked from commit c0803f8f271ea6b2c653b3a443f7807185303912) --- 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 cdf939d6be84f..3d4bdefdab734 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -1085,6 +1085,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 aa3b203e0104f..013e5522dcf80 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -759,6 +759,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