Skip to content

Instantly share code, notes, and snippets.

@etoews
Created December 4, 2014 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etoews/24ee560b2c55b3fc51a1 to your computer and use it in GitHub Desktop.
Save etoews/24ee560b2c55b3fc51a1 to your computer and use it in GitHub Desktop.
{
"images": [
{
"status": "ACTIVE",
"updated": "2014-08-08T04:43:36Z",
"links": [
{
"href": "http://192.168.24.16:8774/v2/d312a9d1acee46499e04fc2c0cd7e540/images/cd9d57a9-0978-45f3-9cbc-edb99347be6b",
"rel": "self"
},
{
"href": "http://192.168.24.16:8774/d312a9d1acee46499e04fc2c0cd7e540/images/cd9d57a9-0978-45f3-9cbc-edb99347be6b",
"rel": "bookmark"
},
{
"href": "http://192.168.24.16:9292/d312a9d1acee46499e04fc2c0cd7e540/images/cd9d57a9-0978-45f3-9cbc-edb99347be6b",
"type": "application/vnd.openstack.image",
"rel": "alternate"
}
],
"id": "cd9d57a9-0978-45f3-9cbc-edb99347be6b",
"OS-EXT-IMG-SIZE:size": 0,
"name": "t11",
"created": "2014-08-08T04:43:36Z",
"minDisk": 0,
"progress": 100,
"minRam": 0,
"metadata": {
"block_device_mapping": [
{
"guest_format": null,
"boot_index": 0,
"no_device": null,
"volume_id": null,
"volume_size": null,
"disk_bus": null,
"image_id": null,
"source_type": "snapshot",
"device_type": null,
"snapshot_id": "a900a56c-61b7-4438-9150-76312fa1aa10",
"destination_type": "volume",
"delete_on_termination": null
}
],
"checksum": "32c08d302f9206668030d47789b77858",
"min_ram": "1",
"disk_format": "qcow2",
"image_name": "Ubuntu LTS 14.04",
"bdm_v2": "True",
"image_id": "cfefefc1-eba2-4b1e-9b07-a8c74a872d65",
"root_device_name": "/dev/vda",
"container_format": "bare",
"min_disk": "8",
"size": "254149120"
}
}
]
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.openstack.nova.v2_0.features;
import com.google.common.collect.FluentIterable;
import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.MockWebServer;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.domain.Image;
import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
@Test(groups = "unit")
public class ImageApiMockTest extends BaseOpenStackMockTest<NovaApi> {
public void testImageWithBlockDeviceMapping() throws Exception {
MockWebServer server = mockOpenStackServer();
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/image_list_with_block_device_mapping.json"))));
try {
NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova");
ImageApi imageApi = novaApi.getImageApi("RegionOne");
FluentIterable<? extends Image> images = imageApi.listInDetail().concat();
assertEquals(images.size(), 1);
} finally {
server.shutdown();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment