def probe(): start_time = ospf_instance.start_time running_time = util.current_time() - start_time router_id = ospf_instance.rid probe = { 'router_id': router_id, 'start_time': str(start_time), 'running_time': str(running_time), } return json.dumps(probe)
def __init__(self, config): self.start_time = util.current_time() self.area_list = dict() self.backbone = None # unused self.virtual_link = None # unused self.external_router = list() # unused self.as_external_lsa = dict() # type-5 lsa list self.nssa_lsa = dict() # type-7 lsa list self.opaque11_lsa = dict() # type-11 lsa list self.config = config self.rid = self.config['router_id'] self.interface_mame = self.config['interface'] self.local_ip = self.config['ip'] # Check config parameters legality if self.config['hello_interval'] < 1 or self.config[ 'hello_interval'] > 65535: LOG.critical( '[OSPF Instance] Hello interval is beyond the limitation.') return try: self.config['options'] = OspfProtocol.parse_options_config( self.config['options']) except Exception: LOG.critical('[OSPF Instance] Options is illegal.') return # The probe only connect to one area, so area list has no meaning. self.area = OspfArea(self) self.area_list[self.area.area_id] = self.area self.lsdb = OspfLsdb(self) self.recv = OspfReceiver(self.area.interface, self.area.interface.nbr_list, self.config['packet_display']) self._sock = None # socket for receiving ospf packets # Statistics self.stat = OspfStat()
def __init__(self, config): self.start_time = util.current_time() self.area_list = dict() self.backbone = None # unused self.virtual_link = None # unused self.external_router = list() # unused self.as_external_lsa = dict() # type-5 lsa list self.nssa_lsa = dict() # type-7 lsa list self.opaque11_lsa = dict() # type-11 lsa list self.config = config self.rid = self.config['router_id'] self.interface_mame = self.config['interface'] self.local_ip = self.config['ip'] # Check config parameters legality if self.config['hello_interval'] < 1 or self.config['hello_interval'] > 65535: LOG.critical('[OSPF Instance] Hello interval is beyond the limitation.') return try: self.config['options'] = OspfProtocol.parse_options_config(self.config['options']) except Exception: LOG.critical('[OSPF Instance] Options is illegal.') return # The probe only connect to one area, so area list has no meaning. self.area = OspfArea(self) self.area_list[self.area.area_id] = self.area self.lsdb = OspfLsdb(self) self.recv = OspfReceiver(self.area.interface, self.area.interface.nbr_list, self.config['packet_display']) self._sock = None # socket for receiving ospf packets # Statistics self.stat = OspfStat()