def main(): addservice(JoshService) session = pycore.Session(persistent=True) test(2,100,session) # now we launch cored.py services so GUI can connect to this script print "launching cored services" # the following lines are from cored.py cored() cfg, args = cored.getMergedConfig("%s/core.conf" % CORE_CONF_DIR) cored.banner() server = cored.CoreServer(("localhost", coreapi.CORE_API_PORT), cored.CoreRequestHandler, cfg) print "adding session %s to cored.server" % session.sessionid server.addsession(session) print "running cored server - you may now connect the GUI" try: server.serve_forever() except KeyboardInterrupt: pass
sleep 5 } rbnstart() { # start the routing by name agent ln -sv $RBN_DIR/rbnagent.sh . ./rbnagent.sh >rbnagent.log 2>&1 & sleep 5 } start() { ccnstart olsrstart rbnstart } stop() { $CCNX_DIR/bin/ccndstop } $1 sleep 3 """ % configdict return cfg # this line is required to add the above class to the list of available services addservice(CcnOlsrNS3Service)
# import os from core.service import CoreService, addservice from core.misc.utils import * class ServiceFlag(CoreService): _name = "serviceFlag" _group = "Service Flags" _depends = () class IGP(ServiceFlag): _name = "IGP" addservice(IGP) class EGP(ServiceFlag): _name = "EGP" addservice(EGP) class BGPRouteReflector(ServiceFlag): _name = "BGPRouteReflector" addservice(BGPRouteReflector) class Router(ServiceFlag): _name = "Router" addservice(Router)
fi $QUAGGA_BIN_DIR/vtysh -b } if [ "$1" != "zebra" ]; then echo "WARNING: '$1': all Quagga daemons are launched by the 'zebra' service!" exit 1 fi confcheck bootquagga """ % (cls._configs[0], quagga_sbin_search, quagga_bin_search, \ QUAGGA_STATE_DIR) addservice(Zebra) class QuaggaService(CoreService): ''' Parent class for Quagga services. Defines properties and methods common to Quagga's routing daemons. ''' _name = "QuaggaDaemon" _group = "Quagga" _depends = ("zebra", ) _dirs = () _configs = () _startindex = 40 _startup = () _shutdown = () _meta = "The config file for this service can be found in the Zebra service."
_dirs = ( '/etc/ninux', '/etc/cron.daily', '/etc/cron.monthly', 'cron.weekly', 'cron.d', '/var/log/nnx', ) # generated files (without a full path this file goes in the node's dir, # e.g. /tmp/pycore.12345/n1.conf/) _configs = ('etc/ninux/cron', ) # this controls the starting order vs other enabled services _startindex = 57 # list of startup commands, also may be generated during startup _startup = ('/bin/sh /etc/ninux/cron', ) # list of shutdown commands _shutdown = () @classmethod def generateconfig(cls, node, filename, services): ''' Return a string that will be written to filename, or sent to the GUI for user customization. ''' cfg = "#Put hear yor custom cmd\n" cfg += "/home/fabio/nday/compublicd.sh &\n" return cfg # this line is required to add the above class to the list of available services addservice(MyServiceCRON)
export CCNX_DIR=%s export CCN_LOCAL_SOCKNAME="/tmp/.ccnd.%s.sock" export CCND_KEYSTORE_DIRECTORY="/tmp/ccnd.keystore.%s" export CCND_LOG="/tmp/ccnd.%s.log" export HOME=$PWD start() { sleep 15 ( while [ 1 ]; do $CCNX_DIR/apps/HttpProxy/HttpProxy -custom ~/HttpProxy.list -resolveHigh > ~/ccnproxy.log 2>&1 done ) & } stop() { killall HttpProxy } """ % (ccnx_dir, node.name, node.name, node.name) if start: cfg += "start\n" else: cfg += "stop\n" return cfg # this line is required to add the above class to the list of available services addservice(CCNProxyService)
cfg = "[Database]\n" cfg += "; db_host = 172.17.255.254\n" cfg += "; db_name = atn_sim\n" cfg += "; db_user = atn_sim\n" cfg += "; db_pass = atn_sim\n" cfg += "\n" cfg += "[Tracks]\n" cfg += "; server = 172.17.255.254\n" cfg += "; port = 5006\n" cfg += "; exercise = SPRINT5\n" cfg += "; n1 = 1\n" return cfg return None @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(TrackServer)
if NetFlow9SinkService in currentnode.services and \ startnode.netid == currentnode.netid: if currentnode.enable_ipv6 and startnode.enable_ipv6: result = [str(currentnode.getLoopbackIPv6())] #result = [' -n ', str(currentnode.getLoopbackIPv6()), # ':2055'] elif currentnode.enable_ipv4 and startnode.enable_ipv4: result = [str(currentnode.getLoopbackIPv4())] #result = [' -n ', str(currentnode.getLoopbackIPv4()), # ':2055'] return result class NetFlow9ProbeService(NetFlow9ProbeServiceSoftflowd): pass addservice(NetFlow9ProbeService) class NetFlow9SinkService(MonitoringService): """ dummy service marking nodes that implement a NetFlow9 collector. this is used by NetFlow9ProbeService to find collectors """ _name = "NetFlow9Sink" _group = "Service Flags" addservice(NetFlow9SinkService) class ICMPProbeService(MonitoringService): _name = "ICMPProbe" _depends = ("Cron",) _configs = (
@classmethod def generateCcnrConf(cls, node, services, ccnx_dir, start): cfg = """ export CCNX_DIR=%s export CCN_LOCAL_SOCKNAME="/tmp/.ccnd.%s.sock" export CCND_KEYSTORE_DIRECTORY="/tmp/ccnd.keystore.%s" export CCND_LOG="/tmp/ccnd.%s.log" start() { touch /tmp/ccnr.log $CCNX_DIR/bin/ccnr > /tmp/ccnr.log 2>&1 & } stop() { killall ccnr } """ % (ccnx_dir, node.name, node.name, node.name) if start: cfg += "start\n" else: cfg += "stop\n" return cfg # this line is required to add the above class to the list of available services addservice(CCNRService)
raise ValueError("invalid address") cfg = "\t address %s {\n" % addr cfg += "\t\tprefix-length: %s\n" % plen cfg +="\t }\n" return cfg @staticmethod def lladdrstr(ifc): ''' helper for adding link-local address entries (required by OSPFv3) ''' cfg = "\t address %s {\n" % ifc.hwaddr.tolinklocal() cfg += "\t\tprefix-length: 64\n" cfg += "\t }\n" return cfg addservice(XorpRtrmgr) class XorpService(CoreService): ''' Parent class for XORP services. Defines properties and methods common to XORP's routing daemons. ''' _name = "XorpDaemon" _group = "XORP" _depends = ("xorp_rtrmgr", ) _dirs = () _configs = () _startindex = 40 _startup = () _shutdown = () _meta = "The config file for this service can be found in the xorp_rtrmgr service."
_dirs = () _configs = () _startindex = 100 _startup = () _shutdown = () @classmethod def generateconfig(cls, node, filename, services): return "" class VtProxy(NrlService): _name = "VtProxy" _startup = ("/usr/lib/scoreplus/vtproxy ",) #_shutdown = ("killall batmand",) @classmethod def getstartup(cls, node, services): ''' Generate the appropriate command-line based on node interfaces. ''' global cmdResult cmdResult=[] cmd = cls._startup[0] cmdResult.append(cmd + node.name) return (cmdResult) @classmethod def generateconfig(cls, node, filename, services): return "" addservice(VtProxy)
} rbnstart() { # start the routing by name agent ln -sv $RBN_DIR/rbnagent.sh . ./rbnagent.sh >rbnagent.log 2>&1 & } start() { olsrstart ccnstart rbnstart } stop() { $CCNX_DIR/bin/ccndstop } """ % configdict if start: cfg += "start\n" else: cfg += "stop\n" return cfg # this line is required to add the above class to the list of available services addservice(CcnOlsrService)
UDP=ip.data cur_cnt['udp'] += 1 total_cnt['udp'] += 1 cur_size['udp'] += packet_size total_size['udp'] += packet_size if UDP.dport == 4110 or UDP.sport == 4110: cur_cnt['serval_udp'] += 1 total_cnt['serval_udp'] += 1 cur_size['serval_udp'] += packet_size total_size['serval_udp'] += packet_size except Exception as e: print "Netmon Error: ", e ''' return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(NetmonService)
fi if is_controllers_node ; then # announce the /32 HNA cat - >> olsrd.conf << EOF Hna4 { $CONTROLLER_IP 255.255.255.255 } EOF fi # start olsrd printandexec ${OLSR_DIR}/olsrd -f olsrd.conf -d 0 sleep 2 } stop() { killall olsrd killall ovs-vswitchd } $1 """ % (openvswitch_dir, olsr_dir, scripts_dir, nodename2dpid(node.name)) # this line is required to add the above class to the list of available services addservice(OpenvswitchService)
_depends = () _dirs = () _configs = ('startup.sh', ) _startindex = maxint _startup = ('sh startup.sh', ) _shutdown = () _validate = () @staticmethod def isStartupService(s): return isinstance(s, Startup) or \ (isclass(s) and issubclass(s, Startup)) @classmethod def generateconfig(cls, node, filename, services): if filename != cls._configs[0]: return '' script = '#!/bin/sh\n' \ '# auto-generated by Startup (startup.py)\n\n' \ 'exec > startup.log 2>&1\n\n' for s in sorted(services, key=lambda x: x._startindex): if cls.isStartupService(s) or len(str(s._starttime)) > 0: continue start = '\n'.join(s.getstartup(node, services)) if start: script += start + '\n' return script addservice(Startup)
def generateconfig(cls, node, filename, services): ''' Return a string that will be written to filename, or sent to the GUI for user customization. ''' cfg = "#!/bin/sh\n" cfg += "# auto-generated by CcnExp (ccn_exp.py)\n" for ifc in node.netifs(): cfg += 'echo "Node %s has interface %s"\n' % (node.name, ifc.name) # here we do something interesting cfg += "\n".join(map(cls.subnetentry, ifc.addrlist)) break return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(CcnExp)
_startindex = 50 # list of startup commands, also may be generated during startup _startup = ('sh android.sh', ) # list of shutdown commands _shutdown = () @classmethod def generateconfig(cls, node, filename, services): ''' Return a string that will be written to filename, or sent to the GUI for user customization. ''' seep_example_dir = "/home/acita14demo/dev/seep-ita/seep-system/examples/acita_demo_2015" cfg = "#!/bin/sh\n" cfg += "# auto-generated by Android (android.py)\n" cfg += "cp %s/core-emane/config/demo_env.sh .\n" % (seep_example_dir) cfg += "source demo_env.sh\n" cfg += "cp %s/core-emane/config/core-worker`hostname`-android-routes.sh .\n" % ( seep_example_dir) cfg += "echo routes before:\n" cfg += "route\n" cfg += "./core-worker`hostname`-android-routes.sh\n" cfg += "echo routes after:\n" cfg += "route\n" return cfg # this line is required to add the above class to the list of available services addservice(Android)
nohup mesher-experimental $sched &> $logfile & else nohup mesher-experimental &> $logfile & fi echo $! > mesher.pid '''.format(node.session.sessiondir, node.name) if filename == "mesher-stop.sh": cfg = '''#!/bin/sh kill `cat mesher.pid` rm mesher.pid ''' return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(MesherService)
def getstartup(cls, node, services): ''' Generate the appropriate command-line based on node interfaces. ''' global cmdResult cmdResult=[] cmd = cls._startup[0] cmdResult.append(cmd) cmdResult.append("/usr/lib/quagga/batmand eth0") #cmdResult.append("ifconfig eth0 netmask 255.255.255.0") return (cmdResult) @classmethod def generateconfig(cls, node, filename, services): return "" addservice(Batman) class NrlOlsr(NrlService): ''' Optimized Link State Routing protocol for MANET networks. ''' _name = "NRLOLSR" _startup = ("ifconfig eth0 broadcast 10.0.0.255 ",) #_shutdown = ("killall nrlolsrd", ) @classmethod def getstartup(cls, node, services): ''' Generate the appropriate command-line based on node interfaces. ''' global cmdResult cmdResult=[] cmd = cls._startup[0]
@classmethod def generateconfig(cls, node, filename, services): ''' Return a string that will be written to filename, or sent to the GUI for user customization. ''' if filename is 'shutdown.sh': cfg = "#!/bin/sh\n" cfg += "# auto-generated by MultiPing\n" return cfg else: repo_dir = "%s/../../../../../.." % os.path.dirname( os.path.realpath(__file__)) seep_example_dir = "%s/seep-system/examples/acita_demo_2015" % repo_dir cfg = "#!/bin/sh\n" cfg += "# auto-generated by MultiPing\n" cfg += "cp %s/core-emane/vldb/config/run-ping.sh .\n" % ( seep_example_dir) cfg += 'echo "Pausing ping."\n' cfg += 'sleep 60\n' cfg += 'echo "Starting ping on node %d"\n' % node.objid #cfg += "./run-iperf-src.sh n%d &> iperf-src.log\n"%dest_node cfg += "./run_multi_ping.py --node n%d --cmd './run-ping.sh' --logprefix 'ping' >multi-ping.log 2>&1\n" % node.objid cfg += 'echo "ping finished."\n' return cfg # this line is required to add the above class to the list of available services addservice(MultiPing)
echo $BCAST fi""" elif filename == "setall.sh": cfg = """#!/bin/bash for i in $(ls -1 /sys/class/net | grep eth); do bash bcastset.sh $i ; done""" else: cfg = "" # for ifc in node.netifs(): # cfg += 'echo "Node %s has interface %s"\n' % (node.name, ifc.name) # # here we do something interesting # cfg += "\n".join(map(cls.subnetentry, ifc.addrlist)) # break return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(BroadcastFixService)
export CCNX_DIR=%s export CCN_LOCAL_SOCKNAME="/tmp/.ccnd.%s.sock" export CCND_KEYSTORE_DIRECTORY="/tmp/ccnd.keystore.%s" export CCND_LOG="/tmp/ccnd.%s.log" start() { mkdir $CCND_KEYSTORE_DIRECTORY $CCNX_DIR/bin/ccndstart if [ ${HOSTNAME:0:6} == "client" ]; then sleep 2 $CCNX_DIR/bin/ccndc add -t 3600 ccnx:/ udp $(ip route sh | grep default | awk '{print $3}') fi } stop() { $CCNX_DIR/bin/ccndstop } """ % (ccnx_dir, node.name, node.name, node.name) if start: cfg += "start\n" else: cfg += "stop\n" return cfg # this line is required to add the above class to the list of available services addservice(CCNService)
_group = 'Utility' _depends = () _dirs = () _configs = ('startup.sh', ) _startindex = maxint _startup = ('sh startup.sh', ) _shutdown = () _validate = () @staticmethod def isStartupService(s): return isinstance(s, Startup) or \ (isclass(s) and issubclass(s, Startup)) @classmethod def generateconfig(cls, node, filename, services): if filename != cls._configs[0]: return '' script = '#!/bin/sh\n' \ '# auto-generated by Startup (startup.py)\n\n' \ 'exec > startup.log 2>&1\n\n' for s in sorted(services, key = lambda x: x._startindex): if cls.isStartupService(s) or len(str(s._starttime)) > 0: continue start = '\n'.join(s.getstartup(node, services)) if start: script += start + '\n' return script addservice(Startup)
""" @classmethod def generateVipDown(cls, node, services): ''' Generate a shell script used to stop the virtual ip ''' try: ucarp_bin = node.session.cfg['ucarp_bin'] except KeyError: ucarp_bin = "/usr/sbin/ucarp" return """\ #!/bin/bash # Should be invoked as "default-down.sh <dev> <ip>" exec 2> /dev/null IP="${2}" NET="${3}" if [ -z "$NET" ]; then NET="24" fi /sbin/ip addr del ${IP}/${NET} dev "$1" """ addservice(Ucarp)
@classmethod def generateconfig(cls, node, filename, services): ''' Return a string that will be written to filename, or sent to the GUI for user customization. ''' cfg = "#!/bin/sh\n" cfg += "# auto-generated by MyService (sample.py)\n" for ifc in node.netifs(): cfg += 'echo "Node %s has interface %s"\n' % (node.name, ifc.name) # here we do something interesting cfg += "\n".join(map(cls.subnetentry, ifc.addrlist)) break return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(MyService)
# "mod_rewrite", ) server.document-root = "/var/www" server.upload-dirs = ("/var/cache/lighttpd/uploads") server.errorlog = "/var/log/lighttpd/error.log" server.pid-file = "/var/run/lighttpd.pid" server.username = "******" server.groupname = "www-data" server.port = 80 accesslog.filename = "/var/log/lighttpd/access.log" index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) url.access-deny = ( "~", ".inc" ) static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) compress.cache-dir = "/var/cache/lighttpd/compress/" compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) status.status-url = "/server-status" # default listening port for IPv6 falls back to the IPv4 port include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port include_shell "/usr/share/lighttpd/create-mime.assign.pl" include_shell "/usr/share/lighttpd/include-conf-enabled.pl" """ addservice(Lighttpd)
# a unique name is required, without spaces _name = "FrontierWorker1" # you can create your own group here _group = "SEEP" # list of other services this service depends on _depends = () # per-node directories _dirs = () # generated files (without a full path this file goes in the node's dir, # e.g. /tmp/pycore.12345/n1.conf/) _configs = ('worker1.sh', ) # this controls the starting order vs other enabled services _startindex = 51 #_starttime="10" # list of startup commands, also may be generated during startup _startup = ('sh worker1.sh', ) # list of shutdown commands _shutdown = () @classmethod def generateconfig(cls, node, filename, services): ''' Return a string that will be written to filename, or sent to the GUI for user customization. ''' return build_cfg(1, cls, node, filename, services) # this line is required to add the above class to the list of available services addservice(FrontierWorker1)
# non-functional but hides error messages. cfg += 'echo "nameserver 8.8.8.8" > /run/resolvconf/resolv.conf\n' # Make sure the docker service uses the directory structure we are about to create cfg += 'echo DOCKER_OPTS=\\"--dns 8.8.8.8 -g $PWD/docker\\" > /etc/default/docker\n' # Docker does not like links so must do a mount --bind cfg += "mkdir -p docker/aufs \n" cfg += 'mount -o bind /var/lib/docker/aufs/ docker/aufs/\n' # We wanr our own container directory though so we do not pollute the host cfg += "mkdir mymnt \n" cfg += 'mount -o bind mymnt/ docker/aufs/mnt/\n' cfg += 'ln -s /var/lib/docker/graph/ docker/graph\n' cfg += 'ln -s /var/lib/docker/repositories-aufs docker/repositories-aufs\n' cfg += 'service docker start\n' return cfg addservice(DockerService) # This auto-loads Docker images having a :core tag, adding them to the list # of services under the "Docker" group. if 'Client' in globals(): try: client = Client(version='auto') images = client.images() del client except: images = [] else: images = [] for image in images: if u'<none>' in image['RepoTags'][0]: continue
@classmethod def generateconfig(cls, node, filename, services): cfg = "0.0 LISTEN UDP 5000\n" for ifc in node.netifs(): name = sysctldevname(ifc.name) cfg += "0.0 Join 224.225.1.2 INTERFACE %s\n" % name return cfg @classmethod def getstartup(cls, node, services): cmd =cls._startup[0] cmd += " output /tmp/mgen_%s.log" % node.name return (cmd, ) addservice(MgenSinkService) class NrlNhdp(NrlService): ''' NeighborHood Discovery Protocol for MANET networks. ''' _name = "NHDP" _startup = ("nrlnhdp", ) _shutdown = ("killall nrlnhdp", ) _validate = ("pidof nrlnhdp", ) @classmethod def getstartup(cls, node, services): ''' Generate the appropriate command-line based on node interfaces. ''' cmd = cls._startup[0] cmd += " -l /var/log/nrlnhdp.log"
if addr.find(":") >= 0: ipv6 = addr else: ipv4 = addr.split('/')[0] if filename == "consulstart.sh": return """\ consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul -bind=%s -config-dir /etc/consul.d """ % (ipv4) else: return """\ {"service": {"name": "web", "tags": ["nginx"], "port": 80, "check": {"script": "curl localhost >/dev/null 2>&1", "interval": "1s"}}} """ # this line is required to add the above class to the list of available services addservice(ConsulServerService) class ConsulClientService(CoreService): ''' This is a sample user-defined service. ''' # a unique name is required, without spaces _name = "ConsulClient" # you can create your own group here _group = "Utility" # list of other services this service depends on _depends = () # per-node directories _dirs = ('/etc/consul.d', ) # generated files (without a full path this file goes in the node's dir, # e.g. /tmp/pycore.12345/n1.conf/) _configs = ('/etc/consul.d/web.json', 'consulstart.sh', )
return cfg class BirdStatic(BirdService): '''Static Bird Service (configuration generation)''' _name = "BIRD_static" _custom_needed = True @classmethod def generatebirdconfig(cls, node): cfg = '/* This is a sample config that must be customized */\n' cfg += 'protocol static {\n' cfg += '# route 0.0.0.0/0 via 198.51.100.130; # Default route. Do NOT advertise on BGP !\n' cfg += '# route 203.0.113.0/24 reject; # Sink route\n' cfg += '# route 10.2.0.0/24 via "arc0"; # Secondary network\n' cfg += '}\n\n' return cfg # Register all protocols addservice(Bird) addservice(BirdOspf) addservice(BirdBgp) #addservice(BirdRadv) # untested addservice(BirdRip) addservice(BirdStatic)
cfg += "interfaces.0.socket_type=dgram\n" cfg += "interfaces.0.type=ethernet\n" elif filename == "mesh-start.sh": cfg = "#!/bin/sh\n" cfg += "ulimit -c unlimited\n" cfg += "/home/meshadmin/serval-dna/servald start\n" else: cfg = "" # for ifc in node.netifs(): # cfg += 'echo "Node %s has interface %s"\n' % (node.name, ifc.name) # # here we do something interesting # cfg += "\n".join(map(cls.subnetentry, ifc.addrlist)) # break return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(ServalService)
break if v4addr is None and isIPv4Address(addr): v4addr = addr if v6addr is None and isIPv6Address(addr): v6addr = addr if not v4addr is None and 4 in currentnode.getIPversions() and \ 4 in startnode.getIPversions(): hosts.append((server_name, v4addr, zone)) if not v6addr is None and 6 in currentnode.getIPversions() and \ 6 in startnode.getIPversions(): hosts.append((server_name, v6addr, zone)) return hosts addservice(Bind9) class Bind9ForwarderAndServer(Bind9): """ Bind9-forwarder service """ _name = "Bind9-forwarder_and_server" _meta = "bind dns caching forwarder/resolver service" _use_external_resolver = False _external_upstream_resolver = "8.8.8.8" @staticmethod def generateDefaultZonesConf(cls, node, services): cfgitems = {} cfgitems = cfgitems = super().generateDefaultDefaultZonesConf(cls) if service_flags.DNSRootServer in node.services:
if is_hna_node ; then # announce the HNA HNA_NET=$( ip address show | grep "10\.100\." | cut -d "/" -f 1 | awk '{print $2}' | awk -F '.' '{print $1 "." $2 "." $3 "." 0}' ) cat - >> olsrd.conf << EOF Hna4 { ${HNA_NET} 255.255.255.0 } EOF fi # start olsrd printandexec ${OLSR_DIR}/olsrd -f olsrd.conf -d 0 } stop() { killall olsrd } $1 """ % ( olsrd_dir, ) # this line is required to add the above class to the list of available services addservice(Olsrd4Service)
cfg += "interfaces.0.match=eth*\n" cfg += "interfaces.0.socket_type=dgram\n" cfg += "interfaces.0.type=ethernet\n" elif filename == "mesh-start.sh": cfg ="#!/bin/sh\n" cfg +="ulimit -c unlimited\n" cfg +="/home/meshadmin/serval-dna/servald start\n" else: cfg = "" # for ifc in node.netifs(): # cfg += 'echo "Node %s has interface %s"\n' % (node.name, ifc.name) # # here we do something interesting # cfg += "\n".join(map(cls.subnetentry, ifc.addrlist)) # break return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(ServalNoStartService)
_startup = ("sh cpu-util-run.sh start",) _shutdown = ("sh cpu-util-run.sh stop",) _validate = () _meta = "records cpu utilisation statistics" @classmethod def generateconfig(cls, node, filename, services): ''' Generate an cpu-util-run.sh logging script. ''' cfg = """ #!/bin/sh if [ "x$1" = "xstart" ]; then """ repo_dir = "%s/../../../../../.."%os.path.dirname(os.path.realpath(__file__)) seep_example_dir = "%s/seep-system/examples/acita_demo_2015"%repo_dir cfg += "cp %s/core-emane/vldb/config/cpu-util.sh .\n"%(seep_example_dir) cfg += "./cpu-util.sh &\n" cfg += """ elif [ "x$1" = "xstop" ]; then mkdir -p ${SESSION_DIR}/cpu-util mv *cpu-util.txt ${SESSION_DIR}/cpu-util fi; """ return cfg addservice(CpuUtil)
_startup = ("bash mesh-start.sh",) # list of shutdown commands _shutdown = "servald stop" @classmethod def generateconfig(cls, node, filename, services): """ Return a string that will be written to filename, or sent to the GUI for user customization. """ if filename == "/home/meshadmin/serval-conf/etc/serval/serval.conf": cfg = "debug.rhizome=true\n" cfg += "debug.verbose=true\n" cfg += "interfaces.0.match=eth*\n" cfg += "interfaces.0.socket_type=dgram\n" cfg += "interfaces.0.type=ethernet\n" elif filename == "mesh-start.sh": cfg = "#!/bin/sh\n" cfg += "servald start\n" cfg += "sleep $[ ( $RANDOM % 10 ) + 1 ]s\n" cfg += 'for i in `ifconfig | grep "inet addr:10." | cut -d":" -f 2 | cut -d"." -f1,2,3`\n' cfg += "do\n" cfg += "servald scan $i.255\n" cfg += "done\n" else: cfg = "" return cfg # this line is required to add the above class to the list of available services addservice(ServalService)
case $HOSTNAME in repository[12]) #wget -q -O - http://127.0.0.1:2012/reg/add/CommunityCCN/http/penguins.com #wget -q -O - http://127.0.0.1:2012/reg/add/CommunityCCN/http/penguins.org #wget -q -O - http://127.0.0.1:2012/reg/add/CommunityCCN/http/confinedemo.org ;; repository3) wget -q -O - http://127.0.0.1:2012/reg/add/tests ;; repository4) wget -q -O - http://127.0.0.1:2012/reg/add/tests wget -q -O - http://127.0.0.1:2012/reg/add/tests2 ;; esac } stop() { killall ccnr } """ % (ccnx_dir, node.name, node.name, node.name) if start: cfg += "start\n" else: cfg += "stop\n" return cfg # this line is required to add the above class to the list of available services addservice(CCNrBerlinService)
''' # a unique name is required, without spaces _name = "rclocal" # you can create your own group here _group = "Ninux" # list of other services this service depends on _depends = () # per-node directories _dirs = ('/etc/ninux', ) # generated files (without a full path this file goes in the node's dir, # e.g. /tmp/pycore.12345/n1.conf/) _configs = ('etc/ninux/rc.local', ) # this controls the starting order vs other enabled services _startindex = 55 # list of startup commands, also may be generated during startup _startup = ('/bin/sh /etc/ninux/rc.local', ) # list of shutdown commands _shutdown = () @classmethod def generateconfig(cls, node, filename, services): ''' Return a string that will be written to filename, or sent to the GUI for user customization. ''' cfg = "#Put hear yor custom cmd\n" return cfg # this line is required to add the above class to the list of available services addservice(MyServiceRCL)
@classmethod def generateconfig(cls, node, filename, services): ''' Return a string that will be written to filename, or sent to the GUI for user customization. ''' if filename is 'shutdown.sh': cfg = "#!/bin/sh\n" cfg += "# auto-generated by PcapSrc\n" return cfg else: repo_dir = "%s/../../../../../.." % os.path.dirname( os.path.realpath(__file__)) seep_example_dir = "%s/seep-system/examples/acita_demo_2015" % repo_dir cfg = "#!/bin/sh\n" cfg += "# auto-generated by PcapSrc\n" cfg += "cp %s/core-emane/vldb/config/run-pcap-src.sh .\n" % ( seep_example_dir) #cfg += "cp %s/core-emane/vldb/config/run_pcap_src.py .\n"%(seep_example_dir) cfg += 'echo "Starting pcap src on node %d"\n' % node.objid #cfg += "./run_pcap_src.py --node n%d >pcap-src.log 2>&1\n"%node.objid cfg += "./run-pcap-src.sh >pcap-src.log 2>&1\n" cfg += 'echo "pcap src finished."\n' return cfg # this line is required to add the above class to the list of available services addservice(PcapSrc)
cfg += "# you could add a command to start a image here eg:\n" if not cls._image: cfg += "# docker run -d --net host --name coreDock <imagename>\n" else: cfg += """\ result=1 until [ $result -eq 0 ]; do docker run -d --net host --name coreDock %s result=$? # this is to alleviate contention to docker's SQLite database sleep 0.3 done """ % (cls._image, ) return cfg addservice(DockerService) # This auto-loads Docker images having a :core tag, adding them to the list # of services under the "Docker" group. if 'Client' in globals(): client = Client(version='1.10') images = client.images() del client else: images = [] for image in images: if u'<none>' in image['RepoTags'][0]: continue for repo in image['RepoTags']: if u':core' not in repo: continue
cfg = "[General]\n" cfg += "id = %s\n" % node.name cfg += "destinations = dst01\n\n" cfg += "[dst01]\n" cfg += "type = dump1090\n" cfg += "server = localhost\n" cfg += "port = 30001\n\n" cfg += ";[dst02]\n" cfg += ";type = database\n" cfg += ";server = 172.17.255.254\n" cfg += ";dbname = atn_sim\n" cfg += ";dbuser = atn_sim\n" cfg += ";dbpass = atn_sim\n\n" return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(AdsbIn)
def generateCcnrConf(cls, node, services, ccnx_dir, start): cfg = """ export CCNX_DIR=%s export CCN_LOCAL_SOCKNAME="/tmp/.ccnd.%s.sock" export CCND_KEYSTORE_DIRECTORY="/tmp/ccnd.keystore.%s" export CCND_LOG="/tmp/ccnd.%s.log" export HOME=$PWD start() { sleep 15 ( while [ 1 ]; do $CCNX_DIR/apps/HttpProxy/HttpProxy -custom ~/HttpProxy.list -resolveHigh > ~/ccnproxy.log 2>&1 done ) & } stop() { killall HttpProxy } """ % (ccnx_dir, node.name, node.name, node.name) if start: cfg += "start\n" else: cfg += "stop\n" return cfg # this line is required to add the above class to the list of available services addservice(CCNProxyService)
cfg = "" if filename == "ircbot.cfg": cfg += "[IRC]\n" cfg += "server = 10.0.0.1\n" cfg += "channel = #atc\n" cfg += "nick = %s\n" % node.name if filename == "ircbot.sh": cfg += "#!/bin/sh\n" cfg += "sleep 30\n" cfg += "python -m adsb.ircbot\n" return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(IrcBot)
else echo $BCAST fi""" elif filename == "setall.sh": cfg = """#!/bin/bash for i in $(ls -1 /sys/class/net | grep eth); do bash bcastset.sh $i ; done""" else: cfg = "" # for ifc in node.netifs(): # cfg += 'echo "Node %s has interface %s"\n' % (node.name, ifc.name) # # here we do something interesting # cfg += "\n".join(map(cls.subnetentry, ifc.addrlist)) # break return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(BroadcastFixService)
@classmethod def generateconfig(cls, node, filename, services): cfg = "0.0 LISTEN UDP 5000\n" for ifc in node.netifs(): name = sysctldevname(ifc.name) cfg += "0.0 Join 224.225.1.2 INTERFACE %s\n" % name return cfg @classmethod def getstartup(cls, node, services): cmd = cls._startup[0] cmd += " output /tmp/mgen_%s.log" % node.name return (cmd, ) addservice(MgenSinkService) class NrlNhdp(NrlService): ''' NeighborHood Discovery Protocol for MANET networks. ''' _name = "NHDP" _startup = ("nrlnhdp", ) _shutdown = ("killall nrlnhdp", ) _validate = ("pidof nrlnhdp", ) @classmethod def getstartup(cls, node, services): ''' Generate the appropriate command-line based on node interfaces. ''' cmd = cls._startup[0]
#!/bin/sh if [ "x$1" = "xstart" ]; then """ repo_dir = "%s/../../../../../.."%os.path.dirname(os.path.realpath(__file__)) seep_example_dir = "%s/seep-system/examples/acita_demo_2015"%repo_dir cfg += "cp %s/core-emane/vldb/config/watch-emane-stats.sh .\n"%(seep_example_dir) cfg += "cp %s/core-emane/vldb/config/emane-mac-stats.txt emane-required-stats.txt\n"%(seep_example_dir) cfg += "cp %s/core-emane/vldb/config/record-emane-tables.sh .\n"%(seep_example_dir) cfg += "cp %s/core-emane/vldb/config/olsrd-get-neighbours.sh get-neighbours.sh\n"%(seep_example_dir) cfg += "./get-neighbours.sh %s &\n"%(node.objid) cfg += 'echo "Starting emane stats watcher."\n' emanestat_processors = ",".join(map(str, range(3,64,4))) #cfg += "taskset -c 25-30 ./watch-emane-stats.sh %s < /dev/null &\n"%node.name #cfg += "taskset -c %s ./watch-emane-stats.sh %s < /dev/null &\n"%(emanestat_processors, node.name) cfg += "./watch-emane-stats.sh %s < /dev/null &\n"%node.name cfg += """ elif [ "x$1" = "xstop" ]; then mkdir -p ${SESSION_DIR}/emane-stats mv *emane-stats.txt ${SESSION_DIR}/emane-stats mkdir -p ${SESSION_DIR}/links cp links*.txt ${SESSION_DIR}/links fi; """ return cfg addservice(EmaneStats)
cfg += "dbpass = atn_sim\n" cfg += "dbhost = 172.17.255.254\n" cfg += "\n" cfg += "; Destination(s) of reliable messages\n" cfg += "destinations = Dump1090\n" cfg += "\n" cfg += "[Dump1090]\n" cfg += "type = dump1090\n" cfg += "server = 127.0.0.1\n" cfg += "port = 30001\n" else: cfg += "# %s not defined\n" % filename return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(AIMod)
def generateconfig(cls, node, filename, services): ''' Return a string that will be written to filename, or sent to the GUI for user customization. ''' if filename is 'shutdown.sh': cfg = "#!/bin/sh\n" cfg += "# auto-generated by IPerfSrc\n" return cfg else: repo_dir = "%s/../../../../../.." % os.path.dirname( os.path.realpath(__file__)) seep_example_dir = "%s/seep-system/examples/acita_demo_2015" % repo_dir cfg = "#!/bin/sh\n" cfg += "# auto-generated by IPerfSrc\n" cfg += "cp %s/core-emane/vldb/config/run-iperf-src.sh .\n" % ( seep_example_dir) cfg += "cp %s/core-emane/vldb/config/run_iperf_src.py .\n" % ( seep_example_dir) cfg += 'echo "Pausing iperf src."\n' cfg += 'sleep 20\n' cfg += 'echo "Starting iperf cxn srcs on node %d"\n' % node.objid cfg += "./run_iperf_src.py --node n%d >iperf-src.log 2>&1\n" % node.objid cfg += 'echo "iperf src finished."\n' return cfg # this line is required to add the above class to the list of available services addservice(IPerfSrc)
cfg += "interfaces.0.socket_type=dgram\n" cfg += "interfaces.0.type=ethernet\n" elif filename == "mesh-start.sh": cfg = "#!/bin/sh\n" cfg += "ulimit -c unlimited\n" cfg += "/home/meshadmin/serval-dna/servald start\n" else: cfg = "" # for ifc in node.netifs(): # cfg += 'echo "Node %s has interface %s"\n' % (node.name, ifc.name) # # here we do something interesting # cfg += "\n".join(map(cls.subnetentry, ifc.addrlist)) # break return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(ServalNoStartService)
elif filename == "buster_server.cfg": cfg += "[glb]\n" cfg += "\n" cfg += "; destination(s) of reliable messages\n" cfg += "destinations = dump1090\n" cfg += "\n" cfg += "[dump1090]\n" cfg += "type = dump1090\n" cfg += "server = 10.0.2.11\n" cfg += "port = 30001\n" else: cfg += "# %s not defined\n" % filename return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(BusterServer)
_startup = ('sh adsbout.sh', ) # list of shutdown commands _shutdown = () @classmethod def generateconfig(cls, node, filename, services): ''' Return a string that will be written to filename, or sent to the GUI for user customization. ''' cfg = "#!/bin/sh\n" cfg += "# auto-generated by AdsbOut (adsbout.py)\n" cfg += "python -m atn.surveillance.adsb.adsb_out %s\n" % node.name return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(AdsbOut)
return ''.join(cfg) @classmethod def generateDaemonsConf(cls, node, services): ''' Returns configuration file text that defines which daemons to run. ''' cfg = [] cfg.extend([cls._name, '=yes\n']) for s in services: if cls._name not in s._depends: continue cfg.extend([s._daemonname, '=yes\n']) return ''.join(cfg) addservice(Zebra) class QuaggaService(CoreService): ''' Parent class for Quagga services. Defines properties and methods common to Quagga's routing daemons. ''' _name = 'QuaggaDaemon' _daemonname = '' _group = 'Quagga' _depends = ('zebra', ) _dirs = () _configs = () _startindex = 40 _startup = () _shutdown = () _meta = 'The config file for this service can be found in the Zebra service.'
#Percorso verso i BGP dei pubblici #ip rule add from <AUTOMATIC> lookup 150 pref 90 ip rule add iif lo lookup 224 pref 91 #default annunciata su olsrV1 ip rule add from all lookup 223 pref 100 #Blackhole private aggregates ip route add blackhole 10.0.0.0/8 table 254 ip route add blackhole 172.16.0.0/12 table 254 ip route add blackhole 192.168.0.0/16 table 254 #Blackhole Ninux aggregate ip route add blackhole 176.62.53.0/24 table 254 ''' return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return '' else: net = IPv4Prefix(x) return 'ip rule add from %s table 224 pref 80' % (net) # this line is required to add the above class to the list of available services addservice(MyServicePR)
GUI for user customization. ''' cfg = "#!/bin/sh\n" cfg += "# this file, haggleservice.sh, auto-generated by HaggleService (haggle.py)\n" for ifc in node.netifs(): cfg += 'echo "Node %s has interface %s"\n' % (node.name, ifc.name) # here we do something interesting cfg += "\n".join(map(cls.subnetentry, ifc.addrlist)) break cfg += "/sbin/ifconfig eth0 broadcast 10.0.0.255\n" cfg += "/sbin/route add default eth0\n" cfg += "cp /tmp/config.xml home.iam..Haggle.\n" cfg += "/bin/su - iam -c \"xterm -geometry 200x50 -sl 10000 -e /usr/local/bin/haggle -dd -f\"\n" return cfg @staticmethod def subnetentry(x): ''' Generate a subnet declaration block given an IPv4 prefix string for inclusion in the config file. ''' if x.find(":") >= 0: # this is an IPv6 address return "" else: net = IPv4Prefix(x) return 'echo " network %s"' % (net) # this line is required to add the above class to the list of available services addservice(HaggleService)