@@ -214,19 +214,19 @@ func (a *App) startTransfer(t Task) error {
214
214
body , statusCode := a .apiRequest ("PUT" , endpoint , nil )
215
215
if statusCode != 204 {
216
216
log .Debugf ("Expected status code '204' and received: %d\n " , statusCode )
217
- log .Warnf ("Error Starting Transfer for Group %s Copy %s\n " , t .GroupName , t .CopyName )
217
+ log .Warnf ("%s - Error Starting Transfer for Copy %s\n " , t .GroupName , t .CopyName )
218
218
return errors .New (string (body ))
219
219
}
220
220
}
221
- fmt .Printf ("Starting Transfer for Group %s Copy %s\n " , t .GroupName , t .CopyName )
221
+ fmt .Printf ("%s - Starting Transfer for Copy %s\n " , t .GroupName , t .CopyName )
222
222
return nil
223
223
}
224
224
225
225
func (a * App ) imageAccess (t Task ) error {
226
- operationName := "Disabling "
226
+ operationName := "Disabled "
227
227
operation := "disable_image_access"
228
228
if t .Enable == true {
229
- operationName = "Enabling "
229
+ operationName = "Enabled "
230
230
operation = "image_access/latest/enable"
231
231
}
232
232
endpoint := fmt .Sprintf (
@@ -249,41 +249,40 @@ func (a *App) imageAccess(t Task) error {
249
249
return errors .New (string (body ))
250
250
}
251
251
}
252
- fmt .Printf ("%s Latest Image for Group %s Copy %s\n " , operationName , t .GroupName , t .CopyName )
252
+ fmt .Printf ("%s - %s Latest Image for Group Copy %s\n " , t .GroupName , operationName , t .CopyName )
253
253
return nil
254
254
}
255
255
256
- func (a * App ) pollImageAccessEnabled (groupID int , stateDesired bool ) {
256
+ func (a * App ) pollImageAccessEnabled (groupID int , groupName string , stateDesired bool ) {
257
257
pollDelay := a .Config .PollDelay // seconds
258
258
pollMax := a .Config .PollMax // max times to poll before breaking the poll loop
259
259
pollCount := 0 // iteration counter
260
260
261
- fmt .Println ( "waiting for image access to update.." )
261
+ fmt .Printf ( "%s - Waiting for image access to update..\n " , groupName )
262
262
groupCopiesSettings := a .getGroupCopiesSettings (groupID )
263
263
copySettings := a .getRequestedCopy (groupCopiesSettings )
264
264
for copySettings .ImageAccessInformation .ImageAccessEnabled != stateDesired {
265
265
log .Debug ("polling - image access enabled: " , copySettings .ImageAccessInformation .ImageAccessEnabled )
266
- log .Debug ("polling - image logged access mode: " , copySettings .ImageAccessInformation .ImageInformation .Mode )
267
266
time .Sleep (time .Duration (pollDelay ) * time .Second )
268
267
groupCopiesSettings = a .getGroupCopiesSettings (groupID )
269
268
copySettings = a .getRequestedCopy (groupCopiesSettings )
270
269
if pollCount > pollMax {
271
- fmt .Println ("Maximum poll count reached while waiting for image access" )
270
+ fmt .Println ("Maximum poll count reached while waiting for image access. Consider increasing 'pollmax' in configuration " )
272
271
break
273
272
}
274
273
pollCount ++
275
274
}
275
+ pollCount = 0 // reset counter before polling for logged access
276
276
if stateDesired == true {
277
277
// if the desired state is to have image access == true, we should ensure that logged access is also
278
278
// set before continuing. This seems to take a few seconds longer.. so we will continue polling for mode.
279
279
for copySettings .ImageAccessInformation .ImageInformation .Mode != "LOGGED_ACCESS" {
280
- log .Debug ("polling image access enabled: " , copySettings .ImageAccessInformation .ImageAccessEnabled )
281
280
log .Debug ("polling image logged access mode: " , copySettings .ImageAccessInformation .ImageInformation .Mode )
282
281
time .Sleep (time .Duration (pollDelay ) * time .Second )
283
282
groupCopiesSettings = a .getGroupCopiesSettings (groupID )
284
283
copySettings = a .getRequestedCopy (groupCopiesSettings )
285
284
if pollCount > pollMax {
286
- fmt .Println ("Maximum poll count reached while waiting for logged access" )
285
+ fmt .Println ("Maximum poll count reached while waiting for logged access. Consider increasing 'pollmax' in configuration " )
287
286
break
288
287
}
289
288
pollCount ++
@@ -298,10 +297,10 @@ func (a *App) directAccess(t Task) error {
298
297
pollMax := a .Config .PollMax // max times to poll before breaking the poll loop
299
298
pollCount := 0 // iteration counter
300
299
301
- operationName := "Disabling"
300
+ operationName := "Disabl" // suffix is appended based on message
302
301
operation := "disable_direct_access"
303
302
if t .Enable == true {
304
- operationName = "Enabling"
303
+ operationName = "Enabl" // suffix is appended based on message
305
304
operation = "enable_direct_access"
306
305
}
307
306
endpoint := fmt .Sprintf (
@@ -314,14 +313,14 @@ func (a *App) directAccess(t Task) error {
314
313
time .Sleep (time .Duration (pollDelay ) * time .Second )
315
314
body , statusCode = a .apiRequest ("PUT" , endpoint , nil )
316
315
if pollCount > pollMax {
317
- fmt . Println ( " Maximum poll count reached while waiting for direct access" )
318
- log .Warnf ("Error %s Direct Access for Group %s Copy %s\n " , operationName , t .GroupName , t .CopyName )
316
+ log . Warnf ( "%s - Maximum poll count reached while waiting for direct access\n " , t . GroupName )
317
+ log .Warnf ("%s - Error %sing Direct Access for Copy %s\n " , t .GroupName , operationName , t .CopyName )
319
318
return errors .New (string (body ))
320
319
}
321
320
pollCount ++
322
321
}
323
322
}
324
- fmt .Printf ("%s Direct Access for Group %s Copy %s\n " , operationName , t .GroupName , t .CopyName )
323
+ fmt .Printf ("%s - %sed Direct Access for Copy %s\n " , t .GroupName , operationName , t .CopyName )
325
324
return nil
326
325
}
327
326
@@ -331,15 +330,15 @@ func (a *App) EnableAll() {
331
330
groups := a .getAllGroups ()
332
331
for _ , g := range groups {
333
332
var t Task
334
- GroupName := a .getGroupName (g .ID )
333
+ groupName := a .getGroupName (g .ID )
335
334
groupCopiesSettings := a .getGroupCopiesSettings (g .ID )
336
335
copySettings := a .getRequestedCopy (groupCopiesSettings )
337
336
// skip if copy is already 'enabled'
338
337
if copySettings .RoleInfo .Role == "ACTIVE" {
339
- fmt .Printf ("Image Access already enabled for %s -> %s\n " , a .Group , copySettings .Name )
338
+ fmt .Printf ("%s - Image Access already enabled for copy: %s\n " , a .Group , copySettings .Name )
340
339
continue
341
340
}
342
- t .GroupName = GroupName
341
+ t .GroupName = groupName
343
342
t .GroupUID = copySettings .CopyUID .GroupUID .ID
344
343
t .ClusterUID = copySettings .CopyUID .GlobalCopyUID .ClusterUID .ID
345
344
t .CopyName = copySettings .Name
@@ -348,13 +347,13 @@ func (a *App) EnableAll() {
348
347
if ! a .Config .CheckMode {
349
348
err := a .imageAccess (t )
350
349
if err != nil {
351
- log .Warnf ("%s %s\n " , GroupName , err )
350
+ log .Warnf ("%s - %s\n " , groupName , err )
352
351
continue
353
352
}
354
- a .pollImageAccessEnabled (g .ID , true )
353
+ a .pollImageAccessEnabled (g .ID , groupName , true )
355
354
err = a .directAccess (t )
356
355
if err != nil {
357
- log .Warnf ("%s %s\n " , GroupName , err )
356
+ log .Warnf ("%s - %s\n " , groupName , err )
358
357
continue
359
358
}
360
359
}
@@ -373,7 +372,7 @@ func (a *App) EnableOne() {
373
372
copySettings := a .getRequestedCopy (groupCopiesSettings )
374
373
// skip if copy is already 'enabled'
375
374
if copySettings .RoleInfo .Role == "ACTIVE" {
376
- fmt .Printf ("Image Access already enabled for %s -> %s\n " , a .Group , copySettings .Name )
375
+ fmt .Printf ("%s - Image Access already enabled for copy: %s\n " , a .Group , copySettings .Name )
377
376
return
378
377
}
379
378
t .GroupName = a .Group
@@ -385,13 +384,13 @@ func (a *App) EnableOne() {
385
384
if ! a .Config .CheckMode {
386
385
err := a .imageAccess (t )
387
386
if err != nil {
388
- log .Warnf ("%s %s\n " , a .Group , err )
387
+ log .Warnf ("%s - %s\n " , a .Group , err )
389
388
return
390
389
}
391
- a .pollImageAccessEnabled (groupID , true )
390
+ a .pollImageAccessEnabled (groupID , a . Group , true )
392
391
err = a .directAccess (t )
393
392
if err != nil {
394
- log .Warnf ("%s %s\n " , a .Group , err )
393
+ log .Warnf ("%s - %s\n " , a .Group , err )
395
394
}
396
395
}
397
396
elapsed := time .Since (start )
@@ -404,10 +403,10 @@ func (a *App) FinishAll() {
404
403
groups := a .getAllGroups ()
405
404
for _ , g := range groups {
406
405
var t Task
407
- GroupName := a .getGroupName (g .ID )
406
+ groupName := a .getGroupName (g .ID )
408
407
groupCopiesSettings := a .getGroupCopiesSettings (g .ID )
409
408
copySettings := a .getRequestedCopy (groupCopiesSettings )
410
- t .GroupName = GroupName
409
+ t .GroupName = groupName
411
410
t .GroupUID = copySettings .CopyUID .GroupUID .ID
412
411
t .ClusterUID = copySettings .CopyUID .GlobalCopyUID .ClusterUID .ID
413
412
t .CopyName = copySettings .Name
@@ -416,15 +415,15 @@ func (a *App) FinishAll() {
416
415
if ! a .Config .CheckMode {
417
416
err := a .imageAccess (t )
418
417
if err != nil {
419
- log .Warnf ("%s %s\n " , GroupName , err )
418
+ log .Warnf ("%s - %s\n " , groupName , err )
420
419
// continue as we cannot start transfer when image access does
421
420
// not update as expected.
422
421
continue
423
422
}
424
- a .pollImageAccessEnabled (g .ID , false )
423
+ a .pollImageAccessEnabled (g .ID , groupName , false )
425
424
err = a .startTransfer (t )
426
425
if err != nil {
427
- log .Warnf ("%s %s\n " , GroupName , err )
426
+ log .Warnf ("%s - %s\n " , groupName , err )
428
427
}
429
428
}
430
429
time .Sleep (time .Duration (a .Config .Delay ) * time .Second )
@@ -449,13 +448,13 @@ func (a *App) FinishOne() {
449
448
if ! a .Config .CheckMode {
450
449
err := a .imageAccess (t )
451
450
if err != nil {
452
- log .Warnf ("%s %s\n " , a .Group , err )
451
+ log .Warnf ("%s - %s\n " , a .Group , err )
453
452
return
454
453
}
455
- a .pollImageAccessEnabled (groupID , false )
454
+ a .pollImageAccessEnabled (groupID , a . Group , false )
456
455
err = a .startTransfer (t )
457
456
if err != nil {
458
- log .Warnf ("%s %s\n " , a .Group , err )
457
+ log .Warnf ("%s - %s\n " , a .Group , err )
459
458
}
460
459
}
461
460
elapsed := time .Since (start )
0 commit comments