@@ -207,18 +207,20 @@ func (a *App) getRequestedCopy(gcs []GroupCopiesSettings) GroupCopiesSettings {
207
207
return c
208
208
}
209
209
210
- func (a * App ) startTransfer (t Task ) {
210
+ func (a * App ) startTransfer (t Task ) error {
211
211
endpoint := fmt .Sprintf (
212
212
a .Config .RPAURL + "/fapi/rest/5_1/groups/%d/clusters/%d/copies/%d/start_transfer" ,
213
213
t .GroupUID , t .ClusterUID , t .CopyUID )
214
214
if ! a .Config .CheckMode {
215
- _ , statusCode := a .apiRequest ("PUT" , endpoint , nil )
215
+ body , statusCode := a .apiRequest ("PUT" , endpoint , nil )
216
216
if statusCode != 204 {
217
- log .Errorf ("Expected status code '204' and received: %d\n " , statusCode )
218
- log .Fatalf ("Error Starting Transfer for Group %s Copy %s\n " , t .GroupName , t .CopyName )
217
+ log .Debugf ("Expected status code '204' and received: %d\n " , statusCode )
218
+ log .Warnf ("Error Starting Transfer for Group %s Copy %s\n " , t .GroupName , t .CopyName )
219
+ return errors .New (string (body ))
219
220
}
220
221
}
221
222
fmt .Printf ("Starting Transfer for Group %s Copy %s\n " , t .GroupName , t .CopyName )
223
+ return nil
222
224
}
223
225
224
226
func (a * App ) imageAccess (t Task ) error {
@@ -271,7 +273,7 @@ func (a *App) pollImageAccessEnabled(groupID int, stateDesired bool) {
271
273
}
272
274
}
273
275
274
- func (a * App ) directAccess (t Task ) {
276
+ func (a * App ) directAccess (t Task ) error {
275
277
operationName := "Disabling"
276
278
operation := "disable_direct_access"
277
279
if t .Enable == true {
@@ -282,13 +284,15 @@ func (a *App) directAccess(t Task) {
282
284
a .Config .RPAURL + "/fapi/rest/5_1/groups/%d/clusters/%d/copies/%d/%s" ,
283
285
t .GroupUID , t .ClusterUID , t .CopyUID , operation )
284
286
if ! a .Config .CheckMode {
285
- _ , statusCode := a .apiRequest ("PUT" , endpoint , nil )
287
+ body , statusCode := a .apiRequest ("PUT" , endpoint , nil )
286
288
if statusCode != 204 {
287
- log .Errorf ("Expected status code '204' and received: %d\n " , statusCode )
288
- log .Fatalf ("Error enabling Direct Access for Group %s Copy %s\n " , t .GroupName , t .CopyName )
289
+ log .Debugf ("Expected status code '204' and received: %d\n " , statusCode )
290
+ log .Warnf ("Error enabling Direct Access for Group %s Copy %s\n " , t .GroupName , t .CopyName )
291
+ return errors .New (string (body ))
289
292
}
290
293
}
291
294
fmt .Printf ("%s Direct Access for Group %s Copy %s\n " , operationName , t .GroupName , t .CopyName )
295
+ return nil
292
296
}
293
297
294
298
// EnableAll wraper for enabling Direct Image Access for all CG
@@ -317,7 +321,11 @@ func (a *App) EnableAll() {
317
321
continue
318
322
}
319
323
a .pollImageAccessEnabled (g .ID , true )
320
- a .directAccess (t )
324
+ err = a .directAccess (t )
325
+ if err != nil {
326
+ log .Warnf ("%s %s\n " , GroupName , err )
327
+ continue
328
+ }
321
329
}
322
330
time .Sleep (time .Duration (a .Config .Delay ) * time .Second )
323
331
}
@@ -347,7 +355,10 @@ func (a *App) EnableOne() {
347
355
return
348
356
}
349
357
a .pollImageAccessEnabled (groupID , true )
350
- a .directAccess (t )
358
+ err = a .directAccess (t )
359
+ if err != nil {
360
+ log .Warnf ("%s %s\n " , a .Group , err )
361
+ }
351
362
}
352
363
}
353
364
@@ -369,10 +380,15 @@ func (a *App) FinishAll() {
369
380
err := a .imageAccess (t )
370
381
if err != nil {
371
382
log .Warnf ("%s %s\n " , GroupName , err )
383
+ // continue as we cannot start transfer when image access does
384
+ // not update as expected.
372
385
continue
373
386
}
374
387
a .pollImageAccessEnabled (g .ID , false )
375
- a .startTransfer (t )
388
+ err = a .startTransfer (t )
389
+ if err != nil {
390
+ log .Warnf ("%s %s\n " , GroupName , err )
391
+ }
376
392
}
377
393
time .Sleep (time .Duration (a .Config .Delay ) * time .Second )
378
394
}
@@ -397,6 +413,9 @@ func (a *App) FinishOne() {
397
413
return
398
414
}
399
415
a .pollImageAccessEnabled (groupID , false )
400
- a .startTransfer (t )
416
+ err = a .startTransfer (t )
417
+ if err != nil {
418
+ log .Warnf ("%s %s\n " , a .Group , err )
419
+ }
401
420
}
402
421
}
0 commit comments