Merge "Change ViewBuilder into v2.1 for servers"

This commit is contained in:
Jenkins 2014-08-27 02:42:56 +00:00 committed by Gerrit Code Review
commit 58e6eb857a
62 changed files with 145 additions and 165 deletions

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "9cc36101a27c2a69c1a18241f6228454d9d7f466bd90c62db8e8b856",
"hostId": "9cc36101a27c2a69c1a18241f6228454d9d7f466bd90c62db8e8b856",
"id": "f474386b-4fb6-4e1f-b1d5-d6bf4437f7d5",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "f1e160ad2bf07084f3d3e0dfdd0795d80da18a60825322c15775c0dd",
"hostId": "f1e160ad2bf07084f3d3e0dfdd0795d80da18a60825322c15775c0dd",
"id": "9cbefc35-d372-40c5-88e2-9fda1b6ea12c",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "5c8072dbcda8ce3f26deb6662bd7718e1a6d349bdf2296911d1be4ac",
"hostId": "5c8072dbcda8ce3f26deb6662bd7718e1a6d349bdf2296911d1be4ac",
"id": "53a63a19-c145-47f8-9ae5-b39d6bff33ec",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "b3a6fd97c027e18d6d9c7506eea8a236cf2ceca420cfdfe0239a64a8",
"hostId": "b3a6fd97c027e18d6d9c7506eea8a236cf2ceca420cfdfe0239a64a8",
"id": "5eedbf0c-c303-4ed3-933a-a4d3732cfa0a",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "ea0fd522e5bc2fea872429b331304a6f930f2d9aa2a5dc95b3c6061a",
"hostId": "ea0fd522e5bc2fea872429b331304a6f930f2d9aa2a5dc95b3c6061a",
"id": "fea9595c-ce6e-4565-987e-2d301fe056ac",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "9896cb12c9845becf1b9b06c8ff5b131d20300f83e2cdffc92e3f4a4",
"hostId": "9896cb12c9845becf1b9b06c8ff5b131d20300f83e2cdffc92e3f4a4",
"id": "934760e1-2b0b-4f9e-a916-eac1e69839dc",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "1642bbdbd61a0f1c513b4bb6e418326103172698104bfa278eca106b",
"hostId": "1642bbdbd61a0f1c513b4bb6e418326103172698104bfa278eca106b",
"id": "7838ff1b-b71f-48b9-91e9-7c08de20b249",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "1ed067c90341cd9d94bbe5da960922b56f107262cdc75719a0d97b78",
"hostId": "1ed067c90341cd9d94bbe5da960922b56f107262cdc75719a0d97b78",
"id": "f0318e69-11eb-4aed-9840-59b6c72beee8",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "b75d6736650f9b272223ceb48f4cde001de1856e381613a922117ab7",
"hostId": "b75d6736650f9b272223ceb48f4cde001de1856e381613a922117ab7",
"id": "f22e4521-d03a-4e9f-9fd3-016b9e227219",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "cf5540800371e53064a60b36ff9d6d1d6a8719ffc870c63a270c6bee",
"hostId": "cf5540800371e53064a60b36ff9d6d1d6a8719ffc870c63a270c6bee",
"id": "55f43fa2-dc7c-4c0b-b21a-76f9abe516f9",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "3bf189131c61d0e71b0a8686a897a0f50d1693b48c47b721fe77155b",
"hostId": "3bf189131c61d0e71b0a8686a897a0f50d1693b48c47b721fe77155b",
"id": "c278163e-36f9-4cf2-b1ac-80db4c63f7a8",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "63cf07a9fd82e1d2294926ec5c0d2e1e0ca449224246df75e16f23dc",
"hostId": "63cf07a9fd82e1d2294926ec5c0d2e1e0ca449224246df75e16f23dc",
"id": "a8c1c13d-ec7e-47c7-b4ff-077f72c1ca46",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "46d2aa2d637bd55606304b611a1928627ee1278c149aef2206268d6e",
"hostId": "46d2aa2d637bd55606304b611a1928627ee1278c149aef2206268d6e",
"id": "a868cb5e-c794-47bf-9cd8-e302b72bb94b",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "a275e77473e464558c4aba0d68e1914d1164e7ee2f69affde7aaae2b",
"hostId": "a275e77473e464558c4aba0d68e1914d1164e7ee2f69affde7aaae2b",
"id": "6c8b5385-e74c-4fd5-add6-2fcf42d74a98",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "8feef92e2152b9970b51dbdade024afbec7f8f03daf7cb335a3c1cb9",
"hostId": "8feef92e2152b9970b51dbdade024afbec7f8f03daf7cb335a3c1cb9",
"id": "7d62983e-23df-4320-bc89-bbc77f2a2e40",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "f9622ec1b5ab6e3785661ea1c1e0294f95aecbcf27ac4cb60b06bd02",
"hostId": "f9622ec1b5ab6e3785661ea1c1e0294f95aecbcf27ac4cb60b06bd02",
"id": "8e479732-7701-48cd-af7a-04d84f51b742",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -11,13 +11,13 @@
}
]
},
"host_id": "d0635823e9162b22b90ff103f0c30f129bacf6ffb72f4d6fde87e738",
"hostId": "d0635823e9162b22b90ff103f0c30f129bacf6ffb72f4d6fde87e738",
"id": "4bdee8c7-507f-40f2-8429-d301edd3791b",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -12,13 +12,13 @@
}
]
},
"host_id": "a4fa72ae8741e5e18fb062c15657b8f689b8da2837b734c61fc9eedd",
"hostId": "a4fa72ae8741e5e18fb062c15657b8f689b8da2837b734c61fc9eedd",
"id": "a747eac1-e3ed-446c-935a-c2a2853f919c",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "b7e88944272df30c113572778bcf5527f02e9c2a745221214536c1a2",
"hostId": "b7e88944272df30c113572778bcf5527f02e9c2a745221214536c1a2",
"id": "9dafa6bc-7a9f-45b2-8177-11800ceb7224",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "416f83c758ea0f9271018b278a9dcedb91b1190deaa598704b87219b",
"hostId": "416f83c758ea0f9271018b278a9dcedb91b1190deaa598704b87219b",
"id": "ef440f98-04e8-46ea-ae74-e24d437040ea",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "f04994c5b4aac1cacbb83b09c2506e457d97dd54f620961624574690",
"hostId": "f04994c5b4aac1cacbb83b09c2506e457d97dd54f620961624574690",
"id": "2fd0c66b-50af-41d2-9253-9fa41e7e8dd8",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "53cd4520a6cc639eeabcae4a0512b93e4675d431002e0b60e2dcfc04",
"hostId": "53cd4520a6cc639eeabcae4a0512b93e4675d431002e0b60e2dcfc04",
"id": "edfc3905-1f3c-4819-8fc3-a7d8131cfa22",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "0e312d6763795d572ccd716973fd078290d9ec446517b222d3395660",
"hostId": "0e312d6763795d572ccd716973fd078290d9ec446517b222d3395660",
"id": "f6961f7a-0133-4f27-94cd-901dca4ba426",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "afeeb125d4d37d0a2123e3144a20a6672fda5d4b6cb85ec193430d82",
"hostId": "afeeb125d4d37d0a2123e3144a20a6672fda5d4b6cb85ec193430d82",
"id": "1b94e3fc-1b1c-431a-a077-6b280fb720ce",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "73cf3a40601b63f5992894be2daa3712dd599d1c919984951e21edda",
"hostId": "73cf3a40601b63f5992894be2daa3712dd599d1c919984951e21edda",
"id": "cee6d136-e378-4cfc-9eec-71797f025991",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "117535ce0eda7ee02ebffe2c976173629385481ae3f2bded5e14a66b",
"hostId": "117535ce0eda7ee02ebffe2c976173629385481ae3f2bded5e14a66b",
"id": "ae114799-9164-48f5-a036-6ef9310acbc4",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "28d8d56f0e3a77e20891f455721cbb68032e017045e20aa5dfc6cb66",
"hostId": "28d8d56f0e3a77e20891f455721cbb68032e017045e20aa5dfc6cb66",
"id": "a0a80a94-3d81-4a10-822a-daa0cf9e870b",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "92154fab69d5883ba2c8622b7e65f745dd33257221c07af363c51b29",
"hostId": "92154fab69d5883ba2c8622b7e65f745dd33257221c07af363c51b29",
"id": "0e44cc9c-e052-415d-afbf-469b0d384170",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "bcf92836fc9ed4203a75cb0337afc7f917d2be504164b995c2334b25",
"hostId": "bcf92836fc9ed4203a75cb0337afc7f917d2be504164b995c2334b25",
"id": "f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]

View File

@ -147,20 +147,3 @@ class ViewBuilder(common.ViewBuilder):
"saving": 50,
"active": 100,
}.get(image.get("status"), 0)
class ViewBuilderV3(ViewBuilder):
def _get_bookmark_link(self, request, identifier, collection_name):
"""Create a URL that refers to a specific resource."""
if collection_name == "images":
glance_url = glance.generate_image_url(identifier)
return self._update_glance_link_prefix(glance_url)
else:
raise NotImplementedError
# NOTE(cyeoh) The V3 version of _get_bookmark_link should
# only ever be called with images as the
# collection_name. The images API has been removed in the
# V3 API and the V3 version of the view only exists for
# the servers view to be able to generate the appropriate
# bookmark link for the image of the instance.

View File

@ -241,7 +241,9 @@ class ViewBuilderV3(ViewBuilder):
"""Initialize view builder."""
super(ViewBuilderV3, self).__init__()
self._address_builder = views_addresses.ViewBuilderV3()
self._image_builder = views_images.ViewBuilderV3()
# TODO(alex_xu): In V3 API, we correct the image bookmark link to
# use glance endpoint. We revert back it to use nova endpoint for v2.1.
self._image_builder = views_images.ViewBuilder()
def show(self, request, instance):
"""Detailed view of a single instance."""
@ -253,7 +255,10 @@ class ViewBuilderV3(ViewBuilder):
"tenant_id": instance.get("project_id") or "",
"user_id": instance.get("user_id") or "",
"metadata": self._get_metadata(instance),
"host_id": self._get_host_id(instance) or "",
"hostId": self._get_host_id(instance) or "",
# TODO(alex_xu): '_get_image' return {} when there image_ref
# isn't existed in V3 API, we revert it back to return "" in
# V2.1.
"image": self._get_image(request, instance),
"flavor": self._get_flavor(request, instance),
"created": timeutils.isotime(instance["created_at"]),
@ -272,7 +277,4 @@ class ViewBuilderV3(ViewBuilder):
if server["server"]["status"] in self._progress_statuses:
server["server"]["progress"] = instance.get("progress", 0)
# We should modify the "image" to empty dictionary
if not server["server"]["image"]:
server["server"]["image"] = {}
return server

View File

@ -303,8 +303,8 @@ class ServersControllerTest(ControllerTest):
server1 = self.controller.show(req, FAKE_UUID)
server2 = self.controller.show(req, FAKE_UUID)
self.assertNotEqual(server1['server']['host_id'],
server2['server']['host_id'])
self.assertNotEqual(server1['server']['hostId'],
server2['server']['hostId'])
def _get_server_data_dict(self, uuid, image_bookmark, flavor_bookmark,
status="ACTIVE", progress=100):
@ -318,7 +318,7 @@ class ServersControllerTest(ControllerTest):
"progress": progress,
"name": "server1",
"status": status,
"host_id": '',
"hostId": '',
"image": {
"id": "10",
"links": [
@ -363,7 +363,7 @@ class ServersControllerTest(ControllerTest):
def test_get_server_by_id(self):
self.flags(use_ipv6=True)
image_bookmark = "http://localhost:9292/images/10"
image_bookmark = "http://localhost/images/10"
flavor_bookmark = "http://localhost/flavors/1"
uuid = FAKE_UUID
@ -379,7 +379,7 @@ class ServersControllerTest(ControllerTest):
self.assertThat(res_dict, matchers.DictMatches(expected_server))
def test_get_server_with_active_status_by_id(self):
image_bookmark = "http://localhost:9292/images/10"
image_bookmark = "http://localhost/images/10"
flavor_bookmark = "http://localhost/flavors/1"
new_return_server = fakes.fake_instance_get(
@ -396,7 +396,7 @@ class ServersControllerTest(ControllerTest):
def test_get_server_with_id_image_ref_by_id(self):
image_ref = "10"
image_bookmark = "http://localhost:9292/images/10"
image_bookmark = "http://localhost/images/10"
flavor_id = "1"
flavor_bookmark = "http://localhost/flavors/1"
@ -1226,7 +1226,7 @@ class ServersControllerTest(ControllerTest):
"links": [
{
"rel": "bookmark",
"href": 'http://localhost:9292/images/10',
"href": 'http://localhost/images/10',
},
],
}
@ -1235,7 +1235,7 @@ class ServersControllerTest(ControllerTest):
for i, s in enumerate(res_dict['servers']):
self.assertEqual(s['id'], fakes.get_fake_uuid(i))
self.assertEqual(s['host_id'], '')
self.assertEqual(s['hostId'], '')
self.assertEqual(s['name'], 'server%d' % (i + 1))
self.assertEqual(s['image'], expected_image)
self.assertEqual(s['flavor'], expected_flavor)
@ -1244,8 +1244,8 @@ class ServersControllerTest(ControllerTest):
def test_get_all_server_details_with_host(self):
"""We want to make sure that if two instances are on the same host,
then they return the same host_id. If two instances are on different
hosts, they should return different host_ids. In this test,
then they return the same hostId. If two instances are on different
hosts, they should return different hostIds. In this test,
there are 5 instances - 2 on one host and 3 on another.
"""
@ -1261,13 +1261,13 @@ class ServersControllerTest(ControllerTest):
res_dict = self.controller.detail(req)
server_list = res_dict['servers']
host_ids = [server_list[0]['host_id'], server_list[1]['host_id']]
host_ids = [server_list[0]['hostId'], server_list[1]['hostId']]
self.assertTrue(host_ids[0] and host_ids[1])
self.assertNotEqual(host_ids[0], host_ids[1])
for i, s in enumerate(server_list):
self.assertEqual(s['id'], fakes.get_fake_uuid(i))
self.assertEqual(s['host_id'], host_ids[i % 2])
self.assertEqual(s['hostId'], host_ids[i % 2])
self.assertEqual(s['name'], 'server%d' % (i + 1))
def test_get_servers_joins_pci_devices(self):
@ -2695,7 +2695,7 @@ class ServersViewBuilderTest(test.TestCase):
self.assertThat(output, matchers.DictMatches(expected_server))
def test_build_server_detail(self):
image_bookmark = "http://localhost:9292/images/5"
image_bookmark = "http://localhost/images/5"
flavor_bookmark = "http://localhost/flavors/1"
self_link = "http://localhost/v3/servers/%s" % self.uuid
bookmark_link = "http://localhost/servers/%s" % self.uuid
@ -2709,7 +2709,7 @@ class ServersViewBuilderTest(test.TestCase):
"progress": 0,
"name": "test_server",
"status": "BUILD",
"host_id": '',
"hostId": '',
"image": {
"id": "5",
"links": [
@ -2753,17 +2753,12 @@ class ServersViewBuilderTest(test.TestCase):
output = self.view_builder.show(self.request, self.instance)
self.assertThat(output, matchers.DictMatches(expected_server))
def test_build_server_no_image(self):
self.instance["image_ref"] = ""
output = self.view_builder.show(self.request, self.instance)
self.assertEqual(output['server']['image'], {})
def test_build_server_detail_with_fault(self):
self.instance['vm_state'] = vm_states.ERROR
self.instance['fault'] = fake_instance.fake_fault_obj(
self.request.context, self.uuid)
image_bookmark = "http://localhost:9292/images/5"
image_bookmark = "http://localhost/images/5"
flavor_bookmark = "http://localhost/flavors/1"
self_link = "http://localhost/v3/servers/%s" % self.uuid
bookmark_link = "http://localhost/servers/%s" % self.uuid
@ -2776,7 +2771,7 @@ class ServersViewBuilderTest(test.TestCase):
"created": "2010-10-10T12:00:00Z",
"name": "test_server",
"status": "ERROR",
"host_id": '',
"hostId": '',
"image": {
"id": "5",
"links": [
@ -2912,7 +2907,7 @@ class ServersViewBuilderTest(test.TestCase):
# set the power state of the instance to running
self.instance['vm_state'] = vm_states.ACTIVE
self.instance['progress'] = 100
image_bookmark = "http://localhost:9292/images/5"
image_bookmark = "http://localhost/images/5"
flavor_bookmark = "http://localhost/flavors/1"
self_link = "http://localhost/v3/servers/%s" % self.uuid
bookmark_link = "http://localhost/servers/%s" % self.uuid
@ -2926,7 +2921,7 @@ class ServersViewBuilderTest(test.TestCase):
"progress": 100,
"name": "test_server",
"status": "ACTIVE",
"host_id": '',
"hostId": '',
"image": {
"id": "5",
"links": [
@ -2977,7 +2972,7 @@ class ServersViewBuilderTest(test.TestCase):
metadata = nova_utils.metadata_to_dict(metadata)
self.instance['metadata'] = metadata
image_bookmark = "http://localhost:9292/images/5"
image_bookmark = "http://localhost/images/5"
flavor_bookmark = "http://localhost/flavors/1"
self_link = "http://localhost/v3/servers/%s" % self.uuid
bookmark_link = "http://localhost/servers/%s" % self.uuid
@ -2991,7 +2986,7 @@ class ServersViewBuilderTest(test.TestCase):
"progress": 0,
"name": "test_server",
"status": "BUILD",
"host_id": '',
"hostId": '',
"image": {
"id": "5",
"links": [

View File

@ -22,13 +22,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -23,13 +23,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(image_id)s",
"links": [
{
"href": "%(glance_host)s/images/%(image_id)s",
"href": "%(host)s/images/%(image_id)s",
"rel": "bookmark"
}
]

View File

@ -22,13 +22,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -22,13 +22,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -23,13 +23,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -22,13 +22,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -22,13 +22,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -23,13 +23,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -24,13 +24,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -25,13 +25,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -25,13 +25,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -26,13 +26,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -22,13 +22,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -12,13 +12,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -12,13 +12,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -22,13 +22,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -22,13 +22,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -32,7 +32,7 @@
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]
@ -50,7 +50,7 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"metadata": {
"My Server Name": "Apache1"
}

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -20,13 +20,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]

View File

@ -21,13 +21,13 @@
}
]
},
"host_id": "%(hostid)s",
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"href": "%(host)s/images/%(uuid)s",
"rel": "bookmark"
}
]