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

RCG Actions #136

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
63 changes: 62 additions & 1 deletion inttests/replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,67 @@ func TestExecuteResumeOnReplicationGroup(t *testing.T) {
assert.Nil(t, err)
}

// Test TestSetRPOOnReplicationGroup
func TestSetRPOOnReplicationGroup(t *testing.T) {
// Set the RCG context
TestGetReplicationConsistencyGroups(t)
// Update the RPO
err := rep.rcg.SetRPOOnReplicationGroup(siotypes.SetRPOReplicationConsistencyGroup{RpoInSeconds: "60"})
assert.Nil(t, err)
}

// Test TestSetTargetVolumeAccessModeOnReplicationGroup
func TestSetTargetVolumeAccessModeOnReplicationGroup(t *testing.T) {
// Set the RCG context
TestGetReplicationConsistencyGroups(t)
err := rep.rcg.SetTargetVolumeAccessModeOnReplicationGroup(siotypes.SetTargetVolumeAccessModeOnReplicationGroup{TargetVolumeAccessMode: "ReadOnly"})
assert.Nil(t, err)
}

// Test TestSetNewNameOnReplicationGroup
func TestSetNewNameOnReplicationGroup(t *testing.T) {
// Set the RCG context
TestGetReplicationConsistencyGroups(t)
err := rep.rcg.SetNewNameOnReplicationGroup(siotypes.SetNewNameOnReplicationGroup{NewName: "UpdatedNameRCG"})
assert.Nil(t, err)
// Sleep for 10 to make sure the name is updated, then update it back to the original name
time.Sleep(10 * time.Second)
err = rep.rcg.SetNewNameOnReplicationGroup(siotypes.SetNewNameOnReplicationGroup{NewName: "inttestrcg"})
assert.Nil(t, err)
}

// Test TestExecuteInconsistentOnReplicationGroup
func TestExecuteInconsistentOnReplicationGroup(t *testing.T) {
// Set the RCG context
TestGetReplicationConsistencyGroups(t)
err := rep.rcg.ExecuteInconsistentOnReplicationGroup()
assert.Nil(t, err)
}

// Test TestExecuteConsistentOnReplicationGroup
func TestExecuteConsistentOnReplicationGroup(t *testing.T) {
// Set the RCG context
TestGetReplicationConsistencyGroups(t)
err := rep.rcg.ExecuteConsistentOnReplicationGroup()
assert.Nil(t, err)
}

// Test TestExecuteTerminateOnReplicationGroup
func TestExecuteTerminateOnReplicationGroup(t *testing.T) {
// Set the RCG context
TestGetReplicationConsistencyGroups(t)
err := rep.rcg.ExecuteTerminateOnReplicationGroup()
assert.Nil(t, err)
}

// Test TestExecuteActivateOnReplicationGroup
func TestExecuteActivateOnReplicationGroup(t *testing.T) {
// Set the RCG context
TestGetReplicationConsistencyGroups(t)
err := rep.rcg.ExecuteActivateOnReplicationGroup()
assert.Nil(t, err)
}

// Test ResizeReplicationPair
func TestResizeReplicationPair(t *testing.T) {
if C2 == nil {
Expand Down Expand Up @@ -605,7 +666,7 @@ func TestRemoveReplicationConsistencyGroup(t *testing.T) {
if C2 == nil {
t.Skip("no client connection to replication target system")
}

TestGetReplicationConsistencyGroups(t)
assert.NotNil(t, rep.rcg)

err := rep.rcg.RemoveReplicationConsistencyGroup(false)
Expand Down
74 changes: 74 additions & 0 deletions replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,80 @@ func (rcg *ReplicationConsistencyGroup) ExecuteSyncOnReplicationGroup() (*types.
return resp, err
}

// SetRPOOnReplicationGroup on the ConsistencyGroup.
func (rcg *ReplicationConsistencyGroup) SetRPOOnReplicationGroup(param types.SetRPOReplicationConsistencyGroup) error {
defer TimeSpent("SetRPOOnReplicationGroup", time.Now())

uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/ModifyReplicationConsistencyGroupRpo"

err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil)
return err
}

// SetTargetVolumeAccessModeOnReplicationGroup on the ConsistencyGroup.
func (rcg *ReplicationConsistencyGroup) SetTargetVolumeAccessModeOnReplicationGroup(param types.SetTargetVolumeAccessModeOnReplicationGroup) error {
defer TimeSpent("SetTargetVolumeAccessModeOnReplicationGroup", time.Now())

uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/modifyReplicationConsistencyGroupTargetVolumeAccessMode"

err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil)
return err
}

// SetNewNameOnReplicationGroup on the ConsistencyGroup.
func (rcg *ReplicationConsistencyGroup) SetNewNameOnReplicationGroup(param types.SetNewNameOnReplicationGroup) error {
defer TimeSpent("SetNewNameOnReplicationGroup", time.Now())

uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/renameReplicationConsistencyGroup"

err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil)
return err
}

// ExecuteConsistentOnReplicationGroup on the ConsistencyGroup.
func (rcg *ReplicationConsistencyGroup) ExecuteConsistentOnReplicationGroup() error {
defer TimeSpent("ExecuteConsistentOnReplicationGroup", time.Now())

uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/setReplicationConsistencyGroupConsistent"
param := types.EmptyPayload{}

err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil)
return err
}

// ExecuteInconsistentOnReplicationGroup on the ConsistencyGroup.
func (rcg *ReplicationConsistencyGroup) ExecuteInconsistentOnReplicationGroup() error {
defer TimeSpent("ExecuteInconsistentOnReplicationGroup", time.Now())

uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/setReplicationConsistencyGroupInconsistent"
param := types.EmptyPayload{}

err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil)
return err
}

// ExecuteActivateOnReplicationGroup on the ConsistencyGroup.
func (rcg *ReplicationConsistencyGroup) ExecuteActivateOnReplicationGroup() error {
defer TimeSpent("ExecuteActivateOnReplicationGroup", time.Now())

uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/activateReplicationConsistencyGroup"
param := types.EmptyPayload{}

err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil)
return err
}

// ExecuteTerminateOnReplicationGroup on the ConsistencyGroup.
func (rcg *ReplicationConsistencyGroup) ExecuteTerminateOnReplicationGroup() error {
defer TimeSpent("ExecuteTerminateOnReplicationGroup", time.Now())

uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/terminateReplicationConsistencyGroup"
param := types.EmptyPayload{}

err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil)
return err
}

// GetSyncStateOnReplicationGroup returns the sync status of the ReplicaitonConsistencyGroup.
func (rcg *ReplicationConsistencyGroup) GetSyncStateOnReplicationGroup(syncKey string) error {
defer TimeSpent("ExecuteSyncOnReplicationGroup", time.Now())
Expand Down
33 changes: 33 additions & 0 deletions types/v1/replication.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* Copyright © 2020-2024 Dell Inc. or its subsidiaries. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package goscaleio

// PauseMode states in which the ConsistencyGroup can be set to when Paused.
Expand All @@ -14,6 +32,21 @@ type PauseReplicationConsistencyGroup struct {
PauseMode string `json:"pauseMode"`
}

// SetRPOReplicationConsistencyGroup defines struct for SetRPOReplicationConsistencyGroup.
type SetRPOReplicationConsistencyGroup struct {
RpoInSeconds string `json:"rpoInSeconds"`
}

// SetTargetVolumeAccessModeOnReplicationGroup defines struct for SetTargetVolumeAccessModeOnReplicationGroup.
type SetTargetVolumeAccessModeOnReplicationGroup struct {
TargetVolumeAccessMode string `json:"targetVolumeAccessMode"`
}

// SetNewNameOnReplicationGroup defines struct for SetNewNameOnReplicationGroup.
type SetNewNameOnReplicationGroup struct {
NewName string `json:"newName"`
}

// SynchronizationResponse defines struct for SynchronizationResponse.
type SynchronizationResponse struct {
SyncNowKey string `json:"syncNowKey"`
Expand Down