Merge pull request #9835 from fatmcgav/openstack_fw_policy_v1_add_value_specs

provider/openstack: Add 'value_specs' option to 'openstack_fw_policy_v1' resource
This commit is contained in:
Joe Topjian 2016-11-04 19:33:14 -06:00 committed by GitHub
commit 5efe1a7400
3 changed files with 29 additions and 6 deletions

View File

@ -56,6 +56,11 @@ func resourceFWPolicyV1() *schema.Resource {
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"value_specs": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
},
}, },
} }
} }
@ -79,12 +84,15 @@ func resourceFWPolicyV1Create(d *schema.ResourceData, meta interface{}) error {
audited := d.Get("audited").(bool) audited := d.Get("audited").(bool)
opts := policies.CreateOpts{ opts := PolicyCreateOpts{
Name: d.Get("name").(string), policies.CreateOpts{
Description: d.Get("description").(string), Name: d.Get("name").(string),
Audited: &audited, Description: d.Get("description").(string),
TenantID: d.Get("tenant_id").(string), Audited: &audited,
Rules: rules, TenantID: d.Get("tenant_id").(string),
Rules: rules,
},
MapValueSpecs(d),
} }
if r, ok := d.GetOk("shared"); ok { if r, ok := d.GetOk("shared"); ok {

View File

@ -2,6 +2,7 @@ package openstack
import ( import (
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs"
"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/fwaas/rules"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers"
@ -46,6 +47,18 @@ func (opts NetworkCreateOpts) ToNetworkCreateMap() (map[string]interface{}, erro
return BuildRequest(opts, "network") return BuildRequest(opts, "network")
} }
// PolicyCreateOpts represents the attributes used when creating a new firewall policy.
type PolicyCreateOpts struct {
policies.CreateOpts
ValueSpecs map[string]string `json:"value_specs,omitempty"`
}
// ToPolicyCreateMap casts a CreateOpts struct to a map.
// It overrides policies.ToFirewallPolicyCreateMap to add the ValueSpecs field.
func (opts PolicyCreateOpts) ToFirewallPolicyCreateMap() (map[string]interface{}, error) {
return BuildRequest(opts, "firewall_policy")
}
// PortCreateOpts represents the attributes used when creating a new port. // PortCreateOpts represents the attributes used when creating a new port.
type PortCreateOpts struct { type PortCreateOpts struct {
ports.CreateOpts ports.CreateOpts

View File

@ -69,6 +69,8 @@ The following arguments are supported:
`shared` status of an existing firewall policy. Only administrative users `shared` status of an existing firewall policy. Only administrative users
can specify if the policy should be shared. can specify if the policy should be shared.
* `value_specs` - (Optional) Map of additional options.
## Attributes Reference ## Attributes Reference
The following attributes are exported: The following attributes are exported: