Apply v2.1 API to href of version API
Now Nova contains v2 and v2.1 APIs, but version API returns the same href between v2 and v2.1 like: {"href": "http://192.168.11.62:8774/v2/", "rel": "self"} in a response. In addition, current generate_href() handles v3 API case also. However v3 API has disappeared, so the code is meaningless now. This patch fixes the problem for returning a right href. Change-Id: Ie3ac1223a9c88a33bcc037c7a50ac308bcebea2d Closes-Bug: #1373741
This commit is contained in:
parent
422b22eaf7
commit
46bd4e4292
@ -15,7 +15,7 @@
|
||||
"id": "v2.1",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/v2/",
|
||||
"href": "http://openstack.example.com/v2.1/",
|
||||
"rel": "self"
|
||||
}
|
||||
],
|
||||
|
@ -85,8 +85,8 @@ class ViewBuilder(common.ViewBuilder):
|
||||
def generate_href(self, version, path=None):
|
||||
"""Create an url that refers to a specific version_number."""
|
||||
prefix = self._update_compute_link_prefix(self.base_url)
|
||||
if version.find('v3.') == 0:
|
||||
version_number = 'v3'
|
||||
if version.find('v2.1') == 0:
|
||||
version_number = 'v2.1'
|
||||
else:
|
||||
version_number = 'v2'
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"id": "v2.1",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/v2/",
|
||||
"href": "http://openstack.example.com/v2.1/",
|
||||
"rel": "self"
|
||||
}
|
||||
],
|
||||
|
@ -112,7 +112,7 @@ class VersionsTestV20(test.NoDBTestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v2/",
|
||||
"href": "http://localhost/v2.1/",
|
||||
}],
|
||||
},
|
||||
]
|
||||
@ -206,7 +206,7 @@ class VersionsTestV20(test.NoDBTestCase):
|
||||
"status": "EXPERIMENTAL",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://localhost/v2/images/1",
|
||||
"href": "http://localhost/v2.1/images/1",
|
||||
"rel": "self",
|
||||
},
|
||||
],
|
||||
@ -265,7 +265,7 @@ class VersionsTestV20(test.NoDBTestCase):
|
||||
"status": "EXPERIMENTAL",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://localhost/v2/servers/" + uuid,
|
||||
"href": "http://localhost/v2.1/servers/" + uuid,
|
||||
"rel": "self",
|
||||
},
|
||||
],
|
||||
@ -329,7 +329,7 @@ class VersionsViewBuilderTests(test.NoDBTestCase):
|
||||
def test_generate_href_v21(self):
|
||||
base_url = "http://example.org/app/"
|
||||
|
||||
expected = "http://example.org/app/v2/"
|
||||
expected = "http://example.org/app/v2.1/"
|
||||
|
||||
builder = views.versions.ViewBuilder(base_url)
|
||||
actual = builder.generate_href('v2.1')
|
||||
|
Loading…
x
Reference in New Issue
Block a user