Skip to content

Commit debe7c7

Browse files
committed
update json tags and add tests for syncvolume api
Signed-off-by: Nikhil Barge <[email protected]>
1 parent 385a5dc commit debe7c7

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

cns/client_test.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,34 +1763,34 @@ func TestClient(t *testing.T) {
17631763
t.Logf("syncDatastore on %v with full sync successful\n", dsUrl)
17641764

17651765
// Test CnsSyncVolume API
1766-
/*
1767-
t.Logf("Calling syncVolume for volumeId: %v ...\n", volumeId)
1768-
var cnsSyncVolumeSpecs []cnstypes.CnsSyncVolumeSpec
1769-
dataStore := ds.Reference()
1770-
cnsSyncVolumeSpec := cnstypes.CnsSyncVolumeSpec{
1771-
VolumeId: cnstypes.CnsVolumeId{
1772-
Id: volumeId,
1773-
},
1774-
Datastore: &dataStore,
1775-
SyncMode: []string{string(cnstypes.CnsSyncVolumeModeSPACE_USAGE)},
1776-
}
1777-
cnsSyncVolumeSpecs = append(cnsSyncVolumeSpecs, cnsSyncVolumeSpec)
1778-
syncVolumeTask, err := cnsClient.SyncVolume(ctx, cnsSyncVolumeSpecs)
1779-
if err != nil {
1780-
t.Errorf("Failed to sync volume %v. Error: %+v \n", volumeId, err)
1781-
t.Fatal(err)
1782-
}
1783-
syncVolumeTaskInfo, err := GetTaskInfo(ctx, syncVolumeTask)
1784-
if err != nil {
1785-
t.Errorf("Failed to get sync volume taskInfo. Error: %+v \n", err)
1786-
t.Fatal(err)
1787-
}
1788-
if syncVolumeTaskInfo.State != vim25types.TaskInfoStateSuccess {
1789-
t.Errorf("Failed to sync volume. Error: %+v \n", syncVolumeTaskInfo.Error)
1790-
t.Fatalf("%+v", syncVolumeTaskInfo.Error)
1791-
}
1792-
t.Logf("syncVolume for volumeId: %v successful...\n", volumeId)
1793-
*/
1766+
1767+
t.Logf("Calling syncVolume for volumeId: %v ...\n", volumeId)
1768+
var cnsSyncVolumeSpecs []cnstypes.CnsSyncVolumeSpec
1769+
dataStore := ds.Reference()
1770+
cnsSyncVolumeSpec := cnstypes.CnsSyncVolumeSpec{
1771+
VolumeId: cnstypes.CnsVolumeId{
1772+
Id: volumeId,
1773+
},
1774+
Datastore: &dataStore,
1775+
SyncMode: []string{string(cnstypes.CnsSyncVolumeModeSPACE_USAGE)},
1776+
}
1777+
1778+
cnsSyncVolumeSpecs = append(cnsSyncVolumeSpecs, cnsSyncVolumeSpec)
1779+
syncVolumeTask, err := cnsClient.SyncVolume(ctx, cnsSyncVolumeSpecs)
1780+
if err != nil {
1781+
t.Errorf("Failed to sync volume %v. Error: %+v \n", volumeId, err)
1782+
t.Fatal(err)
1783+
}
1784+
syncVolumeTaskInfo, err := GetTaskInfo(ctx, syncVolumeTask)
1785+
if err != nil {
1786+
t.Errorf("Failed to get sync volume taskInfo. Error: %+v \n", err)
1787+
t.Fatal(err)
1788+
}
1789+
if syncVolumeTaskInfo.State != vim25types.TaskInfoStateSuccess {
1790+
t.Errorf("Failed to sync volume. Error: %+v \n", syncVolumeTaskInfo.Error)
1791+
t.Fatalf("%+v", syncVolumeTaskInfo.Error)
1792+
}
1793+
t.Logf("syncVolume for volumeId: %v successful...\n", volumeId)
17941794

17951795
}
17961796

cns/types/types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -964,24 +964,24 @@ func init() {
964964
}
965965

966966
type CnsSyncVolumeRequestType struct {
967-
This types.ManagedObjectReference `xml:"_this"`
968-
SyncSpecs []CnsSyncVolumeSpec `xml:"syncSpecs,omitempty"`
967+
This types.ManagedObjectReference `xml:"_this" json:"-"`
968+
SyncSpecs []CnsSyncVolumeSpec `xml:"syncSpecs,omitempty" json:"syncSpecs,omitempty"`
969969
}
970970

971971
func init() {
972972
types.Add("vsan:CnsSyncVolumeRequestType", reflect.TypeOf((*CnsSyncVolumeRequestType)(nil)).Elem())
973973
}
974974

975975
type CnsSyncVolumeResponse struct {
976-
Returnval types.ManagedObjectReference `xml:"returnval"`
976+
Returnval types.ManagedObjectReference `xml:"returnval" json:"returnval"`
977977
}
978978

979979
type CnsSyncVolumeSpec struct {
980980
types.DynamicData
981981

982-
VolumeId CnsVolumeId `xml:"volumeId"`
983-
Datastore *types.ManagedObjectReference `xml:"datastore,omitempty"`
984-
SyncMode []string `xml:"syncMode,omitempty"`
982+
VolumeId CnsVolumeId `xml:"volumeId" json:"volumeId"`
983+
Datastore *types.ManagedObjectReference `xml:"datastore,omitempty" json:"datastore,omitempty"`
984+
SyncMode []string `xml:"syncMode,omitempty" json:"syncMode,omitempty"`
985985
}
986986

987987
func init() {

0 commit comments

Comments
 (0)