本文整理匯總了Golang中github.com/hooklift/terraform-provider-vix/provider/vix.VM.Refresh方法的典型用法代碼示例。如果您正苦於以下問題:Golang VM.Refresh方法的具體用法?Golang VM.Refresh怎麽用?Golang VM.Refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hooklift/terraform-provider-vix/provider/vix.VM
的用法示例。
在下文中一共展示了VM.Refresh方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: resourceVIXVMRead
func resourceVIXVMRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
vmxFile := d.Id()
vm := new(vix.VM)
vm.Provider = config.Product
vm.VerifySSL = config.VerifySSL
running, err := vm.Refresh(vmxFile)
if err != nil {
return err
}
// This is to let TF know the resource is gone
if !running {
return nil
}
// Refreshes only what makes sense, for example, we do not refresh settings
// that modify the behavior of this provider
d.Set("name", vm.Name)
d.Set("description", vm.Description)
d.Set("cpus", vm.CPUs)
d.Set("memory", vm.Memory)
d.Set("ip_address", vm.IPAddress)
err = net_vix_to_tf(vm, d)
if err != nil {
return err
}
err = cdrom_vix_to_tf(vm, d)
if err != nil {
return err
}
return nil
}