OpenStack Networking (Neutron)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.8 KiB

# Copyright (c) 2016 Red Hat 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
# 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.api.definitions import portbindings
from neutron_lib import constants
from neutron_lib.db import constants as db_consts
from import base
from import constants as qos_consts
from oslo_log import log as logging
from neutron.objects import network as network_object
LOG = logging.getLogger(__name__)
qos_consts.MAX_KBPS: {
'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]},
qos_consts.MAX_BURST: {
'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]},
qos_consts.DIRECTION: {
'type:values': constants.VALID_DIRECTIONS}
qos_consts.DSCP_MARK: {'type:values': constants.VALID_DSCP_MARKS}
qos_consts.MIN_KBPS: {
'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]},
qos_consts.DIRECTION: {'type:values': constants.VALID_DIRECTIONS}
class OVSDriver(base.DriverBase):
def create():
return OVSDriver(
vnic_types=[portbindings.VNIC_NORMAL, portbindings.VNIC_DIRECT],
def validate_rule_for_port(self, context, rule, port):
return self.validate_rule_for_network(context, rule, port.network_id)
def validate_rule_for_network(self, context, rule, network_id):
# Minimum-bandwidth rule is only supported on networks whose
# first segment is backed by a physnet.
if rule.rule_type == qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH:
net = network_object.Network.get_object(
context, id=network_id)
physnet = net.segments[0].physical_network
if physnet is None:
return False
return True
def register():
"""Register the driver."""
global DRIVER
if not DRIVER:
DRIVER = OVSDriver.create()
LOG.debug('Open vSwitch QoS driver registered')