52de5b6cef
neutron-lib contains the qos constants now, and neutron is moving to it in I6ed379b178a2b79fd14385a1d1e87d87eb04bfb9. This patch moves all references from neutron's qos constants to neutron-lib. Change-Id: I047e187af8c5a7ea04b94659ccc725f796553066
85 lines
2.7 KiB
Python
85 lines
2.7 KiB
Python
# Copyright 2017 VMware, Inc.
|
|
#
|
|
# 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.
|
|
|
|
from neutron_lib.services.qos import base
|
|
from neutron_lib.services.qos import constants as qos_consts
|
|
from oslo_log import log as logging
|
|
|
|
from neutron.common import constants as n_consts
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
DRIVER = None
|
|
SUPPORTED_RULES = {
|
|
qos_consts.RULE_TYPE_BANDWIDTH_LIMIT: {
|
|
qos_consts.MAX_KBPS: {
|
|
'type:range': [0, n_consts.DB_INTEGER_MAX_VALUE]},
|
|
qos_consts.MAX_BURST: {
|
|
'type:range': [0, n_consts.DB_INTEGER_MAX_VALUE]},
|
|
qos_consts.DIRECTION: {
|
|
'type:values': [n_consts.EGRESS_DIRECTION,
|
|
n_consts.INGRESS_DIRECTION]}
|
|
},
|
|
qos_consts.RULE_TYPE_DSCP_MARKING: {
|
|
qos_consts.DSCP_MARK: {'type:values': n_consts.VALID_DSCP_MARKS}
|
|
}
|
|
}
|
|
|
|
|
|
class NSXvQosDriver(base.DriverBase):
|
|
|
|
@staticmethod
|
|
def create(core_plugin):
|
|
return NSXvQosDriver(
|
|
core_plugin,
|
|
name='NSXvQosDriver',
|
|
vif_types=None,
|
|
vnic_types=None,
|
|
supported_rules=SUPPORTED_RULES,
|
|
requires_rpc_notifications=False)
|
|
|
|
def __init__(self, core_plugin, **kwargs):
|
|
super(NSXvQosDriver, self).__init__(**kwargs)
|
|
self.core_plugin = core_plugin
|
|
self.requires_rpc_notifications = False
|
|
|
|
def is_vif_type_compatible(self, vif_type):
|
|
return True
|
|
|
|
def is_vnic_compatible(self, vnic_type):
|
|
return True
|
|
|
|
def create_policy(self, context, policy):
|
|
pass
|
|
|
|
def update_policy(self, context, policy):
|
|
# get all the bound networks of this policy
|
|
networks = policy.get_bound_networks()
|
|
for net_id in networks:
|
|
# update the new bw limitations for this network
|
|
self.core_plugin._update_qos_on_backend_network(
|
|
context, net_id, policy.id)
|
|
|
|
def delete_policy(self, context, policy):
|
|
pass
|
|
|
|
|
|
def register(core_plugin):
|
|
"""Register the NSX-V QoS driver."""
|
|
global DRIVER
|
|
if not DRIVER:
|
|
DRIVER = NSXvQosDriver.create(core_plugin)
|
|
LOG.debug('NSXvQosDriver QoS driver registered')
|