本文整理汇总了Golang中github.com/vmware/vic/pkg/vsphere/vm.VirtualMachine.FetchExtraConfig方法的典型用法代码示例。如果您正苦于以下问题:Golang VirtualMachine.FetchExtraConfig方法的具体用法?Golang VirtualMachine.FetchExtraConfig怎么用?Golang VirtualMachine.FetchExtraConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vmware/vic/pkg/vsphere/vm.VirtualMachine
的用法示例。
在下文中一共展示了VirtualMachine.FetchExtraConfig方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: isVCH
func (d *Dispatcher) isVCH(vm *vm.VirtualMachine) (bool, error) {
if vm == nil {
return false, errors.New("nil parameter")
}
defer trace.End(trace.Begin(vm.InventoryPath))
info, err := vm.FetchExtraConfig(d.ctx)
if err != nil {
err = errors.Errorf("Failed to fetch guest info of appliance vm: %s", err)
return false, err
}
var remoteConf config.VirtualContainerHostConfigSpec
extraconfig.Decode(extraconfig.MapSource(info), &remoteConf)
// if the moref of the target matches where we expect to find it for a VCH, run with it
if remoteConf.ExecutorConfig.ID == vm.Reference().String() {
return true, nil
}
return false, nil
}
示例2: GetVCHConfig
func (d *Dispatcher) GetVCHConfig(vm *vm.VirtualMachine) (*metadata.VirtualContainerHostConfigSpec, error) {
defer trace.End(trace.Begin(""))
//this is the appliance vm
mapConfig, err := vm.FetchExtraConfig(d.ctx)
if err != nil {
err = errors.Errorf("Failed to get VM extra config of %s, %s", vm.Reference(), err)
log.Errorf("%s", err)
return nil, err
}
data := extraconfig.MapSource(mapConfig)
vchConfig := &metadata.VirtualContainerHostConfigSpec{}
result := extraconfig.Decode(data, vchConfig)
if result == nil {
err = errors.Errorf("Failed to decode VM configuration %s, %s", vm.Reference(), err)
log.Errorf("%s", err)
return nil, err
}
// vchConfig.ID
return vchConfig, nil
}