Fix refresing ACL rules when the ACL is deleted

This commit is contained in:
Sander van Harmelen 2016-07-08 17:16:35 +02:00
parent b55da4c3e7
commit 29ce2df873
11 changed files with 44 additions and 3 deletions

View File

@ -59,6 +59,7 @@ func resourceCloudStackDisk() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

View File

@ -105,6 +105,7 @@ func resourceCloudStackInstance() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

View File

@ -31,6 +31,7 @@ func resourceCloudStackIPAddress() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

View File

@ -97,6 +97,7 @@ func resourceCloudStackNetwork() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

View File

@ -29,6 +29,12 @@ func resourceCloudStackNetworkACL() *schema.Resource {
ForceNew: true,
},
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"vpc_id": &schema.Schema{
Type: schema.TypeString,
Required: true,
@ -70,7 +76,7 @@ func resourceCloudStackNetworkACLRead(d *schema.ResourceData, meta interface{})
// Get the network ACL list details
f, count, err := cs.NetworkACL.GetNetworkACLListByID(
d.Id(),
cloudstack.WithVPCID(d.Get("vpc_id").(string)),
cloudstack.WithProject(d.Get("project").(string)),
)
if err != nil {
if count == 0 {

View File

@ -2,6 +2,7 @@ package cloudstack
import (
"fmt"
"log"
"strconv"
"strings"
"sync"
@ -88,6 +89,12 @@ func resourceCloudStackNetworkACLRule() *schema.Resource {
},
},
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"parallelism": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
@ -265,6 +272,22 @@ func createNetworkACLRule(d *schema.ResourceData, meta interface{}, rule map[str
func resourceCloudStackNetworkACLRuleRead(d *schema.ResourceData, meta interface{}) error {
cs := meta.(*cloudstack.CloudStackClient)
// First check if the ACL itself still exists
_, count, err := cs.NetworkACL.GetNetworkACLListByID(
d.Id(),
cloudstack.WithProject(d.Get("project").(string)),
)
if err != nil {
if count == 0 {
log.Printf(
"[DEBUG] Network ACL list %s does no longer exist", d.Id())
d.SetId("")
return nil
}
return err
}
// Get all the rules from the running environment
p := cs.NetworkACL.NewListNetworkACLsParams()
p.SetAclid(d.Id())

View File

@ -54,6 +54,7 @@ func resourceCloudStackTemplate() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

View File

@ -50,6 +50,7 @@ func resourceCloudStackVPC() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

View File

@ -34,7 +34,7 @@ The following arguments are supported:
* `attach` - (Optional) Determines whether or not to attach the disk volume to a
virtual machine (defaults false).
* `device` - (Optional) The device to map the disk volume to within the guest OS.
* `device_id` - (Optional) The device ID to map the disk volume to within the guest OS.
* `disk_offering` - (Required) The name or ID of the disk offering to use for
this disk volume.
@ -58,4 +58,4 @@ The following arguments are supported:
The following attributes are exported:
* `id` - The ID of the disk volume.
* `device` - The device the disk volume is mapped to within the guest OS.
* `device_id` - The device ID the disk volume is mapped to within the guest OS.

View File

@ -29,6 +29,9 @@ The following arguments are supported:
* `description` - (Optional) The description of the ACL. Changing this forces a
new resource to be created.
* `project` - (Optional) The name or ID of the project to deploy this
instance to. Changing this forces a new resource to be created.
* `vpc_id` - (Required) The ID of the VPC to create this ACL for. Changing this
forces a new resource to be created.

View File

@ -40,6 +40,9 @@ The following arguments are supported:
* `rule` - (Optional) Can be specified multiple times. Each rule block supports
fields documented below. If `managed = false` at least one rule is required!
* `project` - (Optional) The name or ID of the project to deploy this
instance to. Changing this forces a new resource to be created.
* `parallelism` (Optional) Specifies how much rules will be created or deleted
concurrently. (defaults 2)