| 1 |
# Copyright 2015 Huawei Technologies India Pvt Ltd, Inc. |
| 2 |
# All Rights Reserved |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 |
# not use this file except in compliance with the License. You may obtain |
| 6 |
# a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 |
# License for the specific language governing permissions and limitations |
| 14 |
# under the License. |
| 15 |
# |
| 16 |
|
| 17 |
|
| 18 |
from neutronclient._i18n import _ |
| 19 |
from neutronclient.neutron import v2_0 as neutronv20 |
| 20 |
from neutronclient.neutron.v2_0.qos import policy as qos_policy |
| 21 |
|
| 22 |
|
| 23 |
def add_policy_argument(parser): |
| 24 |
parser.add_argument( |
| 25 |
'policy', metavar='QOS_POLICY', |
| 26 |
help=_('ID or name of the QoS policy.')) |
| 27 |
|
| 28 |
|
| 29 |
def add_rule_argument(parser): |
| 30 |
parser.add_argument( |
| 31 |
'rule', metavar='QOS_RULE', |
| 32 |
help=_('ID of the QoS rule.')) |
| 33 |
|
| 34 |
|
| 35 |
def update_policy_args2body(parsed_args, body): |
| 36 |
neutronv20.update_dict(parsed_args, body, ['policy']) |
| 37 |
|
| 38 |
|
| 39 |
def update_rule_args2body(parsed_args, body): |
| 40 |
neutronv20.update_dict(parsed_args, body, ['rule']) |
| 41 |
|
| 42 |
|
| 43 |
class QosRuleMixin(object): |
| 44 |
def add_known_arguments(self, parser): |
| 45 |
add_policy_argument(parser) |
| 46 |
|
| 47 |
def set_extra_attrs(self, parsed_args): |
| 48 |
self.parent_id = qos_policy.get_qos_policy_id(self.get_client(), |
| 49 |
parsed_args.policy) |
| 50 |
|
| 51 |
def args2body(self, parsed_args): |
| 52 |
body = {} |
| 53 |
update_policy_args2body(parsed_args, body) |
| 54 |
return {'qos_rule': body} |
| 55 |
|
| 56 |
|
| 57 |
class ListQoSRuleTypes(neutronv20.ListCommand): |
| 58 |
"""List available qos rule types.""" |
| 59 |
|
| 60 |
resource = 'rule_type' |
| 61 |
shadow_resource = 'qos_rule_type' |
| 62 |
pagination_support = True |
| 63 |
sorting_support = True |