Move routines to subcommands;Add initial logic for datacenter configuration; Move code to package
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
45
pkg/hypervisor/dc.go
Normal file
45
pkg/hypervisor/dc.go
Normal file
@ -0,0 +1,45 @@
|
||||
package hypervisor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
|
||||
"github.com/vmware/govmomi/find"
|
||||
"github.com/vmware/govmomi/object"
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
func CreateNetworkProtocolProfile(ctx context.Context, clt *vim25.Client, datacenter, network string) error {
|
||||
dc, err := find.NewFinder(clt, true).Datacenter(ctx, datacenter)
|
||||
if err != nil {
|
||||
log.Fatalf("[ERROR] Unable to determine datacenter: %s", err)
|
||||
}
|
||||
|
||||
object.NewCommon(clt, dc.Reference())
|
||||
request := &types.CreateIpPool{
|
||||
This: types.ManagedObjectReference{
|
||||
Type: "",
|
||||
Value: "",
|
||||
},
|
||||
Pool: types.IpPool{
|
||||
Name: "Test",
|
||||
},
|
||||
}
|
||||
response, err := methods.CreateIpPool(ctx, clt.RoundTripper, request)
|
||||
if err != nil {
|
||||
log.Fatalf("Bar: %s", err)
|
||||
}
|
||||
spew.Dump(response)
|
||||
|
||||
// task := object.NewTask(clt)
|
||||
// err = task.Wait(ctx)
|
||||
// if err != nil {
|
||||
// log.Fatalf("Foo: %s", err)
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
@ -3,8 +3,10 @@ package hypervisor
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/vmware/govmomi/find"
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
"github.com/vmware/govmomi/vim25/mo"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
@ -14,10 +16,18 @@ type vAPPProperty struct {
|
||||
Value string
|
||||
}
|
||||
|
||||
func SetVirtualMachineProperties(ctx context.Context, fnd *find.Finder, virtualmachine string, network string) error {
|
||||
vm, err := fnd.VirtualMachine(ctx, virtualmachine)
|
||||
func SetVirtualMachineProperties(ctx context.Context, clt *vim25.Client, datacenter, virtualmachine, network string) error {
|
||||
finder := find.NewFinder(clt, true)
|
||||
|
||||
dc, err := finder.Datacenter(ctx, datacenter)
|
||||
if err != nil {
|
||||
return err
|
||||
log.Fatalf("[ERROR] Unable to determine datacenter: %s", err)
|
||||
}
|
||||
|
||||
finder.SetDatacenter(dc)
|
||||
vm, err := finder.VirtualMachine(ctx, virtualmachine)
|
||||
if err != nil {
|
||||
log.Fatalf("[ERROR] Unable to determine virtual machine: %s", err)
|
||||
}
|
||||
|
||||
var moref mo.VirtualMachine
|
||||
|
Reference in New Issue
Block a user