Create bare minimum IpPool
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:
@ -4,42 +4,45 @@ import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"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)
|
||||
finder := find.NewFinder(clt, true)
|
||||
dc, err := finder.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)
|
||||
finder.SetDatacenter(dc)
|
||||
// nw, err := finder.Network(ctx, network)
|
||||
// if err != nil {
|
||||
// log.Fatalf("Foo: %s", err)
|
||||
// log.Fatalf("[ERROR] Unable to determine network: %s", err)
|
||||
// }
|
||||
|
||||
request := &types.CreateIpPool{
|
||||
This: *clt.ServiceContent.IpPoolManager,
|
||||
Dc: dc.Reference(),
|
||||
Pool: types.IpPool{
|
||||
Name: "ippool-" + (uuid.New().String()),
|
||||
DnsDomain: "meta.k8s.cluster",
|
||||
DnsSearchPath: "meta.k8s.cluster",
|
||||
// NetworkAssociation: []types.IpPoolAssociation{{
|
||||
// // This generates the error 'cannot use nw.Reference() (value of type types.ManagedObjectReference) as type *types.ManagedObjectReference in struct literal'
|
||||
// Network: nw.Reference(),
|
||||
// NetworkName: network,
|
||||
// },
|
||||
// },
|
||||
},
|
||||
}
|
||||
|
||||
if _, err := methods.CreateIpPool(ctx, clt.RoundTripper, request); err != nil {
|
||||
log.Fatalf("[ERROR]: Failed creating new network protocol profile (for network '%s' within datacenter '%s'): %s", network, datacenter, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user