~ubuntu-branches/ubuntu/quantal/quantum/quantal-updates

« back to all changes in this revision

Viewing changes to quantum/extensions/qos.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandelman
  • Date: 2012-06-22 12:49:23 UTC
  • mfrom: (2.1.8)
  • Revision ID: package-import@ubuntu.com-20120622124923-5q185p2z7nooaxs0
Tags: 2012.2~f2~20120621.868-0ubuntu1
[ Chuck Short ]
* New upstream release.
* Add missing upsart jobs for agents. 
* Add sudo wrapper for quantum-rootwrap. (LP: #999142)

[ Adam Gandelman ]
* debian/control: Fix spacing issues that cause mk-build-deps to fail.
* debian/quantum-server.install: Install new plugins config directory
  instead of old .ini.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""
2
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
2
#
4
3
# Copyright 2011 Cisco Systems, Inc.  All rights reserved.
16
15
#    under the License.
17
16
#
18
17
# @author: Ying Liu, Cisco Systems, Inc.
19
 
#
20
 
"""
 
18
 
21
19
import logging
22
20
 
23
 
from quantum import wsgi
24
21
from webob import exc
 
22
 
 
23
from quantum.api import api_common as common
25
24
from quantum.extensions import _qos_view as qos_view
26
 
from quantum.api import api_common as common
27
25
from quantum.extensions import extensions
28
26
from quantum.manager import QuantumManager
29
27
from quantum.plugins.cisco.common import cisco_exceptions as exception
30
28
from quantum.plugins.cisco.common import cisco_faults as faults
 
29
from quantum import wsgi
31
30
 
32
31
 
33
32
LOG = logging.getLogger('quantum.api.qoss')
78
77
    """ qos API controller
79
78
        based on QuantumController """
80
79
 
81
 
    _qos_ops_param_list = [{
82
 
        'param-name': 'qos_name',
83
 
        'required': True}, {
84
 
        'param-name': 'qos_desc',
85
 
        'required': True}]
 
80
    _qos_ops_param_list = [
 
81
        {'param-name': 'qos_name', 'required': True},
 
82
        {'param-name': 'qos_desc', 'required': True},
 
83
    ]
 
84
 
86
85
    _serialization_metadata = {
87
86
        "application/xml": {
88
87
            "attributes": {
103
102
        """ Returns a list of qoss. """
104
103
        qoss = self._plugin.get_all_qoss(tenant_id)
105
104
        builder = qos_view.get_view_builder(request)
106
 
        result = [builder.build(qos, is_detail)['qos']
107
 
                  for qos in qoss]
 
105
        result = [builder.build(qos, is_detail)['qos'] for qos in qoss]
108
106
        return dict(qoss=result)
109
107
 
110
108
    # pylint: disable-msg=E1101
111
109
    def show(self, request, tenant_id, id):
112
110
        """ Returns qos details for the given qos id """
113
111
        try:
114
 
            qos = self._plugin.get_qos_details(
115
 
                            tenant_id, id)
 
112
            qos = self._plugin.get_qos_details(tenant_id, id)
116
113
            builder = qos_view.get_view_builder(request)
117
114
            #build response with details
118
115
            result = builder.build(qos, True)
125
122
        #look for qos name in request
126
123
        try:
127
124
            body = self._deserialize(request.body, request.get_content_type())
128
 
            req_body = \
129
 
                self._prepare_request_body(body,
130
 
                                           self._qos_ops_param_list)
 
125
            req_body = self._prepare_request_body(body,
 
126
                                                  self._qos_ops_param_list)
131
127
            req_params = req_body[self._resource_name]
132
128
        except exc.HTTPError as exp:
133
129
            return faults.Fault(exp)
134
 
        qos = self._plugin.\
135
 
                       create_qos(tenant_id,
136
 
                                          req_params['qos_name'],
137
 
                                          req_params['qos_desc'])
 
130
        qos = self._plugin.create_qos(tenant_id,
 
131
                                      req_params['qos_name'],
 
132
                                      req_params['qos_desc'])
138
133
        builder = qos_view.get_view_builder(request)
139
134
        result = builder.build(qos)
140
135
        return dict(qoss=result)
143
138
        """ Updates the name for the qos with the given id """
144
139
        try:
145
140
            body = self._deserialize(request.body, request.get_content_type())
146
 
            req_body = \
147
 
                self._prepare_request_body(body,
148
 
                                           self._qos_ops_param_list)
 
141
            req_body = self._prepare_request_body(body,
 
142
                                                  self._qos_ops_param_list)
149
143
            req_params = req_body[self._resource_name]
150
144
        except exc.HTTPError as exp:
151
145
            return faults.Fault(exp)
152
146
        try:
153
 
            qos = self._plugin.\
154
 
            rename_qos(tenant_id,
155
 
                        id, req_params['qos_name'])
 
147
            qos = self._plugin.rename_qos(tenant_id, id,
 
148
                                          req_params['qos_name'])
156
149
 
157
150
            builder = qos_view.get_view_builder(request)
158
151
            result = builder.build(qos, True)