1. Automate the process of replication user creation during single site to multi-site migration
2. Provide a support for automatic restart post creation of default realm/zone group/zone as a part of multisite migrate
Fixes: https://tracker.ceph.com/issues/69052
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
@allow_empty_body
# pylint: disable=W0102,W0613
def migrate(self, daemon_name=None, realm_name=None, zonegroup_name=None, zone_name=None,
- zonegroup_endpoints=None, zone_endpoints=None, access_key=None,
- secret_key=None):
+ zonegroup_endpoints=None, zone_endpoints=None, username=None):
multisite_instance = RgwMultisite()
result = multisite_instance.migrate_to_multisite(realm_name, zonegroup_name,
zone_name, zonegroup_endpoints,
- zone_endpoints, access_key,
- secret_key)
+ zone_endpoints, username)
return result
@RESTController.Collection(method='POST', path='/multisite-replications')
</div>
<div class="form-group row">
<label class="cd-col-form-label required"
- for="access_key"
- i18n>S3 access key
- <cd-helper>
- <span>To see or copy your S3 access key, go to <b>Object Gateway > Users</b> and click on your user name. In <b>Keys</b>, click <b>Show</b>. View the access key by clicking Show and copy the key by clicking <b>Copy to Clipboard</b>.</span>
- </cd-helper>
- </label>
+ for="username"
+ i18n>Username</label>
<div class="cd-col-form-input">
<input class="form-control"
type="text"
- placeholder="e.g."
- id="access_key"
- name="access_key"
- formControlName="access_key">
- </div>
- </div>
- <div class="form-group row">
- <label class="cd-col-form-label required"
- for="access_key"
- i18n>S3 secret key
- <cd-helper>
- <span>To see or copy your S3 access key, go to <b>Object Gateway > Users</b> and click on your user name. In <b>Keys</b>, click <b>Show</b>. View the secret key by clicking Show and copy the key by clicking <b>Copy to Clipboard</b>.</span>
- </cd-helper>
- </label>
- <div class="cd-col-form-input">
- <input class="form-control"
- type="text"
- placeholder="e.g."
- id="secret_key"
- name="secret_key"
- formControlName="secret_key">
+ placeholder="username"
+ id="username"
+ name="username"
+ formControlName="username">
+ <cd-help-text>
+ <span i18n>Specify the username for the system user. This user will be created automatically as part of the process.</span>
+ </cd-help-text>
+ <span class="invalid-feedback"
+ *ngIf="multisiteMigrateForm.showError('username', formDir, 'required')"
+ i18n>This field is required.</span>
</div>
</div>
</div>
import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
import { CdValidators } from '~/app/shared/forms/cd-validators';
import { NotificationService } from '~/app/shared/services/notification.service';
-import { RgwRealm, RgwZone, RgwZonegroup, SystemKey } from '../models/rgw-multisite';
+import { RgwRealm, RgwZone, RgwZonegroup } from '../models/rgw-multisite';
import { ModalService } from '~/app/shared/services/modal.service';
import { RgwDaemonService } from '~/app/shared/api/rgw-daemon.service';
Validators.required
]
),
- access_key: new UntypedFormControl(null),
- secret_key: new UntypedFormControl(null)
+ username: new UntypedFormControl(null, {
+ validators: [Validators.required]
+ })
});
}
this.zone = new RgwZone();
this.zone.name = values['zoneName'];
this.zone.endpoints = values['zone_endpoints'];
- this.zone.system_key = new SystemKey();
- this.zone.system_key.access_key = values['access_key'];
- this.zone.system_key.secret_key = values['secret_key'];
- this.rgwMultisiteService.migrate(this.realm, this.zonegroup, this.zone).subscribe(
- () => {
- this.notificationService.show(
- NotificationType.success,
- $localize`Migration done successfully`
- );
- this.submitAction.emit();
- this.activeModal.close();
- },
- () => {
- this.notificationService.show(NotificationType.error, $localize`Migration failed`);
- }
- );
+ this.rgwMultisiteService
+ .migrate(this.realm, this.zonegroup, this.zone, values['username'])
+ .subscribe(
+ () => {
+ this.rgwMultisiteService.setRestartGatewayMessage(false);
+ this.notificationService.show(
+ NotificationType.success,
+ $localize`Migration done successfully`
+ );
+ this.submitAction.emit();
+ this.activeModal.close();
+ },
+ () => {
+ this.notificationService.show(NotificationType.error, $localize`Migration failed`);
+ }
+ );
}
}
constructor(private http: HttpClient, public rgwDaemonService: RgwDaemonService) {}
- migrate(realm: RgwRealm, zonegroup: RgwZonegroup, zone: RgwZone) {
+ migrate(realm: RgwRealm, zonegroup: RgwZonegroup, zone: RgwZone, username: string) {
return this.rgwDaemonService.request((params: HttpParams) => {
params = params.appendAll({
realm_name: realm.name,
zone_name: zone.name,
zonegroup_endpoints: zonegroup.endpoints,
zone_endpoints: zone.endpoints,
- access_key: zone.system_key.access_key,
- secret_key: zone.system_key.secret_key
+ username: username
});
return this.http.put(`${this.uiUrl}/migrate`, null, { params: params });
});
class RgwMultisite:
def migrate_to_multisite(self, realm_name: str, zonegroup_name: str, zone_name: str,
- zonegroup_endpoints: str, zone_endpoints: str, access_key: str,
- secret_key: str):
+ zonegroup_endpoints: str, zone_endpoints: str, username: str):
rgw_realm_create_cmd = ['realm', 'create', '--rgw-realm', realm_name, '--default']
try:
exit_code, _, err = mgr.send_rgwadmin_command(rgw_realm_create_cmd, False)
http_status_code=500, component='rgw')
except SubprocessError as error:
raise DashboardException(error, http_status_code=500, component='rgw')
+ self.update_period()
- if access_key and secret_key:
- rgw_zone_modify_cmd = ['zone', 'modify', '--rgw-zone', zone_name,
- '--access-key', access_key, '--secret', secret_key]
- try:
- exit_code, _, err = mgr.send_rgwadmin_command(rgw_zone_modify_cmd)
- if exit_code > 0:
- raise DashboardException(e=err, msg='Unable to modify zone',
+ try:
+ user_details = self.create_system_user(username, zone_name)
+ if user_details:
+ keys = user_details['keys'][0]
+ access_key = keys['access_key']
+ secret_key = keys['secret_key']
+ if access_key and secret_key:
+ self.modify_zone(zone_name=zone_name,
+ zonegroup_name=zonegroup_name,
+ default='true', master='true',
+ endpoints=zone_endpoints,
+ access_key=keys['access_key'],
+ secret_key=keys['secret_key'])
+ else:
+ raise DashboardException(msg='Access key or secret key is missing',
http_status_code=500, component='rgw')
- except SubprocessError as error:
- raise DashboardException(error, http_status_code=500, component='rgw')
- self.update_period()
+ except Exception as e:
+ raise DashboardException(msg='Failed to modify zone or create system user: %s' % e,
+ http_status_code=500, component='rgw')
+
+ try:
+ rgw_service_manager = RgwServiceManager()
+ rgw_service_manager.restart_rgw_daemons_and_set_credentials()
+ except Exception as e:
+ raise DashboardException(msg='Failed to restart RGW daemon: %s' % e,
+ http_status_code=500, component='rgw')
def create_realm(self, realm_name: str, default: bool):
rgw_realm_create_cmd = ['realm', 'create']