Skip to content

Commit ae01a55

Browse files
chore(deps): update cloudstack sdk to v2.15.0
1 parent daca688 commit ae01a55

8 files changed

+42
-37
lines changed

cloudstack/resource_cloudstack_autoscale_vm_profile.go

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ package cloudstack
2222
import (
2323
"fmt"
2424
"log"
25-
"net/url"
2625
"strings"
2726
"time"
2827

@@ -101,16 +100,15 @@ func resourceCloudStackAutoScaleVMProfileCreate(d *schema.ResourceData, meta int
101100
if err != nil {
102101
return err
103102
}
104-
p.SetDestroyvmgraceperiod(int(duration.Seconds()))
103+
p.SetExpungevmgraceperiod(int(duration.Seconds()))
105104
}
106105

107106
if v, ok := d.GetOk("other_deploy_params"); ok {
108-
otherMap := v.(map[string]interface{})
109-
result := url.Values{}
110-
for k, v := range otherMap {
111-
result.Set(k, fmt.Sprint(v))
107+
nv := make(map[string]string)
108+
for k, v := range v.(map[string]interface{}) {
109+
nv[k] = v.(string)
112110
}
113-
p.SetOtherdeployparams(result.Encode())
111+
p.SetOtherdeployparams(nv)
114112
}
115113

116114
// Create the new vm profile
@@ -164,19 +162,10 @@ func resourceCloudStackAutoScaleVMProfileRead(d *schema.ResourceData, meta inter
164162
setValueOrID(d, "template", template.Name, p.Templateid)
165163
setValueOrID(d, "zone", zone.Name, p.Zoneid)
166164

167-
d.Set("destroy_vm_grace_period", (time.Duration(p.Destroyvmgraceperiod) * time.Second).String())
165+
d.Set("destroy_vm_grace_period", (time.Duration(p.Expungevmgraceperiod) * time.Second).String())
168166

169-
if p.Otherdeployparams != "" {
170-
var values url.Values
171-
values, err = url.ParseQuery(p.Otherdeployparams)
172-
if err != nil {
173-
return err
174-
}
175-
otherParams := make(map[string]interface{}, len(values))
176-
for key := range values {
177-
otherParams[key] = values.Get(key)
178-
}
179-
d.Set("other_deploy_params", otherParams)
167+
if p.Otherdeployparams != nil {
168+
d.Set("other_deploy_params", p.Otherdeployparams)
180169
}
181170

182171
metadata, err := getMetadata(cs, d, "AutoScaleVmProfile")
@@ -211,7 +200,7 @@ func resourceCloudStackAutoScaleVMProfileUpdate(d *schema.ResourceData, meta int
211200
if err != nil {
212201
return err
213202
}
214-
p.SetDestroyvmgraceperiod(int(duration.Seconds()))
203+
p.SetExpungevmgraceperiod(int(duration.Seconds()))
215204
}
216205

217206
_, err := cs.AutoScale.UpdateAutoScaleVmProfile(p)

cloudstack/resource_cloudstack_autoscale_vm_profile_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package cloudstack
2121

2222
import (
2323
"fmt"
24+
"reflect"
2425
"testing"
2526

2627
"github.com/apache/cloudstack-go/v2/cloudstack"
@@ -162,7 +163,10 @@ func testAccCheckCloudStackAutoscaleVMProfileBasicAttributes(
162163
return fmt.Errorf("Bad zone: %s", vmProfile.Zoneid)
163164
}
164165

165-
if vmProfile.Otherdeployparams != "displayname=display1&networkids=net1" {
166+
if reflect.DeepEqual(vmProfile.Otherdeployparams, map[string]string{
167+
"displayname": "display1",
168+
"networkids": "net1",
169+
}) {
166170
return fmt.Errorf("Bad otherdeployparams: %s", vmProfile.Otherdeployparams)
167171
}
168172

@@ -174,8 +178,8 @@ func testAccCheckCloudStackAutoscaleVMProfileUpdatedAttributes(
174178
vmProfile *cloudstack.AutoScaleVmProfile) resource.TestCheckFunc {
175179
return func(s *terraform.State) error {
176180

177-
if vmProfile.Destroyvmgraceperiod != 10 {
178-
return fmt.Errorf("Bad destroy_vm_grace_period: %d", vmProfile.Destroyvmgraceperiod)
181+
if vmProfile.Expungevmgraceperiod != 10 {
182+
return fmt.Errorf("Bad destroy_vm_grace_period: %d", vmProfile.Expungevmgraceperiod)
179183
}
180184

181185
return nil

cloudstack/resource_cloudstack_instance.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,11 @@ func resourceCloudStackInstanceUpdate(d *schema.ResourceData, meta interface{})
635635
if d.HasChange("keypair") {
636636
log.Printf("[DEBUG] SSH keypair changed for %s, starting update", name)
637637

638-
p := cs.SSH.NewResetSSHKeyForVirtualMachineParams(d.Id(), d.Get("keypair").(string))
638+
p := cs.SSH.NewResetSSHKeyForVirtualMachineParams(d.Id())
639+
640+
if keypair, ok := d.GetOk("keypair"); ok {
641+
p.SetKeypair(keypair.(string))
642+
}
639643

640644
// If there is a project supplied, we retrieve and set the project id
641645
if err := setProjectid(p, cs, d); err != nil {

cloudstack/resource_cloudstack_loadbalancer_rule.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package cloudstack
2222
import (
2323
"fmt"
2424
"log"
25+
"strconv"
2526
"strings"
2627

2728
"github.com/apache/cloudstack-go/v2/cloudstack"
@@ -202,11 +203,21 @@ func resourceCloudStackLoadBalancerRuleRead(d *schema.ResourceData, meta interfa
202203
return err
203204
}
204205

206+
public_port, err := strconv.Atoi(lb.Publicport)
207+
if err != nil {
208+
return err
209+
}
210+
211+
private_port, err := strconv.Atoi(lb.Privateport)
212+
if err != nil {
213+
return err
214+
}
215+
205216
d.Set("name", lb.Name)
206217
d.Set("ip_address_id", lb.Publicipid)
207218
d.Set("algorithm", lb.Algorithm)
208-
d.Set("public_port", lb.Publicport)
209-
d.Set("private_port", lb.Privateport)
219+
d.Set("public_port", public_port)
220+
d.Set("private_port", private_port)
210221
d.Set("protocol", lb.Protocol)
211222

212223
// Only set network if user specified it to avoid spurious diffs

cloudstack/resource_cloudstack_network.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,12 @@ func resourceCloudStackNetworkCreate(d *schema.ResourceData, meta interface{}) e
176176
return e.Error()
177177
}
178178

179-
// Compute/set the display text
180-
displaytext, ok := d.GetOk("display_text")
181-
if !ok {
182-
displaytext = name
183-
}
184-
185179
// Create a new parameter struct
186-
p := cs.Network.NewCreateNetworkParams(displaytext.(string), name, networkofferingid, zoneid)
180+
p := cs.Network.NewCreateNetworkParams(name, networkofferingid, zoneid)
181+
182+
if displaytext, ok := d.GetOk("display_text"); ok {
183+
p.SetDisplaytext(displaytext.(string))
184+
}
187185

188186
// Get the network offering to check if it supports specifying IP ranges
189187
no, _, err := cs.NetworkOffering.GetNetworkOfferingByID(networkofferingid)

cloudstack/resource_cloudstack_private_gateway.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ func resourceCloudStackPrivateGatewayCreate(d *schema.ResourceData, meta interfa
100100
d.Get("gateway").(string),
101101
ipaddress,
102102
d.Get("netmask").(string),
103-
d.Get("vlan").(string),
104103
d.Get("vpc_id").(string),
105104
)
106105

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module github.com/terraform-providers/terraform-provider-cloudstack
22

33
require (
4-
github.com/apache/cloudstack-go/v2 v2.13.2
4+
github.com/apache/cloudstack-go/v2 v2.15.0
55
github.com/go-ini/ini v1.67.0
66
github.com/hashicorp/go-multierror v1.1.1
77
github.com/hashicorp/terraform-plugin-go v0.22.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/ProtonMail/go-crypto v1.1.0-alpha.0 h1:nHGfwXmFvJrSR9xu8qL7BkO4DqTHXE
66
github.com/ProtonMail/go-crypto v1.1.0-alpha.0/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
77
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
88
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
9-
github.com/apache/cloudstack-go/v2 v2.13.2 h1:Y06CXNle++Gs24YjeNI7Ot8ZUQjLix2oPn/CMuVr/TU=
10-
github.com/apache/cloudstack-go/v2 v2.13.2/go.mod h1:aosD8Svfu5nhH5Sp4zcsVV1hT5UGt3mTgRXM8YqTKe0=
9+
github.com/apache/cloudstack-go/v2 v2.15.0 h1:oojn1qx0+wBwrFSSmA2rL8XjWd4BXqwYo0RVCrAXoHk=
10+
github.com/apache/cloudstack-go/v2 v2.15.0/go.mod h1:Mc+tXpujtslBuZFk5atoGT2LanVxOrXS2GGgidAoz1A=
1111
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
1212
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
1313
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=

0 commit comments

Comments
 (0)