]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: RGW bucket creation when no placement target received
authoralfonsomthd <almartin@redhat.com>
Thu, 25 Jul 2019 09:42:57 +0000 (11:42 +0200)
committeralfonsomthd <almartin@redhat.com>
Thu, 25 Jul 2019 09:42:57 +0000 (11:42 +0200)
Fixes: https://tracker.ceph.com/issues/40567
Signed-off-by: alfonsomthd <almartin@redhat.com>
src/pybind/mgr/dashboard/controllers/rgw.py
src/pybind/mgr/dashboard/services/rgw_client.py

index 485159c646d09a61b4aa3295e74d6d3f7d597352..c5a0c1004985d183dc7942e38f051bc1854e71a0 100644 (file)
@@ -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)
index 51c7649e96dfe1d7ea4e00319d80c71b4b4a9602..a2cc197af3ee4a11a7351c4354eb54e8131397f8 100644 (file)
@@ -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()