Update blockstorage v2 API
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()