diff --git a/ipmininet/router/__router.py b/ipmininet/router/__router.py index 963f06c5..bd7f5f10 100644 --- a/ipmininet/router/__router.py +++ b/ipmininet/router/__router.py @@ -11,6 +11,7 @@ from ipmininet.link import IPIntf from .config import BasicRouterConfig, NodeConfig, RouterConfig + import mininet.clean from mininet.node import Node, Host from mininet.log import lg @@ -126,7 +127,11 @@ def start(self): self._old_sysctl[opt] = self._set_sysctl(opt, val) # Fire up all daemons for d in self.nconfig.daemons: - self._processes.popen(shlex.split(d.startup_line)) + if (hasattr(d,'logfile')): + with open(d.logfile,"w") as err: + self._processes.popen(shlex.split(d.startup_line),stderr=err) + else: + self._processes.popen(shlex.split(d.startup_line)) # Busy-wait if the daemon needs some time before being started while not d.has_started(): time.sleep(.001) diff --git a/ipmininet/router/config/__init__.py b/ipmininet/router/config/__init__.py index b96c9969..1dc97625 100644 --- a/ipmininet/router/config/__init__.py +++ b/ipmininet/router/config/__init__.py @@ -17,6 +17,7 @@ from .ripng import RIPng from .openrd import OpenrDaemon from .openr import Openr, OpenrDomain +from .pimd_troglobit import Pimd __all__ = ['BasicRouterConfig', 'NodeConfig', 'Zebra', 'OSPF', 'OSPF6', 'OSPFArea', 'BGP', 'AS', 'SHARE', 'CLIENT_PROVIDER', @@ -27,4 +28,4 @@ 'OpenrDaemon', 'Openr', 'OpenrDomain', 'AF_INET', 'AF_INET6', 'BorderRouterConfig', 'Rule', 'Chain', 'ChainRule', 'NOT', 'PortClause', 'InterfaceClause', 'AddressClause', 'Filter', - 'InputFilter', 'OutputFilter', 'TransitFilter', 'Allow', 'Deny'] + 'InputFilter', 'OutputFilter', 'TransitFilter', 'Allow', 'Deny','Pimd'] diff --git a/ipmininet/router/config/pimd_troglobit.py b/ipmininet/router/config/pimd_troglobit.py new file mode 100644 index 00000000..6b9119f9 --- /dev/null +++ b/ipmininet/router/config/pimd_troglobit.py @@ -0,0 +1,35 @@ +from .base import RouterDaemon + +class Pimd(RouterDaemon): + """ This class configure the pim Daemon which can be found here: + https://github.com/troglobit/pimd + """ + NAME = 'pimd' + KILL_PATTERNS = (NAME,) + + def __init__(self,node,*args,**kwargs): + super().__init__(node=node,*args,**kwargs) + # add some custom attr + if "cfg" in kwargs: + self.custom_config = kwargs["cfg"] + if "log_file" in kwargs: + self.logfile = kwargs["log_file"] + + + @property + def startup_line(self): + if hasattr(self,'custom_config'): + return '{name} -f --config={cfg}'.format(name=self.NAME,cfg=self.custom_config) + else: + return '{name} -f --config={cfg}'.format(name=self.NAME,cfg=self.cfg_filename) + + @property + def dry_run(self): + return 'echo 2BeOrNot2Be > /dev/null' + + def set_defaults(self,defaults): + super().set_defaults(defaults) + + def build(self): + cfg = super().build() + return cfg diff --git a/ipmininet/router/config/templates/pimd.mako b/ipmininet/router/config/templates/pimd.mako index b9f4161b..e69de29b 100644 --- a/ipmininet/router/config/templates/pimd.mako +++ b/ipmininet/router/config/templates/pimd.mako @@ -1,23 +0,0 @@ -hostname ${node.name} -password ${node.password} - -% if node.pimd.logfile: - log file ${node.pimd.logfile} -% endif - -% for section in node.pimd.debug: - debug pimd ${section} -% endfor -! -ip multicast-routing -! -% for itf in node.pimd.interfaces: -interface ${itf.name} - % if itf.ssm: - ip pim ssm - % endif - % if itf.igmp: - ip igmp - % endif -! -% endfor