diff --git a/builtin/providers/cloudstack/resource_cloudstack_egress_firewall.go b/builtin/providers/cloudstack/resource_cloudstack_egress_firewall.go index 6119a2441..0ff330ef4 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_egress_firewall.go +++ b/builtin/providers/cloudstack/resource_cloudstack_egress_firewall.go @@ -81,6 +81,12 @@ func resourceCloudStackEgressFirewall() *schema.Resource { }, }, }, + + "parallelism": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Default: 2, + }, }, } } @@ -130,7 +136,7 @@ func createEgressFirewallRules( var wg sync.WaitGroup wg.Add(nrs.Len()) - sem := make(chan struct{}, 10) + sem := make(chan struct{}, d.Get("parallelism").(int)) for _, rule := range nrs.List() { // Put in a tiny sleep here to avoid DoS'ing the API time.Sleep(500 * time.Millisecond) @@ -437,7 +443,7 @@ func deleteEgressFirewallRules( var wg sync.WaitGroup wg.Add(ors.Len()) - sem := make(chan struct{}, 10) + sem := make(chan struct{}, d.Get("parallelism").(int)) for _, rule := range ors.List() { // Put a sleep here to avoid DoS'ing the API time.Sleep(500 * time.Millisecond) diff --git a/builtin/providers/cloudstack/resource_cloudstack_firewall.go b/builtin/providers/cloudstack/resource_cloudstack_firewall.go index 7bb60ef28..cfe3531f7 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_firewall.go +++ b/builtin/providers/cloudstack/resource_cloudstack_firewall.go @@ -81,6 +81,12 @@ func resourceCloudStackFirewall() *schema.Resource { }, }, }, + + "parallelism": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Default: 2, + }, }, } } @@ -129,7 +135,7 @@ func createFirewallRules( var wg sync.WaitGroup wg.Add(nrs.Len()) - sem := make(chan struct{}, 10) + sem := make(chan struct{}, d.Get("parallelism").(int)) for _, rule := range nrs.List() { // Put in a tiny sleep here to avoid DoS'ing the API time.Sleep(500 * time.Millisecond) @@ -438,7 +444,7 @@ func deleteFirewallRules( var wg sync.WaitGroup wg.Add(ors.Len()) - sem := make(chan struct{}, 10) + sem := make(chan struct{}, d.Get("parallelism").(int)) for _, rule := range ors.List() { // Put a sleep here to avoid DoS'ing the API time.Sleep(500 * time.Millisecond) diff --git a/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule.go b/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule.go index 66dcc772e..14e39d99c 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule.go +++ b/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule.go @@ -93,6 +93,12 @@ func resourceCloudStackNetworkACLRule() *schema.Resource { }, }, }, + + "parallelism": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Default: 2, + }, }, } } @@ -134,7 +140,7 @@ func createNetworkACLRules( var wg sync.WaitGroup wg.Add(nrs.Len()) - sem := make(chan struct{}, 10) + sem := make(chan struct{}, d.Get("parallelism").(int)) for _, rule := range nrs.List() { // Put in a tiny sleep here to avoid DoS'ing the API time.Sleep(500 * time.Millisecond) @@ -491,7 +497,7 @@ func deleteNetworkACLRules( var wg sync.WaitGroup wg.Add(ors.Len()) - sem := make(chan struct{}, 10) + sem := make(chan struct{}, d.Get("parallelism").(int)) for _, rule := range ors.List() { // Put a sleep here to avoid DoS'ing the API time.Sleep(500 * time.Millisecond) diff --git a/website/source/docs/providers/cloudstack/r/egress_firewall.html.markdown b/website/source/docs/providers/cloudstack/r/egress_firewall.html.markdown index dfb42281a..acec778d9 100644 --- a/website/source/docs/providers/cloudstack/r/egress_firewall.html.markdown +++ b/website/source/docs/providers/cloudstack/r/egress_firewall.html.markdown @@ -38,6 +38,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! +* `parallelism` (Optional) Specifies how much rules will be created or deleted + concurrently. (defaults 2) + The `rule` block supports: * `cidr_list` - (Required) A CIDR list to allow access to the given ports. diff --git a/website/source/docs/providers/cloudstack/r/firewall.html.markdown b/website/source/docs/providers/cloudstack/r/firewall.html.markdown index 70478fa10..01a93cbf7 100644 --- a/website/source/docs/providers/cloudstack/r/firewall.html.markdown +++ b/website/source/docs/providers/cloudstack/r/firewall.html.markdown @@ -38,6 +38,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! +* `parallelism` (Optional) Specifies how much rules will be created or deleted + concurrently. (defaults 2) + The `rule` block supports: * `cidr_list` - (Required) A CIDR list to allow access to the given ports. diff --git a/website/source/docs/providers/cloudstack/r/network_acl_rule.html.markdown b/website/source/docs/providers/cloudstack/r/network_acl_rule.html.markdown index 59b6f1b9a..267eca346 100644 --- a/website/source/docs/providers/cloudstack/r/network_acl_rule.html.markdown +++ b/website/source/docs/providers/cloudstack/r/network_acl_rule.html.markdown @@ -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! +* `parallelism` (Optional) Specifies how much rules will be created or deleted + concurrently. (defaults 2) + The `rule` block supports: * `action` - (Optional) The action for the rule. Valid options are: `allow` and