diff options
| author | Ken Pepple <ken.pepple@gmail.com> | 2011-02-17 17:41:36 -0800 |
|---|---|---|
| committer | Ken Pepple <ken.pepple@gmail.com> | 2011-02-17 17:41:36 -0800 |
| commit | 6cf0a30b31beffc09b56950e9869dd423d5f3b11 (patch) | |
| tree | dd503b74e9b689965511a172449ed984fa812db8 /nova/api | |
| parent | ff0ef603fd3f87ad9294260d13ea3c122bab387f (diff) | |
| parent | 5dfa5ce7d1374509fea51f8d0b132ea865f34dc6 (diff) | |
| download | nova-6cf0a30b31beffc09b56950e9869dd423d5f3b11.tar.gz nova-6cf0a30b31beffc09b56950e9869dd423d5f3b11.tar.xz nova-6cf0a30b31beffc09b56950e9869dd423d5f3b11.zip | |
merged trunk
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/__init__.py | 4 | ||||
| -rw-r--r-- | nova/api/openstack/auth.py | 1 | ||||
| -rw-r--r-- | nova/api/openstack/servers.py | 5 | ||||
| -rw-r--r-- | nova/api/openstack/zones.py | 80 |
4 files changed, 87 insertions, 3 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index bf477bd32..d7347a171 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -34,6 +34,7 @@ from nova.api.openstack import flavors from nova.api.openstack import images from nova.api.openstack import servers from nova.api.openstack import shared_ip_groups +from nova.api.openstack import zones LOG = logging.getLogger('nova.api.openstack') @@ -82,6 +83,9 @@ class APIRouter(wsgi.Router): server_members['resume'] = 'POST' server_members['reset_network'] = 'POST' + mapper.resource("zone", "zones", controller=zones.Controller(), + collection={'detail': 'GET'}) + mapper.resource("server", "servers", controller=servers.Controller(), collection={'detail': 'GET'}, member=server_members) diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py index 1dfdd5318..473071738 100644 --- a/nova/api/openstack/auth.py +++ b/nova/api/openstack/auth.py @@ -19,6 +19,7 @@ import datetime import hashlib import json import time +import logging import webob.exc import webob.dec diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index c7f863764..486eca508 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -1,5 +1,3 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - # Copyright 2010 OpenStack LLC. # All Rights Reserved. # @@ -179,7 +177,8 @@ class Controller(wsgi.Controller): display_name=env['server']['name'], display_description=env['server']['name'], key_name=key_pair['name'], - key_data=key_pair['public_key']) + key_data=key_pair['public_key'], + onset_files=env.get('onset_files', [])) return _translate_keys(instances[0]) def update(self, req, id): diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py new file mode 100644 index 000000000..830464ffd --- /dev/null +++ b/nova/api/openstack/zones.py @@ -0,0 +1,80 @@ +# Copyright 2010 OpenStack LLC. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import common +import logging + +from nova import flags +from nova import wsgi +from nova import db + + +FLAGS = flags.FLAGS + + +def _filter_keys(item, keys): + """ + Filters all model attributes except for keys + item is a dict + + """ + return dict((k, v) for k, v in item.iteritems() if k in keys) + + +def _scrub_zone(zone): + return _filter_keys(zone, ('id', 'api_url')) + + +class Controller(wsgi.Controller): + + _serialization_metadata = { + 'application/xml': { + "attributes": { + "zone": ["id", "api_url"]}}} + + def index(self, req): + """Return all zones in brief""" + items = db.zone_get_all(req.environ['nova.context']) + items = common.limited(items, req) + items = [_scrub_zone(item) for item in items] + return dict(zones=items) + + def detail(self, req): + """Return all zones in detail""" + return self.index(req) + + def show(self, req, id): + """Return data about the given zone id""" + zone_id = int(id) + zone = db.zone_get(req.environ['nova.context'], zone_id) + return dict(zone=_scrub_zone(zone)) + + def delete(self, req, id): + zone_id = int(id) + db.zone_delete(req.environ['nova.context'], zone_id) + return {} + + def create(self, req): + context = req.environ['nova.context'] + env = self._deserialize(req.body, req) + zone = db.zone_create(context, env["zone"]) + return dict(zone=_scrub_zone(zone)) + + def update(self, req, id): + context = req.environ['nova.context'] + env = self._deserialize(req.body, req) + zone_id = int(id) + zone = db.zone_update(context, zone_id, env["zone"]) + return dict(zone=_scrub_zone(zone)) |
