added project_id for flavors requests links
This commit is contained in:
@@ -72,7 +72,8 @@ class ControllerV11(Controller):
|
||||
|
||||
def _get_view_builder(self, req):
|
||||
base_url = req.application_url
|
||||
return views.flavors.ViewBuilderV11(base_url)
|
||||
project_id = getattr(req.environ['nova.context'], 'project_id', '')
|
||||
return views.flavors.ViewBuilderV11(base_url, project_id)
|
||||
|
||||
|
||||
class FlavorXMLSerializer(wsgi.XMLDictSerializer):
|
||||
|
||||
@@ -166,10 +166,10 @@ class ControllerV10(Controller):
|
||||
class ControllerV11(Controller):
|
||||
"""Version 1.1 specific controller logic."""
|
||||
|
||||
def get_builder(self, request):
|
||||
def get_builder(self, req):
|
||||
"""Property to get the ViewBuilder class we need to use."""
|
||||
base_url = request.application_url
|
||||
project_id = request.environ['nova.context'].project_id
|
||||
base_url = req.application_url
|
||||
project_id = getattr(req.environ['nova.context'], 'project_id', '')
|
||||
return images_view.ViewBuilderV11(base_url, project_id)
|
||||
|
||||
def index(self, req):
|
||||
|
||||
@@ -639,7 +639,7 @@ class ControllerV11(Controller):
|
||||
return common.get_id_from_href(flavor_ref)
|
||||
|
||||
def _build_view(self, req, instance, is_detail=False):
|
||||
project_id = req.environ['nova.context'].project_id
|
||||
project_id = getattr(req.environ['nova.context'], 'project_id', '')
|
||||
base_url = req.application_url
|
||||
flavor_builder = nova.api.openstack.views.flavors.ViewBuilderV11(
|
||||
base_url, project_id)
|
||||
|
||||
@@ -152,11 +152,11 @@ class FlavorsTest(test.TestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v1.1/flavors/12",
|
||||
"href": "http://localhost/v1.1/fake/flavors/12",
|
||||
},
|
||||
{
|
||||
"rel": "bookmark",
|
||||
"href": "http://localhost/flavors/12",
|
||||
"href": "http://localhost/fake/flavors/12",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -177,11 +177,11 @@ class FlavorsTest(test.TestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v1.1/flavors/1",
|
||||
"href": "http://localhost/v1.1/fake/flavors/1",
|
||||
},
|
||||
{
|
||||
"rel": "bookmark",
|
||||
"href": "http://localhost/flavors/1",
|
||||
"href": "http://localhost/fake/flavors/1",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -191,11 +191,11 @@ class FlavorsTest(test.TestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v1.1/flavors/2",
|
||||
"href": "http://localhost/v1.1/fake/flavors/2",
|
||||
},
|
||||
{
|
||||
"rel": "bookmark",
|
||||
"href": "http://localhost/flavors/2",
|
||||
"href": "http://localhost/fake/flavors/2",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -219,11 +219,11 @@ class FlavorsTest(test.TestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v1.1/flavors/1",
|
||||
"href": "http://localhost/v1.1/fake/flavors/1",
|
||||
},
|
||||
{
|
||||
"rel": "bookmark",
|
||||
"href": "http://localhost/flavors/1",
|
||||
"href": "http://localhost/fake/flavors/1",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -235,11 +235,11 @@ class FlavorsTest(test.TestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v1.1/flavors/2",
|
||||
"href": "http://localhost/v1.1/fake/flavors/2",
|
||||
},
|
||||
{
|
||||
"rel": "bookmark",
|
||||
"href": "http://localhost/flavors/2",
|
||||
"href": "http://localhost/fake/flavors/2",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -274,11 +274,11 @@ class FlavorsXMLSerializationTest(test.TestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v1.1/flavors/12",
|
||||
"href": "http://localhost/v1.1/fake/flavors/12",
|
||||
},
|
||||
{
|
||||
"rel": "bookmark",
|
||||
"href": "http://localhost/flavors/12",
|
||||
"href": "http://localhost/fake/flavors/12",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -294,8 +294,10 @@ class FlavorsXMLSerializationTest(test.TestCase):
|
||||
name="asdf"
|
||||
ram="256"
|
||||
disk="10">
|
||||
<atom:link href="http://localhost/v1.1/flavors/12" rel="self"/>
|
||||
<atom:link href="http://localhost/flavors/12" rel="bookmark"/>
|
||||
<atom:link href="http://localhost/v1.1/fake/flavors/12"
|
||||
rel="self"/>
|
||||
<atom:link href="http://localhost/fake/flavors/12"
|
||||
rel="bookmark"/>
|
||||
</flavor>
|
||||
""".replace(" ", ""))
|
||||
|
||||
@@ -313,11 +315,11 @@ class FlavorsXMLSerializationTest(test.TestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v1.1/flavors/12",
|
||||
"href": "http://localhost/v1.1/fake/flavors/12",
|
||||
},
|
||||
{
|
||||
"rel": "bookmark",
|
||||
"href": "http://localhost/flavors/12",
|
||||
"href": "http://localhost/fake/flavors/12",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -333,8 +335,10 @@ class FlavorsXMLSerializationTest(test.TestCase):
|
||||
name="asdf"
|
||||
ram="256"
|
||||
disk="10">
|
||||
<atom:link href="http://localhost/v1.1/flavors/12" rel="self"/>
|
||||
<atom:link href="http://localhost/flavors/12" rel="bookmark"/>
|
||||
<atom:link href="http://localhost/v1.1/fake/flavors/12"
|
||||
rel="self"/>
|
||||
<atom:link href="http://localhost/fake/flavors/12"
|
||||
rel="bookmark"/>
|
||||
</flavor>
|
||||
""".replace(" ", ""))
|
||||
|
||||
@@ -353,11 +357,11 @@ class FlavorsXMLSerializationTest(test.TestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v1.1/flavors/23",
|
||||
"href": "http://localhost/v1.1/fake/flavors/23",
|
||||
},
|
||||
{
|
||||
"rel": "bookmark",
|
||||
"href": "http://localhost/flavors/23",
|
||||
"href": "http://localhost/fake/flavors/23",
|
||||
},
|
||||
],
|
||||
}, {
|
||||
@@ -368,11 +372,11 @@ class FlavorsXMLSerializationTest(test.TestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v1.1/flavors/13",
|
||||
"href": "http://localhost/v1.1/fake/flavors/13",
|
||||
},
|
||||
{
|
||||
"rel": "bookmark",
|
||||
"href": "http://localhost/flavors/13",
|
||||
"href": "http://localhost/fake/flavors/13",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -389,15 +393,19 @@ class FlavorsXMLSerializationTest(test.TestCase):
|
||||
name="flavor 23"
|
||||
ram="512"
|
||||
disk="20">
|
||||
<atom:link href="http://localhost/v1.1/flavors/23" rel="self"/>
|
||||
<atom:link href="http://localhost/flavors/23" rel="bookmark"/>
|
||||
<atom:link href="http://localhost/v1.1/fake/flavors/23"
|
||||
rel="self"/>
|
||||
<atom:link href="http://localhost/fake/flavors/23"
|
||||
rel="bookmark"/>
|
||||
</flavor>
|
||||
<flavor id="13"
|
||||
name="flavor 13"
|
||||
ram="256"
|
||||
disk="10">
|
||||
<atom:link href="http://localhost/v1.1/flavors/13" rel="self"/>
|
||||
<atom:link href="http://localhost/flavors/13" rel="bookmark"/>
|
||||
<atom:link href="http://localhost/v1.1/fake/flavors/13"
|
||||
rel="self"/>
|
||||
<atom:link href="http://localhost/fake/flavors/13"
|
||||
rel="bookmark"/>
|
||||
</flavor>
|
||||
</flavors>
|
||||
""".replace(" ", "") % locals())
|
||||
@@ -417,11 +425,11 @@ class FlavorsXMLSerializationTest(test.TestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v1.1/flavors/23",
|
||||
"href": "http://localhost/v1.1/fake/flavors/23",
|
||||
},
|
||||
{
|
||||
"rel": "bookmark",
|
||||
"href": "http://localhost/flavors/23",
|
||||
"href": "http://localhost/fake/flavors/23",
|
||||
},
|
||||
],
|
||||
}, {
|
||||
@@ -432,11 +440,11 @@ class FlavorsXMLSerializationTest(test.TestCase):
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "http://localhost/v1.1/flavors/13",
|
||||
"href": "http://localhost/v1.1/fake/flavors/13",
|
||||
},
|
||||
{
|
||||
"rel": "bookmark",
|
||||
"href": "http://localhost/flavors/13",
|
||||
"href": "http://localhost/fake/flavors/13",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -450,12 +458,16 @@ class FlavorsXMLSerializationTest(test.TestCase):
|
||||
<flavors xmlns="http://docs.openstack.org/compute/api/v1.1"
|
||||
xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<flavor id="23" name="flavor 23">
|
||||
<atom:link href="http://localhost/v1.1/flavors/23" rel="self"/>
|
||||
<atom:link href="http://localhost/flavors/23" rel="bookmark"/>
|
||||
<atom:link href="http://localhost/v1.1/fake/flavors/23"
|
||||
rel="self"/>
|
||||
<atom:link href="http://localhost/fake/flavors/23"
|
||||
rel="bookmark"/>
|
||||
</flavor>
|
||||
<flavor id="13" name="flavor 13">
|
||||
<atom:link href="http://localhost/v1.1/flavors/13" rel="self"/>
|
||||
<atom:link href="http://localhost/flavors/13" rel="bookmark"/>
|
||||
<atom:link href="http://localhost/v1.1/fake/flavors/13"
|
||||
rel="self"/>
|
||||
<atom:link href="http://localhost/fake/flavors/13"
|
||||
rel="bookmark"/>
|
||||
</flavor>
|
||||
</flavors>
|
||||
""".replace(" ", "") % locals())
|
||||
|
||||
Reference in New Issue
Block a user