Skip to content

Commit 3929792

Browse files
authored
Merge pull request hashicorp#9552 from fatmcgav/openstack_networking_floatingip_add_value_specs
provider/openstack: Add 'value_specs' option to 'openstack_networking…
2 parents 1d66951 + 60ddc06 commit 3929792

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

builtin/providers/openstack/resource_openstack_networking_floatingip_v2.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ func resourceNetworkingFloatingIPV2() *schema.Resource {
5757
Optional: true,
5858
Computed: true,
5959
},
60+
"value_specs": &schema.Schema{
61+
Type: schema.TypeMap,
62+
Optional: true,
63+
ForceNew: true,
64+
},
6065
},
6166
}
6267
}
@@ -75,12 +80,16 @@ func resourceNetworkFloatingIPV2Create(d *schema.ResourceData, meta interface{})
7580
if len(poolID) == 0 {
7681
return fmt.Errorf("No network found with name: %s", d.Get("pool").(string))
7782
}
78-
createOpts := floatingips.CreateOpts{
79-
FloatingNetworkID: poolID,
80-
PortID: d.Get("port_id").(string),
81-
TenantID: d.Get("tenant_id").(string),
82-
FixedIP: d.Get("fixed_ip").(string),
83+
createOpts := FloatingIPCreateOpts{
84+
floatingips.CreateOpts{
85+
FloatingNetworkID: poolID,
86+
PortID: d.Get("port_id").(string),
87+
TenantID: d.Get("tenant_id").(string),
88+
FixedIP: d.Get("fixed_ip").(string),
89+
},
90+
MapValueSpecs(d),
8391
}
92+
8493
log.Printf("[DEBUG] Create Options: %#v", createOpts)
8594
floatingIP, err := floatingips.Create(networkingClient, createOpts).Extract()
8695
if err != nil {

builtin/providers/openstack/types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
package openstack
22

33
import (
4+
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
45
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers"
56
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
67
"github.com/gophercloud/gophercloud/openstack/networking/v2/ports"
78
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
89
)
910

11+
// FloatingIPCreateOpts represents the attributes used when creating a new port.
12+
type FloatingIPCreateOpts struct {
13+
floatingips.CreateOpts
14+
ValueSpecs map[string]string `json:"value_specs,omitempty"`
15+
}
16+
17+
// ToFloatingIPCreateMap casts a CreateOpts struct to a map.
18+
// It overrides floatingips.ToFloatingIPCreateMap to add the ValueSpecs field.
19+
func (opts FloatingIPCreateOpts) ToFloatingIPCreateMap() (map[string]interface{}, error) {
20+
return BuildRequest(opts, "floatingip")
21+
}
22+
1023
// NetworkCreateOpts represents the attributes used when creating a new network.
1124
type NetworkCreateOpts struct {
1225
networks.CreateOpts

website/source/docs/providers/openstack/r/networking_floatingip_v2.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ The following arguments are supported:
4545
* `fixed_ip` - Fixed IP of the port to associate with this floating IP. Required if
4646
the port has multiple fixed IPs.
4747

48+
* `value_specs` - (Optional) Map of additional options.
49+
4850
## Attributes Reference
4951

5052
The following attributes are exported:

0 commit comments

Comments
 (0)