def test_create_agent_config_map_fails_for_invalid_tunnel_config(self):
     self.addCleanup(cfg.CONF.reset)
     # An ip address is required for tunneling but there is no default
     cfg.CONF.set_override('tunnel_type', constants.TYPE_GRE,
                           group='AGENT')
     with testtools.ExpectedException(ValueError):
         ovs_neutron_agent.create_agent_config_map(cfg.CONF)
 def test_create_agent_config_map_fails_for_invalid_tunnel_config(self):
     # An ip address is required for tunneling but there is no default,
     # verify this for both gre and vxlan tunnels.
     cfg.CONF.set_override("tunnel_types", [p_const.TYPE_GRE], group="AGENT")
     with testtools.ExpectedException(ValueError):
         ovs_neutron_agent.create_agent_config_map(cfg.CONF)
     cfg.CONF.set_override("tunnel_types", [p_const.TYPE_VXLAN], group="AGENT")
     with testtools.ExpectedException(ValueError):
         ovs_neutron_agent.create_agent_config_map(cfg.CONF)
Beispiel #3
0
 def test_create_agent_config_map_fails_for_invalid_tunnel_config(self):
     # An ip address is required for tunneling but there is no default,
     # verify this for both gre and vxlan tunnels.
     cfg.CONF.set_override('tunnel_types', [p_const.TYPE_GRE],
                           group='AGENT')
     with testtools.ExpectedException(ValueError):
         ovs_neutron_agent.create_agent_config_map(cfg.CONF)
     cfg.CONF.set_override('tunnel_types', [p_const.TYPE_VXLAN],
                           group='AGENT')
     with testtools.ExpectedException(ValueError):
         ovs_neutron_agent.create_agent_config_map(cfg.CONF)
 def test_create_agent_config_map_enable_tunneling(self):
     # Verify setting only enable_tunneling will default tunnel_type to GRE
     cfg.CONF.set_override('tunnel_types', None, group='AGENT')
     cfg.CONF.set_override('enable_tunneling', True, group='OVS')
     cfg.CONF.set_override('local_ip', '10.10.10.10', group='OVS')
     cfgmap = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
     self.assertEqual(cfgmap['tunnel_types'], [p_const.TYPE_GRE])
 def test_create_agent_config_map_multiple_tunnel_types(self):
     cfg.CONF.set_override('local_ip', '10.10.10.10', group='OVS')
     cfg.CONF.set_override('tunnel_types', [p_const.TYPE_GRE,
                           p_const.TYPE_VXLAN], group='AGENT')
     cfgmap = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
     self.assertEqual(cfgmap['tunnel_types'],
                      [p_const.TYPE_GRE, p_const.TYPE_VXLAN])
def main():
    cfg.CONF.register_opts(ip_lib.OPTS)
    config.register_root_helper(cfg.CONF)
    common_config.init(sys.argv[1:])
    common_config.setup_logging()
    q_utils.log_opt_values(LOG)

    try:
        agent_config = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
    except ValueError as e:
        LOG.error(_LE('%s Agent terminated!'), e)
        sys.exit(1)

    is_xen_compute_host = 'rootwrap-xen-dom0' in cfg.CONF.AGENT.root_helper
    if is_xen_compute_host:
        # Force ip_lib to always use the root helper to ensure that ip
        # commands target xen dom0 rather than domU.
        cfg.CONF.set_default('ip_lib_force_root', True)

    agent = L2OVSControllerAgent(**agent_config)

    signal.signal(signal.SIGTERM, agent._handle_sigterm)

    # Start everything.
    LOG.info(_LI("Agent initialized successfully, now running... "))
    agent.daemon_loop()
Beispiel #7
0
 def test_create_agent_config_map_enable_distributed_routing(self):
     self.addCleanup(cfg.CONF.reset)
     # Verify setting only enable_tunneling will default tunnel_type to GRE
     cfg.CONF.set_override('enable_distributed_routing', True,
                           group='AGENT')
     cfgmap = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
     self.assertEqual(cfgmap['enable_distributed_routing'], True)
    def setUp(self):
        super(TestOvsNeutronAgent, self).setUp()
        notifier_p = mock.patch(NOTIFIER)
        notifier_cls = notifier_p.start()
        self.notifier = mock.Mock()
        notifier_cls.return_value = self.notifier
        # Avoid rpc initialization for unit tests
        cfg.CONF.set_override("rpc_backend", "neutron.openstack.common.rpc.impl_fake")
        kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)

        class MockFixedIntervalLoopingCall(object):
            def __init__(self, f):
                self.f = f

            def start(self, interval=0):
                self.f()

        with contextlib.nested(
            mock.patch(
                "neutron.plugins.openvswitch.agent.ovs_neutron_agent." "OVSNeutronAgent.setup_integration_br",
                return_value=mock.Mock(),
            ),
            mock.patch(
                "neutron.plugins.openvswitch.agent.ovs_neutron_agent." "OVSNeutronAgent.setup_ancillary_bridges",
                return_value=[],
            ),
            mock.patch("neutron.agent.linux.ovs_lib.OVSBridge." "get_local_port_mac", return_value="00:00:00:00:00:01"),
            mock.patch("neutron.agent.linux.utils.get_interface_mac", return_value="00:00:00:00:00:01"),
            mock.patch(
                "neutron.openstack.common.loopingcall." "FixedIntervalLoopingCall", new=MockFixedIntervalLoopingCall
            ),
        ):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**kwargs)
            self.agent.tun_br = mock.Mock()
        self.agent.sg_agent = mock.Mock()
    def setUp(self):
        super(TestOvsNeutronAgent, self).setUp()
        self.addCleanup(cfg.CONF.reset)
        self.addCleanup(mock.patch.stopall)
        notifier_p = mock.patch(NOTIFIER)
        notifier_cls = notifier_p.start()
        self.notifier = mock.Mock()
        notifier_cls.return_value = self.notifier
        # Avoid rpc initialization for unit tests
        cfg.CONF.set_override('rpc_backend',
                              'neutron.openstack.common.rpc.impl_fake')
        cfg.CONF.set_override('report_interval', 0, 'AGENT')
        kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)

        with contextlib.nested(
            mock.patch('neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                       'OVSNeutronAgent.setup_integration_br',
                       return_value=mock.Mock()),
            mock.patch('neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                       'OVSNeutronAgent.setup_ancillary_bridges',
                       return_value=[]),
            mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                       'get_local_port_mac',
                       return_value='00:00:00:00:00:01'),
            mock.patch('neutron.agent.linux.utils.get_interface_mac',
                       return_value='00:00:00:00:00:01')):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**kwargs)
            self.agent.tun_br = mock.Mock()
        self.agent.sg_agent = mock.Mock()
 def test_create_agent_config_map_enable_tunneling(self):
     # Verify setting only enable_tunneling will default tunnel_type to GRE
     cfg.CONF.set_override("tunnel_types", None, group="AGENT")
     cfg.CONF.set_override("enable_tunneling", True, group="OVS")
     cfg.CONF.set_override("local_ip", "10.10.10.10", group="OVS")
     cfgmap = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
     self.assertEqual(cfgmap["tunnel_types"], [p_const.TYPE_GRE])
Beispiel #11
0
 def test_create_agent_config_map_enable_tunneling(self):
     # Verify setting only enable_tunneling will default tunnel_type to GRE
     cfg.CONF.set_override('tunnel_types', None, group='AGENT')
     cfg.CONF.set_override('enable_tunneling', True, group='OVS')
     cfg.CONF.set_override('local_ip', '10.10.10.10', group='OVS')
     cfgmap = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
     self.assertEqual(cfgmap['tunnel_types'], [p_const.TYPE_GRE])
 def test_create_agent_config_map_multiple_tunnel_types(self):
     cfg.CONF.set_override('local_ip', '10.10.10.10', group='OVS')
     cfg.CONF.set_override('tunnel_types', [p_const.TYPE_GRE,
                           p_const.TYPE_VXLAN], group='AGENT')
     cfgmap = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
     self.assertEqual(cfgmap['tunnel_types'],
                      [p_const.TYPE_GRE, p_const.TYPE_VXLAN])
 def test_create_agent_config_map_enable_distributed_routing(self):
     self.addCleanup(cfg.CONF.reset)
     # Verify setting only enable_tunneling will default tunnel_type to GRE
     cfg.CONF.set_override('enable_distributed_routing', True,
                           group='AGENT')
     cfgmap = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
     self.assertEqual(cfgmap['enable_distributed_routing'], True)
def create_agent_config_map(conf):
    agent_config = ovs.create_agent_config_map(conf)
    agent_config['hybrid_mode'] = conf.OPFLEX.hybrid_mode
    agent_config['epg_mapping_dir'] = conf.OPFLEX.epg_mapping_dir
    agent_config['opflex_networks'] = conf.OPFLEX.opflex_networks
    agent_config['internal_floating_ip_pool'] = (
        conf.OPFLEX.internal_floating_ip_pool)
    agent_config['internal_floating_ip6_pool'] = (
        conf.OPFLEX.internal_floating_ip6_pool)
    # DVR not supported
    agent_config['enable_distributed_routing'] = False
    # ARP responder not supported
    agent_config['arp_responder'] = False

    # read external-segment next-hop info
    es_info = {}
    multi_parser = cfg.MultiConfigParser()
    multi_parser.read(conf.config_file)
    for parsed_file in multi_parser.parsed:
        for parsed_item in parsed_file.keys():
            if parsed_item.startswith('opflex_external_segment:'):
                es_name = parsed_item.split(':', 1)[1]
                if es_name:
                    es_info[es_name] = parsed_file[parsed_item].items()
    agent_config['external_segment'] = es_info
    agent_config['dhcp_domain'] = conf.dhcp_domain
    return agent_config
 def setUp(self):
     super(AncillaryBridgesTest, self).setUp()
     notifier_p = mock.patch(NOTIFIER)
     notifier_cls = notifier_p.start()
     self.notifier = mock.Mock()
     notifier_cls.return_value = self.notifier
     cfg.CONF.set_default("firewall_driver", "neutron.agent.firewall.NoopFirewallDriver", group="SECURITYGROUP")
     cfg.CONF.set_override("report_interval", 0, "AGENT")
     self.kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
def create_agent_config_map(conf):
    agent_config = ovs.create_agent_config_map(conf)
    agent_config['hybrid_mode'] = conf.OPFLEX.hybrid_mode
    agent_config['epg_mapping_dir'] = conf.OPFLEX.epg_mapping_dir
    agent_config['opflex_networks'] = conf.OPFLEX.opflex_networks
    # DVR not supported
    agent_config['enable_distributed_routing'] = False
    # ARP responder not supported
    agent_config['arp_responder'] = False
    return agent_config
 def setUp(self):
     super(AncillaryBridgesTest, self).setUp()
     notifier_p = mock.patch(NOTIFIER)
     notifier_cls = notifier_p.start()
     self.notifier = mock.Mock()
     notifier_cls.return_value = self.notifier
     # Avoid rpc initialization for unit tests
     cfg.CONF.set_override("rpc_backend", "neutron.openstack.common.rpc.impl_fake")
     cfg.CONF.set_override("report_interval", 0, "AGENT")
     self.kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
def create_agent_config_map(conf):
    agent_config = ovs.create_agent_config_map(conf)
    agent_config['hybrid_mode'] = conf.OPFLEX.hybrid_mode
    agent_config['epg_mapping_dir'] = conf.OPFLEX.epg_mapping_dir
    agent_config['opflex_networks'] = conf.OPFLEX.opflex_networks
    # DVR not supported
    agent_config['enable_distributed_routing'] = False
    # ARP responder not supported
    agent_config['arp_responder'] = False
    return agent_config
Beispiel #19
0
 def setUp(self):
     super(AncillaryBridgesTest, self).setUp()
     self.addCleanup(cfg.CONF.reset)
     notifier_p = mock.patch(NOTIFIER)
     notifier_cls = notifier_p.start()
     self.notifier = mock.Mock()
     notifier_cls.return_value = self.notifier
     # Avoid rpc initialization for unit tests
     cfg.CONF.set_override('rpc_backend',
                           'neutron.openstack.common.rpc.impl_fake')
     cfg.CONF.set_override('report_interval', 0, 'AGENT')
     self.kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
 def setUp(self):
     super(AncillaryBridgesTest, self).setUp()
     self.addCleanup(cfg.CONF.reset)
     self.addCleanup(mock.patch.stopall)
     notifier_p = mock.patch(NOTIFIER)
     notifier_cls = notifier_p.start()
     self.notifier = mock.Mock()
     notifier_cls.return_value = self.notifier
     # Avoid rpc initialization for unit tests
     cfg.CONF.set_override('rpc_backend',
                           'neutron.openstack.common.rpc.impl_fake')
     cfg.CONF.set_override('report_interval', 0, 'AGENT')
     self.kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
    def setUp(self):
        super(TestOvsNeutronAgent, self).setUp()
        notifier_p = mock.patch(NOTIFIER)
        notifier_cls = notifier_p.start()
        self.notifier = mock.Mock()
        notifier_cls.return_value = self.notifier
        cfg.CONF.set_default('firewall_driver',
                             'neutron.agent.firewall.NoopFirewallDriver',
                             group='SECURITYGROUP')
        # Avoid rpc initialization for unit tests
        cfg.CONF.set_override('rpc_backend',
                              'neutron.openstack.common.rpc.impl_fake')
        kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)

        class MockFixedIntervalLoopingCall(object):
            def __init__(self, f):
                self.f = f

            def start(self, interval=0):
                self.f()

        with contextlib.nested(
                mock.patch(
                    'neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                    'OVSNeutronAgent.setup_integration_br',
                    return_value=mock.Mock()),
                mock.patch(
                    'neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                    'OVSNeutronAgent.setup_ancillary_bridges',
                    return_value=[]),
                mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                           'create'),
                mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                           'set_secure_mode'),
                mock.patch(
                    'neutron.agent.linux.ovs_lib.OVSBridge.'
                    'get_local_port_mac',
                    return_value='00:00:00:00:00:01'),
                mock.patch('neutron.agent.linux.utils.get_interface_mac',
                           return_value='00:00:00:00:00:01'),
                mock.patch(
                    'neutron.openstack.common.loopingcall.'
                    'FixedIntervalLoopingCall',
                    new=MockFixedIntervalLoopingCall),
                mock.patch(
                    'neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                    'OVSNeutronAgent._check_arp_responder_support',
                    return_value=True)):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**kwargs)
            self.agent.tun_br = mock.Mock()
        self.agent.sg_agent = mock.Mock()
 def setUp(self):
     super(AncillaryBridgesTest, self).setUp()
     notifier_p = mock.patch(NOTIFIER)
     notifier_cls = notifier_p.start()
     self.notifier = mock.Mock()
     notifier_cls.return_value = self.notifier
     cfg.CONF.set_default('firewall_driver',
                          'neutron.agent.firewall.NoopFirewallDriver',
                          group='SECURITYGROUP')
     # Avoid rpc initialization for unit tests
     cfg.CONF.set_override('rpc_backend',
                           'neutron.openstack.common.rpc.impl_fake')
     cfg.CONF.set_override('report_interval', 0, 'AGENT')
     self.kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
Beispiel #23
0
 def setUp(self):
     super(AncillaryBridgesTest, self).setUp()
     notifier_p = mock.patch(NOTIFIER)
     notifier_cls = notifier_p.start()
     self.notifier = mock.Mock()
     notifier_cls.return_value = self.notifier
     cfg.CONF.set_default('firewall_driver',
                          'neutron.agent.firewall.NoopFirewallDriver',
                          group='SECURITYGROUP')
     # Avoid rpc initialization for unit tests
     cfg.CONF.set_override('rpc_backend',
                           'neutron.openstack.common.rpc.impl_fake')
     cfg.CONF.set_override('report_interval', 0, 'AGENT')
     self.kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
Beispiel #24
0
    def setUp(self):
        super(TestOvsDvrNeutronAgent, self).setUp()
        notifier_p = mock.patch(NOTIFIER)
        notifier_cls = notifier_p.start()
        self.notifier = mock.Mock()
        notifier_cls.return_value = self.notifier
        cfg.CONF.set_default('firewall_driver',
                             'neutron.agent.firewall.NoopFirewallDriver',
                             group='SECURITYGROUP')
        kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)

        class MockFixedIntervalLoopingCall(object):
            def __init__(self, f):
                self.f = f

            def start(self, interval=0):
                self.f()

        with contextlib.nested(
                mock.patch(
                    'neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                    'OVSNeutronAgent.setup_integration_br',
                    return_value=mock.Mock()),
                mock.patch(
                    'neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                    'OVSNeutronAgent.setup_ancillary_bridges',
                    return_value=[]),
                mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                           'create'),
                mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                           'set_secure_mode'),
                mock.patch(
                    'neutron.agent.linux.ovs_lib.OVSBridge.'
                    'get_local_port_mac',
                    return_value='00:00:00:00:00:01'),
                mock.patch('neutron.agent.linux.utils.get_interface_mac',
                           return_value='00:00:00:00:00:01'),
                mock.patch('neutron.agent.linux.ovs_lib.BaseOVS.get_bridges'),
                mock.patch(
                    'neutron.openstack.common.loopingcall.'
                    'FixedIntervalLoopingCall',
                    new=MockFixedIntervalLoopingCall)):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**kwargs)
            # set back to true because initial report state will succeed due
            # to mocked out RPC calls
            self.agent.use_call = True
            self.agent.tun_br = mock.Mock()
        self.agent.sg_agent = mock.Mock()
    def setUp(self):
        super(TestOvsNeutronAgent, self).setUp()
        notifier_p = mock.patch(NOTIFIER)
        notifier_cls = notifier_p.start()
        self.notifier = mock.Mock()
        notifier_cls.return_value = self.notifier
        cfg.CONF.set_default('firewall_driver',
                             'neutron.agent.firewall.NoopFirewallDriver',
                             group='SECURITYGROUP')
        # Avoid rpc initialization for unit tests
        cfg.CONF.set_override('rpc_backend',
                              'neutron.openstack.common.rpc.impl_fake')
        kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)

        class MockFixedIntervalLoopingCall(object):
            def __init__(self, f):
                self.f = f

            def start(self, interval=0):
                self.f()

        with contextlib.nested(
            mock.patch('neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                       'OVSNeutronAgent.setup_integration_br',
                       return_value=mock.Mock()),
            mock.patch('neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                       'OVSNeutronAgent.setup_ancillary_bridges',
                       return_value=[]),
            mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                       'create'),
            mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                       'set_secure_mode'),
            mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                       'get_local_port_mac',
                       return_value='00:00:00:00:00:01'),
            mock.patch('neutron.agent.linux.utils.get_interface_mac',
                       return_value='00:00:00:00:00:01'),
            mock.patch('neutron.agent.linux.ovs_lib.'
                       'get_bridges'),
            mock.patch('neutron.openstack.common.loopingcall.'
                       'FixedIntervalLoopingCall',
                       new=MockFixedIntervalLoopingCall),
            mock.patch('neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                       'OVSNeutronAgent._check_arp_responder_support',
                       return_value=True)):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**kwargs)
            self.agent.tun_br = mock.Mock()
        self.agent.sg_agent = mock.Mock()
    def setUp(self):
        super(TestOvsDvrNeutronAgent, self).setUp()
        notifier_p = mock.patch(NOTIFIER)
        notifier_cls = notifier_p.start()
        self.notifier = mock.Mock()
        notifier_cls.return_value = self.notifier
        cfg.CONF.set_default('firewall_driver',
                             'neutron.agent.firewall.NoopFirewallDriver',
                             group='SECURITYGROUP')
        kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)

        class MockFixedIntervalLoopingCall(object):
            def __init__(self, f):
                self.f = f

            def start(self, interval=0):
                self.f()

        with contextlib.nested(
            mock.patch('neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                       'OVSNeutronAgent.setup_integration_br',
                       return_value=mock.Mock()),
            mock.patch('neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                       'OVSNeutronAgent.setup_ancillary_bridges',
                       return_value=[]),
            mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                       'create'),
            mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                       'set_secure_mode'),
            mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                       'get_local_port_mac',
                       return_value='00:00:00:00:00:01'),
            mock.patch('neutron.agent.linux.utils.get_interface_mac',
                       return_value='00:00:00:00:00:01'),
            mock.patch('neutron.agent.linux.ovs_lib.BaseOVS.get_bridges'),
            mock.patch('neutron.openstack.common.loopingcall.'
                       'FixedIntervalLoopingCall',
                       new=MockFixedIntervalLoopingCall)):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**kwargs)
            # set back to true because initial report state will succeed due
            # to mocked out RPC calls
            self.agent.use_call = True
            self.agent.tun_br = mock.Mock()
        self.agent.sg_agent = mock.Mock()
    def setUp(self):
        super(TestOvsNeutronAgent, self).setUp()
        notifier_p = mock.patch(NOTIFIER)
        notifier_cls = notifier_p.start()
        self.notifier = mock.Mock()
        notifier_cls.return_value = self.notifier
        cfg.CONF.set_default("firewall_driver", "neutron.agent.firewall.NoopFirewallDriver", group="SECURITYGROUP")
        cfg.CONF.set_default("quitting_rpc_timeout", 10, "AGENT")
        kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)

        class MockFixedIntervalLoopingCall(object):
            def __init__(self, f):
                self.f = f

            def start(self, interval=0):
                self.f()

        with contextlib.nested(
            mock.patch(
                "neutron.plugins.openvswitch.agent.ovs_neutron_agent." "OVSNeutronAgent.setup_integration_br",
                return_value=mock.Mock(),
            ),
            mock.patch(
                "neutron.plugins.openvswitch.agent.ovs_neutron_agent." "OVSNeutronAgent.setup_ancillary_bridges",
                return_value=[],
            ),
            mock.patch("neutron.agent.linux.ovs_lib.OVSBridge." "create"),
            mock.patch("neutron.agent.linux.ovs_lib.OVSBridge." "set_secure_mode"),
            mock.patch("neutron.agent.linux.ovs_lib.OVSBridge." "get_local_port_mac", return_value="00:00:00:00:00:01"),
            mock.patch("neutron.agent.linux.utils.get_interface_mac", return_value="00:00:00:00:00:01"),
            mock.patch("neutron.agent.linux.ovs_lib.BaseOVS.get_bridges"),
            mock.patch(
                "neutron.openstack.common.loopingcall." "FixedIntervalLoopingCall", new=MockFixedIntervalLoopingCall
            ),
        ):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**kwargs)
            # set back to true because initial report state will succeed due
            # to mocked out RPC calls
            self.agent.use_call = True
            self.agent.tun_br = mock.Mock()
        self.agent.sg_agent = mock.Mock()
    def setUp(self):
        super(TestOvsNeutronAgent, self).setUp()
        self.addCleanup(cfg.CONF.reset)
        self.addCleanup(mock.patch.stopall)
        notifier_p = mock.patch(NOTIFIER)
        notifier_cls = notifier_p.start()
        self.notifier = mock.Mock()
        notifier_cls.return_value = self.notifier
        # Avoid rpc initialization for unit tests
        cfg.CONF.set_override("rpc_backend", "neutron.openstack.common.rpc.impl_fake")
        cfg.CONF.set_override("report_interval", 0, "AGENT")
        kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)

        with contextlib.nested(
            mock.patch(
                "neutron.plugins.openvswitch.agent.ovs_neutron_agent." "OVSNeutronAgent.setup_integration_br",
                return_value=mock.Mock(),
            ),
            mock.patch("neutron.agent.linux.utils.get_interface_mac", return_value="00:00:00:00:00:01"),
        ):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**kwargs)
            self.agent.tun_br = mock.Mock()
        self.agent.sg_agent = mock.Mock()
Beispiel #29
0
 def test_create_agent_config_map_fails_for_invalid_tunnel_type(self):
     cfg.CONF.set_override('tunnel_types', ['foobar'], group='AGENT')
     with testtools.ExpectedException(ValueError):
         ovs_neutron_agent.create_agent_config_map(cfg.CONF)
 def test_create_agent_config_map_fails_no_local_ip(self):
     self.addCleanup(cfg.CONF.reset)
     # An ip address is required for tunneling but there is no default
     cfg.CONF.set_override('enable_tunneling', True, group='OVS')
     with testtools.ExpectedException(ValueError):
         ovs_neutron_agent.create_agent_config_map(cfg.CONF)
 def test_create_agent_config_map_fails_for_invalid_tunnel_type(self):
     cfg.CONF.set_override("tunnel_types", ["foobar"], group="AGENT")
     with testtools.ExpectedException(ValueError):
         ovs_neutron_agent.create_agent_config_map(cfg.CONF)
Beispiel #32
0
 def test_create_agent_config_map_fails_no_local_ip(self):
     # An ip address is required for tunneling but there is no default
     cfg.CONF.set_override('enable_tunneling', True, group='OVS')
     with testtools.ExpectedException(ValueError):
         ovs_neutron_agent.create_agent_config_map(cfg.CONF)
 def test_create_agent_config_map_fails_no_local_ip(self):
     # An ip address is required for tunneling but there is no default
     cfg.CONF.set_override("tunnel_types", [p_const.TYPE_VXLAN], group="AGENT")
     with testtools.ExpectedException(ValueError):
         ovs_neutron_agent.create_agent_config_map(cfg.CONF)
Beispiel #34
0
 def test_create_agent_config_map_succeeds(self):
     self.assertTrue(ovs_neutron_agent.create_agent_config_map(cfg.CONF))
 def test_create_agent_config_map_succeeds(self):
     self.assertTrue(ovs_neutron_agent.create_agent_config_map(cfg.CONF))
 def test_create_agent_config_map_fails_for_invalid_tunnel_type(self):
     self.addCleanup(cfg.CONF.reset)
     cfg.CONF.set_override('tunnel_types', ['foobar'], group='AGENT')
     with testtools.ExpectedException(ValueError):
         ovs_neutron_agent.create_agent_config_map(cfg.CONF)
 def test_create_agent_config_map_multiple_tunnel_types(self):
     cfg.CONF.set_override("local_ip", "10.10.10.10", group="OVS")
     cfg.CONF.set_override("tunnel_types", [p_const.TYPE_GRE, p_const.TYPE_VXLAN], group="AGENT")
     cfgmap = ovs_neutron_agent.create_agent_config_map(cfg.CONF)
     self.assertEqual(cfgmap["tunnel_types"], [p_const.TYPE_GRE, p_const.TYPE_VXLAN])