except NoRgwDaemonsException as e:
raise DashboardException(e, http_status_code=404, component='rgw')
+ @allow_empty_body
+ # pylint: disable=W0613
+ def set(self, realm_name, default, new_realm_name, daemon_name=None):
+ try:
+ instance = RgwClient.admin_instance()
+ result = instance.edit_realm(realm_name, default, new_realm_name)
+ return result
+ except NoRgwDaemonsException as e:
+ raise DashboardException(e, http_status_code=404, component='rgw')
+
@APIRouter('/rgw/zonegroup', Scope.RGW)
class RgwZonegroup(RESTController):
<i [ngClass]="node.data.icon"></i>
{{ node.data.name }}
</span>
+ <span *ngIf="node.data.type"
+ class="badge badge-info me-3">
+ {{ node.data.type }}
+ </span>
<span class="badge badge-success me-2"
*ngIf="node.data.is_default">
default
*ngIf="node.data.is_master">
master
</span>
+ <div class="btn-group align-inline-btns"
+ *ngIf="node.isFocused && node.data.type === 'realm'"
+ role="group">
+ <button type="button"
+ [title]="title"
+ class="btn btn-light dropdown-toggle-split ms-1"
+ (click)="openModal(node, true)"
+ ngbDropdownToggle>
+ <i [ngClass]="[icons.edit]"></i>
+ </button>
+ </div>
</ng-template>
</tree-root>
</div>
.tree-container {
height: calc(100vh - vv.$tree-container-height);
}
+
+.align-inline-btns {
+ margin-left: 15em;
+}
}
openModal(entity: any, edit = false) {
- const entityName = edit ? entity.data.name : entity;
+ const entityName = edit ? entity.data.type : entity;
const action = edit ? 'edit' : 'create';
const initialState = {
resource: entityName,
export class RgwMultisiteRealmFormComponent implements OnInit {
action: string;
multisiteRealmForm: CdFormGroup;
+ info: any;
editing = false;
resource: string;
multisiteInfo: object[] = [];
realm: RgwRealm;
realmList: RgwRealm[] = [];
realmNames: string[];
+ newRealmName: string;
constructor(
public activeModal: NgbActiveModal,
validators: [
Validators.required,
CdValidators.custom('uniqueName', (realmName: string) => {
- return this.realmNames && this.realmNames.indexOf(realmName) !== -1;
+ return (
+ this.action === 'create' &&
+ this.realmNames &&
+ this.realmNames.indexOf(realmName) !== -1
+ );
})
]
}),
this.realmNames = this.realmList.map((realm) => {
return realm['name'];
});
+ if (this.action === 'edit') {
+ this.multisiteRealmForm.get('realmName').setValue(this.info.data.name);
+ this.multisiteRealmForm.get('default_realm').setValue(this.info.data.is_default);
+ }
}
submit() {
const values = this.multisiteRealmForm.value;
this.realm = new RgwRealm();
- this.realm.name = values['realmName'];
- this.rgwRealmService.create(this.realm, values['default_realm']).subscribe(
- () => {
- this.notificationService.show(
- NotificationType.success,
- $localize`Realm: '${values['realmName']}' created successfully`
- );
- this.activeModal.close();
- },
- () => {
- this.multisiteRealmForm.setErrors({ cdSubmitButton: true });
- }
- );
+ if (this.action === 'create') {
+ this.realm.name = values['realmName'];
+ this.rgwRealmService.create(this.realm, values['default_realm']).subscribe(
+ () => {
+ this.notificationService.show(
+ NotificationType.success,
+ $localize`Realm: '${values['realmName']}' created successfully`
+ );
+ this.activeModal.close();
+ },
+ () => {
+ this.multisiteRealmForm.setErrors({ cdSubmitButton: true });
+ }
+ );
+ } else if (this.action === 'edit') {
+ this.realm.name = this.info.data.name;
+ this.newRealmName = values['realmName'];
+ this.rgwRealmService.update(this.realm, values['default_realm'], this.newRealmName).subscribe(
+ () => {
+ this.notificationService.show(
+ NotificationType.success,
+ $localize`Realm: '${values['realmName']}' updated successfully`
+ );
+ this.activeModal.close();
+ },
+ () => {
+ this.multisiteRealmForm.setErrors({ cdSubmitButton: true });
+ }
+ );
+ }
}
}
});
}
+ update(realm: RgwRealm, defaultRealm: boolean, newRealmName: string) {
+ return this.rgwDaemonService.request((params: HttpParams) => {
+ params = params.appendAll({
+ realm_name: realm.name,
+ default: defaultRealm,
+ new_realm_name: newRealmName
+ });
+ return this.http.put(`${this.url}/${realm.name}`, null, { params: params });
+ });
+ }
+
list(): Observable<object> {
return this.rgwDaemonService.request(() => {
return this.http.get<object>(`${this.url}`);
let realmIds = [];
nodes['id'] = realm.id;
realmIds.push(realm.id);
- nodes['name'] = realm.name + ' (realm)';
+ nodes['name'] = realm.name;
nodes['info'] = realm;
nodes['is_default'] = realm.id === defaultRealmId ? true : false;
nodes['icon'] = Icons.reweight;
+ nodes['type'] = 'realm';
return {
nodes: nodes,
realmIds: realmIds
let zoneIds = [];
nodes['id'] = zone.id;
zoneIds.push(zone.id);
- nodes['name'] = zone.name + ' (zone)';
+ nodes['name'] = zone.name;
nodes['info'] = zone;
nodes['icon'] = Icons.deploy;
nodes['parent'] = zonegroup ? zonegroup.name : '';
nodes['second_parent'] = realm ? realm.name : '';
nodes['is_default'] = zone.id === defaultZoneId ? true : false;
nodes['is_master'] = zonegroup && zonegroup.master_zone === zone.id ? true : false;
+ nodes['type'] = 'zone';
return {
nodes: nodes,
zoneIds: zoneIds
getZonegroupTree(zonegroup: RgwZonegroup, defaultZonegroupId: string, realm?: RgwRealm) {
let nodes = {};
nodes['id'] = zonegroup.id;
- nodes['name'] = zonegroup.name + ' (zonegroup)';
+ nodes['name'] = zonegroup.name;
nodes['info'] = zonegroup;
nodes['icon'] = Icons.cubes;
nodes['is_master'] = zonegroup.is_master;
nodes['parent'] = realm ? realm.name : '';
nodes['is_default'] = zonegroup.id === defaultZonegroupId ? true : false;
+ nodes['type'] = 'zonegroup';
return nodes;
}
}
- jwt: []
tags:
- RgwRealm
+ put:
+ parameters:
+ - in: path
+ name: realm_name
+ required: true
+ schema:
+ type: string
+ requestBody:
+ content:
+ application/json:
+ schema:
+ properties:
+ daemon_name:
+ type: string
+ default:
+ type: string
+ new_realm_name:
+ type: string
+ required:
+ - default
+ - new_realm_name
+ type: object
+ responses:
+ '200':
+ content:
+ application/vnd.ceph.api.v1.0+json:
+ type: object
+ description: Resource updated.
+ '202':
+ content:
+ application/vnd.ceph.api.v1.0+json:
+ type: object
+ description: Operation is still executing. Please check the task queue.
+ '400':
+ description: Operation exception. Please check the response body for details.
+ '401':
+ description: Unauthenticated access. Please login first.
+ '403':
+ description: Unauthorized access. Please check your permissions.
+ '500':
+ description: Unexpected error. Please check the response body for the stack
+ trace.
+ security:
+ - jwt: []
+ tags:
+ - RgwRealm
/api/rgw/site:
get:
parameters:
pytest-cov
pytest-instafail
pyfakefs==4.5.0
-jsonschema==4.16.0
+jsonschema
from ..exceptions import DashboardException
from ..rest_client import RequestException, RestClient
from ..settings import Settings
-from ..tools import dict_contains_path, dict_get, json_str_to_object
+from ..tools import dict_contains_path, dict_get, json_str_to_object, str_to_bool
try:
from typing import Any, Dict, List, Optional, Tuple, Union
except SubprocessError as error:
raise DashboardException(error, http_status_code=500, component='rgw')
+ def edit_realm(self, realm_name: str, default: bool, new_realm_name: str):
+ rgw_realm_edit_cmd = []
+ cmd_edit_realm_options = []
+ if new_realm_name == realm_name:
+ if str_to_bool(default):
+ rgw_realm_edit_cmd = ['realm', 'default']
+ cmd_edit_realm_options = ['--rgw-realm', realm_name]
+ rgw_realm_edit_cmd += cmd_edit_realm_options
+ try:
+ exit_code, _, err = mgr.send_rgwadmin_command(rgw_realm_edit_cmd)
+ if exit_code > 0:
+ raise DashboardException(e=err, msg='Unable to set {} as default realm'.format(realm_name), # noqa E501 #pylint: disable=line-too-long
+ http_status_code=500, component='rgw')
+ except SubprocessError as error:
+ raise DashboardException(error, http_status_code=500, component='rgw')
+ else:
+ raise DashboardException(msg='The realm already exists',
+ http_status_code=400, component='rgw')
+ else:
+ rgw_realm_edit_cmd = ['realm', 'rename']
+ cmd_edit_realm_options = ['--rgw-realm', realm_name, '--realm-new-name', new_realm_name]
+ rgw_realm_edit_cmd += cmd_edit_realm_options
+ try:
+ exit_code, _, err = mgr.send_rgwadmin_command(rgw_realm_edit_cmd)
+ if exit_code > 0:
+ raise DashboardException(e=err, msg='Unable to edit realm',
+ http_status_code=500, component='rgw')
+ except ValueError:
+ pass
+
+ if str_to_bool(default):
+ rgw_realm_edit_cmd = ['realm', 'default']
+ cmd_edit_realm_options = ['--rgw-realm', new_realm_name]
+ try:
+ exit_code, _, _ = mgr.send_rgwadmin_command(rgw_realm_edit_cmd)
+ if exit_code > 0:
+ raise DashboardException(msg='Unable to set {} as default realm'.format(new_realm_name), # noqa E501 #pylint: disable=line-too-long
+ http_status_code=500, component='rgw')
+ except SubprocessError as error:
+ raise DashboardException(error, http_status_code=500, component='rgw')
+
def create_zonegroup(self, realm_name: str, zonegroup_name: str,
default: bool, master: bool, endpoints: List[str]):
rgw_zonegroup_create_cmd = ['zonegroup', 'create']
http_status_code=500, component='rgw')
except SubprocessError as error:
raise DashboardException(error, http_status_code=500, component='rgw')
- self.update_period()
return out
def list_zonegroups(self):
for rgw_zonegroup in rgw_zonegroup_list['zonegroups']:
zonegroup_info = self.get_zonegroup(rgw_zonegroup)
zonegroups_info.append(zonegroup_info)
- all_zonegroups_info['zonegroups'] = zonegroups_info # type: ignore
+ all_zonegroups_info['zonegroups'] = zonegroups_info # type: ignore
else:
all_zonegroups_info['zonegroups'] = [] # type: ignore
if 'default_info' in rgw_zonegroup_list and rgw_zonegroup_list['default_info'] != '':