provider/openstack: Add value_specs option to openstack_networking_port_v2.
Refactored to use common types.go Add supporting documentation
This commit is contained in:
parent
eb8a9ef547
commit
b31b044785
|
@ -115,6 +115,11 @@ func resourceNetworkingPortV2() *schema.Resource {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"value_specs": &schema.Schema{
|
||||||
|
Type: schema.TypeMap,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,17 +131,20 @@ func resourceNetworkingPortV2Create(d *schema.ResourceData, meta interface{}) er
|
||||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
createOpts := ports.CreateOpts{
|
createOpts := PortCreateOpts{
|
||||||
Name: d.Get("name").(string),
|
ports.CreateOpts{
|
||||||
AdminStateUp: resourcePortAdminStateUpV2(d),
|
Name: d.Get("name").(string),
|
||||||
NetworkID: d.Get("network_id").(string),
|
AdminStateUp: resourcePortAdminStateUpV2(d),
|
||||||
MACAddress: d.Get("mac_address").(string),
|
NetworkID: d.Get("network_id").(string),
|
||||||
TenantID: d.Get("tenant_id").(string),
|
MACAddress: d.Get("mac_address").(string),
|
||||||
DeviceOwner: d.Get("device_owner").(string),
|
TenantID: d.Get("tenant_id").(string),
|
||||||
SecurityGroups: resourcePortSecurityGroupsV2(d),
|
DeviceOwner: d.Get("device_owner").(string),
|
||||||
DeviceID: d.Get("device_id").(string),
|
SecurityGroups: resourcePortSecurityGroupsV2(d),
|
||||||
FixedIPs: resourcePortFixedIpsV2(d),
|
DeviceID: d.Get("device_id").(string),
|
||||||
AllowedAddressPairs: resourceAllowedAddressPairsV2(d),
|
FixedIPs: resourcePortFixedIpsV2(d),
|
||||||
|
AllowedAddressPairs: resourceAllowedAddressPairsV2(d),
|
||||||
|
},
|
||||||
|
MapValueSpecs(d),
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||||
|
|
|
@ -3,6 +3,7 @@ package openstack
|
||||||
import (
|
import (
|
||||||
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers"
|
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers"
|
||||||
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
|
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
|
||||||
|
"github.com/gophercloud/gophercloud/openstack/networking/v2/ports"
|
||||||
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
|
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,6 +19,18 @@ func (opts NetworkCreateOpts) ToNetworkCreateMap() (map[string]interface{}, erro
|
||||||
return BuildRequest(opts, "network")
|
return BuildRequest(opts, "network")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PortCreateOpts represents the attributes used when creating a new port.
|
||||||
|
type PortCreateOpts struct {
|
||||||
|
ports.CreateOpts
|
||||||
|
ValueSpecs map[string]string `json:"value_specs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToPortCreateMap casts a CreateOpts struct to a map.
|
||||||
|
// It overrides ports.ToPortCreateMap to add the ValueSpecs field.
|
||||||
|
func (opts PortCreateOpts) ToPortCreateMap() (map[string]interface{}, error) {
|
||||||
|
return BuildRequest(opts, "port")
|
||||||
|
}
|
||||||
|
|
||||||
// RouterCreateOpts represents the attributes used when creating a new router.
|
// RouterCreateOpts represents the attributes used when creating a new router.
|
||||||
type RouterCreateOpts struct {
|
type RouterCreateOpts struct {
|
||||||
routers.CreateOpts
|
routers.CreateOpts
|
||||||
|
|
|
@ -67,6 +67,8 @@ The following arguments are supported:
|
||||||
addresses that can be active on this port. The structure is described
|
addresses that can be active on this port. The structure is described
|
||||||
below.
|
below.
|
||||||
|
|
||||||
|
* `value_specs` - (Optional) Map of additional options.
|
||||||
|
|
||||||
The `fixed_ip` block supports:
|
The `fixed_ip` block supports:
|
||||||
|
|
||||||
* `subnet_id` - (Required) Subnet in which to allocate IP address for
|
* `subnet_id` - (Required) Subnet in which to allocate IP address for
|
||||||
|
|
Loading…
Reference in New Issue