From 55744ef51a423b1067c6df9f5676f1eb9986eaa1 Mon Sep 17 00:00:00 2001 From: alfonsomthd Date: Thu, 25 Jul 2019 11:42:57 +0200 Subject: [PATCH] mgr/dashboard: RGW bucket creation when no placement target received Fixes: https://tracker.ceph.com/issues/40567 Signed-off-by: alfonsomthd --- src/pybind/mgr/dashboard/controllers/rgw.py | 2 +- src/pybind/mgr/dashboard/services/rgw_client.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/rgw.py b/src/pybind/mgr/dashboard/controllers/rgw.py index 485159c646d..c5a0c100498 100644 --- a/src/pybind/mgr/dashboard/controllers/rgw.py +++ b/src/pybind/mgr/dashboard/controllers/rgw.py @@ -144,7 +144,7 @@ class RgwBucket(RgwRESTController): result = self.proxy('GET', 'bucket', {'bucket': bucket}) return self._append_bid(result) - def create(self, bucket, uid, zonegroup, placement_target): + def create(self, bucket, uid, zonegroup=None, placement_target=None): try: rgw_client = RgwClient.instance(uid) return rgw_client.create_bucket(bucket, zonegroup, placement_target) diff --git a/src/pybind/mgr/dashboard/services/rgw_client.py b/src/pybind/mgr/dashboard/services/rgw_client.py index 51c7649e96d..a2cc197af3e 100644 --- a/src/pybind/mgr/dashboard/services/rgw_client.py +++ b/src/pybind/mgr/dashboard/services/rgw_client.py @@ -448,14 +448,17 @@ class RgwClient(RestClient): raise e @RestClient.api_put('/{bucket_name}') - def create_bucket(self, bucket_name, zonegroup, placement_target, request=None): + def create_bucket(self, bucket_name, zonegroup=None, placement_target=None, request=None): logger.info("Creating bucket: %s, zonegroup: %s, placement_target: %s", bucket_name, zonegroup, placement_target) - create_bucket_configuration = ET.Element('CreateBucketConfiguration') - location_constraint = ET.SubElement(create_bucket_configuration, 'LocationConstraint') - location_constraint.text = '{}:{}'.format(zonegroup, placement_target) - - return request(data=ET.tostring(create_bucket_configuration, encoding='utf-8')) + data = None + if zonegroup and placement_target: + create_bucket_configuration = ET.Element('CreateBucketConfiguration') + location_constraint = ET.SubElement(create_bucket_configuration, 'LocationConstraint') + location_constraint.text = '{}:{}'.format(zonegroup, placement_target) + data = ET.tostring(create_bucket_configuration, encoding='utf-8') + + return request(data=data) def get_placement_targets(self): # type: () -> Dict[str, Any] zone = self._get_daemon_zone_info() -- 2.39.5