"id": version['id'],
"status": version['status'],
"links": [{"rel": "self",
- "href": self.generate_href(req.path), }, ],
+ "href": self.generate_href(version['id'],
+ req.path), }, ],
"media-types": version['media-types'], })
return dict(choices=version_objs)
def _build_links(self, version_data):
"""Generate a container of links that refer to the provided version."""
- href = self.generate_href()
+ href = self.generate_href(version_data['id'])
links = [{'rel': 'self',
'href': href, }, ]
return links
- def generate_href(self, path=None):
+ def generate_href(self, version, path=None):
"""Create an url that refers to a specific version_number."""
- version_number = 'v1'
+ if version.find('v1.') == 0:
+ version_number = 'v1'
+ else:
+ version_number = 'v2'
+
if path:
path = path.strip('/')
return os.path.join(self.base_url, version_number, path)
@classmethod
def blank(cls, *args, **kwargs):
- kwargs['base_url'] = 'http://localhost/v1'
+ if args != None:
+ if args[0].find('v1') == 0:
+ kwargs['base_url'] = 'http://localhost/v1'
+ else:
+ kwargs['base_url'] = 'http://localhost/v2'
+
use_admin_context = kwargs.pop('use_admin_context', False)
out = os_wsgi.Request.blank(*args, **kwargs)
out.environ['cinder.context'] = FakeRequestContext(
'description': 'Volume Test Desc',
'id': '1',
'links':
- [{'href': 'http://localhost/v1/fake/volumes/1',
+ [{'href': 'http://localhost/v2/fake/volumes/1',
'rel': 'self'},
{'href': 'http://localhost/fake/volumes/1',
'rel': 'bookmark'}],
'description': 'Volume Test Desc',
'id': '1',
'links':
- [{'href': 'http://localhost/v1/fake/volumes/1',
+ [{'href': 'http://localhost/v2/fake/volumes/1',
'rel': 'self'},
{'href': 'http://localhost/fake/volumes/1',
'rel': 'bookmark'}],
'size': 1,
'links': [
{
- 'href': 'http://localhost/v1/fake/volumes/1',
+ 'href': 'http://localhost/v2/fake/volumes/1',
'rel': 'self'
},
{
'size': 1,
'links': [
{
- 'href': 'http://localhost/v1/fake/volumes/1',
+ 'href': 'http://localhost/v2/fake/volumes/1',
'rel': 'self'
},
{
'size': 1,
'links': [
{
- 'href': 'http://localhost/v1/fake/volumes/1',
+ 'href': 'http://localhost/v2/fake/volumes/1',
'rel': 'self'
},
{
'id': '1',
'links': [
{
- 'href': 'http://localhost/v1/fake/volumes/1',
+ 'href': 'http://localhost/v2/fake/volumes/1',
'rel': 'self'
},
{
'size': 1,
'links': [
{
- 'href': 'http://localhost/v1/fake/volumes/1',
+ 'href': 'http://localhost/v2/fake/volumes/1',
'rel': 'self'
},
{
'size': 1,
'links': [
{
- 'href': 'http://localhost/v1/fakeproject'
+ 'href': 'http://localhost/v2/fakeproject'
'/volumes/1',
'rel': 'self'
},
'size': 1,
'links': [
{
- 'href': 'http://localhost/v1/fake/volumes/1',
+ 'href': 'http://localhost/v2/fake/volumes/1',
'rel': 'self'
},
{
'size': 1,
'links': [
{
- 'href': 'http://localhost/v1/fake/volumes/1',
+ 'href': 'http://localhost/v2/fake/volumes/1',
'rel': 'self'
},
{
'size': 1,
'links': [
{
- 'href': 'http://localhost/v1/fakeproject/volumes/1',
+ 'href': 'http://localhost/v2/fakeproject/volumes/1',
'rel': 'self'
},
{