Make the concurrence for applying rules configurable

This commit is contained in:
Sander van Harmelen 2016-01-21 21:30:54 +01:00
parent a83d1bab23
commit 3385100f56
6 changed files with 33 additions and 6 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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.

View File

@ -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.

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!
* `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