diff options
| author | Michael Gundlach <michael.gundlach@rackspace.com> | 2010-08-25 16:49:32 -0400 |
|---|---|---|
| committer | Michael Gundlach <michael.gundlach@rackspace.com> | 2010-08-25 16:49:32 -0400 |
| commit | 0aa2eceba81e569dcde8bca318b696d121fe9f81 (patch) | |
| tree | ecd58921e5373857634aff0f227feaa01fba3795 /nova/api | |
| parent | cf0b5de1f78fd81ada2bada8c84e26b3238b8596 (diff) | |
| parent | 686ad09fe4416bb578661a42f6f083528d4a7ca9 (diff) | |
| download | nova-0aa2eceba81e569dcde8bca318b696d121fe9f81.tar.gz nova-0aa2eceba81e569dcde8bca318b696d121fe9f81.tar.xz nova-0aa2eceba81e569dcde8bca318b696d121fe9f81.zip | |
Merge from trunk
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/rackspace/images.py | 2 | ||||
| -rw-r--r-- | nova/api/services/__init__.py | 0 | ||||
| -rw-r--r-- | nova/api/services/image.py | 90 |
3 files changed, 1 insertions, 91 deletions
diff --git a/nova/api/rackspace/images.py b/nova/api/rackspace/images.py index 09f55ea96..06fb0d38f 100644 --- a/nova/api/rackspace/images.py +++ b/nova/api/rackspace/images.py @@ -15,9 +15,9 @@ # License for the specific language governing permissions and limitations # under the License. +from nova import image from nova.api.rackspace import base from nova.api.rackspace import _id_translator -from nova.api.services import image from webob import exc class Controller(base.Controller): diff --git a/nova/api/services/__init__.py b/nova/api/services/__init__.py deleted file mode 100644 index e69de29bb..000000000 --- a/nova/api/services/__init__.py +++ /dev/null diff --git a/nova/api/services/image.py b/nova/api/services/image.py deleted file mode 100644 index 1a7a258b7..000000000 --- a/nova/api/services/image.py +++ /dev/null @@ -1,90 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# 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 cPickle as pickle -import os.path -import random -import string - -class ImageService(object): - """Provides storage and retrieval of disk image objects.""" - - @staticmethod - def load(): - """Factory method to return image service.""" - #TODO(gundlach): read from config. - class_ = LocalImageService - return class_() - - def index(self): - """ - Return a dict from opaque image id to image data. - """ - - def show(self, id): - """ - Returns a dict containing image data for the given opaque image id. - """ - - -class GlanceImageService(ImageService): - """Provides storage and retrieval of disk image objects within Glance.""" - # TODO(gundlach): once Glance has an API, build this. - pass - - -class LocalImageService(ImageService): - """Image service storing images to local disk.""" - - def __init__(self): - self._path = "/tmp/nova/images" - try: - os.makedirs(self._path) - except OSError: # exists - pass - - def _path_to(self, image_id=''): - return os.path.join(self._path, image_id) - - def _ids(self): - """The list of all image ids.""" - return os.listdir(self._path) - - def index(self): - return [ self.show(id) for id in self._ids() ] - - def show(self, id): - return pickle.load(open(self._path_to(id))) - - def create(self, data): - """ - Store the image data and return the new image id. - """ - id = ''.join(random.choice(string.letters) for _ in range(20)) - data['id'] = id - self.update(id, data) - return id - - def update(self, image_id, data): - """Replace the contents of the given image with the new data.""" - pickle.dump(data, open(self._path_to(image_id), 'w')) - - def delete(self, image_id): - """ - Delete the given image. Raises OSError if the image does not exist. - """ - os.unlink(self._path_to(image_id)) |
