fixes after adding rackspace/gophercloud commits
diff --git a/acceptance/openstack/networking/v2/extensions/lbaas/common.go b/acceptance/openstack/networking/v2/extensions/lbaas/common.go
index 045a8ae..ed948bd 100644
--- a/acceptance/openstack/networking/v2/extensions/lbaas/common.go
+++ b/acceptance/openstack/networking/v2/extensions/lbaas/common.go
@@ -3,6 +3,7 @@
import (
"testing"
+ "github.com/gophercloud/gophercloud"
base "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/monitors"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/pools"
@@ -22,7 +23,7 @@
s, err := subnets.Create(base.Client, subnets.CreateOpts{
NetworkID: n.ID,
CIDR: "192.168.199.0/24",
- IPVersion: subnets.IPv4,
+ IPVersion: gophercloud.IPv4,
Name: "tmp_subnet",
}).Extract()
th.AssertNoErr(t, err)
diff --git a/openstack/blockstorage/v1/apiversions/urls_test.go b/openstack/blockstorage/v1/apiversions/urls_test.go
deleted file mode 100644
index 68cfb8c..0000000
--- a/openstack/blockstorage/v1/apiversions/urls_test.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package apiversions
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-const endpoint = "http://localhost:57909/"
-const endpoint2 = "http://localhost:57909/v1/3a02ee0b5cf14816b41b17e851d29a94"
-
-func endpointClient() *gophercloud.ServiceClient {
- return &gophercloud.ServiceClient{Endpoint: endpoint}
-}
-
-func endpointClient2() *gophercloud.ServiceClient {
- return &gophercloud.ServiceClient{Endpoint: endpoint2}
-}
-
-func TestGetURL(t *testing.T) {
- actual := getURL(endpointClient(), "v1")
- expected := endpoint + "v1/"
- th.AssertEquals(t, expected, actual)
-}
-
-func TestListURL(t *testing.T) {
- actual := listURL(endpointClient2())
- expected := endpoint
- th.AssertEquals(t, expected, actual)
-}
diff --git a/openstack/compute/v2/extensions/defsecrules/fixtures.go b/openstack/compute/v2/extensions/defsecrules/fixtures.go
index 4fee896..bf708f8 100644
--- a/openstack/compute/v2/extensions/defsecrules/fixtures.go
+++ b/openstack/compute/v2/extensions/defsecrules/fixtures.go
@@ -83,8 +83,8 @@
{
"security_group_default_rule": {
"ip_protocol": "ICMP",
- "from_port": 0,
- "to_port": 0,
+ "from_port": 80,
+ "to_port": 80,
"cidr": "10.10.12.0/24"
}
}
@@ -96,13 +96,13 @@
fmt.Fprintf(w, `
{
"security_group_default_rule": {
- "from_port": 0,
+ "from_port": 80,
"id": "{ruleID}",
"ip_protocol": "ICMP",
"ip_range": {
"cidr": "10.10.12.0/24"
},
- "to_port": 0
+ "to_port": 80
}
}
`)
diff --git a/openstack/compute/v2/extensions/defsecrules/requests.go b/openstack/compute/v2/extensions/defsecrules/requests.go
index 6f24bb3..5d74256 100644
--- a/openstack/compute/v2/extensions/defsecrules/requests.go
+++ b/openstack/compute/v2/extensions/defsecrules/requests.go
@@ -14,7 +14,7 @@
// CreateOpts represents the configuration for adding a new default rule.
type CreateOpts struct {
- // The lower bound of the port range that will be opened.
+ // The lower bound of the port range that will be opened.s
FromPort int `json:"from_port" required:"true"`
// The upper bound of the port range that will be opened.
ToPort int `json:"to_port" required:"true"`
diff --git a/openstack/compute/v2/extensions/defsecrules/requests_test.go b/openstack/compute/v2/extensions/defsecrules/requests_test.go
index df568fe..3cbc990 100644
--- a/openstack/compute/v2/extensions/defsecrules/requests_test.go
+++ b/openstack/compute/v2/extensions/defsecrules/requests_test.go
@@ -77,8 +77,8 @@
opts := CreateOpts{
IPProtocol: "ICMP",
- FromPort: 0,
- ToPort: 0,
+ FromPort: 80,
+ ToPort: 80,
CIDR: "10.10.12.0/24",
}
@@ -87,8 +87,8 @@
expected := &DefaultRule{
ID: ruleID,
- FromPort: 0,
- ToPort: 0,
+ FromPort: 80,
+ ToPort: 80,
IPProtocol: "ICMP",
IPRange: secgroups.IPRange{CIDR: "10.10.12.0/24"},
}
diff --git a/openstack/compute/v2/extensions/secgroups/fixtures.go b/openstack/compute/v2/extensions/secgroups/fixtures.go
index e4ca587..4e4c0e4 100644
--- a/openstack/compute/v2/extensions/secgroups/fixtures.go
+++ b/openstack/compute/v2/extensions/secgroups/fixtures.go
@@ -226,9 +226,9 @@
th.TestJSONRequest(t, r, `
{
"security_group_rule": {
- "from_port": 0,
+ "from_port": 80,
"ip_protocol": "ICMP",
- "to_port": 0,
+ "to_port": 80,
"parent_group_id": "{groupID}",
"cidr": "0.0.0.0/0"
}
@@ -240,10 +240,10 @@
fmt.Fprintf(w, `
{
"security_group_rule": {
- "from_port": 0,
+ "from_port": 80,
"group": {},
"ip_protocol": "ICMP",
- "to_port": 0,
+ "to_port": 80,
"parent_group_id": "{groupID}",
"ip_range": {
"cidr": "0.0.0.0/0"
diff --git a/openstack/compute/v2/extensions/secgroups/requests.go b/openstack/compute/v2/extensions/secgroups/requests.go
index 81993bd..1cdbde0 100644
--- a/openstack/compute/v2/extensions/secgroups/requests.go
+++ b/openstack/compute/v2/extensions/secgroups/requests.go
@@ -101,23 +101,23 @@
// CreateRuleOpts represents the configuration for adding a new rule to an
// existing security group.
type CreateRuleOpts struct {
- // Required - the ID of the group that this rule will be added to.
+ // the ID of the group that this rule will be added to.
ParentGroupID string `json:"parent_group_id" required:"true"`
- // Required - the lower bound of the port range that will be opened.
+ // the lower bound of the port range that will be opened.
FromPort int `json:"from_port" required:"true"`
- // Required - the upper bound of the port range that will be opened.
+ // the upper bound of the port range that will be opened.
ToPort int `json:"to_port" required:"true"`
- // Required - the protocol type that will be allowed, e.g. TCP.
+ // the protocol type that will be allowed, e.g. TCP.
IPProtocol string `json:"ip_protocol" required:"true"`
// ONLY required if FromGroupID is blank. This represents the IP range that
// will be the source of network traffic to your security group. Use
// 0.0.0.0/0 to allow all IP addresses.
- CIDR string `json:"cidr,omitempty"`
+ CIDR string `json:"cidr,omitempty" or:"FromGroupID"`
// ONLY required if CIDR is blank. This value represents the ID of a group
// that forwards traffic to the parent group. So, instead of accepting
// network traffic from an entire IP range, you can instead refine the
// inbound source by an existing security group.
- FromGroupID string `json:"group_id,omitempty"`
+ FromGroupID string `json:"group_id,omitempty" or:"CIDR"`
}
// CreateRuleOptsBuilder builds the create rule options into a serializable format.
diff --git a/openstack/compute/v2/extensions/secgroups/requests_test.go b/openstack/compute/v2/extensions/secgroups/requests_test.go
index bdbedcd..1509733 100644
--- a/openstack/compute/v2/extensions/secgroups/requests_test.go
+++ b/openstack/compute/v2/extensions/secgroups/requests_test.go
@@ -225,8 +225,8 @@
opts := CreateRuleOpts{
ParentGroupID: groupID,
- FromPort: 0,
- ToPort: 0,
+ FromPort: 80,
+ ToPort: 80,
IPProtocol: "ICMP",
CIDR: "0.0.0.0/0",
}
@@ -235,8 +235,8 @@
th.AssertNoErr(t, err)
expected := &Rule{
- FromPort: 0,
- ToPort: 0,
+ FromPort: 80,
+ ToPort: 80,
Group: Group{},
IPProtocol: "ICMP",
ParentGroupID: groupID,
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 {