本文整理汇总了Golang中github.com/vmware/vic/pkg/vsphere/vm.VirtualMachine.InventoryPath方法的典型用法代码示例。如果您正苦于以下问题:Golang VirtualMachine.InventoryPath方法的具体用法?Golang VirtualMachine.InventoryPath怎么用?Golang VirtualMachine.InventoryPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vmware/vic/pkg/vsphere/vm.VirtualMachine
的用法示例。
在下文中一共展示了VirtualMachine.InventoryPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewVCHFromComputePath
func (d *Dispatcher) NewVCHFromComputePath(computePath string, name string, v *validate.Validator) (*vm.VirtualMachine, error) {
defer trace.End(trace.Begin(fmt.Sprintf("path %q, name %q", computePath, name)))
var err error
parent, err := v.ResourcePoolHelper(d.ctx, computePath)
if err != nil {
return nil, err
}
d.vchPoolPath = path.Join(parent.InventoryPath, name)
var vchPool *object.ResourcePool
if d.isVC {
vapp, err := d.findVirtualApp(d.vchPoolPath)
if err != nil {
log.Errorf("Failed to get VCH virtual app %q: %s", d.vchPoolPath, err)
return nil, err
}
if vapp != nil {
vchPool = vapp.ResourcePool
}
}
if vchPool == nil {
vchPool, err = d.session.Finder.ResourcePool(d.ctx, d.vchPoolPath)
if err != nil {
log.Errorf("Failed to get VCH resource pool %q: %s", d.vchPoolPath, err)
return nil, err
}
}
rp := compute.NewResourcePool(d.ctx, d.session, vchPool.Reference())
var vmm *vm.VirtualMachine
if vmm, err = rp.GetChildVM(d.ctx, d.session, name); err != nil {
log.Errorf("Failed to get VCH VM: %s", err)
return nil, err
}
if vmm == nil {
err = errors.Errorf("Didn't find VM %q in resource pool %q", name, rp.Name())
log.Error(err)
return nil, err
}
vmm.InventoryPath = path.Join(d.vchPoolPath, name)
// check if it's VCH
var ok bool
if ok, err = d.isVCH(vmm); err != nil {
log.Error(err)
return nil, err
}
if !ok {
err = errors.Errorf("Not a VCH")
log.Error(err)
return nil, err
}
return vmm, nil
}