Merge pull request #9836 from fatmcgav/openstack_fw_firewall_v1_add_value_specs

provider/openstack: Add 'value_specs' option to 'openstack_fw_firewall_v1' resource
This commit is contained in:
Joe Topjian 2016-11-05 09:04:04 -06:00 committed by GitHub
commit 6f67b693c0
3 changed files with 30 additions and 7 deletions

View File

@ -51,6 +51,11 @@ func resourceFWFirewallV1() *schema.Resource {
ForceNew: true,
Computed: true,
},
"value_specs": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
},
},
}
}
@ -65,12 +70,15 @@ func resourceFWFirewallV1Create(d *schema.ResourceData, meta interface{}) error
adminStateUp := d.Get("admin_state_up").(bool)
firewallConfiguration := firewalls.CreateOpts{
firewallConfiguration := FirewallCreateOpts{
firewalls.CreateOpts{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
PolicyID: d.Get("policy_id").(string),
AdminStateUp: &adminStateUp,
TenantID: d.Get("tenant_id").(string),
},
MapValueSpecs(d),
}
log.Printf("[DEBUG] Create firewall: %#v", firewallConfiguration)

View File

@ -2,6 +2,7 @@ package openstack
import (
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/policies"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/rules"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
@ -11,7 +12,19 @@ import (
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
)
// FloatingIPCreateOpts represents the attributes used when creating a new port.
// FirewallCreateOpts represents the attributes used when creating a new firewall.
type FirewallCreateOpts struct {
firewalls.CreateOpts
ValueSpecs map[string]string `json:"value_specs,omitempty"`
}
// ToFirewallCreateMap casts a CreateOpts struct to a map.
// It overrides firewalls.ToFirewallCreateMap to add the ValueSpecs field.
func (opts FirewallCreateOpts) ToFirewallCreateMap() (map[string]interface{}, error) {
return BuildRequest(opts, "firewall")
}
// FloatingIPCreateOpts represents the attributes used when creating a new floating ip.
type FloatingIPCreateOpts struct {
floatingips.CreateOpts
ValueSpecs map[string]string `json:"value_specs,omitempty"`

View File

@ -69,6 +69,8 @@ The following arguments are supported:
to create a firewall for another tenant. Changing this creates a new
firewall.
* `value_specs` - (Optional) Map of additional options.
## Attributes Reference
The following attributes are exported: