Comments (3)
I was looking at the code and it is not as simple as implementing it within the openrd dry_run
method. My idea was piping OpenR and wait for the output Starting OpenR daemon.
openrd --foo="bar" [...] --dryrun | grep -m1 "Starting OpenR daemon."
I realized that piping is not possible with the current implementation of pexec in the router.
Maybe an expect
script would be a viable solution. However, this would introduce a new dependency. Any thoughts how to implement a proper dry_run for OpenR?
from ipmininet.
What you likely want is to launch openrd using popen
instead of pexec
.
One way to do that would be to rework how we use dry_run
such that:
- The logic using
dry_run
is abstracted, i.e., extractedfrom __router.py to a new method in Daemon such asdo_config_check()
def do_config_check(self):
out, err, code = self._node.pexec(shlex.split(self.dry_run))
if code:
lg.error(d.NAME, 'configuration check failed [ rcode:', str(code), ']\nstdout:',
str(out), '\nstderr:', str(err))
return code
OpenrDaemon
would then override that new method à-la:
import fcntl
import os
import time
# [...]
@property
def dry_run(self):
raise TypeError('OpenrDaemon requires to use its custom do_config_check')
def do_config_check(self):
p = self._node.popen('...')
# read p.stdout or p.stderr here and match on your target string
# naive example below
fcntl.fcntl(p.stdout.fileno(), fcntl.F_SETFL,
fcntl.fcntl(proc.stdout.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK)
output = ''
start -= time.clock()
while True:
output += p.stdout.read(64)
if 'some_string' in output:
break
if start + time.clock() > 5:
p.terminate()
raise RuntimeError('OpenrDaemon took more than 5s to check the config')
time.sleep(.1)
p.terminate()
return perform_more_sanity_checks()
The downside of this is that there would not be any integration with the current process management system that tries to ensure that all processes are cleaned up before the network is destroyed.
Maybe the daemons should hold a reference to the router __processes instance instead of the node? (I cannot remember if this is already the case)
from ipmininet.
Ok, this is exactly the direction I was thinking of. Maybe a decorator comes in handy. I need to study the cleanup code more. Thx for the guidance.
from ipmininet.
Related Issues (20)
- Whether ipmininet supprt HMAC TLV? HOT 2
- ImportError: cannot import name 'StaticRoute' HOT 1
- BGP default permit filters collide with autogenerated route map names HOT 1
- Various pitfalls when trying to use complex BGP filters
- [Enhancement][PCEP] Add support for PCEPLib
- Why traffic cann't be captured by wireshark? HOT 2
- Can't open the srv6 example correctly. HOT 4
- Does ipmininet available for both SDN(by openflow ) and SRv6? HOT 2
- Cannot install IPmininet HOT 4
- citation HOT 1
- [OpenR] The OpenR install script does not work on Ubuntu 20.04
- Please create a new release of VM HOT 1
- [Install failed] Can't install in ubuntu 22.04 HOT 1
- Is adding a OpenFlow Switch in a network possbile?
- Impossible to use BBP RouteMapEntry call_action and exit_policy
- Hub is not working HOT 1
- Is it possible to unbuffer sys.stdin for a node's shell process HOT 2
- OpenR doesnt work
- Hosts can't ping each other in a simple topology. HOT 2
- How to modify FRRouting configuration file settings? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipmininet.