mirror of
https://github.com/letic/terraform-provider-proxmox.git
synced 2024-07-03 08:02:39 +00:00
add resourceLxcUpdate
This commit is contained in:
parent
abe8e813d7
commit
9c1cd150f6
|
@ -400,7 +400,101 @@ func resourceLxcCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLxcUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceLxcUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
return resourceLxcRead(d, meta)
|
pconf := meta.(*providerConfiguration)
|
||||||
|
pmParallelBegin(pconf)
|
||||||
|
client := pconf.Client
|
||||||
|
|
||||||
|
_, _, vmID, err := parseResourceId(d.Id())
|
||||||
|
if err != nil {
|
||||||
|
pmParallelEnd(pconf)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
vmr := pxapi.NewVmRef(vmID)
|
||||||
|
_, err = client.GetVmInfo(vmr)
|
||||||
|
if err != nil {
|
||||||
|
pmParallelEnd(pconf)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// configDisksSet := d.Get("disk").(*schema.Set)
|
||||||
|
// qemuDisks := DevicesSetToMap(configDisksSet)
|
||||||
|
// configNetworksSet := d.Get("network").(*schema.Set)
|
||||||
|
// qemuNetworks := DevicesSetToMap(configNetworksSet)
|
||||||
|
|
||||||
|
config := pxapi.NewConfigLxc()
|
||||||
|
config.Ostemplate = d.Get("ostemplate").(string)
|
||||||
|
config.Arch = d.Get("arch").(string)
|
||||||
|
config.BWLimit = d.Get("bwlimit").(int)
|
||||||
|
config.CMode = d.Get("cmode").(string)
|
||||||
|
config.Console = d.Get("console").(bool)
|
||||||
|
config.Cores = d.Get("cores").(int)
|
||||||
|
config.CPULimit = d.Get("cpulimit").(int)
|
||||||
|
config.CPUUnits = d.Get("cpuunits").(int)
|
||||||
|
config.Description = d.Get("description").(string)
|
||||||
|
features := d.Get("features").(*schema.Set)
|
||||||
|
featureSetList := features.List()
|
||||||
|
if len(featureSetList) > 0 {
|
||||||
|
// only apply the first feature set,
|
||||||
|
// because proxmox api only allows one feature set
|
||||||
|
config.Features = featureSetList[0].(map[string]interface{})
|
||||||
|
}
|
||||||
|
config.Force = d.Get("force").(bool)
|
||||||
|
config.Hookscript = d.Get("hookscript").(string)
|
||||||
|
config.Hostname = d.Get("hostname").(string)
|
||||||
|
config.IgnoreUnpackErrors = d.Get("ignore_unpack_errors").(bool)
|
||||||
|
config.Lock = d.Get("lock").(string)
|
||||||
|
config.Memory = d.Get("memory").(int)
|
||||||
|
// proxmox api allows multiple mountpoint sets,
|
||||||
|
// having a unique 'id' parameter foreach set
|
||||||
|
mountpoints := d.Get("mountpoint").(*schema.Set)
|
||||||
|
lxcMountpoints := DevicesSetToMap(mountpoints)
|
||||||
|
config.Mountpoints = lxcMountpoints
|
||||||
|
config.Nameserver = d.Get("nameserver").(string)
|
||||||
|
// proxmox api allows multiple network sets,
|
||||||
|
// having a unique 'id' parameter foreach set
|
||||||
|
networks := d.Get("network").(*schema.Set)
|
||||||
|
lxcNetworks := DevicesSetToMap(networks)
|
||||||
|
config.Networks = lxcNetworks
|
||||||
|
config.OnBoot = d.Get("onboot").(bool)
|
||||||
|
config.OsType = d.Get("ostype").(string)
|
||||||
|
config.Password = d.Get("password").(string)
|
||||||
|
config.Pool = d.Get("pool").(string)
|
||||||
|
config.Protection = d.Get("protection").(bool)
|
||||||
|
config.Restore = d.Get("restore").(bool)
|
||||||
|
config.RootFs = d.Get("rootfs").(string)
|
||||||
|
config.SearchDomain = d.Get("searchdomain").(string)
|
||||||
|
config.SSHPublicKeys = d.Get("ssh_public_keys").(string)
|
||||||
|
config.Start = d.Get("start").(bool)
|
||||||
|
config.Startup = d.Get("startup").(string)
|
||||||
|
config.Storage = d.Get("storage").(string)
|
||||||
|
config.Swap = d.Get("swap").(int)
|
||||||
|
config.Template = d.Get("template").(bool)
|
||||||
|
config.Tty = d.Get("tty").(int)
|
||||||
|
config.Unique = d.Get("unique").(bool)
|
||||||
|
config.Unprivileged = d.Get("unprivileged").(bool)
|
||||||
|
// proxmox api allows to specify unused volumes
|
||||||
|
// even if it is recommended not to change them manually
|
||||||
|
unusedVolumes := d.Get("unused").([]interface{})
|
||||||
|
var volumes []string
|
||||||
|
for _, v := range unusedVolumes {
|
||||||
|
volumes = append(volumes, v.(string))
|
||||||
|
}
|
||||||
|
config.Unused = volumes
|
||||||
|
|
||||||
|
// targetNode := d.Get("target_node").(string)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
err = config.UpdateConfig(vmr, client)
|
||||||
|
if err != nil {
|
||||||
|
pmParallelEnd(pconf)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLxcRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceLxcRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user