~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/api/openstack/compute/flavors.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
import webob
19
19
 
 
20
from nova.api.openstack import common
20
21
from nova.api.openstack.compute.views import flavors as flavors_view
21
 
from nova.api.openstack import common
22
22
from nova.api.openstack import wsgi
23
23
from nova.api.openstack import xmlutil
24
24
from nova.compute import instance_types
73
73
    def index(self, req):
74
74
        """Return all flavors in brief."""
75
75
        flavors = self._get_flavors(req)
76
 
        limited_flavors = common.limited_by_marker(flavors.values(), req)
77
 
        return self._view_builder.index(req, limited_flavors)
 
76
        return self._view_builder.index(req, flavors)
78
77
 
79
78
    @wsgi.serializers(xml=FlavorsTemplate)
80
79
    def detail(self, req):
81
80
        """Return all flavors in detail."""
82
81
        flavors = self._get_flavors(req)
83
 
        limited_flavors = common.limited_by_marker(flavors.values(), req)
84
 
        return self._view_builder.detail(req, limited_flavors)
 
82
        return self._view_builder.detail(req, flavors)
85
83
 
86
84
    @wsgi.serializers(xml=FlavorTemplate)
87
85
    def show(self, req, id):
100
98
            try:
101
99
                filters['min_memory_mb'] = int(req.params['minRam'])
102
100
            except ValueError:
103
 
                pass  # ignore bogus values per spec
 
101
                msg = _('Invalid minRam filter [%s]') % req.params['minRam']
 
102
                raise webob.exc.HTTPBadRequest(explanation=msg)
104
103
 
105
104
        if 'minDisk' in req.params:
106
105
            try:
107
106
                filters['min_root_gb'] = int(req.params['minDisk'])
108
107
            except ValueError:
109
 
                pass  # ignore bogus values per spec
 
108
                msg = _('Invalid minDisk filter [%s]') % req.params['minDisk']
 
109
                raise webob.exc.HTTPBadRequest(explanation=msg)
110
110
 
111
 
        return instance_types.get_all_types(filters=filters)
 
111
        flavors = instance_types.get_all_types(filters=filters)
 
112
        flavors_list = flavors.values()
 
113
        sorted_flavors = sorted(flavors_list,
 
114
                                key=lambda item: item['flavorid'])
 
115
        limited_flavors = common.limited_by_marker(sorted_flavors, req)
 
116
        return limited_flavors
112
117
 
113
118
 
114
119
def create_resource():