Update blockstorage v2 API
diff --git a/openstack/blockstorage/v2/volumes/fixtures.go b/openstack/blockstorage/v2/volumes/fixtures.go
new file mode 100644
index 0000000..b70e298
--- /dev/null
+++ b/openstack/blockstorage/v2/volumes/fixtures.go
@@ -0,0 +1,204 @@
+package volumes
+
+import (
+ "fmt"
+ "net/http"
+ "testing"
+
+ th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
+)
+
+func MockListResponse(t *testing.T) {
+ th.Mux.HandleFunc("/volumes/detail", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "GET")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+
+ w.Header().Add("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+
+ fmt.Fprintf(w, `
+ {
+ "volumes": [
+ {
+ "volume_type": "lvmdriver-1",
+ "created_at": "2015-09-17T03:35:03.000000",
+ "bootable": "false",
+ "name": "vol-001",
+ "os-vol-mig-status-attr:name_id": null,
+ "consistencygroup_id": null,
+ "source_volid": null,
+ "os-volume-replication:driver_data": null,
+ "multiattach": false,
+ "snapshot_id": null,
+ "replication_status": "disabled",
+ "os-volume-replication:extended_status": null,
+ "encrypted": false,
+ "os-vol-host-attr:host": null,
+ "availability_zone": "nova",
+ "attachments": [
+ {
+ "attachment_id": "03987cd1-0ad5-40d1-9b2a-7cc48295d4fa",
+ "id": "47e9ecc5-4045-4ee3-9a4b-d859d546a0cf",
+ "volume_id": "289da7f8-6440-407c-9fb4-7db01ec49164",
+ "server_id": "d1c4788b-9435-42e2-9b81-29f3be1cd01f",
+ "host_name": "stack",
+ "device": "/dev/vdc"
+ }
+ ],
+ "id": "289da7f8-6440-407c-9fb4-7db01ec49164",
+ "size": 75,
+ "user_id": "ff1ce52c03ab433aaba9108c2e3ef541",
+ "os-vol-tenant-attr:tenant_id": "304dc00909ac4d0da6c62d816bcb3459",
+ "os-vol-mig-status-attr:migstat": null,
+ "metadata": {"foo": "bar"},
+ "status": "available",
+ "description": null
+ },
+ {
+ "volume_type": "lvmdriver-1",
+ "created_at": "2015-09-17T03:32:29.000000",
+ "bootable": "false",
+ "name": "vol-002",
+ "os-vol-mig-status-attr:name_id": null,
+ "consistencygroup_id": null,
+ "source_volid": null,
+ "os-volume-replication:driver_data": null,
+ "multiattach": false,
+ "snapshot_id": null,
+ "replication_status": "disabled",
+ "os-volume-replication:extended_status": null,
+ "encrypted": false,
+ "os-vol-host-attr:host": null,
+ "availability_zone": "nova",
+ "attachments": [],
+ "id": "96c3bda7-c82a-4f50-be73-ca7621794835",
+ "size": 75,
+ "user_id": "ff1ce52c03ab433aaba9108c2e3ef541",
+ "os-vol-tenant-attr:tenant_id": "304dc00909ac4d0da6c62d816bcb3459",
+ "os-vol-mig-status-attr:migstat": null,
+ "metadata": {},
+ "status": "available",
+ "description": null
+ }
+ ]
+}
+
+ `)
+ })
+}
+
+func MockGetResponse(t *testing.T) {
+ th.Mux.HandleFunc("/volumes/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "GET")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+
+ w.Header().Add("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ fmt.Fprintf(w, `
+{
+ "volume": {
+ "volume_type": "lvmdriver-1",
+ "created_at": "2015-09-17T03:32:29.000000",
+ "bootable": "false",
+ "name": "vol-001",
+ "os-vol-mig-status-attr:name_id": null,
+ "consistencygroup_id": null,
+ "source_volid": null,
+ "os-volume-replication:driver_data": null,
+ "multiattach": false,
+ "snapshot_id": null,
+ "replication_status": "disabled",
+ "os-volume-replication:extended_status": null,
+ "encrypted": false,
+ "os-vol-host-attr:host": null,
+ "availability_zone": "nova",
+ "attachments": [{
+ "attachment_id": "dbce64e3-f3b9-4423-a44f-a2b15deffa1b",
+ "id": "3eafc6f5-ed74-456d-90fb-f253f594dbae",
+ "volume_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
+ "server_id": "d1c4788b-9435-42e2-9b81-29f3be1cd01f",
+ "host_name": "stack",
+ "device": "/dev/vdd"
+ }],
+ "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
+ "size": 75,
+ "user_id": "ff1ce52c03ab433aaba9108c2e3ef541",
+ "os-vol-tenant-attr:tenant_id": "304dc00909ac4d0da6c62d816bcb3459",
+ "os-vol-mig-status-attr:migstat": null,
+ "metadata": {},
+ "status": "available",
+ "description": null
+ }
+}
+ `)
+ })
+}
+
+func MockCreateResponse(t *testing.T) {
+ th.Mux.HandleFunc("/volumes", 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, `
+{
+ "volume": {
+ "name": "vol-001",
+ "size": 75
+ }
+}
+ `)
+
+ w.Header().Add("Content-Type", "application/json")
+ w.WriteHeader(http.StatusAccepted)
+
+ fmt.Fprintf(w, `
+{
+ "volume": {
+ "size": 75,
+ "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
+ "metadata": {},
+ "created_at": "2015-09-17T03:32:29.044216",
+ "encrypted": false,
+ "bootable": "false",
+ "availability_zone": "nova",
+ "attachments": [],
+ "user_id": "ff1ce52c03ab433aaba9108c2e3ef541",
+ "status": "creating",
+ "description": null,
+ "volume_type": "lvmdriver-1",
+ "name": "vol-001",
+ "replication_status": "disabled",
+ "consistencygroup_id": null,
+ "source_volid": null,
+ "snapshot_id": null,
+ "multiattach": false
+ }
+}
+ `)
+ })
+}
+
+func MockDeleteResponse(t *testing.T) {
+ th.Mux.HandleFunc("/volumes/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "DELETE")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+ w.WriteHeader(http.StatusAccepted)
+ })
+}
+
+func MockUpdateResponse(t *testing.T) {
+ th.Mux.HandleFunc("/volumes/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "PUT")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+ w.WriteHeader(http.StatusOK)
+ fmt.Fprintf(w, `
+{
+ "volume": {
+ "name": "vol-002"
+ }
+}
+ `)
+ })
+}
diff --git a/openstack/blockstorage/v2/volumes/requests.go b/openstack/blockstorage/v2/volumes/requests.go
index 3e9243a..4c60936 100644
--- a/openstack/blockstorage/v2/volumes/requests.go
+++ b/openstack/blockstorage/v2/volumes/requests.go
@@ -17,19 +17,28 @@
// the volumes.Create function. For more information about these parameters,
// see the Volume object.
type CreateOpts struct {
- // OPTIONAL
- Availability string
- // OPTIONAL
+ // The availability zone [OPTIONAL]
+ AvailabilityZone string
+ // ConsistencyGroupID is the ID of a consistency group [OPTINAL]
+ ConsistencyGroupID string
+ // The volume description [OPTIONAL]
Description string
- // OPTIONAL
+ // One or more metadata key and value pairs to associate with the volume [OPTIONAL]
Metadata map[string]string
- // OPTIONAL
+ // The volume name [OPTIONAL]
Name string
- // REQUIRED
+ // The size of the volume, in gibibytes (GiB) [REQUIRED]
Size int
- // OPTIONAL
- SnapshotID, SourceVolID, ImageID string
- // OPTIONAL
+ // the ID of the existing volume snapshot [OPTIONAL]
+ SnapshotID string
+ // SourceReplica is a UUID of an existing volume to replicate with [OPTIONAL]
+ SourceReplica string
+ // the ID of the existing volume [OPTIONAL]
+ SourceVolID string
+ // The ID of the image from which you want to create the volume.
+ // Required to create a bootable volume.
+ ImageID string
+ // The associated volume type [OPTIONAL]
VolumeType string
}
@@ -43,11 +52,14 @@
}
v["size"] = opts.Size
- if opts.Availability != "" {
- v["availability_zone"] = opts.Availability
+ if opts.AvailabilityZone != "" {
+ v["availability_zone"] = opts.AvailabilityZone
+ }
+ if opts.ConsistencyGroupID != "" {
+ v["consistencygroup_id"] = opts.ConsistencyGroupID
}
if opts.Description != "" {
- v["display_description"] = opts.Description
+ v["description"] = opts.Description
}
if opts.ImageID != "" {
v["imageRef"] = opts.ImageID
@@ -56,7 +68,10 @@
v["metadata"] = opts.Metadata
}
if opts.Name != "" {
- v["display_name"] = opts.Name
+ v["name"] = opts.Name
+ }
+ if opts.SourceReplica != "" {
+ v["source_replica"] = opts.SourceReplica
}
if opts.SourceVolID != "" {
v["source_volid"] = opts.SourceVolID
@@ -84,7 +99,7 @@
}
_, res.Err = client.Post(createURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{
- OkCodes: []int{200, 201},
+ OkCodes: []int{202},
})
return res
}
@@ -173,13 +188,13 @@
v := make(map[string]interface{})
if opts.Description != "" {
- v["display_description"] = opts.Description
+ v["description"] = opts.Description
}
if opts.Metadata != nil {
v["metadata"] = opts.Metadata
}
if opts.Name != "" {
- v["display_name"] = opts.Name
+ v["name"] = opts.Name
}
return map[string]interface{}{"volume": v}, nil
diff --git a/openstack/blockstorage/v2/volumes/requests_test.go b/openstack/blockstorage/v2/volumes/requests_test.go
index 75c2bbc..962d94b 100644
--- a/openstack/blockstorage/v2/volumes/requests_test.go
+++ b/openstack/blockstorage/v2/volumes/requests_test.go
@@ -3,7 +3,6 @@
import (
"testing"
- fixtures "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/testing"
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
"github.com/rackspace/gophercloud/testhelper/client"
@@ -13,7 +12,7 @@
th.SetupHTTP()
defer th.TeardownHTTP()
- fixtures.MockListResponse(t)
+ MockListResponse(t)
count := 0
@@ -26,13 +25,58 @@
}
expected := []Volume{
- Volume{
+ {
ID: "289da7f8-6440-407c-9fb4-7db01ec49164",
Name: "vol-001",
+ Attachments: []map[string]interface{}{{
+ "AttachmentID": "03987cd1-0ad5-40d1-9b2a-7cc48295d4fa",
+ "ID": "47e9ecc5-4045-4ee3-9a4b-d859d546a0cf",
+ "VolumeID": "289da7f8-6440-407c-9fb4-7db01ec49164",
+ "ServerID": "d1c4788b-9435-42e2-9b81-29f3be1cd01f",
+ "HostName": "stack",
+ "Device": "/dev/vdc",
+ }},
+ AvailabilityZone: "nova",
+ Bootable: "false",
+ ConsistencyGroupID: "",
+ CreatedAt: "2015-09-17T03:35:03.000000",
+ Description: "",
+ Encrypted: false,
+ Metadata: map[string]string{"foo": "bar"},
+ Multiattach: false,
+ TenantID: "304dc00909ac4d0da6c62d816bcb3459",
+ ReplicationDriverData: "",
+ ReplicationExtendedStatus: "",
+ ReplicationStatus: "disabled",
+ Size: 75,
+ SnapshotID: "",
+ SourceVolID: "",
+ Status: "available",
+ UserID: "ff1ce52c03ab433aaba9108c2e3ef541",
+ VolumeType: "lvmdriver-1",
},
- Volume{
- ID: "96c3bda7-c82a-4f50-be73-ca7621794835",
- Name: "vol-002",
+ {
+ ID: "96c3bda7-c82a-4f50-be73-ca7621794835",
+ Name: "vol-002",
+ Attachments: []map[string]interface{}{},
+ AvailabilityZone: "nova",
+ Bootable: "false",
+ ConsistencyGroupID: "",
+ CreatedAt: "2015-09-17T03:32:29.000000",
+ Description: "",
+ Encrypted: false,
+ Metadata: map[string]string{},
+ Multiattach: false,
+ TenantID: "304dc00909ac4d0da6c62d816bcb3459",
+ ReplicationDriverData: "",
+ ReplicationExtendedStatus: "",
+ ReplicationStatus: "disabled",
+ Size: 75,
+ SnapshotID: "",
+ SourceVolID: "",
+ Status: "available",
+ UserID: "ff1ce52c03ab433aaba9108c2e3ef541",
+ VolumeType: "lvmdriver-1",
},
}
@@ -50,7 +94,7 @@
th.SetupHTTP()
defer th.TeardownHTTP()
- fixtures.MockListResponse(t)
+ MockListResponse(t)
allPages, err := List(client.ServiceClient(), &ListOpts{}).AllPages()
th.AssertNoErr(t, err)
@@ -58,13 +102,58 @@
th.AssertNoErr(t, err)
expected := []Volume{
- Volume{
+ {
ID: "289da7f8-6440-407c-9fb4-7db01ec49164",
Name: "vol-001",
+ Attachments: []map[string]interface{}{{
+ "AttachmentID": "03987cd1-0ad5-40d1-9b2a-7cc48295d4fa",
+ "ID": "47e9ecc5-4045-4ee3-9a4b-d859d546a0cf",
+ "VolumeID": "289da7f8-6440-407c-9fb4-7db01ec49164",
+ "ServerID": "d1c4788b-9435-42e2-9b81-29f3be1cd01f",
+ "HostName": "stack",
+ "Device": "/dev/vdc",
+ }},
+ AvailabilityZone: "nova",
+ Bootable: "false",
+ ConsistencyGroupID: "",
+ CreatedAt: "2015-09-17T03:35:03.000000",
+ Description: "",
+ Encrypted: false,
+ Metadata: map[string]string{"foo": "bar"},
+ Multiattach: false,
+ TenantID: "304dc00909ac4d0da6c62d816bcb3459",
+ ReplicationDriverData: "",
+ ReplicationExtendedStatus: "",
+ ReplicationStatus: "disabled",
+ Size: 75,
+ SnapshotID: "",
+ SourceVolID: "",
+ Status: "available",
+ UserID: "ff1ce52c03ab433aaba9108c2e3ef541",
+ VolumeType: "lvmdriver-1",
},
- Volume{
- ID: "96c3bda7-c82a-4f50-be73-ca7621794835",
- Name: "vol-002",
+ {
+ ID: "96c3bda7-c82a-4f50-be73-ca7621794835",
+ Name: "vol-002",
+ Attachments: []map[string]interface{}{},
+ AvailabilityZone: "nova",
+ Bootable: "false",
+ ConsistencyGroupID: "",
+ CreatedAt: "2015-09-17T03:32:29.000000",
+ Description: "",
+ Encrypted: false,
+ Metadata: map[string]string{},
+ Multiattach: false,
+ TenantID: "304dc00909ac4d0da6c62d816bcb3459",
+ ReplicationDriverData: "",
+ ReplicationExtendedStatus: "",
+ ReplicationStatus: "disabled",
+ Size: 75,
+ SnapshotID: "",
+ SourceVolID: "",
+ Status: "available",
+ UserID: "ff1ce52c03ab433aaba9108c2e3ef541",
+ VolumeType: "lvmdriver-1",
},
}
@@ -76,27 +165,26 @@
th.SetupHTTP()
defer th.TeardownHTTP()
- fixtures.MockGetResponse(t)
+ MockGetResponse(t)
v, err := Get(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22").Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, v.Name, "vol-001")
th.AssertEquals(t, v.ID, "d32019d3-bc6e-4319-9c1d-6722fc136a22")
- th.AssertEquals(t, v.Attachments[0]["device"], "/dev/vde")
}
func TestCreate(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- fixtures.MockCreateResponse(t)
+ MockCreateResponse(t)
- options := &CreateOpts{Size: 75}
+ options := &CreateOpts{Size: 75, Name: "vol-001"}
n, err := Create(client.ServiceClient(), options).Extract()
th.AssertNoErr(t, err)
- th.AssertEquals(t, n.Size, 4)
+ th.AssertEquals(t, n.Size, 75)
th.AssertEquals(t, n.ID, "d32019d3-bc6e-4319-9c1d-6722fc136a22")
}
@@ -104,7 +192,7 @@
th.SetupHTTP()
defer th.TeardownHTTP()
- fixtures.MockDeleteResponse(t)
+ MockDeleteResponse(t)
res := Delete(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22")
th.AssertNoErr(t, res.Err)
@@ -114,7 +202,7 @@
th.SetupHTTP()
defer th.TeardownHTTP()
- fixtures.MockUpdateResponse(t)
+ MockUpdateResponse(t)
options := UpdateOpts{Name: "vol-002"}
v, err := Update(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22", options).Extract()
diff --git a/openstack/blockstorage/v2/volumes/results.go b/openstack/blockstorage/v2/volumes/results.go
index 2fd4ef1..59fa530 100644
--- a/openstack/blockstorage/v2/volumes/results.go
+++ b/openstack/blockstorage/v2/volumes/results.go
@@ -9,44 +9,68 @@
// Volume contains all the information associated with an OpenStack Volume.
type Volume struct {
- // Current status of the volume.
- Status string `mapstructure:"status"`
-
- // Human-readable display name for the volume.
- Name string `mapstructure:"display_name"`
-
// Instances onto which the volume is attached.
Attachments []map[string]interface{} `mapstructure:"attachments"`
- // This parameter is no longer used.
+ // AvailabilityZone is which availability zone the volume is in.
AvailabilityZone string `mapstructure:"availability_zone"`
// Indicates whether this is a bootable volume.
Bootable string `mapstructure:"bootable"`
+ // ConsistencyGroupID is the consistency group ID.
+ ConsistencyGroupID string `mapstructure:"consistencygroup_id"`
+
// The date when this volume was created.
CreatedAt string `mapstructure:"created_at"`
// Human-readable description for the volume.
- Description string `mapstructure:"display_description"`
+ Description string `mapstructure:"description"`
+
+ // Encrypted denotes if the volume is encrypted.
+ Encrypted bool `mapstructure:"encrypted"`
+
+ // Human-readable display name for the volume.
+ Name string `mapstructure:"name"`
// The type of volume to create, either SATA or SSD.
VolumeType string `mapstructure:"volume_type"`
+ // ReplicationDriverData contains data about the replication driver.
+ ReplicationDriverData string `mapstructure:"os-volume-replication:driver_data"`
+
+ // ReplicationExtendedStatus contains extended status about replication.
+ ReplicationExtendedStatus string `mapstructure:"os-volume-replication:extended_status"`
+
+ // ReplicationStatus is the status of replication.
+ ReplicationStatus string `mapstructure:"replication_status"`
+
// The ID of the snapshot from which the volume was created
SnapshotID string `mapstructure:"snapshot_id"`
// The ID of another block storage volume from which the current volume was created
SourceVolID string `mapstructure:"source_volid"`
+ // Current status of the volume.
+ Status string `mapstructure:"status"`
+
+ // TenantID is the id of the project that owns the volume.
+ TenantID string `mapstructure:"os-vol-tenant-attr:tenant_id"`
+
// Arbitrary key-value pairs defined by the user.
Metadata map[string]string `mapstructure:"metadata"`
+ // Multiattach denotes if the volume is multi-attach capable.
+ Multiattach bool `mapstructure:"multiattach"`
+
// Unique identifier for the volume.
ID string `mapstructure:"id"`
// Size of the volume in GB.
Size int `mapstructure:"size"`
+
+ // UserID is the id of the user who created the volume.
+ UserID string `mapstructure:"user_id"`
}
// CreateResult contains the response body and error from a Create request.
diff --git a/openstack/blockstorage/v2/volumes/testing/doc.go b/openstack/blockstorage/v2/volumes/testing/doc.go
deleted file mode 100644
index 2f66ba5..0000000
--- a/openstack/blockstorage/v2/volumes/testing/doc.go
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
-This is package created is to hold fixtures (which imports testing),
-so that importing volumes package does not inadvertently import testing into production code
-More information here:
-https://github.com/rackspace/gophercloud/issues/473
-*/
-package testing
diff --git a/openstack/blockstorage/v2/volumes/testing/fixtures.go b/openstack/blockstorage/v2/volumes/testing/fixtures.go
deleted file mode 100644
index 3df7653..0000000
--- a/openstack/blockstorage/v2/volumes/testing/fixtures.go
+++ /dev/null
@@ -1,113 +0,0 @@
-package testing
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func MockListResponse(t *testing.T) {
- th.Mux.HandleFunc("/volumes", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
- {
- "volumes": [
- {
- "id": "289da7f8-6440-407c-9fb4-7db01ec49164",
- "display_name": "vol-001"
- },
- {
- "id": "96c3bda7-c82a-4f50-be73-ca7621794835",
- "display_name": "vol-002"
- }
- ]
- }
- `)
- })
-}
-
-func MockGetResponse(t *testing.T) {
- th.Mux.HandleFunc("/volumes/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
- fmt.Fprintf(w, `
-{
- "volume": {
- "display_name": "vol-001",
- "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
- "attachments": [
- {
- "device": "/dev/vde",
- "server_id": "a740d24b-dc5b-4d59-ac75-53971c2920ba",
- "id": "d6da11e5-2ed3-413e-88d8-b772ba62193d",
- "volume_id": "d6da11e5-2ed3-413e-88d8-b772ba62193d"
- }
- ]
- }
-}
- `)
- })
-}
-
-func MockCreateResponse(t *testing.T) {
- th.Mux.HandleFunc("/volumes", 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, `
-{
- "volume": {
- "size": 75
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
-
- fmt.Fprintf(w, `
-{
- "volume": {
- "size": 4,
- "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22"
- }
-}
- `)
- })
-}
-
-func MockDeleteResponse(t *testing.T) {
- th.Mux.HandleFunc("/volumes/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusNoContent)
- })
-}
-
-func MockUpdateResponse(t *testing.T) {
- th.Mux.HandleFunc("/volumes/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusOK)
- fmt.Fprintf(w, `
- {
- "volume": {
- "display_name": "vol-002",
- "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22"
- }
- }
- `)
- })
-}
diff --git a/openstack/blockstorage/v2/volumes/urls.go b/openstack/blockstorage/v2/volumes/urls.go
index 29629a1..2523ec6 100644
--- a/openstack/blockstorage/v2/volumes/urls.go
+++ b/openstack/blockstorage/v2/volumes/urls.go
@@ -7,7 +7,7 @@
}
func listURL(c *gophercloud.ServiceClient) string {
- return createURL(c)
+ return c.ServiceURL("volumes", "detail")
}
func deleteURL(c *gophercloud.ServiceClient, id string) string {
diff --git a/openstack/blockstorage/v2/volumes/urls_test.go b/openstack/blockstorage/v2/volumes/urls_test.go
index a95270e..792b19b 100644
--- a/openstack/blockstorage/v2/volumes/urls_test.go
+++ b/openstack/blockstorage/v2/volumes/urls_test.go
@@ -21,7 +21,7 @@
func TestListURL(t *testing.T) {
actual := listURL(endpointClient())
- expected := endpoint + "volumes"
+ expected := endpoint + "volumes/detail"
th.AssertEquals(t, expected, actual)
}