Merge pull request #489 from feiskyer/blockstoragev2-volumes
[rfr] Add volumes part of blockstorage v2 API
diff --git a/openstack/compute/v2/images/requests_test.go b/openstack/compute/v2/images/requests_test.go
index 93a97bd..21e8296 100644
--- a/openstack/compute/v2/images/requests_test.go
+++ b/openstack/compute/v2/images/requests_test.go
@@ -37,8 +37,7 @@
"created": "2014-09-23T12:54:52Z",
"minDisk": 0,
"progress": 100,
- "minRam": 0,
- "metadata": {}
+ "minRam": 0
},
{
"status": "ACTIVE",
@@ -49,8 +48,7 @@
"created": "2014-09-23T12:51:42Z",
"minDisk": 0,
"progress": 100,
- "minRam": 0,
- "metadata": {}
+ "minRam": 0
}
]
}
@@ -130,8 +128,7 @@
"created": "2014-09-23T12:54:52Z",
"minDisk": 0,
"progress": 100,
- "minRam": 0,
- "metadata": {}
+ "minRam": 0
}
}
`)
diff --git a/openstack/compute/v2/images/results.go b/openstack/compute/v2/images/results.go
index 40e814d..482e7d6 100644
--- a/openstack/compute/v2/images/results.go
+++ b/openstack/compute/v2/images/results.go
@@ -51,6 +51,8 @@
Status string
Updated string
+
+ Metadata map[string]string
}
// ImagePage contains a single page of results from a List operation.
diff --git a/openstack/compute/v2/servers/results_test.go b/openstack/compute/v2/servers/results_test.go
index 2dba484..9ee5579 100644
--- a/openstack/compute/v2/servers/results_test.go
+++ b/openstack/compute/v2/servers/results_test.go
@@ -10,6 +10,7 @@
"github.com/rackspace/gophercloud"
th "github.com/rackspace/gophercloud/testhelper"
+ "github.com/rackspace/gophercloud/testhelper/client"
"golang.org/x/crypto/ssh"
)
@@ -97,3 +98,14 @@
th.AssertNoErr(t, err)
th.AssertEquals(t, "ruZKK0tqxRfYm5t7lSJq", pwd)
}
+
+func TestListAddressesAllPages(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleAddressListSuccessfully(t)
+
+ allPages, err := ListAddresses(client.ServiceClient(), "asdfasdfasdf").AllPages()
+ th.AssertNoErr(t, err)
+ _, err = ExtractAddresses(allPages)
+ th.AssertNoErr(t, err)
+}
diff --git a/pagination/pager.go b/pagination/pager.go
index a7593ac..6f1ca04 100644
--- a/pagination/pager.go
+++ b/pagination/pager.go
@@ -138,6 +138,11 @@
// that type.
pageType := reflect.TypeOf(testPage)
+ // if it's a single page, just return the testPage (first page)
+ if _, found := pageType.FieldByName("SinglePageBase"); found {
+ return testPage, nil
+ }
+
// Switch on the page body type. Recognized types are `map[string]interface{}`,
// `[]byte`, and `[]interface{}`.
switch testPage.GetBody().(type) {
@@ -153,7 +158,14 @@
key = k
}
}
- pagesSlice = append(pagesSlice, b[key].([]interface{})...)
+ switch keyType := b[key].(type) {
+ case map[string]interface{}:
+ pagesSlice = append(pagesSlice, keyType)
+ case []interface{}:
+ pagesSlice = append(pagesSlice, b[key].([]interface{})...)
+ default:
+ return false, fmt.Errorf("Unsupported page body type: %+v", keyType)
+ }
return true, nil
})
if err != nil {
diff --git a/rackspace/compute/v2/images/fixtures.go b/rackspace/compute/v2/images/fixtures.go
index ccfbdc6..cb8bda3 100644
--- a/rackspace/compute/v2/images/fixtures.go
+++ b/rackspace/compute/v2/images/fixtures.go
@@ -180,6 +180,29 @@
MinRAM: 512,
Progress: 100,
Status: "ACTIVE",
+ Metadata: map[string]string{
+ "auto_disk_config": "True",
+ "cache_in_nova": "True",
+ "com.rackspace__1__build_core": "1",
+ "com.rackspace__1__build_managed": "1",
+ "com.rackspace__1__build_rackconnect": "1",
+ "com.rackspace__1__options": "0",
+ "com.rackspace__1__platform_target": "PublicCloud",
+ "com.rackspace__1__release_build_date": "2014-10-01_12-31-03",
+ "com.rackspace__1__release_id": "1007",
+ "com.rackspace__1__release_version": "6",
+ "com.rackspace__1__source": "kickstart",
+ "com.rackspace__1__visible_core": "1",
+ "com.rackspace__1__visible_managed": "1",
+ "com.rackspace__1__visible_rackconnect": "1",
+ "image_type": "base",
+ "org.openstack__1__architecture": "x64",
+ "org.openstack__1__os_distro": "com.ubuntu",
+ "org.openstack__1__os_version": "14.04",
+ "os_distro": "ubuntu",
+ "os_type": "linux",
+ "vm_mode": "xen",
+ },
}
// UbuntuImage is the second Image structure that should be parsed from ListOutput and
@@ -193,6 +216,29 @@
MinRAM: 512,
Progress: 100,
Status: "ACTIVE",
+ Metadata: map[string]string{
+ "auto_disk_config": "True",
+ "cache_in_nova": "True",
+ "com.rackspace__1__build_core": "1",
+ "com.rackspace__1__build_managed": "1",
+ "com.rackspace__1__build_rackconnect": "1",
+ "com.rackspace__1__options": "0",
+ "com.rackspace__1__platform_target": "PublicCloud",
+ "com.rackspace__1__release_build_date": "2014-10-01_12-31-03",
+ "com.rackspace__1__release_id": "1007",
+ "com.rackspace__1__release_version": "6",
+ "com.rackspace__1__source": "kickstart",
+ "com.rackspace__1__visible_core": "1",
+ "com.rackspace__1__visible_managed": "1",
+ "com.rackspace__1__visible_rackconnect": "1",
+ "image_type": "base",
+ "org.openstack__1__architecture": "x64",
+ "org.openstack__1__os_distro": "com.ubuntu",
+ "org.openstack__1__os_version": "14.04",
+ "os_distro": "ubuntu",
+ "os_type": "linux",
+ "vm_mode": "xen",
+ },
}
// ExpectedImageSlice is the collection of images that should be parsed from ListOutput,