Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pimd daemon #92

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ipmininet/router/__router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature should always be there, and not only for the daemons have a logfile attribute.

I'd suggest to always log stderr/stdout of all daemons, e.g.,

  • Create a temp logdir using daemon_logs tempfile.TemporaryDirectory(dir='tmp')
  • display it on the global logger
  • capture stdout/stderr for all daemon, e.g. stderr='%s/%s_%s_err.log' % (daemon_log, node, daemon_name)

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)
Expand Down
3 changes: 2 additions & 1 deletion ipmininet/router/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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']
35 changes: 35 additions & 0 deletions ipmininet/router/config/pimd_troglobit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from .base import RouterDaemon

class Pimd(RouterDaemon):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this something less ambiguous, given that 'PIMD' already exists...

""" This class configure the pim Daemon which can be found here:
https://github.com/troglobit/pimd
"""
NAME = 'pimd'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same than above, define a more specific name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue here is that if I put a more specific name, for example 'pimd_troglobit' I got the following error:
RuntimeError: [pimd_troglobit] is not available in $PATH

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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more general solution would be to make this return an empty string/None, and then update the global dry_run callsite to check for these empty/None string (i;e., "if d.dry_run: ... else: log.warning('Cannot check the config validity of daemon %s', d.Name'))

This problem is bound to happen on more than one daemon...


def set_defaults(self,defaults):
super().set_defaults(defaults)

def build(self):
cfg = super().build()
return cfg
23 changes: 0 additions & 23 deletions ipmininet/router/config/templates/pimd.mako
Original file line number Diff line number Diff line change
@@ -1,23 +0,0 @@
hostname ${node.name}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this.

This file configures the FRR pimd, and as such cannot be erased by this commit.

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