本文整理汇总了Golang中github.com/vmware/govmomi/object.StoragePod.Reference方法的典型用法代码示例。如果您正苦于以下问题:Golang StoragePod.Reference方法的具体用法?Golang StoragePod.Reference怎么用?Golang StoragePod.Reference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vmware/govmomi/object.StoragePod
的用法示例。
在下文中一共展示了StoragePod.Reference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: buildStoragePlacementSpecClone
// buildStoragePlacementSpecClone builds StoragePlacementSpec for clone action.
func buildStoragePlacementSpecClone(c *govmomi.Client, f *object.DatacenterFolders, vm *object.VirtualMachine, rp *object.ResourcePool, storagePod object.StoragePod) types.StoragePlacementSpec {
vmr := vm.Reference()
vmfr := f.VmFolder.Reference()
rpr := rp.Reference()
spr := storagePod.Reference()
var o mo.VirtualMachine
err := vm.Properties(context.TODO(), vmr, []string{"datastore"}, &o)
if err != nil {
return types.StoragePlacementSpec{}
}
ds := object.NewDatastore(c.Client, o.Datastore[0])
log.Printf("[DEBUG] findDatastore: datastore: %#v\n", ds)
devices, err := vm.Device(context.TODO())
if err != nil {
return types.StoragePlacementSpec{}
}
var key int
for _, d := range devices.SelectByType((*types.VirtualDisk)(nil)) {
key = d.GetVirtualDevice().Key
log.Printf("[DEBUG] findDatastore: virtual devices: %#v\n", d.GetVirtualDevice())
}
sps := types.StoragePlacementSpec{
Type: "clone",
Vm: &vmr,
PodSelectionSpec: types.StorageDrsPodSelectionSpec{
StoragePod: &spr,
},
CloneSpec: &types.VirtualMachineCloneSpec{
Location: types.VirtualMachineRelocateSpec{
Disk: []types.VirtualMachineRelocateSpecDiskLocator{
types.VirtualMachineRelocateSpecDiskLocator{
Datastore: ds.Reference(),
DiskBackingInfo: &types.VirtualDiskFlatVer2BackingInfo{},
DiskId: key,
},
},
Pool: &rpr,
},
PowerOn: false,
Template: false,
},
CloneName: "dummy",
Folder: &vmfr,
}
return sps
}
示例2: buildStoragePlacementSpecCreate
// buildStoragePlacementSpecCreate builds StoragePlacementSpec for create action.
func buildStoragePlacementSpecCreate(f *object.DatacenterFolders, rp *object.ResourcePool, storagePod object.StoragePod, configSpec types.VirtualMachineConfigSpec) types.StoragePlacementSpec {
vmfr := f.VmFolder.Reference()
rpr := rp.Reference()
spr := storagePod.Reference()
sps := types.StoragePlacementSpec{
Type: "create",
ConfigSpec: &configSpec,
PodSelectionSpec: types.StorageDrsPodSelectionSpec{
StoragePod: &spr,
},
Folder: &vmfr,
ResourcePool: &rpr,
}
log.Printf("[DEBUG] findDatastore: StoragePlacementSpec: %#v\n", sps)
return sps
}