Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding copyMode param in ModifySnapshot API #58

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,12 @@ type Pmax interface {
// CreatePortGroup creates a port group given the Port Group id and a list of dir/port ids
CreatePortGroup(ctx context.Context, symID string, portGroupID string, dirPorts []types.PortKey, protocol string) (*types.PortGroup, error)

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

// System
// GetSymmetrixIDList gets symmetrix list
GetSymmetrixIDList(ctx context.Context) (*types.SymmetrixIDList, error)
// GetSymmetrixByID gets symmetrix by given ID
GetSymmetrixByID(ctx context.Context, id string) (*types.Symmetrix, error)

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

// ModifySnapshotS executes actions on a snapshot synchronously
ModifySnapshotS(ctx context.Context, symID string, sourceVol []types.VolumeList,
targetVol []types.VolumeList, SnapID string, action string,
newSnapID string, generation int64) error
newSnapID string, generation int64, isCopy bool) error
// DeleteSnapshot deletes a snapshot from a volume
// This is an asynchronous call and waits for the job to complete
DeleteSnapshot(ctx context.Context, symID, SnapID string, sourceVolumes []types.VolumeList, generation int64) error
Expand Down
4 changes: 2 additions & 2 deletions inttest/pmax_replication_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func TestSnapshotLinkage(t *testing.T) {
}

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

func renameSnapshot(symmetrixID, snapshotName, newSnapID string, _ int, sourceVolumeList, targetVolumeList []types.VolumeList) error {
err := client.ModifySnapshot(context.TODO(), symmetrixID, sourceVolumeList, targetVolumeList, snapshotName, "Rename", newSnapID, 0)
err := client.ModifySnapshot(context.TODO(), symmetrixID, sourceVolumeList, targetVolumeList, snapshotName, "Rename", newSnapID, 0, false)
if err != nil {
return fmt.Errorf("Error renaming snapshot: %s", err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions unit_steps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1629,15 +1629,15 @@ func (c *unitContext) iShouldGetAGenerationInfoIfNoError() error {
func (c *unitContext) iCallModifySnapshotWithAnd(sourceVols, targetVols, SnapID, newSnapID string, genID int64, action string) error {
sourceVolumeList := c.createVolumeList(sourceVols)
targetVolumeList := c.createVolumeList(targetVols)
c.err = c.client.ModifySnapshot(context.TODO(), symID, sourceVolumeList, targetVolumeList, SnapID, action, newSnapID, genID)
c.err = c.client.ModifySnapshot(context.TODO(), symID, sourceVolumeList, targetVolumeList, SnapID, action, newSnapID, genID, false)

return nil
}

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

return nil
}
Expand Down
40 changes: 31 additions & 9 deletions volume_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,19 @@ func (c *Client) DeleteSnapshotS(ctx context.Context, symID, snapID string, sour
// VolumeNameListSource is a list which contains the names of source volumes
// VolumeNameListTarget is a list which contains the names of target volumes to which the snapshot is linked or going to be linked
// Symforce flag is used to automate some internal establish scenarios
//  Star mode is used for devices in SRDF relations
//  Use the Force flag in acceptable error conditions
// Star mode is used for devices in SRDF relations
// Use the Force flag in acceptable error conditions
// Restore, when set to true will terminate the Restore and the Snapshot as well
// 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
// Copy when specified creates an exact copy of the source device, otherwise copies the references
// Remote when specified propagates the data to the remote mirror of the RDF device
//  Generation is used to tell which generation of snapshot needs to be updated, it is passed as int64
// Generation is used to tell which generation of snapshot needs to be updated, it is passed as int64
// NewSnapshotName specifies the new snapshot name to which the old snapshot will be renamed
// ExecutionOption tells the Unisphere to perform the operation either in Synchronous mode or Asynchronous mode
// Action defined the operation which will be performed on the given snapshot
func (c *Client) ModifySnapshot(ctx context.Context, symID string, sourceVol []types.VolumeList,
targetVol []types.VolumeList, snapID string, action string,
newSnapID string, generation int64,
newSnapID string, generation int64, isCopy bool,
) error {
defer c.TimeSpent("ModifySnapshot", time.Now())
if _, err := c.IsAllowedArray(symID); err != nil {
Expand All @@ -274,20 +274,31 @@ func (c *Client) ModifySnapshot(ctx context.Context, symID string, sourceVol []t
snapParam := &types.ModifyVolumeSnapshot{}

switch action {
case "Link", "Unlink":
case "Link":
snapParam = &types.ModifyVolumeSnapshot{
VolumeNameListSource: sourceVol,
VolumeNameListTarget: targetVol,
Force: false,
Star: false,
Exact: false,
Copy: false,
Copy: isCopy,
Remote: false,
Symforce: false,
Action: action,
Generation: generation,
ExecutionOption: types.ExecutionOptionAsynchronous,
}
case "Unlink":
snapParam = &types.ModifyVolumeSnapshot{
VolumeNameListSource: sourceVol,
VolumeNameListTarget: targetVol,
Force: false,
Star: false,
Symforce: false,
Action: action,
Generation: generation,
ExecutionOption: types.ExecutionOptionAsynchronous,
}
case "Rename":
snapParam = &types.ModifyVolumeSnapshot{
VolumeNameListSource: sourceVol,
Expand Down Expand Up @@ -326,7 +337,7 @@ func (c *Client) ModifySnapshot(ctx context.Context, symID string, sourceVol []t
// ModifySnapshotS executes actions on snapshots synchronously
func (c *Client) ModifySnapshotS(ctx context.Context, symID string, sourceVol []types.VolumeList,
targetVol []types.VolumeList, snapID string, action string,
newSnapID string, generation int64,
newSnapID string, generation int64, isCopy bool,
) error {
defer c.TimeSpent("ModifySnapshotS", time.Now())

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

switch action {
case "Link", "Unlink":
case "Link":
snapParam = &types.ModifyVolumeSnapshot{
VolumeNameListSource: sourceVol,
VolumeNameListTarget: targetVol,
Force: false,
Star: false,
Exact: false,
Copy: false,
Copy: isCopy,
Remote: false,
Symforce: false,
Action: action,
Generation: generation,
ExecutionOption: types.ExecutionOptionSynchronous,
}
case "Unlink":
snapParam = &types.ModifyVolumeSnapshot{
VolumeNameListSource: sourceVol,
VolumeNameListTarget: targetVol,
Force: false,
Star: false,
Symforce: false,
Action: action,
Generation: generation,
ExecutionOption: types.ExecutionOptionSynchronous,
}
case "Rename":
snapParam = &types.ModifyVolumeSnapshot{
VolumeNameListSource: sourceVol,
Expand Down
Loading