source_zones: Dict[str, Any],
destination_zones: Dict[str, Any],
source_bucket: str = '',
- destination_bucket: str = '', bucket_name: str = ''):
+ destination_bucket: str = '', bucket_name: str = '',
+ user: str = '', mode: str = ''):
multisite_instance = RgwMultisite()
return multisite_instance.create_sync_pipe(group_id, pipe_id, source_zones,
destination_zones, source_bucket,
- destination_bucket, bucket_name, True)
+ destination_bucket, bucket_name, True,
+ user, mode)
@Endpoint(method='DELETE', path='/sync-pipe')
@EndpointDoc("Remove the sync pipe")
def remove_sync_pipe(self, group_id: str, pipe_id: str,
source_zones: Optional[List[str]] = None,
destination_zones: Optional[List[str]] = None,
- destination_bucket: str = '',
bucket_name: str = ''):
multisite_instance = RgwMultisite()
return multisite_instance.remove_sync_pipe(group_id, pipe_id, source_zones,
- destination_zones, destination_bucket,
- bucket_name, True)
+ destination_zones, bucket_name, True)
@APIRouter('/rgw/daemon', Scope.RGW)
i18n-placeholder
placeholder="Source Bucket Name..."
formControlName="source_bucket"/>
+ <cd-help-text>
+ <span i18n>{{ allBucketSelectedHelpText }}</span>
+ </cd-help-text>
</div>
</div>
<div class="form-group row">
i18n-placeholder
placeholder="Destination Bucket Name..."
formControlName="destination_bucket"/>
+ <cd-help-text>
+ <span i18n>{{ allBucketSelectedHelpText }}</span>
+ </cd-help-text>
</div>
</div>
</div>
component.submit();
expect(spy).toHaveBeenCalled();
expect(putDataSpy).toHaveBeenCalled();
- expect(putDataSpy).toHaveBeenCalledWith(component.pipeForm.getRawValue());
+ expect(putDataSpy).toHaveBeenCalledWith({
+ ...component.pipeForm.getRawValue(),
+ mode: '',
+ user: ''
+ });
+ });
+
+ it('should pass "user" and "mode" while creating/editing pipe', () => {
+ component.editing = true;
+ component.pipeForm.patchValue({
+ pipe_id: 'pipe1',
+ group_id: 's3-bucket-replication:enabled',
+ source_bucket: '',
+ source_zones: { added: ['zone1-zg1-realm1'], removed: [] },
+ destination_bucket: '',
+ destination_zones: { added: ['zone2-zg1-realm1'], removed: [] }
+ });
+ component.pipeSelectedRow = {
+ dest: { bucket: '*', zones: ['zone2-zg1-realm1'] },
+ id: 'pipi1',
+ params: {
+ dest: {},
+ mode: 'user',
+ priority: 0,
+ source: { filter: { tags: [] } },
+ user: 'dashboard'
+ },
+ source: { bucket: '*', zones: ['zone1-zg1-realm1'] }
+ };
+
+ component.sourceZones.data.selected = ['zone1-zg1-realm1'];
+ component.destZones.data.selected = ['zone2-zg1-realm1'];
+ const spy = jest.spyOn(component, 'submit');
+ const putDataSpy = jest.spyOn(multisiteServiceMock, 'createEditSyncPipe');
+ component.submit();
+ expect(spy).toHaveBeenCalled();
+ expect(putDataSpy).toHaveBeenCalled();
+ expect(putDataSpy).toHaveBeenCalledWith({
+ ...component.pipeForm.getRawValue(),
+ mode: 'user',
+ user: 'dashboard'
+ });
});
});
import { SucceededActionLabelsI18n } from '~/app/shared/constants/app.constants';
const ALL_ZONES = $localize`All zones (*)`;
+const ALL_BUCKET_SELECTED_HELP_TEXT =
+ 'If no value is provided, all the buckets in the zone group will be selected.';
@Component({
selector: 'cd-rgw-multisite-sync-pipe-modal',
sourceZones = new ZoneData(false, 'Filter Zones');
destZones = new ZoneData(false, 'Filter Zones');
icons = Icons;
+ allBucketSelectedHelpText = ALL_BUCKET_SELECTED_HELP_TEXT;
constructor(
public activeModal: NgbActiveModal,
.createEditSyncPipe({
...this.pipeForm.getRawValue(),
source_zones: sourceZones,
- destination_zones: destZones
+ destination_zones: destZones,
+ user: this.editing ? this.pipeSelectedRow?.params?.user : '',
+ mode: this.editing ? this.pipeSelectedRow?.params?.mode : ''
})
.subscribe(
() => {
);
}
- createEditSyncPipe(payload: any) {
- return this.http.put(`${this.url}/sync-pipe`, payload);
+ createEditSyncPipe(payload: any, user?: string, mode?: string) {
+ let params = new HttpParams();
+ if (user) {
+ params = params.append('user', user);
+ }
+ if (mode) {
+ params = params.append('mode', mode);
+ }
+ return this.http.put(`${this.url}/sync-pipe`, payload, { params });
}
removeSyncPipe(pipe_id: string, group_id: string, bucket_name?: string) {
type: string
group_id:
type: string
+ mode:
+ default: ''
+ type: string
pipe_id:
type: string
source_bucket:
type: string
source_zones:
type: string
+ user:
+ default: ''
+ type: string
required:
- group_id
- pipe_id
name: destination_zones
schema:
type: string
- - default: ''
- in: query
- name: destination_bucket
- schema:
- type: string
- default: ''
in: query
name: bucket_name
source_bucket: str = '',
destination_bucket: str = '',
bucket_name: str = '',
- update_period=False):
+ update_period=False,
+ user: str = '', mode: str = ''):
if source_zones['added'] or destination_zones['added']:
rgw_sync_policy_cmd = ['sync', 'group', 'pipe', 'create',
if bucket_name:
rgw_sync_policy_cmd += ['--bucket', bucket_name]
- if source_bucket:
- rgw_sync_policy_cmd += ['--source-bucket', source_bucket]
+ rgw_sync_policy_cmd += ['--source-bucket', source_bucket]
- if destination_bucket:
- rgw_sync_policy_cmd += ['--dest-bucket', destination_bucket]
+ rgw_sync_policy_cmd += ['--dest-bucket', destination_bucket]
if source_zones['added']:
rgw_sync_policy_cmd += ['--source-zones', ','.join(source_zones['added'])]
if destination_zones['added']:
rgw_sync_policy_cmd += ['--dest-zones', ','.join(destination_zones['added'])]
+ if user:
+ rgw_sync_policy_cmd += ['--uid', user]
+
+ if mode:
+ rgw_sync_policy_cmd += ['--mode', mode]
+
logger.info("Creating sync pipe!")
try:
exit_code, _, err = mgr.send_rgwadmin_command(rgw_sync_policy_cmd)
if ((source_zones['removed'] and '*' not in source_zones['added'])
or (destination_zones['removed'] and '*' not in destination_zones['added'])):
self.remove_sync_pipe(group_id, pipe_id, source_zones['removed'],
- destination_zones['removed'], destination_bucket,
- bucket_name)
+ destination_zones['removed'],
+ bucket_name, True)
def remove_sync_pipe(self, group_id: str, pipe_id: str,
source_zones: Optional[List[str]] = None,
destination_zones: Optional[List[str]] = None,
- destination_bucket: str = '', bucket_name: str = '',
+ bucket_name: str = '',
update_period=False):
rgw_sync_policy_cmd = ['sync', 'group', 'pipe', 'remove',
'--group-id', group_id, '--pipe-id', pipe_id]
if destination_zones:
rgw_sync_policy_cmd += ['--dest-zones', ','.join(destination_zones)]
- if destination_bucket:
- rgw_sync_policy_cmd += ['--dest-bucket', destination_bucket]
-
logger.info("Removing sync pipe! %s", rgw_sync_policy_cmd)
try:
exit_code, _, err = mgr.send_rgwadmin_command(rgw_sync_policy_cmd)