Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions cloudstack/resource_cloudstack_ipaddress.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,21 @@ func resourceCloudStackIPAddressRead(d *schema.ResourceData, meta interface{}) e
}

func resourceCloudStackIPAddressDelete(d *schema.ResourceData, meta interface{}) error {
if !d.Get("is_source_nat").(bool) {
cs := meta.(*cloudstack.CloudStackClient)

// Create a new parameter struct
p := cs.Address.NewDisassociateIpAddressParams(d.Id())

// Disassociate the IP address
if _, err := cs.Address.DisassociateIpAddress(p); err != nil {
// This is a very poor way to be told the ID does no longer exist :(
if strings.Contains(err.Error(), fmt.Sprintf(
"Invalid parameter id value=%s due to incorrect long value format, "+
"or entity does not exist", d.Id())) {
return nil
}
cs := meta.(*cloudstack.CloudStackClient)

return fmt.Errorf("Error disassociating IP address %s: %s", d.Id(), err)
// Create a new parameter struct
p := cs.Address.NewDisassociateIpAddressParams(d.Id())

// Disassociate the IP address
if _, err := cs.Address.DisassociateIpAddress(p); err != nil {
// This is a very poor way to be told the ID does no longer exist :(
if strings.Contains(err.Error(), fmt.Sprintf(
"Invalid parameter id value=%s due to incorrect long value format, "+
"or entity does not exist", d.Id())) {
return nil
}
Comment on lines +286 to 291

return fmt.Errorf("Error disassociating IP address %s: %s", d.Id(), err)
}

return nil
Expand Down
Loading