]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: get bucket replication info
authorNizamudeen A <nia@redhat.com>
Fri, 7 Jun 2024 13:13:00 +0000 (18:43 +0530)
committerNizamudeen A <nia@redhat.com>
Fri, 21 Jun 2024 11:16:23 +0000 (16:46 +0530)
- Show bucket replication status and replication policy in the details
view

Fixes: https://tracker.ceph.com/issues/66241
Signed-off-by: Nizamudeen A <nia@redhat.com>
src/pybind/mgr/dashboard/controllers/rgw.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts
src/pybind/mgr/dashboard/services/rgw_client.py

index a6d8c878a092da0453bc992680ffb6c648cb9f3c..a87ebf12494fea343b262801246378eb470488bb 100644 (file)
@@ -409,6 +409,10 @@ class RgwBucket(RgwRESTController):
             multisite.create_dashboard_admin_sync_group(zonegroup_name=zonegroup_name)
         return rgw_client.set_bucket_replication(bucket_name, replication)
 
+    def _get_replication(self, bucket_name: str):
+        rgw_client = RgwClient.admin_instance()
+        return rgw_client.get_bucket_replication(bucket_name)
+
     @staticmethod
     def strip_tenant_from_bucket_name(bucket_name):
         # type (str) -> str
@@ -463,6 +467,7 @@ class RgwBucket(RgwRESTController):
         result['mfa_delete'] = versioning['MfaDelete']
         result['bucket_policy'] = self._get_policy(bucket_name, daemon_name, result['owner'])
         result['acl'] = self._get_acl(bucket_name, daemon_name, result['owner'])
+        result['replication'] = self._get_replication(bucket_name)
 
         # Append the locking configuration.
         locking = self._get_locking(result['owner'], daemon_name, bucket_name)
index a68ea5661e207c7d221008e8d6d2a3c879f33009..f0b5f1872bcbac03c5932b701051fecc22977a3c 100644 (file)
                   class="bold">Encryption</td>
               <td>{{ selection.encryption }}</td>
             </tr>
+            <tr>
+              <td i18n
+                  class="bold">Replication</td>
+              <td>{{ replicationStatus }}</td>
+            </tr>
             <tr>
               <td i18n
                   class="bold">MFA Delete</td>
                   class="bold w-25">Bucket policy</td>
               <td><pre>{{ selection.bucket_policy | json}}</pre></td>
             </tr>
+            <tr>
+              <td i18n
+                  class="bold w-25">Replication policy</td>
+              <td><pre>{{ selection.replication | json}}</pre></td>
+            </tr>
             <tr>
               <td i18n
                   class="bold w-25">ACL</td>
index 451a7dd381118bb7c870176ea6004ffe4e9aa718..1a709f8644f00dc48cfe84b0ba8acfeded61fcf7 100644 (file)
@@ -14,6 +14,7 @@ export class RgwBucketDetailsComponent implements OnChanges {
   selection: any;
 
   aclPermissions: Record<string, string[]> = {};
+  replicationStatus = $localize`Disabled`;
 
   constructor(private rgwBucketService: RgwBucketService) {}
 
@@ -23,6 +24,8 @@ export class RgwBucketDetailsComponent implements OnChanges {
         bucket['lock_retention_period_days'] = this.rgwBucketService.getLockDays(bucket);
         this.selection = bucket;
         this.aclPermissions = this.parseXmlAcl(this.selection.acl, this.selection.owner);
+        if (this.selection.replication?.['Rule']?.['Status'])
+          this.replicationStatus = this.selection.replication?.['Rule']?.['Status'];
       });
     }
   }
index 22b094d6bd54df469f2068b23e08b49b8160373a..87dbee26dc2e6b40ba359b56250dcf01a8270131 100644 (file)
               <cd-help-text>
                 <span i18n>Enables replication for the objects in the bucket.</span>
               </cd-help-text>
-              <div class="mt-1">
+              <div class="mt-1"
+                   *ngIf="!editing">
                 <cd-alert-panel type="info"
                                 *ngIf="!multisiteStatus.status.available && !multisiteStatus.isDefaultZg"
                                 class="me-1"
index ed072b87d86b8cfb5754e2ac46f35bd16875ad91..189f5b02c85c815003ec8bbe90952b2ac1fa1cb5 100644 (file)
@@ -271,6 +271,14 @@ export class RgwBucketFormComponent extends CdForm implements OnInit, AfterViewC
                 .get('bucket_policy')
                 .setValue(JSON.stringify(value['bucket_policy'], null, 2));
             }
+            if (value['replication']) {
+              const replicationConfig = value['replication'];
+              if (replicationConfig?.['Rule']?.['Status'] === 'Enabled') {
+                this.bucketForm.get('replication').setValue(true);
+              } else {
+                this.bucketForm.get('replication').setValue(false);
+              }
+            }
             this.filterAclPermissions();
           }
         }
index 3872c9073ac610698e613cadb153ee9253eb54a6..17fa33f750851f5c5df9dffbf87edc21fd6fe5fa 100644 (file)
@@ -1040,6 +1040,19 @@ class RgwClient(RestClient):
         except RequestException as e:
             raise DashboardException(msg=str(e), component='rgw')
 
+    @RestClient.api_get('/{bucket_name}?replication')
+    def get_bucket_replication(self, bucket_name, request=None):
+        # pylint: disable=unused-argument
+        try:
+            result = request()
+            return result
+        except RequestException as e:
+            if e.content:
+                content = json_str_to_object(e.content)
+                if content.get('Code') == 'ReplicationConfigurationNotFoundError':
+                    return None
+            raise e
+
 
 class SyncStatus(Enum):
     enabled = 'enabled'