本文整理汇总了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
}