mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Fix refresing ACL rules when the ACL is deleted
This commit is contained in:
parent
b55da4c3e7
commit
29ce2df873
@ -59,6 +59,7 @@ func resourceCloudStackDisk() *schema.Resource {
|
|||||||
"project": &schema.Schema{
|
"project": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@ func resourceCloudStackInstance() *schema.Resource {
|
|||||||
"project": &schema.Schema{
|
"project": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ func resourceCloudStackIPAddress() *schema.Resource {
|
|||||||
"project": &schema.Schema{
|
"project": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ func resourceCloudStackNetwork() *schema.Resource {
|
|||||||
"project": &schema.Schema{
|
"project": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -29,6 +29,12 @@ func resourceCloudStackNetworkACL() *schema.Resource {
|
|||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"project": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
|
|
||||||
"vpc_id": &schema.Schema{
|
"vpc_id": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
@ -70,7 +76,7 @@ func resourceCloudStackNetworkACLRead(d *schema.ResourceData, meta interface{})
|
|||||||
// Get the network ACL list details
|
// Get the network ACL list details
|
||||||
f, count, err := cs.NetworkACL.GetNetworkACLListByID(
|
f, count, err := cs.NetworkACL.GetNetworkACLListByID(
|
||||||
d.Id(),
|
d.Id(),
|
||||||
cloudstack.WithVPCID(d.Get("vpc_id").(string)),
|
cloudstack.WithProject(d.Get("project").(string)),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
|
@ -2,6 +2,7 @@ package cloudstack
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -88,6 +89,12 @@ func resourceCloudStackNetworkACLRule() *schema.Resource {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"project": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
|
|
||||||
"parallelism": &schema.Schema{
|
"parallelism": &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@ -265,6 +272,22 @@ func createNetworkACLRule(d *schema.ResourceData, meta interface{}, rule map[str
|
|||||||
func resourceCloudStackNetworkACLRuleRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceCloudStackNetworkACLRuleRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
cs := meta.(*cloudstack.CloudStackClient)
|
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
|
// Get all the rules from the running environment
|
||||||
p := cs.NetworkACL.NewListNetworkACLsParams()
|
p := cs.NetworkACL.NewListNetworkACLsParams()
|
||||||
p.SetAclid(d.Id())
|
p.SetAclid(d.Id())
|
||||||
|
@ -54,6 +54,7 @@ func resourceCloudStackTemplate() *schema.Resource {
|
|||||||
"project": &schema.Schema{
|
"project": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ func resourceCloudStackVPC() *schema.Resource {
|
|||||||
"project": &schema.Schema{
|
"project": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ The following arguments are supported:
|
|||||||
* `attach` - (Optional) Determines whether or not to attach the disk volume to a
|
* `attach` - (Optional) Determines whether or not to attach the disk volume to a
|
||||||
virtual machine (defaults false).
|
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
|
* `disk_offering` - (Required) The name or ID of the disk offering to use for
|
||||||
this disk volume.
|
this disk volume.
|
||||||
@ -58,4 +58,4 @@ The following arguments are supported:
|
|||||||
The following attributes are exported:
|
The following attributes are exported:
|
||||||
|
|
||||||
* `id` - The ID of the disk volume.
|
* `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.
|
||||||
|
@ -29,6 +29,9 @@ The following arguments are supported:
|
|||||||
* `description` - (Optional) The description of the ACL. Changing this forces a
|
* `description` - (Optional) The description of the ACL. Changing this forces a
|
||||||
new resource to be created.
|
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
|
* `vpc_id` - (Required) The ID of the VPC to create this ACL for. Changing this
|
||||||
forces a new resource to be created.
|
forces a new resource to be created.
|
||||||
|
|
||||||
|
@ -40,6 +40,9 @@ The following arguments are supported:
|
|||||||
* `rule` - (Optional) Can be specified multiple times. Each rule block supports
|
* `rule` - (Optional) Can be specified multiple times. Each rule block supports
|
||||||
fields documented below. If `managed = false` at least one rule is required!
|
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
|
* `parallelism` (Optional) Specifies how much rules will be created or deleted
|
||||||
concurrently. (defaults 2)
|
concurrently. (defaults 2)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user