Skip to content

Commit

Permalink
Merge pull request #4784 from svanharmelen/f-export-parallelism
Browse files Browse the repository at this point in the history
provider/cloudstack: make the concurrence for applying rules configurable
  • Loading branch information
Sander van Harmelen committed Jan 21, 2016
2 parents a83d1ba + 3385100 commit 608aa69
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ func resourceCloudStackEgressFirewall() *schema.Resource {
},
},
},

"parallelism": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Default: 2,
},
},
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions builtin/providers/cloudstack/resource_cloudstack_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ func resourceCloudStackFirewall() *schema.Resource {
},
},
},

"parallelism": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Default: 2,
},
},
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ func resourceCloudStackNetworkACLRule() *schema.Resource {
},
},
},

"parallelism": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Default: 2,
},
},
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 608aa69

Please sign in to comment.