@@ -72,6 +72,11 @@ func resourceCloudStackIPAddress() *schema.Resource {
72
72
Computed : true ,
73
73
},
74
74
75
+ "is_source_nat" : {
76
+ Type : schema .TypeBool ,
77
+ Computed : true ,
78
+ },
79
+
75
80
"tags" : tagsSchema (),
76
81
},
77
82
}
@@ -154,6 +159,7 @@ func resourceCloudStackIPAddressRead(d *schema.ResourceData, meta interface{}) e
154
159
}
155
160
156
161
d .Set ("is_portable" , ip .Isportable )
162
+ d .Set ("is_source_nat" , ip .Issourcenat )
157
163
158
164
// Updated the IP address
159
165
d .Set ("ip_address" , ip .Ipaddress )
@@ -182,21 +188,23 @@ func resourceCloudStackIPAddressRead(d *schema.ResourceData, meta interface{}) e
182
188
}
183
189
184
190
func resourceCloudStackIPAddressDelete (d * schema.ResourceData , meta interface {}) error {
185
- cs := meta .(* cloudstack.CloudStackClient )
186
-
187
- // Create a new parameter struct
188
- p := cs .Address .NewDisassociateIpAddressParams (d .Id ())
189
-
190
- // Disassociate the IP address
191
- if _ , err := cs .Address .DisassociateIpAddress (p ); err != nil {
192
- // This is a very poor way to be told the ID does no longer exist :(
193
- if strings .Contains (err .Error (), fmt .Sprintf (
194
- "Invalid parameter id value=%s due to incorrect long value format, " +
195
- "or entity does not exist" , d .Id ())) {
196
- return nil
191
+ if ! d .Get ("is_source_nat" ).(bool ) {
192
+ cs := meta .(* cloudstack.CloudStackClient )
193
+
194
+ // Create a new parameter struct
195
+ p := cs .Address .NewDisassociateIpAddressParams (d .Id ())
196
+
197
+ // Disassociate the IP address
198
+ if _ , err := cs .Address .DisassociateIpAddress (p ); err != nil {
199
+ // This is a very poor way to be told the ID does no longer exist :(
200
+ if strings .Contains (err .Error (), fmt .Sprintf (
201
+ "Invalid parameter id value=%s due to incorrect long value format, " +
202
+ "or entity does not exist" , d .Id ())) {
203
+ return nil
204
+ }
205
+
206
+ return fmt .Errorf ("Error disassociating IP address %s: %s" , d .Id (), err )
197
207
}
198
-
199
- return fmt .Errorf ("Error disassociating IP address %s: %s" , d .Id (), err )
200
208
}
201
209
202
210
return nil
0 commit comments