godep: update vmware/govmomi
This commit is contained in:
118
vendor/github.com/vmware/govmomi/simulator/folder.go
generated
vendored
118
vendor/github.com/vmware/govmomi/simulator/folder.go
generated
vendored
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"path"
|
||||
"sync"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
@@ -32,12 +31,17 @@ import (
|
||||
|
||||
type Folder struct {
|
||||
mo.Folder
|
||||
}
|
||||
|
||||
m sync.Mutex
|
||||
func (f *Folder) eventArgument() types.FolderEventArgument {
|
||||
return types.FolderEventArgument{
|
||||
Folder: f.Self,
|
||||
EntityEventArgument: types.EntityEventArgument{Name: f.Name},
|
||||
}
|
||||
}
|
||||
|
||||
// update references when objects are added/removed from a Folder
|
||||
func (f *Folder) update(o mo.Reference, u func(types.ManagedObjectReference, []types.ManagedObjectReference) []types.ManagedObjectReference) {
|
||||
func (f *Folder) update(o mo.Reference, u func(mo.Reference, *[]types.ManagedObjectReference, types.ManagedObjectReference)) {
|
||||
ref := o.Reference()
|
||||
|
||||
if f.Parent == nil {
|
||||
@@ -53,9 +57,9 @@ func (f *Folder) update(o mo.Reference, u func(types.ManagedObjectReference, []t
|
||||
|
||||
switch ref.Type {
|
||||
case "Network", "DistributedVirtualSwitch", "DistributedVirtualPortgroup":
|
||||
dc.Network = u(ref, dc.Network)
|
||||
u(dc, &dc.Network, ref)
|
||||
case "Datastore":
|
||||
dc.Datastore = u(ref, dc.Datastore)
|
||||
u(dc, &dc.Datastore, ref)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,12 +74,9 @@ func networkSummary(n *mo.Network) *types.NetworkSummary {
|
||||
func (f *Folder) putChild(o mo.Entity) {
|
||||
Map.PutEntity(f, o)
|
||||
|
||||
f.m.Lock()
|
||||
defer f.m.Unlock()
|
||||
f.ChildEntity = append(f.ChildEntity, o.Reference())
|
||||
|
||||
f.ChildEntity = AddReference(o.Reference(), f.ChildEntity)
|
||||
|
||||
f.update(o, AddReference)
|
||||
f.update(o, Map.AddReference)
|
||||
|
||||
switch e := o.(type) {
|
||||
case *mo.Network:
|
||||
@@ -90,12 +91,9 @@ func (f *Folder) putChild(o mo.Entity) {
|
||||
func (f *Folder) removeChild(o mo.Reference) {
|
||||
Map.Remove(o.Reference())
|
||||
|
||||
f.m.Lock()
|
||||
defer f.m.Unlock()
|
||||
RemoveReference(&f.ChildEntity, o.Reference())
|
||||
|
||||
f.ChildEntity = RemoveReference(o.Reference(), f.ChildEntity)
|
||||
|
||||
f.update(o, RemoveReference)
|
||||
f.update(o, Map.RemoveReference)
|
||||
}
|
||||
|
||||
func (f *Folder) hasChildType(kind string) bool {
|
||||
@@ -195,7 +193,7 @@ func (p *StoragePod) MoveIntoFolderTask(c *types.MoveIntoFolder_Task) soap.HasFa
|
||||
return (&Folder{Folder: p.Folder}).MoveIntoFolderTask(c)
|
||||
}
|
||||
|
||||
func (f *Folder) CreateDatacenter(c *types.CreateDatacenter) soap.HasFault {
|
||||
func (f *Folder) CreateDatacenter(ctx *Context, c *types.CreateDatacenter) soap.HasFault {
|
||||
r := &methods.CreateDatacenterBody{}
|
||||
|
||||
if f.hasChildType("Datacenter") && f.hasChildType("Folder") {
|
||||
@@ -210,6 +208,15 @@ func (f *Folder) CreateDatacenter(c *types.CreateDatacenter) soap.HasFault {
|
||||
r.Res = &types.CreateDatacenterResponse{
|
||||
Returnval: dc.Self,
|
||||
}
|
||||
|
||||
ctx.postEvent(&types.DatacenterCreatedEvent{
|
||||
DatacenterEvent: types.DatacenterEvent{
|
||||
Event: types.Event{
|
||||
Datacenter: datacenterEventArgument(dc),
|
||||
},
|
||||
},
|
||||
Parent: f.eventArgument(),
|
||||
})
|
||||
} else {
|
||||
r.Fault_ = f.typeNotSupported()
|
||||
}
|
||||
@@ -240,6 +247,7 @@ func (f *Folder) CreateClusterEx(c *types.CreateClusterEx) soap.HasFault {
|
||||
type createVM struct {
|
||||
*Folder
|
||||
|
||||
ctx *Context
|
||||
req *types.CreateVM_Task
|
||||
|
||||
register bool
|
||||
@@ -291,27 +299,50 @@ func (c *createVM) Run(task *Task) (types.AnyType, types.BaseMethodFault) {
|
||||
c.Folder.putChild(vm)
|
||||
|
||||
host := Map.Get(*vm.Runtime.Host).(*HostSystem)
|
||||
host.Vm = append(host.Vm, vm.Self)
|
||||
Map.AppendReference(host, &host.Vm, vm.Self)
|
||||
|
||||
for i := range vm.Datastore {
|
||||
ds := Map.Get(vm.Datastore[i]).(*Datastore)
|
||||
ds.Vm = append(ds.Vm, vm.Self)
|
||||
Map.AppendReference(ds, &ds.Vm, vm.Self)
|
||||
}
|
||||
|
||||
switch rp := Map.Get(*vm.ResourcePool).(type) {
|
||||
case *ResourcePool:
|
||||
rp.Vm = append(rp.Vm, vm.Self)
|
||||
case *VirtualApp:
|
||||
rp.Vm = append(rp.Vm, vm.Self)
|
||||
}
|
||||
pool := Map.Get(*vm.ResourcePool)
|
||||
// This can be an internal call from VirtualApp.CreateChildVMTask, where pool is already locked.
|
||||
c.ctx.WithLock(pool, func() {
|
||||
switch rp := pool.(type) {
|
||||
case *ResourcePool:
|
||||
rp.Vm = append(rp.Vm, vm.Self)
|
||||
case *VirtualApp:
|
||||
rp.Vm = append(rp.Vm, vm.Self)
|
||||
}
|
||||
})
|
||||
|
||||
event := vm.event()
|
||||
c.ctx.postEvent(
|
||||
&types.VmBeingCreatedEvent{
|
||||
VmEvent: event,
|
||||
ConfigSpec: &c.req.Config,
|
||||
},
|
||||
&types.VmInstanceUuidAssignedEvent{
|
||||
VmEvent: event,
|
||||
InstanceUuid: vm.Config.InstanceUuid,
|
||||
},
|
||||
&types.VmUuidAssignedEvent{
|
||||
VmEvent: event,
|
||||
Uuid: vm.Config.Uuid,
|
||||
},
|
||||
&types.VmCreatedEvent{
|
||||
VmEvent: event,
|
||||
},
|
||||
)
|
||||
|
||||
return vm.Reference(), nil
|
||||
}
|
||||
|
||||
func (f *Folder) CreateVMTask(c *types.CreateVM_Task) soap.HasFault {
|
||||
func (f *Folder) CreateVMTask(ctx *Context, c *types.CreateVM_Task) soap.HasFault {
|
||||
return &methods.CreateVM_TaskBody{
|
||||
Res: &types.CreateVM_TaskResponse{
|
||||
Returnval: NewTask(&createVM{f, c, false}).Run(),
|
||||
Returnval: NewTask(&createVM{f, ctx, c, false}).Run(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -319,6 +350,7 @@ func (f *Folder) CreateVMTask(c *types.CreateVM_Task) soap.HasFault {
|
||||
type registerVM struct {
|
||||
*Folder
|
||||
|
||||
ctx *Context
|
||||
req *types.RegisterVM_Task
|
||||
}
|
||||
|
||||
@@ -367,6 +399,7 @@ func (c *registerVM) Run(task *Task) (types.AnyType, types.BaseMethodFault) {
|
||||
create := NewTask(&createVM{
|
||||
Folder: c.Folder,
|
||||
register: true,
|
||||
ctx: c.ctx,
|
||||
req: &types.CreateVM_Task{
|
||||
This: c.Folder.Reference(),
|
||||
Config: types.VirtualMachineConfigSpec{
|
||||
@@ -389,10 +422,12 @@ func (c *registerVM) Run(task *Task) (types.AnyType, types.BaseMethodFault) {
|
||||
return create.Info.Result, nil
|
||||
}
|
||||
|
||||
func (f *Folder) RegisterVMTask(c *types.RegisterVM_Task) soap.HasFault {
|
||||
func (f *Folder) RegisterVMTask(ctx *Context, c *types.RegisterVM_Task) soap.HasFault {
|
||||
ctx.Caller = &f.Self
|
||||
|
||||
return &methods.RegisterVM_TaskBody{
|
||||
Res: &types.RegisterVM_TaskResponse{
|
||||
Returnval: NewTask(®isterVM{f, c}).Run(),
|
||||
Returnval: NewTask(®isterVM{f, ctx, c}).Run(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -445,6 +480,33 @@ func (f *Folder) CreateDVSTask(req *types.CreateDVS_Task) soap.HasFault {
|
||||
Description: spec.Description,
|
||||
}
|
||||
|
||||
configInfo := &types.VMwareDVSConfigInfo{
|
||||
DVSConfigInfo: types.DVSConfigInfo{
|
||||
Uuid: dvs.Uuid,
|
||||
Name: spec.Name,
|
||||
ConfigVersion: spec.ConfigVersion,
|
||||
NumStandalonePorts: spec.NumStandalonePorts,
|
||||
MaxPorts: spec.MaxPorts,
|
||||
UplinkPortPolicy: spec.UplinkPortPolicy,
|
||||
UplinkPortgroup: spec.UplinkPortgroup,
|
||||
DefaultPortConfig: spec.DefaultPortConfig,
|
||||
ExtensionKey: spec.ExtensionKey,
|
||||
Description: spec.Description,
|
||||
Policy: spec.Policy,
|
||||
VendorSpecificConfig: spec.VendorSpecificConfig,
|
||||
SwitchIpAddress: spec.SwitchIpAddress,
|
||||
DefaultProxySwitchMaxNumPorts: spec.DefaultProxySwitchMaxNumPorts,
|
||||
InfrastructureTrafficResourceConfig: spec.InfrastructureTrafficResourceConfig,
|
||||
NetworkResourceControlVersion: spec.NetworkResourceControlVersion,
|
||||
},
|
||||
}
|
||||
|
||||
if spec.Contact != nil {
|
||||
configInfo.Contact = *spec.Contact
|
||||
}
|
||||
|
||||
dvs.Config = configInfo
|
||||
|
||||
if dvs.Summary.ProductInfo == nil {
|
||||
product := Map.content().About
|
||||
dvs.Summary.ProductInfo = &types.DistributedVirtualSwitchProductSpec{
|
||||
|
||||
Reference in New Issue
Block a user