Exemple #1
0
def run_tunnels(configfile='/etc/calabar/calabar.conf'):
    """Run the configured VPN/SSH tunnels and keep them running"""
    config = SafeConfigParser()
    config.read(configfile)

    tm = TunnelManager()
    _run_tunnels(tm, config)
    def setUp(self):
        self.executable = 'cal_run_forever'
        self.cmd = [self.executable]

        self.t = TunnelBase(self.cmd, self.executable)

        self.tm = TunnelManager()
        self.tm.tunnels = [self.t]
    def test_invalid_tunnel_type_conf(self):
        conf = SafeConfigParser()
        sec1 = 'tunnel:test'
        conf.add_section(sec1)
        conf.set(sec1, 'tunnel_type', 'INVALID')

        tm = TunnelManager()
        self.assertRaises(NotImplementedError, tm.load_tunnels, *[conf])
    def test_minimums(self):
        self.conf = SafeConfigParser()
        self.sec1 = 'tunnel:testvpnc'
        self.conf.add_section(self.sec1)
        self.conf.set(self.sec1, 'tunnel_type', 'vpnc')
        self.conf.set(self.sec1, 'conf_file', '/path/to/conf.conf')

        tm = TunnelManager()
        tm.load_tunnels(self.conf)

        self.assertEqual(len(tm.tunnels), 1)
    def setUp(self):
        self.executable = 'cal_run_forever'

        self.conf = SafeConfigParser()
        self.sec1 = 'tunnel:test'
        self.conf.add_section(self.sec1)
        self.conf.set(self.sec1, 'tunnel_type', 'base')
        self.conf.set(self.sec1, 'cmd', self.executable)
        self.conf.set(self.sec1, 'executable', self.executable)

        self.tm = TunnelManager()
    def setUp(self):
        self.conf = SafeConfigParser()
        self.sec1 = 'tunnel:testvpnc'
        self.conf.add_section(self.sec1)
        self.conf.set(self.sec1, 'tunnel_type', 'vpnc')
        self.conf.set(self.sec1, 'conf_file', '/path/to/conf.conf')
        self.conf.set(self.sec1, 'ips', '10.10.10.10, 5.5.5.5')

        self.vpnc_sec = 'vpnc'
        self.conf.add_section(self.vpnc_sec)
        self.conf.set(self.vpnc_sec, 'bin', '/path/to/vpnc.bin')
        self.conf.set(self.vpnc_sec, 'base_conn_script', '/path/to/vpnc-conn-script')

        self.tm = TunnelManager()
    def setUp(self):
        self.executable = 'cal_run_forever'

        conf = SafeConfigParser()
        sec1 = 'tunnel:test'
        conf.add_section(sec1)
        conf.set(sec1, 'tunnel_type', 'base')
        conf.set(sec1, 'cmd', self.executable)
        conf.set(sec1, 'executable', self.executable)

        self.tm = TunnelManager()
        self.tm.load_tunnels(conf)
        self.tm.start_tunnels()

        self.t = self.tm.tunnels[0]
    def setUp(self):
        self.tunnel = TunnelBase(['ls'], 'DOESNOTEXIST')

        self.tm = TunnelManager()
        self.tm.tunnels.append(self.tunnel)
    def test_invalid_load_tunnel_type(self):
        tun_conf_d = {'tunnel_type': 'INVALID'}

        tm = TunnelManager()
        self.assertRaises(NotImplementedError, tm._load_tunnel, *['test', tun_conf_d])