本文整理匯總了Golang中github.com/hooklift/terraform-provider-vix/provider/vix.VM.Provider方法的典型用法代碼示例。如果您正苦於以下問題:Golang VM.Provider方法的具體用法?Golang VM.Provider怎麽用?Golang VM.Provider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hooklift/terraform-provider-vix/provider/vix.VM
的用法示例。
在下文中一共展示了VM.Provider方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: resourceVIXVMCreate
func resourceVIXVMCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
vm := new(vix.VM)
vm.Provider = config.Product
vm.VerifySSL = config.VerifySSL
if err := tf_to_vix(d, vm); err != nil {
return err
}
id, err := vm.Create()
if err != nil {
return err
}
log.Printf("[DEBUG] Resource ID: %s\n", id)
d.SetId(id)
// Initialize the connection info
d.SetConnInfo(map[string]string{
"type": "ssh",
"host": vm.IPAddress,
})
return resourceVIXVMRead(d, meta)
}
示例2: resourceVIXVMDelete
func resourceVIXVMDelete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
vmxFile := d.Id()
vm := new(vix.VM)
vm.Provider = config.Product
vm.VerifySSL = config.VerifySSL
if password := d.Get("password"); password != nil {
vm.Image.Password = d.Get("password").(string)
}
return vm.Destroy(vmxFile)
}
示例3: resourceVIXVMUpdate
func resourceVIXVMUpdate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
vm := new(vix.VM)
vm.Provider = config.Product
vm.VerifySSL = config.VerifySSL
// Maps terraform.ResourceState attrbutes to vix.VM
tf_to_vix(d, vm)
err := vm.Update(d.Id())
if err != nil {
return err
}
return resourceVIXVMRead(d, meta)
}
示例4: 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
}