Merge pull request #4784 from svanharmelen/f-export-parallelism
provider/cloudstack: make the concurrence for applying rules configurable
This commit is contained in:
commit
608aa698c8
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue