Skip to content

Commit

Permalink
Merge pull request #542 from mizhka/user/mizhka/541
Browse files Browse the repository at this point in the history
[fix-crash] Correct usage of changed proxmox-api (GetPoolInfo)
  • Loading branch information
mleone87 authored Apr 23, 2022
2 parents 5ec4f03 + d2ade34 commit b426faf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions proxmox/resource_lxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,7 @@ func _resourceLxcRead(d *schema.ResourceData, meta interface{}) error {
if err == nil {
for _, poolInfo := range pools["data"].([]interface{}) {
poolContent, _ := client.GetPoolInfo(poolInfo.(map[string]interface{})["poolid"].(string))
poolMembers := poolContent["data"].(map[string]interface{})["members"]
for _, member := range poolMembers.([]interface{}) {
for _, member := range poolContent["members"].([]interface{}) {
if member.(map[string]interface{})["type"] != "storage" {
if vmID == int(member.(map[string]interface{})["vmid"].(float64)) {
d.Set("pool", poolInfo.(map[string]interface{})["poolid"].(string))
Expand Down
6 changes: 3 additions & 3 deletions proxmox/resource_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ func _resourcePoolRead(d *schema.ResourceData, meta interface{}) error {

d.SetId(clusterResourceId("pools", poolID))
d.Set("comment", "")
if poolInfo["data"].(map[string]interface{})["comment"] != nil {
d.Set("comment", poolInfo["data"].(map[string]interface{})["comment"].(string))
if poolInfo["comment"] != nil {
d.Set("comment", poolInfo["comment"].(string))
}

// DEBUG print the read result
logger.Debug().Str("poolid", poolID).Msgf("Finished pool read resulting in data: '%+v'", poolInfo["data"])
logger.Debug().Str("poolid", poolID).Msgf("Finished pool read resulting in data: '%+v'", poolInfo)
return nil
}

Expand Down
3 changes: 1 addition & 2 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -1500,8 +1500,7 @@ func _resourceVmQemuRead(d *schema.ResourceData, meta interface{}) error {
if err == nil {
for _, poolInfo := range pools["data"].([]interface{}) {
poolContent, _ := client.GetPoolInfo(poolInfo.(map[string]interface{})["poolid"].(string))
poolMembers := poolContent["data"].(map[string]interface{})["members"]
for _, member := range poolMembers.([]interface{}) {
for _, member := range poolContent["members"].([]interface{}) {
if member.(map[string]interface{})["type"] != "storage" {
if vmID == int(member.(map[string]interface{})["vmid"].(float64)) {
d.Set("pool", poolInfo.(map[string]interface{})["poolid"].(string))
Expand Down

0 comments on commit b426faf

Please sign in to comment.