Esempio n. 1
0
    def __init__(self, agent, host):
        self.host = host
        self.conn = n_rpc.create_connection(new=True)
        context = ctx.get_admin_context_without_session()
        node_topic = '%s.%s' % (topics.CISCO_IPSEC_AGENT_TOPIC, self.host)

        self.service_state = {}

        self.endpoints = [self]
        self.conn.create_consumer(node_topic, self.endpoints, fanout=False)
        self.conn.consume_in_threads()
        self.agent_rpc = (CiscoCsrIPsecVpnDriverApi(
            topics.CISCO_IPSEC_DRIVER_TOPIC, '1.0'))
        self.periodic_report = loopingcall.FixedIntervalLoopingCall(
            self.report_status, context)
        self.periodic_report.start(
            interval=agent.conf.cisco_csr_ipsec.status_check_interval)

        csrs_found = find_available_csrs_from_config(cfg.CONF.config_file)
        if csrs_found:
            LOG.info(_("Loaded %(num)d Cisco CSR configuration%(plural)s"), {
                'num': len(csrs_found),
                'plural': 's'[len(csrs_found) == 1:]
            })
        else:
            raise SystemExit(
                _('No Cisco CSR configurations found in: %s') %
                cfg.CONF.config_file)
        self.csrs = dict([
            (k,
             csr_client.CsrRestClient(v['rest_mgmt'], v['tunnel_ip'],
                                      v['username'], v['password'],
                                      v['timeout']))
            for k, v in csrs_found.items()
        ])
Esempio n. 2
0
 def create_vpn_service(self, service_data):
     """Create new entry to track VPN service and its connections."""
     csr = csr_client.CsrRestClient(service_data['router_info'])
     vpn_service_id = service_data['id']
     self.service_state[vpn_service_id] = CiscoCsrVpnService(
         service_data, csr)
     return self.service_state[vpn_service_id]