from neutron.agent.l2.extensions import qos
from neutron.api.rpc.callbacks.consumer import registry
from neutron.api.rpc.callbacks import events
from neutron.api.rpc.callbacks import resources
from neutron.api.rpc.handlers import resources_rpc
from neutron.common import exceptions
from neutron import context
from neutron.objects.qos import policy
from neutron.objects.qos import rule
from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants
from neutron.services.qos import qos_consts
from neutron.tests import base

BASE_TEST_POLICY = {'context': None, 'name': 'test1', 'id': 'fake_policy_id'}

TEST_POLICY = policy.QosPolicy(**BASE_TEST_POLICY)

TEST_POLICY_DESCR = policy.QosPolicy(description='fake_descr',
                                     **BASE_TEST_POLICY)

TEST_POLICY2 = policy.QosPolicy(context=None,
                                name='test2',
                                id='fake_policy_id_2')

TEST_PORT = {'port_id': 'test_port_id', 'qos_policy_id': TEST_POLICY.id}

TEST_PORT2 = {'port_id': 'test_port_id_2', 'qos_policy_id': TEST_POLICY2.id}


class FakeDriver(qos.QosAgentDriver):
Exemplo n.º 2
0
    def setUp(self):
        super(TestQosPlugin, self).setUp()
        self.setup_coreplugin(load_plugins=False)

        mock.patch('neutron.objects.db.api.create_object').start()
        mock.patch('neutron.objects.db.api.update_object').start()
        mock.patch('neutron.objects.db.api.delete_object').start()
        mock.patch('neutron.objects.db.api.get_object').start()
        _mock_qos_load_attr = mock.patch(
            'neutron.objects.qos.policy.QosPolicy.obj_load_attr')
        self.mock_qos_load_attr = _mock_qos_load_attr.start()
        # We don't use real models as per mocks above. We also need to mock-out
        # methods that work with real data types
        mock.patch('neutron.objects.base.NeutronDbObject.modify_fields_from_db'
                   ).start()
        mock.patch.object(policy_object.QosPolicy, 'unset_default').start()
        mock.patch.object(policy_object.QosPolicy, 'set_default').start()

        cfg.CONF.set_override("core_plugin", DB_PLUGIN_KLASS)
        cfg.CONF.set_override("service_plugins", ["qos"])

        manager.init()
        self.qos_plugin = directory.get_plugin(plugins_constants.QOS)

        self.qos_plugin.driver_manager = mock.Mock()

        self.rpc_push = mock.patch('neutron.api.rpc.handlers.resources_rpc'
                                   '.ResourcesPushRpcApi.push').start()

        self.ctxt = context.Context('fake_user', 'fake_tenant')
        mock.patch.object(self.ctxt.session, 'refresh').start()
        mock.patch.object(self.ctxt.session, 'expunge').start()

        self.policy_data = {
            'policy': {
                'id': uuidutils.generate_uuid(),
                'project_id': uuidutils.generate_uuid(),
                'name': 'test-policy',
                'description': 'Test policy description',
                'shared': True,
                'is_default': False
            }
        }

        self.rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 100,
                'max_burst_kbps': 150
            },
            'dscp_marking_rule': {
                'id': uuidutils.generate_uuid(),
                'dscp_mark': 16
            },
            'minimum_bandwidth_rule': {
                'id': uuidutils.generate_uuid(),
                'min_kbps': 10
            }
        }

        self.policy = policy_object.QosPolicy(self.ctxt,
                                              **self.policy_data['policy'])

        self.rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['bandwidth_limit_rule'])

        self.dscp_rule = rule_object.QosDscpMarkingRule(
            self.ctxt, **self.rule_data['dscp_marking_rule'])

        self.min_rule = rule_object.QosMinimumBandwidthRule(
            self.ctxt, **self.rule_data['minimum_bandwidth_rule'])
Exemplo n.º 3
0
    def setUp(self):
        # Reset the drive to re-create it
        qos_driver.DRIVER = None
        super(TestQosNsxV3Notification, self).setUp()
        self.setup_coreplugin(PLUGIN_NAME)

        self.qos_plugin = qos_plugin.QoSPlugin()
        self.ctxt = context.Context('fake_user', 'fake_tenant')
        mock.patch.object(self.ctxt.session, 'refresh').start()
        mock.patch.object(self.ctxt.session, 'expunge').start()
        self.policy_data = {
            'policy': {
                'id': uuidutils.generate_uuid(),
                'project_id': uuidutils.generate_uuid(),
                'name': 'test-policy',
                'description': 'Test policy description',
                'shared': True
            }
        }
        self.rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 2000,
                'max_burst_kbps': 150
            }
        }
        self.ingress_rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 3000,
                'max_burst_kbps': 350,
                'direction': 'ingress'
            }
        }
        self.dscp_rule_data = {
            'dscp_marking_rule': {
                'id': uuidutils.generate_uuid(),
                'dscp_mark': 22
            }
        }

        self.policy = policy_object.QosPolicy(self.ctxt,
                                              **self.policy_data['policy'])

        # egress BW limit rule
        self.rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['bandwidth_limit_rule'])
        # ingress bw limit rule
        self.ingress_rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.ingress_rule_data['bandwidth_limit_rule'])
        self.dscp_rule = rule_object.QosDscpMarkingRule(
            self.ctxt, **self.dscp_rule_data['dscp_marking_rule'])

        self.fake_profile_id = 'fake_profile'
        self.fake_profile = {'id': self.fake_profile_id}

        mock.patch('neutron.objects.db.api.create_object').start()
        mock.patch('neutron.objects.db.api.update_object').start()
        mock.patch('neutron.objects.db.api.delete_object').start()
        mock.patch.object(nsx_db,
                          'get_switch_profile_by_qos_policy',
                          return_value=self.fake_profile_id).start()

        self.peak_bw_multiplier = cfg.CONF.NSX.qos_peak_bw_multiplier

        self.nsxlib = v3_utils.get_nsxlib_wrapper()
    def setUp(self, *mocks):
        # init the nsx-v plugin for testing with DVS
        self._init_dvs_config()
        super(TestQosNsxVNotification, self).setUp(plugin=CORE_PLUGIN,
                                                   ext_mgr=None)
        plugin_instance = manager.NeutronManager.get_plugin()
        self._core_plugin = plugin_instance

        # Setup the QoS plugin:
        # Add a dummy notification driver that calls our handler directly
        # (to skip the message queue)
        cfg.CONF.set_override("notification_drivers", [
            'vmware_nsx.tests.unit.services.qos.fake_nsxv_notifier.'
            'DummyNsxVNotificationDriver'
        ], "qos")
        self.qos_plugin = qos_plugin.QoSPlugin()
        mock.patch.object(qos_utils.NsxVQosRule,
                          '_get_qos_plugin',
                          return_value=self.qos_plugin).start()

        # Pre defined QoS data for the tests
        self.ctxt = context.Context('fake_user', 'fake_tenant')
        self.policy_data = {
            'policy': {
                'id': uuidutils.generate_uuid(),
                'tenant_id': uuidutils.generate_uuid(),
                'name': 'test-policy',
                'description': 'Test policy description',
                'shared': True
            }
        }

        self.rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 100,
                'max_burst_kbps': 150
            }
        }
        self.dscp_rule_data = {
            'dscp_marking_rule': {
                'id': uuidutils.generate_uuid(),
                'dscp_mark': 22
            }
        }

        self.policy = policy_object.QosPolicy(self.ctxt,
                                              **self.policy_data['policy'])

        self.rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['bandwidth_limit_rule'])
        self.dscp_rule = rule_object.QosDscpMarkingRule(
            self.ctxt, **self.dscp_rule_data['dscp_marking_rule'])

        self._net_data = {
            'network': {
                'name': 'test-qos',
                'tenant_id': 'fake_tenant',
                'qos_policy_id': self.policy.id,
                'port_security_enabled': False,
                'admin_state_up': False,
                'shared': False
            }
        }
        self._rules = [self.rule_data['bandwidth_limit_rule']]
        self._dscp_rules = [self.dscp_rule_data['dscp_marking_rule']]

        mock.patch('neutron.objects.db.api.create_object').start()
        mock.patch('neutron.objects.db.api.update_object').start()
        mock.patch('neutron.objects.db.api.delete_object').start()
        mock.patch('neutron.objects.db.api.get_object').start()
        mock.patch(
            'neutron.objects.qos.policy.QosPolicy.obj_load_attr').start()
Exemplo n.º 5
0
 def _create_fake_policy(self):
     policy_dict = {'id': self.network_policy_id}
     policy_obj = qos_policy.QosPolicy(context, **policy_dict)
     policy_obj.obj_reset_changes()
     return policy_obj
Exemplo n.º 6
0
 def _make_qos_policy(self):
     qos_policy = policy_object.QosPolicy(self.admin_ctxt,
                                          **self.policy_data['policy'])
     qos_policy.create()
     return qos_policy
Exemplo n.º 7
0
 def test_detach_network_nonexistent_policy(self):
     policy_obj = policy.QosPolicy(self.context, **self.db_objs[0])
     self.assertRaises(n_exc.NetworkQosBindingNotFound,
                       policy_obj.detach_network, self._network['id'])
Exemplo n.º 8
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 unittest import mock

from oslo_utils import uuidutils

from neutron.agent.l3.extensions.qos import base as qos_base
from neutron.objects.qos import policy
from neutron.tests import base

_uuid = uuidutils.generate_uuid
TEST_POLICY = policy.QosPolicy(context=None, name='test1', id=_uuid())
TEST_POLICY2 = policy.QosPolicy(context=None, name='test2', id=_uuid())

TEST_RES_1 = "res1"
TEST_RES_2 = "res2"


class RateLimitMapsTestCase(base.BaseTestCase):
    def setUp(self):
        super(RateLimitMapsTestCase, self).setUp()
        self.policy_map = qos_base.RateLimitMaps("cache-lock")

    def test_update_policy(self):
        self.policy_map.update_policy(TEST_POLICY)
        self.assertEqual(TEST_POLICY,
                         self.policy_map.known_policies[TEST_POLICY.id])
Exemplo n.º 9
0
 def _create_test_policy(self):
     policy_obj = policy.QosPolicy(self.context, **self.db_obj)
     policy_obj.create()
     return policy_obj
Exemplo n.º 10
0
 def test_detach_port_nonexistent_policy(self):
     policy_obj = policy.QosPolicy(self.context, **self.db_objs[0])
     self.assertRaises(n_exc.PortQosBindingNotFound, policy_obj.detach_port,
                       self._port['id'])
    def setUp(self, *mocks):
        # init the nsx-v plugin for testing with DVS
        self._init_dvs_config()
        # Reset the drive to re-create it
        qos_driver.DRIVER = None
        super(TestQosNsxVNotification, self).setUp(plugin=CORE_PLUGIN,
                                                   ext_mgr=None)
        self.setup_coreplugin(CORE_PLUGIN)

        plugin_instance = directory.get_plugin()
        self._core_plugin = plugin_instance
        self._core_plugin.init_is_complete = True

        self.qos_plugin = qos_plugin.QoSPlugin()
        mock.patch.object(qos_utils.NsxVQosRule,
                          '_get_qos_plugin',
                          return_value=self.qos_plugin).start()

        # Pre defined QoS data for the tests
        self.ctxt = context.Context('fake_user', 'fake_tenant')

        self.policy_data = {
            'policy': {
                'id': uuidutils.generate_uuid(),
                'project_id': uuidutils.generate_uuid(),
                'name': 'test-policy',
                'description': 'Test policy description',
                'shared': True
            }
        }

        self.rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 100,
                'max_burst_kbps': 150,
                'type': qos_consts.RULE_TYPE_BANDWIDTH_LIMIT
            }
        }
        self.dscp_rule_data = {
            'dscp_marking_rule': {
                'id': uuidutils.generate_uuid(),
                'dscp_mark': 22,
                'type': qos_consts.RULE_TYPE_DSCP_MARKING
            }
        }

        self.policy = policy_object.QosPolicy(self.ctxt,
                                              **self.policy_data['policy'])

        self.rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['bandwidth_limit_rule'])
        self.dscp_rule = rule_object.QosDscpMarkingRule(
            self.ctxt, **self.dscp_rule_data['dscp_marking_rule'])

        self._net_data = {
            'network': {
                'name': 'test-qos',
                'tenant_id': 'fake_tenant',
                'qos_policy_id': self.policy.id,
                'port_security_enabled': False,
                'admin_state_up': False,
                'shared': False
            }
        }
        self._rules = [self.rule_data['bandwidth_limit_rule']]
        self._dscp_rules = [self.dscp_rule_data['dscp_marking_rule']]

        mock.patch(
            'neutron.objects.qos.policy.QosPolicy.obj_load_attr').start()
Exemplo n.º 12
0
 def test_get_resource_type(self):
     # we could use any other registered NeutronObject type here
     self.assertEqual(policy.QosPolicy.obj_name(),
                      resources.get_resource_type(policy.QosPolicy()))
Exemplo n.º 13
0
    def setUp(self, *args, **kwargs):
        net_type = kwargs.pop('tenant_network_types', None) or ['vlan']
        ml2_options = {
            'mechanism_drivers': ['apic_aim', 'openvswitch'],
            'extension_drivers': ['apic_aim', 'port_security', 'dns', 'qos'],
            'type_drivers': ['opflex', 'local', 'vlan'],
            'tenant_network_types': net_type
        }
        config.cfg.CONF.set_override('network_vlan_ranges',
                                     ['physnet1:100:200'],
                                     group='ml2_type_vlan')
        self._aim_mech_driver = None
        self._qos_driver = None
        super(TestAIMQosBase, self).setUp(*args,
                                          ml2_options=ml2_options,
                                          qos_plugin='qos',
                                          **kwargs)
        self._plugin = directory.get_plugin()
        self._plugin.remove_networks_from_down_agents = mock.Mock()
        self._plugin.is_agent_down = mock.Mock(return_value=False)
        self._ctx = context.get_admin_context()
        self.ctxt = context.Context('fake_user', 'fake_tenant')
        self.admin_ctxt = context.get_admin_context()

        self.policy_data = {
            'policy': {
                'id': uuidutils.generate_uuid(),
                'project_id': uuidutils.generate_uuid(),
                'name': 'test-policy',
                'description': 'Test policy description',
                'shared': True,
                'is_default': False
            }
        }

        self.rule_data = {
            'egress_bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'direction': 'egress',
                'max_kbps': 100,
                'max_burst_kbps': 150
            },
            'ingress_bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'direction': 'ingress',
                'max_kbps': 101,
                'max_burst_kbps': 1150
            },
            'dscp_marking_rule': {
                'id': uuidutils.generate_uuid(),
                'dscp_mark': 16
            },
        }

        self.policy = policy_object.QosPolicy(self.ctxt,
                                              **self.policy_data['policy'])

        self.egress_rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['egress_bandwidth_limit_rule'])

        self.ingress_rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['ingress_bandwidth_limit_rule'])

        self.dscp_rule = rule_object.QosDscpMarkingRule(
            self.ctxt, **self.rule_data['dscp_marking_rule'])
Exemplo n.º 14
0
 def _get_policy(self):
     return policy_object.QosPolicy(self.ctxt, **self.policy_data['policy'])
Exemplo n.º 15
0
 def update_policy(self, context, policy_id, policy):
     policy = policy_object.QosPolicy(context, **policy['policy'])
     policy.id = policy_id
     policy.update()
     self.notification_driver_manager.update_policy(context, policy)
     return policy
Exemplo n.º 16
0
    def setUp(self):
        super(QosExtensionBaseTestCase, self).setUp()

        self.gw_ip_qos_ext = gateway_ip_qos.RouterGatewayIPQosAgentExtension()
        self.context = context.get_admin_context()
        self.connection = mock.Mock()

        self.policy = policy.QosPolicy(context=None, name='test1', id=_uuid())
        self.ingress_rule = (rule.QosBandwidthLimitRule(
            context=None,
            id=_uuid(),
            qos_policy_id=self.policy.id,
            max_kbps=1111,
            max_burst_kbps=2222,
            direction=lib_const.INGRESS_DIRECTION))
        self.egress_rule = (rule.QosBandwidthLimitRule(
            context=None,
            id=_uuid(),
            qos_policy_id=self.policy.id,
            max_kbps=3333,
            max_burst_kbps=4444,
            direction=lib_const.EGRESS_DIRECTION))
        self.policy.rules = [self.ingress_rule, self.egress_rule]

        self.new_ingress_rule = (rule.QosBandwidthLimitRule(
            context=None,
            id=_uuid(),
            qos_policy_id=self.policy.id,
            max_kbps=5555,
            max_burst_kbps=6666,
            direction=lib_const.INGRESS_DIRECTION))
        self.ingress_rule_only_has_max_kbps = (rule.QosBandwidthLimitRule(
            context=None,
            id=_uuid(),
            qos_policy_id=self.policy.id,
            max_kbps=5555,
            max_burst_kbps=0,
            direction=lib_const.INGRESS_DIRECTION))

        self.policy2 = policy.QosPolicy(context=None, name='test2', id=_uuid())
        self.policy2.rules = [self.ingress_rule]

        self.policy3 = policy.QosPolicy(context=None, name='test3', id=_uuid())
        self.policy3.rules = [self.egress_rule]

        self.policy4 = policy.QosPolicy(context=None, name='test4', id=_uuid())
        self.dscp = rule.QosDscpMarkingRule(context=None,
                                            id=_uuid(),
                                            qos_policy_id=self.policy4.id,
                                            dscp_mark=32)
        self.dscp.obj_reset_changes()
        self.policy4.rules = [self.dscp]

        self.qos_policies = {
            self.policy.id: self.policy,
            self.policy2.id: self.policy2,
            self.policy3.id: self.policy3,
            self.policy4.id: self.policy4
        }

        self.agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
        self.ex_gw_port = {
            'id': _uuid(),
            'fixed_ips': [{
                'ip_address': TEST_QOS_GW_IP
            }],
            'qos_policy_id': self.policy.id,
            'enable_snat': True
        }
        self.fip = {
            'id': _uuid(),
            'floating_ip_address': '172.24.4.9',
            'fixed_ip_address': '192.168.0.1',
            'floating_network_id': _uuid(),
            'port_id': _uuid(),
            'host': HOSTNAME,
            'qos_policy_id': self.policy.id
        }
        self.router = {
            'id': _uuid(),
            'gw_port': self.ex_gw_port,
            'ha': False,
            'distributed': False,
            lib_const.FLOATINGIP_KEY: [self.fip],
            'external_gateway_info': self.ex_gw_port
        }
        self.router_info = l3router.RouterInfo(self.agent, self.router['id'],
                                               self.router, **self.ri_kwargs)
        self.router_info.ex_gw_port = self.ex_gw_port
        self.agent.router_info[self.router['id']] = self.router_info

        def _mock_get_router_info(router_id):
            return self.router_info

        self.get_router_info = mock.patch(
            'neutron.agent.l3.l3_agent_extension_api.'
            'L3AgentExtensionAPI.get_router_info').start()
        self.get_router_info.side_effect = _mock_get_router_info

        self.agent_api = l3_ext_api.L3AgentExtensionAPI(None, None)
        self.gw_ip_qos_ext.consume_api(self.agent_api)
Exemplo n.º 17
0
 def delete_policy(self, context, policy_id):
     policy = policy_object.QosPolicy(context)
     policy.id = policy_id
     self.notification_driver_manager.delete_policy(context, policy)
     policy.delete()
Exemplo n.º 18
0
    def test_floatingip_update_with_port_and_qos_scenarios(self):
        ctx = context.get_admin_context()
        policy_obj_1 = policy.QosPolicy(ctx,
                                        id=uuidutils.generate_uuid(),
                                        project_id='tenant', name='pol2',
                                        rules=[])
        policy_obj_1.create()
        policy_obj_2 = policy.QosPolicy(ctx,
                                        id=uuidutils.generate_uuid(),
                                        project_id='tenant', name='pol3',
                                        rules=[])
        policy_obj_2.create()
        with self.network() as ext_net:
            network_id = ext_net['network']['id']
            self._set_net_external(network_id)
            with self.subnet(
                ext_net, cidr='10.10.10.0/24'
            ), self.router() as router, self.subnet(
                cidr='11.0.0.0/24') as private_subnet, self.port(
                    private_subnet) as port_1, self.port(
                        private_subnet) as port_2:
                self._add_external_gateway_to_router(
                    router['router']['id'],
                    network_id)
                self._router_interface_action(
                    'add', router['router']['id'],
                    private_subnet['subnet']['id'],
                    None)
                fip = self._make_floatingip(self.fmt, network_id)
                self.assertIsNone(fip['floatingip'].get('port_id'))
                self.assertIsNone(
                    fip['floatingip'].get(qos_consts.QOS_POLICY_ID))

                # update from: {port_id: null, qos_policy_id: null}
                #        to  : {port_id: port_id_1, qos_policy_id: null}
                self._update_fip_with_port_or_qos_and_verify(
                    fip['floatingip']['id'],
                    port_1['port']['id'],
                    None,
                    revision_number=fip['floatingip'].get('revision_number'))

                # update from: {port_id: port_id_1, qos_policy_id: null}
                #        to  : {port_id: port_id_1, qos_policy_id: policy_1}
                self._update_fip_with_port_or_qos_and_verify(
                    fip['floatingip']['id'],
                    port_1['port']['id'],
                    policy_obj_1.id)

                # update from: {port_id: port_id_1, qos_policy_id: policy_1}
                #        to  : {port_id: port_id_2, qos_policy_id: policy_2}
                self._update_fip_with_port_or_qos_and_verify(
                    fip['floatingip']['id'],
                    port_2['port']['id'],
                    policy_obj_2.id)

                # update from: {port_id: port_id_2, qos_policy_id: policy_2}
                #        to  : {port_id: port_id_1, qos_policy_id: null}
                self._update_fip_with_port_or_qos_and_verify(
                    fip['floatingip']['id'],
                    port_1['port']['id'],
                    None)

                # update from: {port_id: port_id_1, qos_policy_id: null}
                #        to  : {port_id: null, qos_policy_id: policy_1}
                self._update_fip_with_port_or_qos_and_verify(
                    fip['floatingip']['id'],
                    None,
                    policy_obj_1.id)

                # update from: {port_id: null, qos_policy_id: policy_1}
                #        to  : {port_id: null, qos_policy_id: null}
                self._update_fip_with_port_or_qos_and_verify(
                    fip['floatingip']['id'])
Exemplo n.º 19
0
from neutron.objects.qos import rule
from neutron.plugins.ml2.drivers.openvswitch.agent import (
    ovs_agent_extension_api as ovs_ext_api)
from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl import (
    ovs_bridge)
from neutron.services.qos import qos_consts
from neutron.tests import base

BASE_TEST_POLICY = {
    'context': None,
    'name': 'test1',
    'id': uuidutils.generate_uuid()
}

TEST_POLICY = policy.QosPolicy(**BASE_TEST_POLICY)

TEST_POLICY_DESCR = policy.QosPolicy(description='fake_descr',
                                     **BASE_TEST_POLICY)

TEST_POLICY2 = policy.QosPolicy(context=None,
                                name='test2',
                                id=uuidutils.generate_uuid())

TEST_PORT = {'port_id': 'test_port_id', 'qos_policy_id': TEST_POLICY.id}

TEST_PORT2 = {'port_id': 'test_port_id_2', 'qos_policy_id': TEST_POLICY2.id}

FAKE_RULE_ID = uuidutils.generate_uuid()
REALLY_FAKE_RULE_ID = uuidutils.generate_uuid()
Exemplo n.º 20
0
 def create_policy(self, context, policy):
     policy = policy_object.QosPolicy(context, **policy['policy'])
     policy.create()
     self.notification_driver_manager.create_policy(context, policy)
     return policy
Exemplo n.º 21
0
from oslo_utils import uuidutils

from neutron.agent.l2.extensions import qos
from neutron.api.rpc.callbacks.consumer import registry
from neutron.api.rpc.callbacks import events
from neutron.api.rpc.callbacks import resources
from neutron.api.rpc.handlers import resources_rpc
from neutron.common import exceptions
from neutron import context
from neutron.objects.qos import policy
from neutron.objects.qos import rule
from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants
from neutron.services.qos import qos_consts
from neutron.tests import base

TEST_POLICY = policy.QosPolicy(context=None, name='test1', id='fake_policy_id')
TEST_POLICY2 = policy.QosPolicy(context=None,
                                name='test2',
                                id='fake_policy_id_2')

TEST_PORT = {'port_id': 'test_port_id', 'qos_policy_id': TEST_POLICY.id}

TEST_PORT2 = {'port_id': 'test_port_id_2', 'qos_policy_id': TEST_POLICY2.id}


class FakeDriver(qos.QosAgentDriver):

    SUPPORTED_RULES = {qos_consts.RULE_TYPE_BANDWIDTH_LIMIT}

    def __init__(self):
        super(FakeDriver, self).__init__()