Skip to content

Commit 10cd081

Browse files
authored
Adding copyMode param in ModifySnapshot API (dell#58)
1 parent 274de89 commit 10cd081

File tree

4 files changed

+40
-17
lines changed

4 files changed

+40
-17
lines changed

interface.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,12 @@ type Pmax interface {
203203
// CreatePortGroup creates a port group given the Port Group id and a list of dir/port ids
204204
CreatePortGroup(ctx context.Context, symID string, portGroupID string, dirPorts []types.PortKey, protocol string) (*types.PortGroup, error)
205205

206-
// RenamePortGroup renames port group given it's identifier (which is the name)
206+
// RenamePortGroup renames port group given it is identifier (which is the name)
207207
RenamePortGroup(ctx context.Context, symID string, portGroupID string, newName string) (*types.PortGroup, error)
208208

209-
// System
209+
// GetSymmetrixIDList gets symmetrix list
210210
GetSymmetrixIDList(ctx context.Context) (*types.SymmetrixIDList, error)
211+
// GetSymmetrixByID gets symmetrix by given ID
211212
GetSymmetrixByID(ctx context.Context, id string) (*types.Symmetrix, error)
212213

213214
// GetJobIDList retrieves the list of jobs on a given Symmetrix.
@@ -288,12 +289,12 @@ type Pmax interface {
288289
// This creates a job and waits on its completion
289290
ModifySnapshot(ctx context.Context, symID string, sourceVol []types.VolumeList,
290291
targetVol []types.VolumeList, SnapID string, action string,
291-
newSnapID string, generation int64) error
292+
newSnapID string, generation int64, isCopy bool) error
292293

293294
// ModifySnapshotS executes actions on a snapshot synchronously
294295
ModifySnapshotS(ctx context.Context, symID string, sourceVol []types.VolumeList,
295296
targetVol []types.VolumeList, SnapID string, action string,
296-
newSnapID string, generation int64) error
297+
newSnapID string, generation int64, isCopy bool) error
297298
// DeleteSnapshot deletes a snapshot from a volume
298299
// This is an asynchronous call and waits for the job to complete
299300
DeleteSnapshot(ctx context.Context, symID, SnapID string, sourceVolumes []types.VolumeList, generation int64) error

inttest/pmax_replication_integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ func TestSnapshotLinkage(t *testing.T) {
434434
}
435435

436436
func modifySnapshotLink(sourceVolumeList, targetVolumeList []types.VolumeList, operation, snapshotName string, _ *testing.T) error {
437-
err := client.ModifySnapshot(context.TODO(), symmetrixID, sourceVolumeList, targetVolumeList, snapshotName, operation, "", 0)
437+
err := client.ModifySnapshot(context.TODO(), symmetrixID, sourceVolumeList, targetVolumeList, snapshotName, operation, "", 0, false)
438438
if err != nil {
439439
return fmt.Errorf("Error %sing snapshot(%s)", strings.ToLower(operation), snapshotName)
440440
}
@@ -499,7 +499,7 @@ func TestSnapshotRenaming(t *testing.T) {
499499
}
500500

501501
func renameSnapshot(symmetrixID, snapshotName, newSnapID string, _ int, sourceVolumeList, targetVolumeList []types.VolumeList) error {
502-
err := client.ModifySnapshot(context.TODO(), symmetrixID, sourceVolumeList, targetVolumeList, snapshotName, "Rename", newSnapID, 0)
502+
err := client.ModifySnapshot(context.TODO(), symmetrixID, sourceVolumeList, targetVolumeList, snapshotName, "Rename", newSnapID, 0, false)
503503
if err != nil {
504504
return fmt.Errorf("Error renaming snapshot: %s", err.Error())
505505
}

unit_steps_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,15 +1629,15 @@ func (c *unitContext) iShouldGetAGenerationInfoIfNoError() error {
16291629
func (c *unitContext) iCallModifySnapshotWithAnd(sourceVols, targetVols, SnapID, newSnapID string, genID int64, action string) error {
16301630
sourceVolumeList := c.createVolumeList(sourceVols)
16311631
targetVolumeList := c.createVolumeList(targetVols)
1632-
c.err = c.client.ModifySnapshot(context.TODO(), symID, sourceVolumeList, targetVolumeList, SnapID, action, newSnapID, genID)
1632+
c.err = c.client.ModifySnapshot(context.TODO(), symID, sourceVolumeList, targetVolumeList, SnapID, action, newSnapID, genID, false)
16331633

16341634
return nil
16351635
}
16361636

16371637
func (c *unitContext) iCallModifySnapshotSWithAnd(sourceVols, targetVols, SnapID, newSnapID string, genID int64, action string) error {
16381638
sourceVolumeList := c.createVolumeList(sourceVols)
16391639
targetVolumeList := c.createVolumeList(targetVols)
1640-
c.err = c.client.ModifySnapshotS(context.TODO(), symID, sourceVolumeList, targetVolumeList, SnapID, action, newSnapID, genID)
1640+
c.err = c.client.ModifySnapshotS(context.TODO(), symID, sourceVolumeList, targetVolumeList, SnapID, action, newSnapID, genID, false)
16411641

16421642
return nil
16431643
}

volume_snapshot.go

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,19 +252,19 @@ func (c *Client) DeleteSnapshotS(ctx context.Context, symID, snapID string, sour
252252
// VolumeNameListSource is a list which contains the names of source volumes
253253
// VolumeNameListTarget is a list which contains the names of target volumes to which the snapshot is linked or going to be linked
254254
// Symforce flag is used to automate some internal establish scenarios
255-
//  Star mode is used for devices in SRDF relations
256-
//  Use the Force flag in acceptable error conditions
255+
// Star mode is used for devices in SRDF relations
256+
// Use the Force flag in acceptable error conditions
257257
// Restore, when set to true will terminate the Restore and the Snapshot as well
258258
// Exact when specified, pairs source and link devices in their ordinal positions within the selection. When not set uses the source and link device selections as a pool that pairs by best match
259259
// Copy when specified creates an exact copy of the source device, otherwise copies the references
260260
// Remote when specified propagates the data to the remote mirror of the RDF device
261-
//  Generation is used to tell which generation of snapshot needs to be updated, it is passed as int64
261+
// Generation is used to tell which generation of snapshot needs to be updated, it is passed as int64
262262
// NewSnapshotName specifies the new snapshot name to which the old snapshot will be renamed
263263
// ExecutionOption tells the Unisphere to perform the operation either in Synchronous mode or Asynchronous mode
264264
// Action defined the operation which will be performed on the given snapshot
265265
func (c *Client) ModifySnapshot(ctx context.Context, symID string, sourceVol []types.VolumeList,
266266
targetVol []types.VolumeList, snapID string, action string,
267-
newSnapID string, generation int64,
267+
newSnapID string, generation int64, isCopy bool,
268268
) error {
269269
defer c.TimeSpent("ModifySnapshot", time.Now())
270270
if _, err := c.IsAllowedArray(symID); err != nil {
@@ -274,20 +274,31 @@ func (c *Client) ModifySnapshot(ctx context.Context, symID string, sourceVol []t
274274
snapParam := &types.ModifyVolumeSnapshot{}
275275

276276
switch action {
277-
case "Link", "Unlink":
277+
case "Link":
278278
snapParam = &types.ModifyVolumeSnapshot{
279279
VolumeNameListSource: sourceVol,
280280
VolumeNameListTarget: targetVol,
281281
Force: false,
282282
Star: false,
283283
Exact: false,
284-
Copy: false,
284+
Copy: isCopy,
285285
Remote: false,
286286
Symforce: false,
287287
Action: action,
288288
Generation: generation,
289289
ExecutionOption: types.ExecutionOptionAsynchronous,
290290
}
291+
case "Unlink":
292+
snapParam = &types.ModifyVolumeSnapshot{
293+
VolumeNameListSource: sourceVol,
294+
VolumeNameListTarget: targetVol,
295+
Force: false,
296+
Star: false,
297+
Symforce: false,
298+
Action: action,
299+
Generation: generation,
300+
ExecutionOption: types.ExecutionOptionAsynchronous,
301+
}
291302
case "Rename":
292303
snapParam = &types.ModifyVolumeSnapshot{
293304
VolumeNameListSource: sourceVol,
@@ -326,7 +337,7 @@ func (c *Client) ModifySnapshot(ctx context.Context, symID string, sourceVol []t
326337
// ModifySnapshotS executes actions on snapshots synchronously
327338
func (c *Client) ModifySnapshotS(ctx context.Context, symID string, sourceVol []types.VolumeList,
328339
targetVol []types.VolumeList, snapID string, action string,
329-
newSnapID string, generation int64,
340+
newSnapID string, generation int64, isCopy bool,
330341
) error {
331342
defer c.TimeSpent("ModifySnapshotS", time.Now())
332343

@@ -337,20 +348,31 @@ func (c *Client) ModifySnapshotS(ctx context.Context, symID string, sourceVol []
337348
snapParam := &types.ModifyVolumeSnapshot{}
338349

339350
switch action {
340-
case "Link", "Unlink":
351+
case "Link":
341352
snapParam = &types.ModifyVolumeSnapshot{
342353
VolumeNameListSource: sourceVol,
343354
VolumeNameListTarget: targetVol,
344355
Force: false,
345356
Star: false,
346357
Exact: false,
347-
Copy: false,
358+
Copy: isCopy,
348359
Remote: false,
349360
Symforce: false,
350361
Action: action,
351362
Generation: generation,
352363
ExecutionOption: types.ExecutionOptionSynchronous,
353364
}
365+
case "Unlink":
366+
snapParam = &types.ModifyVolumeSnapshot{
367+
VolumeNameListSource: sourceVol,
368+
VolumeNameListTarget: targetVol,
369+
Force: false,
370+
Star: false,
371+
Symforce: false,
372+
Action: action,
373+
Generation: generation,
374+
ExecutionOption: types.ExecutionOptionSynchronous,
375+
}
354376
case "Rename":
355377
snapParam = &types.ModifyVolumeSnapshot{
356378
VolumeNameListSource: sourceVol,

0 commit comments

Comments
 (0)