summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorCerberus <matt.dietz@rackspace.com>2010-12-27 17:29:45 -0600
committerCerberus <matt.dietz@rackspace.com>2010-12-27 17:29:45 -0600
commit431c54ba76a2a85ff55658c571f68378b47ce39d (patch)
treee3a43f678b371ae3a4a5f2ef2d629faa786c7fc1 /nova/api
parentb879c746049241837af3785adc3068fbe35f199d (diff)
downloadnova-431c54ba76a2a85ff55658c571f68378b47ce39d.tar.gz
nova-431c54ba76a2a85ff55658c571f68378b47ce39d.tar.xz
nova-431c54ba76a2a85ff55658c571f68378b47ce39d.zip
Renamed based on feedback from another branch
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/backup_schedules.py2
-rw-r--r--nova/api/openstack/servers.py27
2 files changed, 14 insertions, 15 deletions
diff --git a/nova/api/openstack/backup_schedules.py b/nova/api/openstack/backup_schedules.py
index a8b0fbbb9..9b8e605f6 100644
--- a/nova/api/openstack/backup_schedules.py
+++ b/nova/api/openstack/backup_schedules.py
@@ -22,10 +22,12 @@ from nova import wsgi
from nova.api.openstack import faults
import nova.image.service
+
def _entity_inst(inst):
""" Coerces the backup schedule into proper dictionary format """
return dict(backupSchedule=inst)
+
class Controller(wsgi.Controller):
""" The backup schedule API controller for the Openstack API """
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 7abf5ec53..9369f6516 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -35,13 +35,9 @@ LOG = logging.getLogger('server')
LOG.setLevel(logging.DEBUG)
-def _entity_list(entities):
- """ Coerces a list of servers into proper dictionary format """
- return dict(servers=entities)
-
-
-def _entity_detail(inst):
- """ Maps everything to Rackspace-like attributes for return"""
+def _translate_detail_keys(inst):
+ """ Coerces into dictionary format, mapping everything to Rackspace-like
+ attributes for return"""
power_mapping = {
None: 'build',
power_state.NOSTATE: 'build',
@@ -67,8 +63,9 @@ def _entity_detail(inst):
return dict(server=inst_dict)
-def _entity_inst(inst):
- """ Filters all model attributes save for id and name """
+def _translate_keys(inst):
+ """ Coerces into dictionary format, excluding all model attributes
+ save for id and name """
return dict(server=dict(id=inst['internal_id'], name=inst['display_name']))
@@ -87,29 +84,29 @@ class Controller(wsgi.Controller):
def index(self, req):
""" Returns a list of server names and ids for a given user """
- return self._items(req, entity_maker=_entity_inst)
+ return self._items(req, entity_maker=_translte_keys)
def detail(self, req):
""" Returns a list of server details for a given user """
- return self._items(req, entity_maker=_entity_detail)
+ return self._items(req, entity_maker=_translate_detail_keys)
def _items(self, req, entity_maker):
"""Returns a list of servers for a given user.
- entity_maker - either _entity_detail or _entity_inst
+ entity_maker - either _translate_detail_keys or _translate_keys
"""
instance_list = self.compute_api.get_instances(
req.environ['nova.context'])
limited_list = common.limited(instance_list, req)
res = [entity_maker(inst)['server'] for inst in limited_list]
- return _entity_list(res)
+ return dict(servers=res)
def show(self, req, id):
""" Returns server details by server id """
try:
instance = self.compute_api.get_instance(
req.environ['nova.context'], int(id))
- return _entity_detail(instance)
+ return _translate_detail_keys(instance)
except exception.NotFound:
return faults.Fault(exc.HTTPNotFound())
@@ -138,7 +135,7 @@ class Controller(wsgi.Controller):
description=env['server']['name'],
key_name=key_pair['name'],
key_data=key_pair['public_key'])
- return _entity_inst(instances[0])
+ return _translate_keys(instances[0])
def update(self, req, id):
""" Updates the server name or password """