def setUp(self):
        super(TestStrongSwanDeviceDriver, self).setUp()
        self.conf = cfg.CONF
        self.conf.register_opts(l3_config.OPTS)
        self.conf.register_opts(ipsec.ipsec_opts, 'ipsec')
        self.conf.register_opts(strongswan_ipsec.strongswan_opts,
                                'strongswan')
        self.conf.set_override('state_path', '/tmp')

        ri_kwargs = {'router': {'id': FAKE_ROUTER_ID},
                     'agent_conf': self.conf,
                     'interface_driver': mock.sentinel.interface_driver}
        self.router = legacy_router.LegacyRouter(router_id=FAKE_ROUTER_ID,
                                                 agent=mock.Mock(),
                                                 **ri_kwargs)
        self.router.router['distributed'] = False
        self.router_id = FAKE_VPN_SERVICE['router_id']

        looping_call_p = mock.patch(
            'oslo_service.loopingcall.FixedIntervalLoopingCall')
        looping_call_p.start()

        vpn_service = mock.Mock()
        vpn_service.conf = self.conf
        self.driver = strongswan_ipsec.StrongSwanDriver(
            vpn_service, host=mock.sentinel.host)
        self.driver.routers[FAKE_ROUTER_ID] = self.router
        self.driver.agent_rpc = mock.Mock()
        self.driver._update_nat = mock.Mock()
        self.driver.agent_rpc.get_vpn_services_on_host.return_value = [
            FAKE_VPN_SERVICE]
        self.addCleanup(self.driver.destroy_router, self.router_id)

        self.router.router_namespace.create()
        self.addCleanup(self.router.router_namespace.delete)
예제 #2
0
 def setUp(self):
     super(TestStrongSwanScenario, self).setUp()
     self.conf.register_opts(strongswan_ipsec.strongswan_opts, 'strongswan')
     VPNAAS_STRONGSWAN_DEVICE = ('neutron_vpnaas.services.vpn.'
                                 'device_drivers.strongswan_ipsec.'
                                 'StrongSwanDriver')
     cfg.CONF.set_override('vpn_device_driver', [VPNAAS_STRONGSWAN_DEVICE],
                           'vpnagent')
     self.agent = neutron_l3_agent.L3NATAgentWithStateReport(
         'agent1', self.conf)
     self.vpn_agent = vpn_agent.L3WithVPNaaS(self.conf)
     vpn_service = mock.Mock()
     vpn_service.conf = self.conf
     self.driver = strongswan_ipsec.StrongSwanDriver(
         vpn_service, host=mock.sentinel.host)