Skip to content

Commit 9617bde

Browse files
committed
examples: add HostConfigManager_OptionManager
1 parent 4f18692 commit 9617bde

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

object/example_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,3 +615,51 @@ func ExampleVirtualMachine_resourcePoolOwner() {
615615
})
616616
// Output: ClusterComputeResource
617617
}
618+
619+
func ExampleHostConfigManager_OptionManager() {
620+
simulator.Run(func(ctx context.Context, c *vim25.Client) error {
621+
m := view.NewManager(c)
622+
kind := []string{"HostSystem"}
623+
624+
v, err := m.CreateContainerView(ctx, c.ServiceContent.RootFolder, kind, true)
625+
if err != nil {
626+
log.Fatal(err)
627+
}
628+
629+
refs, err := v.Find(ctx, kind, nil)
630+
if err != nil {
631+
return err
632+
}
633+
634+
setting := ""
635+
636+
for _, ref := range refs {
637+
host := object.NewHostSystem(c, ref)
638+
m, err := host.ConfigManager().OptionManager(ctx)
639+
if err != nil {
640+
return err
641+
}
642+
643+
opt := []types.BaseOptionValue{&types.OptionValue{
644+
Key: "vcrun",
645+
Value: "Config.HostAgent.plugins.hostsvc.esxAdminsGroup",
646+
}}
647+
648+
err = m.Update(ctx, opt)
649+
if err != nil {
650+
return err
651+
}
652+
653+
opt, err = m.Query(ctx, "vcrun")
654+
if err != nil {
655+
return err
656+
}
657+
setting = opt[0].GetOptionValue().Value.(string)
658+
}
659+
660+
fmt.Println(setting)
661+
662+
return v.Destroy(ctx)
663+
})
664+
// Output: Config.HostAgent.plugins.hostsvc.esxAdminsGroup
665+
}

0 commit comments

Comments
 (0)