fixes after adding rackspace/gophercloud commits
diff --git a/openstack/networking/v2/subnets/requests.go b/openstack/networking/v2/subnets/requests.go
index 2706a5e..769474d 100644
--- a/openstack/networking/v2/subnets/requests.go
+++ b/openstack/networking/v2/subnets/requests.go
@@ -64,16 +64,6 @@
return
}
-// IPVersion is the IP address version for the subnet. Valid instances are
-// 4 and 6
-type IPVersion int
-
-// Valid IP types
-const (
- IPv4 IPVersion = 4
- IPv6 IPVersion = 6
-)
-
// CreateOptsBuilder is the interface options structs have to satisfy in order
// to be used in the main Create operation in this package. Since many
// extensions decorate or modify the common logic, it is useful for them to
@@ -84,16 +74,16 @@
// CreateOpts represents the attributes used when creating a new subnet.
type CreateOpts struct {
- NetworkID string `json:"network_id" required:"true"`
- CIDR string `json:"cidr" required:"true"`
- Name string `json:"name,omitempty"`
- TenantID string `json:"tenant_id,omitempty"`
- AllocationPools []AllocationPool `json:"allocation_pools,omitempty"`
- GatewayIP string `json:"gateway_ip,omitempty"`
- IPVersion IPVersion `json:"ip_version,omitempty"`
- EnableDHCP *bool `json:"enable_dhcp,omitempty"`
- DNSNameservers []string `json:"dns_nameservers,omitempty"`
- HostRoutes []HostRoute `json:"host_routes,omitempty"`
+ NetworkID string `json:"network_id" required:"true"`
+ CIDR string `json:"cidr" required:"true"`
+ Name string `json:"name,omitempty"`
+ TenantID string `json:"tenant_id,omitempty"`
+ AllocationPools []AllocationPool `json:"allocation_pools,omitempty"`
+ GatewayIP *string `json:"gateway_ip"`
+ IPVersion gophercloud.IPVersion `json:"ip_version,omitempty"`
+ EnableDHCP *bool `json:"enable_dhcp,omitempty"`
+ DNSNameservers []string `json:"dns_nameservers,omitempty"`
+ HostRoutes []HostRoute `json:"host_routes,omitempty"`
}
// ToSubnetCreateMap casts a CreateOpts struct to a map.
diff --git a/openstack/networking/v2/subnets/requests_test.go b/openstack/networking/v2/subnets/requests_test.go
index 3738d4b..4241c63 100644
--- a/openstack/networking/v2/subnets/requests_test.go
+++ b/openstack/networking/v2/subnets/requests_test.go
@@ -230,6 +230,7 @@
"subnet": {
"network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
"ip_version": 4,
+ "gateway_ip": null,
"cidr": "192.168.199.0/24",
"dns_nameservers": ["foo"],
"allocation_pools": [
@@ -362,7 +363,6 @@
NetworkID: "d32019d3-bc6e-4319-9c1d-6722fc136a23",
IPVersion: 4,
CIDR: "192.168.1.0/24",
- NoGateway: true,
AllocationPools: []AllocationPool{
AllocationPool{
Start: "192.168.1.2",
@@ -391,60 +391,6 @@
th.AssertEquals(t, s.ID, "54d6f61d-db07-451c-9ab3-b9609b6b6f0c")
}
-func TestCreateInvalidGatewayConfig(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/v2.0/subnets", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
-{
- "subnet": {
- "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23",
- "ip_version": 4,
- "cidr": "192.168.1.0/24",
- "gateway_ip": "192.168.1.1",
- "allocation_pools": [
- {
- "start": "192.168.1.2",
- "end": "192.168.1.254"
- }
- ]
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
- })
-
- opts := CreateOpts{
- NetworkID: "d32019d3-bc6e-4319-9c1d-6722fc136a23",
- IPVersion: 4,
- CIDR: "192.168.1.0/24",
- NoGateway: true,
- GatewayIP: "192.168.1.1",
- AllocationPools: []AllocationPool{
- AllocationPool{
- Start: "192.168.1.2",
- End: "192.168.1.254",
- },
- },
- DNSNameservers: []string{},
- }
- _, err := Create(fake.ServiceClient(), opts).Extract()
- if err == nil {
- t.Fatalf("Expected an error, got none")
- }
-
- if err != errInvalidGatewayConfig {
- t.Fatalf("Exected errInvalidGateway but got: %s", err)
- }
-}
-
func TestRequiredCreateOpts(t *testing.T) {
res := Create(fake.ServiceClient(), CreateOpts{})
if res.Err == nil {