@@ -19,34 +19,34 @@ func resourceCloudStackAutoScaleVMProfile() *schema.Resource {
19
19
Delete : resourceCloudStackAutoScaleVMProfileDelete ,
20
20
21
21
Schema : map [string ]* schema.Schema {
22
- "zone " : {
22
+ "service_offering " : {
23
23
Type : schema .TypeString ,
24
24
Required : true ,
25
25
ForceNew : true ,
26
26
},
27
27
28
- "service_offering " : {
28
+ "template " : {
29
29
Type : schema .TypeString ,
30
30
Required : true ,
31
- ForceNew : true ,
32
31
},
33
32
34
- "template " : {
33
+ "zone " : {
35
34
Type : schema .TypeString ,
36
35
Required : true ,
36
+ ForceNew : true ,
37
37
},
38
38
39
- "other_deploy_params " : {
40
- Type : schema .TypeMap ,
39
+ "destroy_vm_grace_period " : {
40
+ Type : schema .TypeString ,
41
41
Optional : true ,
42
42
Computed : true ,
43
- ForceNew : true ,
44
43
},
45
44
46
- "destroy_vm_grace_period " : {
47
- Type : schema .TypeString ,
45
+ "other_deploy_params " : {
46
+ Type : schema .TypeMap ,
48
47
Optional : true ,
49
48
Computed : true ,
49
+ ForceNew : true ,
50
50
},
51
51
52
52
"metadata" : metadataSchema (),
@@ -77,6 +77,14 @@ func resourceCloudStackAutoScaleVMProfileCreate(d *schema.ResourceData, meta int
77
77
78
78
p := cs .AutoScale .NewCreateAutoScaleVmProfileParams (serviceofferingid , templateid , zoneid )
79
79
80
+ if v , ok := d .GetOk ("destroy_vm_grace_period" ); ok {
81
+ duration , err := time .ParseDuration (v .(string ))
82
+ if err != nil {
83
+ return err
84
+ }
85
+ p .SetDestroyvmgraceperiod (int (duration .Seconds ()))
86
+ }
87
+
80
88
if v , ok := d .GetOk ("other_deploy_params" ); ok {
81
89
otherMap := v .(map [string ]interface {})
82
90
result := url.Values {}
@@ -86,14 +94,6 @@ func resourceCloudStackAutoScaleVMProfileCreate(d *schema.ResourceData, meta int
86
94
p .SetOtherdeployparams (result .Encode ())
87
95
}
88
96
89
- if v , ok := d .GetOk ("destroy_vm_grace_period" ); ok {
90
- duration , err := time .ParseDuration (v .(string ))
91
- if err != nil {
92
- return err
93
- }
94
- p .SetDestroyvmgraceperiod (int (duration .Seconds ()))
95
- }
96
-
97
97
// Create the new vm profile
98
98
r , err := cs .AutoScale .CreateAutoScaleVmProfile (p )
99
99
if err != nil {
@@ -141,9 +141,11 @@ func resourceCloudStackAutoScaleVMProfileRead(d *schema.ResourceData, meta inter
141
141
return err
142
142
}
143
143
144
- setValueOrID (d , "zone" , zone .Name , p .Zoneid )
145
144
setValueOrID (d , "service_offering" , offering .Name , p .Serviceofferingid )
146
145
setValueOrID (d , "template" , template .Name , p .Templateid )
146
+ setValueOrID (d , "zone" , zone .Name , p .Zoneid )
147
+
148
+ d .Set ("destroy_vm_grace_period" , (time .Duration (p .Destroyvmgraceperiod ) * time .Second ).String ())
147
149
148
150
if p .Otherdeployparams != "" {
149
151
var values url.Values
@@ -158,8 +160,6 @@ func resourceCloudStackAutoScaleVMProfileRead(d *schema.ResourceData, meta inter
158
160
d .Set ("other_deploy_params" , otherParams )
159
161
}
160
162
161
- d .Set ("destroy_vm_grace_period" , (time .Duration (p .Destroyvmgraceperiod ) * time .Second ).String ())
162
-
163
163
metadata , err := getMetadata (cs , d , "AutoScaleVmProfile" )
164
164
if err != nil {
165
165
return err
0 commit comments