def build_zebra(self, router): cfg = super(MininetRouterConfig, self).build_zebra(router) # TODO custom private net plen = int(router.private_net.split('/')[1]) cfg.prefixlists = [ ConfigDict(name='PRIVATE', action='permit', prefix=router.private_net, ge=plen + 1) ] cfg.routemaps = [ ConfigDict(name='IMPORT', action='deny', prio='10', prefix=['PRIVATE'], proto=[]), ConfigDict(name='IMPORT', action='permit', prio='20', prefix=[], proto=['ospf']) ] cfg.static_routes.extend(router.static_routes) return cfg
def build_ospf(self, router): interfaces = [] networks = [] for intf in router.interfaces.values(): intf_dict = ConfigDict(name=intf.id, description=str(intf.link)) intf_dict.ospf = ConfigDict( cost=intf.ospf_cost, priority=router.ospf_priority, dead_int=intf.ospf_dead_int, hello_int=intf.ospf_hello_int ) interfaces.append(intf_dict) net_dict = ConfigDict(domain=intf.ip_interface .network.with_prefixlen, area=intf.ospf_area) networks.append(net_dict) return super(FibbingConfigNode, self).build_ospf(router, ConfigDict(interfaces=interfaces, # id is the first interface router_id=str(router .interfaces .values()[0] .ip_interface .ip), networks=networks))
def __init__(self, router, *args, **kwargs): super(MininetRouterConfig, self).__init__(router, *args, **kwargs) self.ospf.redistribute.connected = router.cost_host self.ospf.redistribute.static = router.cost_host self.ospf.router_id = router.id # # Parse LSA throttling parameters # delay = CFG.get("DEFAULT", 'delay') # initial_holdtime = CFG.get("DEFAULT", 'initial_holdtime') # max_holdtime = CFG.get("DEFAULT", 'max_holdtime') # # # Parse minimum LS intervals # min_ls_interval = CFG.get("DEFAULT", 'min_ls_interval') # min_ls_arrival = CFG.get("DEFAULT", 'min_ls_arrival') ospf_intf = router.ospf_interfaces()[0] delay = ospf_intf.params.get('odelay') initial_holdtime = ospf_intf.params.get('initial_holdtime') max_holdtime = ospf_intf.params.get('max_holdtime') min_ls_arrival = ospf_intf.params.get('min_ls_arrival') min_ls_interval = ospf_intf.params.get('min_ls_interval') self.ospf.throttling = ConfigDict( spf=ConfigDict(delay=delay, initial_holdtime=initial_holdtime, max_holdtime=max_holdtime), lsa_all=ConfigDict(min_ls_interval=min_ls_interval)) self.ospf.lsa = ConfigDict(min_ls_arrival=min_ls_arrival)
def build_ospf(self, router): cfg = super(MininetRouterConfig, self).build_ospf(router) networks = [] for itf in router.ospf_interfaces(): c = itf.params.get('cost', FIBBING_MIN_COST) area = itf.params.get('area', FIBBING_DEFAULT_AREA) cfg.interfaces\ .append(ConfigDict(name=itf.name, description=str(itf.link), ospf=ConfigDict(cost=c, priority=10, dead_int=router .dead_interval, hello_int=router .hello_interval))) networks.append( (ip_interface('%s/%s' % (itf.ip, itf.prefixLen)).network, area)) # TODO figure out the private config knob so that the private (not mine) # addresses dont create redundant OSPF session over the same # interface ... try: networks.extend((ip_interface(net).network, area) for net in itf.params[PRIVATE_IP_KEY]) except KeyError: pass # No private ip on that interface for net, area in networks: cfg.networks.append( ConfigDict(domain=net.with_prefixlen, area=area)) return cfg
def build_zebra(self, router, cfg=None): if not cfg: cfg = ConfigDict() if not cfg.routemaps: cfg.routemaps = [] if not cfg.static_routes: cfg.static_routes = [] if not cfg.prefixlists: cfg.prefixlists = [] return cfg
def build_ospf(self, router, cfg=None): if not cfg: cfg = ConfigDict() if not cfg.redistribute: cfg.redistribute = ConfigDict() if not cfg.interfaces: cfg.interfaces = [] if not cfg.networks: cfg.networks = [] return cfg
def __init__(self, router, debug_ospf=(), debug_zebra=(), *args, **kwargs): super(RouterConfigDict, self).__init__(*args, **kwargs) self.hostname = router.name self.password = OSPFD_PASSWORD self.redistribute = ConfigDict() self.ospf = self.build_ospf(router) self.zebra = self.build_zebra(router) self.ospf.logfile = '/tmp/ospfd_%s.log' % router.name self.ospf.debug = debug_ospf self.zebra.logfile = '/tmp/zebra_%s.log' % router.name self.zebra.debug = debug_zebra
def build_ospf(self, router): cfg = super(MininetRouterConfig, self).build_ospf(router) networks = [] for itf in router.ospf_interfaces(): c = itf.params.get('cost', FIBBING_MIN_COST) if c > 0: cfg.interfaces.append( ConfigDict( name=itf.name, description=str(itf.link), ospf=ConfigDict( cost=c, priority=10, # TODO add in configuration dead_int=itf.params.get('dead-interval'), hello_int=itf.params.get('hello-interval')))) area = itf.params.get('area') networks.append( (ip_interface('%s/%s' % (itf.ip, itf.prefixLen)).network, area)) # TODO figure out the private config knob so that the private # addresses dont create redundant OSPF session over the same # interface ... try: PrivateIP = itf.params[PRIVATE_IP_KEY] networks.append( (ip_interface(unicode(PrivateIP)).network, area)) for sec in itf.params.get('secondary-ips'): networks.append( (ip_interface(unicode(sec)).network, area)) except KeyError: pass # No private ip on that interface else: cfg.passive_interfaces.append(itf) for net, area in networks: cfg.networks.append( ConfigDict(domain=net.with_prefixlen, area=area)) return cfg
def build_ospf(self, router, cfg=None): if not cfg: cfg = ConfigDict() if not cfg.redistribute: cfg.redistribute = ConfigDict() if not cfg.interfaces: cfg.interfaces = [] if not cfg.networks: cfg.networks = [] if not cfg.passive_interfaces: cfg.passive_interfaces = [] return cfg