Skip to content

Commit f8cf9ef

Browse files
divyenpateldougm
authored andcommitted
correct SetControlFlags and ClearControlFlags APIs
1 parent 285e80c commit f8cf9ef

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

vslm/client_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ import (
2424

2525
"github.com/vmware/govmomi"
2626
"github.com/vmware/govmomi/cns"
27-
cnstypes "github.com/vmware/govmomi/cns/types"
2827
"github.com/vmware/govmomi/vim25/soap"
28+
"github.com/vmware/govmomi/vim25/types"
29+
30+
cnstypes "github.com/vmware/govmomi/cns/types"
2931
)
3032

3133
func TestClient(t *testing.T) {
@@ -116,4 +118,15 @@ func TestClient(t *testing.T) {
116118
volumeCreateResult := (createTaskResult).(*cnstypes.CnsVolumeCreateResult)
117119
t.Logf("volumeCreateResult %+v", volumeCreateResult)
118120
t.Logf("Volume created sucessfully. volumeId: %s", volumeId)
121+
122+
err = globalObjectManager.SetControlFlags(ctx, types.ID{Id: volumeId}, []string{"FCD_KEEP_AFTER_DELETE_VM"})
123+
if err != nil {
124+
t.Fatal(err)
125+
}
126+
t.Logf("Control flag: FCD_KEEP_AFTER_DELETE_VM set for the volumeId: %s", volumeId)
127+
err = globalObjectManager.ClearControlFlags(ctx, types.ID{Id: volumeId})
128+
if err != nil {
129+
t.Fatal(err)
130+
}
131+
t.Logf("Control flags removed the volumeId: %s", volumeId)
119132
}

vslm/global_object_manager.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,10 @@ func (this *GlobalObjectManager) Relocate(ct context.Context, id vim.ID, spec vi
345345
return NewTask(this.c, res.Returnval), nil
346346
}
347347

348-
func (this *GlobalObjectManager) SetControlFlags(ct context.Context, controlFlags []string) error {
348+
func (this *GlobalObjectManager) SetControlFlags(ct context.Context, id vim.ID, controlFlags []string) error {
349349
req := types.VslmSetVStorageObjectControlFlags{
350350
This: this.Reference(),
351+
Id: id,
351352
ControlFlags: controlFlags,
352353
}
353354

@@ -359,9 +360,10 @@ func (this *GlobalObjectManager) SetControlFlags(ct context.Context, controlFlag
359360
return nil
360361
}
361362

362-
func (this *GlobalObjectManager) ClearControlFlags(ct context.Context) error {
363+
func (this *GlobalObjectManager) ClearControlFlags(ct context.Context, id vim.ID) error {
363364
req := types.VslmClearVStorageObjectControlFlags{
364365
This: this.Reference(),
366+
Id: id,
365367
}
366368

367369
_, err := methods.VslmClearVStorageObjectControlFlags(ct, this.c, &req)

0 commit comments

Comments
 (0)