From d9efaed62e7082ad1a61233515b05b7c15bdc28b Mon Sep 17 00:00:00 2001 From: avanthakkar Date: Thu, 30 Mar 2023 22:48:52 +0530 Subject: [PATCH] mgr/dashboard: add support for editing RGW zonegroup Fixes: https://tracker.ceph.com/issues/59239 Signed-off-by: Avan Thakkar Co-authored-by: Aashish Sharma --- src/pybind/mgr/dashboard/controllers/rgw.py | 15 ++ .../rgw-multisite-details.component.html | 7 +- .../rgw-multisite-details.component.scss | 4 + .../rgw-multisite-details.component.ts | 6 +- ...gw-multisite-zonegroup-form.component.html | 99 +++++++- ...multisite-zonegroup-form.component.spec.ts | 65 ++++++ .../rgw-multisite-zonegroup-form.component.ts | 217 +++++++++++++++--- .../app/shared/api/rgw-zonegroup.service.ts | 27 +++ src/pybind/mgr/dashboard/openapi.yaml | 64 ++++++ .../mgr/dashboard/services/rgw_client.py | 164 ++++++++++++- 10 files changed, 633 insertions(+), 35 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/rgw.py b/src/pybind/mgr/dashboard/controllers/rgw.py index def764eceaa08..d061dc579fa7e 100644 --- a/src/pybind/mgr/dashboard/controllers/rgw.py +++ b/src/pybind/mgr/dashboard/controllers/rgw.py @@ -814,6 +814,21 @@ class RgwZonegroup(RESTController): except NoRgwDaemonsException as e: raise DashboardException(e, http_status_code=404, component='rgw') + @allow_empty_body + # pylint: disable=W0613,W0102 + def set(self, zonegroup_name: str, realm_name: str, new_zonegroup_name: str, default: str = '', + master: str = '', zonegroup_endpoints: List[str] = [], add_zones: List[str] = [], + remove_zones: List[str] = [], placement_targets: List[Dict[str, str]] = [], + daemon_name=None): + try: + instance = RgwClient.admin_instance() + result = instance.edit_zonegroup(realm_name, zonegroup_name, new_zonegroup_name, + default, master, zonegroup_endpoints, add_zones, + remove_zones, placement_targets) + return result + except NoRgwDaemonsException as e: + raise DashboardException(e, http_status_code=404, component='rgw') + @APIRouter('/rgw/zone', Scope.RGW) class RgwZone(RESTController): diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html index 3dcb290c64141..12ae56a2d0742 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html @@ -34,17 +34,18 @@ *ngIf="node.data.is_default"> default - master
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.scss b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.scss index 423c078066afb..537b53a519ccf 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.scss +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.scss @@ -7,3 +7,7 @@ .align-inline-btns { margin-left: 5em; } + +.btn:disabled { + pointer-events: none; +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts index 0a8e598f6e73b..a0edcd95b49aa 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts @@ -76,6 +76,7 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit { defaultZoneId = ''; multisiteInfo: object[] = []; defaultsInfo: string[] = []; + title: string = 'Edit'; constructor( private modalService: ModalService, @@ -291,18 +292,21 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit { } getDisable() { + let isMasterZone = true; if (this.defaultRealmId === '') { return this.messages.noDefaultRealm; } else { - let isMasterZone = true; this.zonegroups.forEach((zgp: any) => { if (_.isEmpty(zgp.master_zone)) { isMasterZone = false; } }); if (!isMasterZone) { + this.title = + 'Please create a master zone for each existing zonegroup to enable this feature'; return this.messages.noMasterZone; } else { + this.title = 'Edit'; return false; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-zonegroup-form/rgw-multisite-zonegroup-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-zonegroup-form/rgw-multisite-zonegroup-form.component.html index adcadde8775ee..b3848052b5b0d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-zonegroup-form/rgw-multisite-zonegroup-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-zonegroup-form/rgw-multisite-zonegroup-form.component.html @@ -52,7 +52,10 @@ type="checkbox">
+ i18n>Default + + Zonegroup doesn't belong to the default realm. +
+ + Multiple master zonegroups can't be configured. If you want to create a new zonegroup and make it the master zonegroup, you must delete the default zonegroup. +
@@ -89,6 +95,97 @@ i18n>Please enter a valid IP address. +
+ +
+ +
+ Cannot remove master zone. +
+
+
+ Placement targets + +
+
+
+ {{ (index + 1) | ordinal }} + × +
+ +
+ +
+ +
+ + + This field is required. + +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ +
+
+
+
+
+
+ +