mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #8155 from fatmcgav/openstack_network_add_value_specs
provider/openstack: Add support for 'value_specs' param on 'openstack_networking_network_v2' provider.
This commit is contained in:
commit
a254aeaf9c
@ -53,10 +53,50 @@ func resourceNetworkingNetworkV2() *schema.Resource {
|
|||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"value_specs": &schema.Schema{
|
||||||
|
Type: schema.TypeMap,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NetworkCreateOpts contains all teh values needed to create a new network.
|
||||||
|
type NetworkCreateOpts struct {
|
||||||
|
AdminStateUp *bool
|
||||||
|
Name string
|
||||||
|
Shared *bool
|
||||||
|
TenantID string
|
||||||
|
ValueSpecs map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToNetworkCreateMpa casts a networkCreateOpts struct to a map.
|
||||||
|
func (opts NetworkCreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) {
|
||||||
|
n := make(map[string]interface{})
|
||||||
|
|
||||||
|
if opts.AdminStateUp != nil {
|
||||||
|
n["admin_state_up"] = &opts.AdminStateUp
|
||||||
|
}
|
||||||
|
if opts.Name != "" {
|
||||||
|
n["name"] = opts.Name
|
||||||
|
}
|
||||||
|
if opts.Shared != nil {
|
||||||
|
n["shared"] = &opts.Shared
|
||||||
|
}
|
||||||
|
if opts.TenantID != "" {
|
||||||
|
n["tenant_id"] = opts.TenantID
|
||||||
|
}
|
||||||
|
|
||||||
|
if opts.ValueSpecs != nil {
|
||||||
|
for k, v := range opts.ValueSpecs {
|
||||||
|
n[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map[string]interface{}{"network": n}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func resourceNetworkingNetworkV2Create(d *schema.ResourceData, meta interface{}) error {
|
func resourceNetworkingNetworkV2Create(d *schema.ResourceData, meta interface{}) error {
|
||||||
config := meta.(*Config)
|
config := meta.(*Config)
|
||||||
networkingClient, err := config.networkingV2Client(d.Get("region").(string))
|
networkingClient, err := config.networkingV2Client(d.Get("region").(string))
|
||||||
@ -64,9 +104,10 @@ func resourceNetworkingNetworkV2Create(d *schema.ResourceData, meta interface{})
|
|||||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
createOpts := networks.CreateOpts{
|
createOpts := NetworkCreateOpts{
|
||||||
Name: d.Get("name").(string),
|
Name: d.Get("name").(string),
|
||||||
TenantID: d.Get("tenant_id").(string),
|
TenantID: d.Get("tenant_id").(string),
|
||||||
|
ValueSpecs: networkValueSpecs(d),
|
||||||
}
|
}
|
||||||
|
|
||||||
asuRaw := d.Get("admin_state_up").(string)
|
asuRaw := d.Get("admin_state_up").(string)
|
||||||
@ -249,3 +290,11 @@ func waitForNetworkDelete(networkingClient *gophercloud.ServiceClient, networkId
|
|||||||
return n, "ACTIVE", nil
|
return n, "ACTIVE", nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func networkValueSpecs(d *schema.ResourceData) map[string]string {
|
||||||
|
m := make(map[string]string)
|
||||||
|
for key, val := range d.Get("value_specs").(map[string]interface{}) {
|
||||||
|
m[key] = val.(string)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
@ -82,6 +82,8 @@ The following arguments are supported:
|
|||||||
Acceptable values are "true" and "false". Changing this value updates the
|
Acceptable values are "true" and "false". Changing this value updates the
|
||||||
state of the existing network.
|
state of the existing network.
|
||||||
|
|
||||||
|
* `value_specs` - (Optional) Map of additional options.
|
||||||
|
|
||||||
## Attributes Reference
|
## Attributes Reference
|
||||||
|
|
||||||
The following attributes are exported:
|
The following attributes are exported:
|
||||||
|
Loading…
Reference in New Issue
Block a user