summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorWilliam Wolf <throughnothing@gmail.com>2011-09-19 22:09:53 -0400
committerWilliam Wolf <throughnothing@gmail.com>2011-09-19 22:09:53 -0400
commitf27ed550fae070c8cfeaf638b2a00a9b80f188c1 (patch)
tree7b8afa180e5f2ada4c8bf35c340fcc043b185f98 /nova/api
parenta0e705359353cb6a9b0c3fc8178e714e4350c585 (diff)
parentb90503021b5d55c51cf082fd168512bd4586383d (diff)
downloadnova-f27ed550fae070c8cfeaf638b2a00a9b80f188c1.tar.gz
nova-f27ed550fae070c8cfeaf638b2a00a9b80f188c1.tar.xz
nova-f27ed550fae070c8cfeaf638b2a00a9b80f188c1.zip
merged with trunk
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/contrib/virtual_interfaces.py16
-rw-r--r--nova/api/openstack/servers.py6
2 files changed, 8 insertions, 14 deletions
diff --git a/nova/api/openstack/contrib/virtual_interfaces.py b/nova/api/openstack/contrib/virtual_interfaces.py
index dab61efc8..1981cd372 100644
--- a/nova/api/openstack/contrib/virtual_interfaces.py
+++ b/nova/api/openstack/contrib/virtual_interfaces.py
@@ -15,15 +15,10 @@
"""The virtual interfaces extension."""
-from webob import exc
-import webob
-
-from nova import compute
-from nova import exception
from nova import log as logging
+from nova import network
from nova.api.openstack import common
from nova.api.openstack import extensions
-from nova.api.openstack import faults
from nova.api.openstack import wsgi
@@ -50,19 +45,14 @@ class ServerVirtualInterfaceController(object):
"""
def __init__(self):
- self.compute_api = compute.API()
+ self.network_api = network.API()
super(ServerVirtualInterfaceController, self).__init__()
def _items(self, req, server_id, entity_maker):
"""Returns a list of VIFs, transformed through entity_maker."""
context = req.environ['nova.context']
- try:
- instance = self.compute_api.get(context, server_id)
- except exception.NotFound:
- return faults.Fault(exc.HTTPNotFound())
-
- vifs = instance['virtual_interfaces']
+ vifs = self.network_api.get_vifs_by_instance(context, server_id)
limited_list = common.limited(vifs, req)
res = [entity_maker(context, vif) for vif in limited_list]
return {'virtual_interfaces': res}
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index ac6b4918a..211925bd0 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -661,7 +661,11 @@ class ControllerV11(Controller):
def _get_key_name(self, req, body):
if 'server' in body:
- return body['server'].get('key_name')
+ try:
+ return body['server'].get('key_name')
+ except AttributeError:
+ msg = _("Malformed server entity")
+ raise exc.HTTPBadRequest(explanation=msg)
def _image_ref_from_req_data(self, data):
try: