changed some logging from info to debug, removed startindex and depends from services
This commit is contained in:
parent
0aca9d7809
commit
37517c45f4
18 changed files with 35 additions and 104 deletions
|
@ -471,12 +471,12 @@ class BasicRangeModel(WirelessModel):
|
||||||
a.name, b.name, linked, d, self.range)
|
a.name, b.name, linked, d, self.range)
|
||||||
if d > self.range:
|
if d > self.range:
|
||||||
if linked:
|
if linked:
|
||||||
logger.info("was linked, unlinking")
|
logger.debug("was linked, unlinking")
|
||||||
self.wlan.unlink(a, b)
|
self.wlan.unlink(a, b)
|
||||||
self.sendlinkmsg(a, b, unlink=True)
|
self.sendlinkmsg(a, b, unlink=True)
|
||||||
else:
|
else:
|
||||||
if not linked:
|
if not linked:
|
||||||
logger.info("was not linked, linking")
|
logger.debug("was not linked, linking")
|
||||||
self.wlan.link(a, b)
|
self.wlan.link(a, b)
|
||||||
self.sendlinkmsg(a, b)
|
self.sendlinkmsg(a, b)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
@ -440,7 +440,7 @@ class LxBrNet(PyCoreNet):
|
||||||
"burst", str(burst), "limit", str(limit)]
|
"burst", str(burst), "limit", str(limit)]
|
||||||
if bw > 0:
|
if bw > 0:
|
||||||
if self.up:
|
if self.up:
|
||||||
logger.info("linkconfig: %s" % ([tc + parent + ["handle", "1:"] + tbf],))
|
logger.debug("linkconfig: %s" % ([tc + parent + ["handle", "1:"] + tbf],))
|
||||||
utils.check_cmd(tc + parent + ["handle", "1:"] + tbf)
|
utils.check_cmd(tc + parent + ["handle", "1:"] + tbf)
|
||||||
netif.setparam("has_tbf", True)
|
netif.setparam("has_tbf", True)
|
||||||
changed = True
|
changed = True
|
||||||
|
@ -485,12 +485,12 @@ class LxBrNet(PyCoreNet):
|
||||||
return
|
return
|
||||||
tc[2] = "delete"
|
tc[2] = "delete"
|
||||||
if self.up:
|
if self.up:
|
||||||
logger.info("linkconfig: %s" % ([tc + parent + ["handle", "10:"]],))
|
logger.debug("linkconfig: %s" % ([tc + parent + ["handle", "10:"]],))
|
||||||
utils.check_cmd(tc + parent + ["handle", "10:"])
|
utils.check_cmd(tc + parent + ["handle", "10:"])
|
||||||
netif.setparam("has_netem", False)
|
netif.setparam("has_netem", False)
|
||||||
elif len(netem) > 1:
|
elif len(netem) > 1:
|
||||||
if self.up:
|
if self.up:
|
||||||
logger.info("linkconfig: %s" % ([tc + parent + ["handle", "10:"] + netem],))
|
logger.debug("linkconfig: %s" % ([tc + parent + ["handle", "10:"] + netem],))
|
||||||
utils.check_cmd(tc + parent + ["handle", "10:"] + netem)
|
utils.check_cmd(tc + parent + ["handle", "10:"] + netem)
|
||||||
netif.setparam("has_netem", True)
|
netif.setparam("has_netem", True)
|
||||||
|
|
||||||
|
|
|
@ -45,12 +45,13 @@ class ServiceShim(object):
|
||||||
:return: value list string
|
:return: value list string
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
valmap = [service.dirs, service.configs, service.startindex, service.startup,
|
start_time = 0
|
||||||
service.shutdown, service.validate, service.meta, service.starttime]
|
start_index = 0
|
||||||
|
valmap = [service.dirs, service.configs, start_index, service.startup,
|
||||||
|
service.shutdown, service.validate, service.meta, start_time]
|
||||||
if not service.custom:
|
if not service.custom:
|
||||||
# this is always reached due to classmethod
|
valmap[1] = service.getconfigfilenames(node)
|
||||||
valmap[valmap.index(service.configs)] = service.getconfigfilenames(node)
|
valmap[3] = service.getstartup(node)
|
||||||
valmap[valmap.index(service.startup)] = service.getstartup(node)
|
|
||||||
vals = map(lambda a, b: "%s=%s" % (a, str(b)), cls.keys, valmap)
|
vals = map(lambda a, b: "%s=%s" % (a, str(b)), cls.keys, valmap)
|
||||||
return "|".join(vals)
|
return "|".join(vals)
|
||||||
|
|
||||||
|
@ -97,8 +98,6 @@ class ServiceShim(object):
|
||||||
service.dirs = value
|
service.dirs = value
|
||||||
elif key == "files":
|
elif key == "files":
|
||||||
service.configs = value
|
service.configs = value
|
||||||
elif key == "startidx":
|
|
||||||
service.startindex = value
|
|
||||||
elif key == "cmdup":
|
elif key == "cmdup":
|
||||||
service.startup = value
|
service.startup = value
|
||||||
elif key == "cmddown":
|
elif key == "cmddown":
|
||||||
|
@ -107,8 +106,6 @@ class ServiceShim(object):
|
||||||
service.validate = value
|
service.validate = value
|
||||||
elif key == "meta":
|
elif key == "meta":
|
||||||
service.meta = value
|
service.meta = value
|
||||||
elif key == "starttime":
|
|
||||||
service.starttime = value
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def servicesfromopaque(cls, opaque):
|
def servicesfromopaque(cls, opaque):
|
||||||
|
@ -422,7 +419,7 @@ class CoreServices(object):
|
||||||
result.get()
|
result.get()
|
||||||
|
|
||||||
def boot_node_dependencies(self, node, boot_path):
|
def boot_node_dependencies(self, node, boot_path):
|
||||||
logger.info("booting node service dependencies: %s", boot_path)
|
logger.debug("booting node service dependencies: %s", boot_path)
|
||||||
for service in boot_path:
|
for service in boot_path:
|
||||||
self.bootnodeservice(node, service)
|
self.bootnodeservice(node, service)
|
||||||
|
|
||||||
|
@ -435,7 +432,7 @@ class CoreServices(object):
|
||||||
:param CoreService service: service to start
|
:param CoreService service: service to start
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
logger.info("starting node(%s) service: %s (%s)", node.name, service.name, service.startindex)
|
logger.info("starting node(%s) service(%s)", node.name, service.name)
|
||||||
|
|
||||||
# create service directories
|
# create service directories
|
||||||
for directory in service.dirs:
|
for directory in service.dirs:
|
||||||
|
@ -501,14 +498,14 @@ class CoreServices(object):
|
||||||
:return: service validation status
|
:return: service validation status
|
||||||
:rtype: int
|
:rtype: int
|
||||||
"""
|
"""
|
||||||
logger.info("validating node(%s) service(%s): %s", node.name, service.name, service.startindex)
|
logger.info("validating node(%s) service(%s)", node.name, service.name)
|
||||||
cmds = service.validate
|
cmds = service.validate
|
||||||
if not service.custom:
|
if not service.custom:
|
||||||
cmds = service.getvalidate(node)
|
cmds = service.getvalidate(node)
|
||||||
|
|
||||||
status = 0
|
status = 0
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
logger.info("validating service(%s) using: %s", service.name, cmd)
|
logger.debug("validating service(%s) using: %s", service.name, cmd)
|
||||||
try:
|
try:
|
||||||
node.check_cmd(cmd)
|
node.check_cmd(cmd)
|
||||||
except CoreCommandError:
|
except CoreCommandError:
|
||||||
|
@ -524,8 +521,7 @@ class CoreServices(object):
|
||||||
:param core.netns.nodes.CoreNode node: node to stop services on
|
:param core.netns.nodes.CoreNode node: node to stop services on
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
services = sorted(node.services, key=lambda x: x.startindex)
|
for service in node.services:
|
||||||
for service in services:
|
|
||||||
self.stopnodeservice(node, service)
|
self.stopnodeservice(node, service)
|
||||||
|
|
||||||
def stopnodeservice(self, node, service):
|
def stopnodeservice(self, node, service):
|
||||||
|
@ -651,13 +647,14 @@ class CoreServices(object):
|
||||||
:param CoreService service: service to reconfigure
|
:param CoreService service: service to reconfigure
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
|
logger.info("node(%s) service(%s) creating config files", node.name, service.name)
|
||||||
# get values depending on if custom or not
|
# get values depending on if custom or not
|
||||||
file_names = service.configs
|
file_names = service.configs
|
||||||
if not service.custom:
|
if not service.custom:
|
||||||
file_names = service.getconfigfilenames(node)
|
file_names = service.getconfigfilenames(node)
|
||||||
|
|
||||||
for file_name in file_names:
|
for file_name in file_names:
|
||||||
logger.info("generating service config: %s", file_name)
|
logger.debug("generating service config: %s", file_name)
|
||||||
if service.custom:
|
if service.custom:
|
||||||
cfg = service.configtxt.get(file_name)
|
cfg = service.configtxt.get(file_name)
|
||||||
if cfg is None:
|
if cfg is None:
|
||||||
|
@ -715,21 +712,12 @@ class CoreService(object):
|
||||||
# group string allows grouping services together
|
# group string allows grouping services together
|
||||||
group = None
|
group = None
|
||||||
|
|
||||||
# list name(s) of services that this service depends upon
|
|
||||||
depends = ()
|
|
||||||
|
|
||||||
# private, per-node directories required by this service
|
# private, per-node directories required by this service
|
||||||
dirs = ()
|
dirs = ()
|
||||||
|
|
||||||
# config files written by this service
|
# config files written by this service
|
||||||
configs = ()
|
configs = ()
|
||||||
|
|
||||||
# index used to determine start order with other services
|
|
||||||
startindex = 0
|
|
||||||
|
|
||||||
# time in seconds after runtime to run startup commands
|
|
||||||
starttime = 0
|
|
||||||
|
|
||||||
# list of startup commands
|
# list of startup commands
|
||||||
startup = ()
|
startup = ()
|
||||||
|
|
||||||
|
@ -762,12 +750,10 @@ class CoreService(object):
|
||||||
self.custom = True
|
self.custom = True
|
||||||
self.dirs = self.__class__.dirs
|
self.dirs = self.__class__.dirs
|
||||||
self.configs = self.__class__.configs
|
self.configs = self.__class__.configs
|
||||||
self.startindex = self.__class__.startindex
|
|
||||||
self.startup = self.__class__.startup
|
self.startup = self.__class__.startup
|
||||||
self.shutdown = self.__class__.shutdown
|
self.shutdown = self.__class__.shutdown
|
||||||
self.validate = self.__class__.validate
|
self.validate = self.__class__.validate
|
||||||
self.meta = self.__class__.meta
|
self.meta = self.__class__.meta
|
||||||
self.starttime = self.__class__.starttime
|
|
||||||
self.configtxt = self.__class__.configtxt
|
self.configtxt = self.__class__.configtxt
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -12,10 +12,8 @@ class Bird(CoreService):
|
||||||
name = "bird"
|
name = "bird"
|
||||||
executables = ("bird",)
|
executables = ("bird",)
|
||||||
group = "BIRD"
|
group = "BIRD"
|
||||||
depends = ()
|
|
||||||
dirs = ("/etc/bird",)
|
dirs = ("/etc/bird",)
|
||||||
configs = ("/etc/bird/bird.conf",)
|
configs = ("/etc/bird/bird.conf",)
|
||||||
startindex = 35
|
|
||||||
startup = ("bird -c %s" % (configs[0]),)
|
startup = ("bird -c %s" % (configs[0]),)
|
||||||
shutdown = ("killall bird",)
|
shutdown = ("killall bird",)
|
||||||
validate = ("pidof bird",)
|
validate = ("pidof bird",)
|
||||||
|
@ -78,7 +76,7 @@ protocol device {
|
||||||
|
|
||||||
# Generate protocol specific configurations
|
# Generate protocol specific configurations
|
||||||
for s in node.services:
|
for s in node.services:
|
||||||
if cls.name not in s.depends:
|
if cls.name not in s.dependencies:
|
||||||
continue
|
continue
|
||||||
cfg += s.generatebirdconfig(node)
|
cfg += s.generatebirdconfig(node)
|
||||||
|
|
||||||
|
@ -95,10 +93,8 @@ class BirdService(CoreService):
|
||||||
executables = ("bird",)
|
executables = ("bird",)
|
||||||
group = "BIRD"
|
group = "BIRD"
|
||||||
dependencies = ("bird",)
|
dependencies = ("bird",)
|
||||||
depends = ("bird",)
|
|
||||||
dirs = ()
|
dirs = ()
|
||||||
configs = ()
|
configs = ()
|
||||||
startindex = 40
|
|
||||||
startup = ()
|
startup = ()
|
||||||
shutdown = ()
|
shutdown = ()
|
||||||
meta = "The config file for this service can be found in the bird service."
|
meta = "The config file for this service can be found in the bird service."
|
||||||
|
|
|
@ -104,7 +104,7 @@ from core.service import ServiceManager
|
||||||
try:
|
try:
|
||||||
from docker import Client
|
from docker import Client
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logger.warns("missing python docker bindings")
|
logger.warn("missing python docker bindings")
|
||||||
|
|
||||||
|
|
||||||
class DockerService(CoreService):
|
class DockerService(CoreService):
|
||||||
|
@ -115,10 +115,8 @@ class DockerService(CoreService):
|
||||||
name = "Docker"
|
name = "Docker"
|
||||||
executables = ("docker",)
|
executables = ("docker",)
|
||||||
group = "Docker"
|
group = "Docker"
|
||||||
depends = ()
|
|
||||||
dirs = ('/var/lib/docker/containers/', '/run/shm', '/run/resolvconf',)
|
dirs = ('/var/lib/docker/containers/', '/run/shm', '/run/resolvconf',)
|
||||||
configs = ('docker.sh',)
|
configs = ('docker.sh',)
|
||||||
startindex = 50
|
|
||||||
startup = ('sh docker.sh',)
|
startup = ('sh docker.sh',)
|
||||||
shutdown = ('service docker stop',)
|
shutdown = ('service docker stop',)
|
||||||
# Container image to start
|
# Container image to start
|
||||||
|
|
|
@ -15,10 +15,8 @@ class NrlService(CoreService):
|
||||||
"""""
|
"""""
|
||||||
name = None
|
name = None
|
||||||
group = "ProtoSvc"
|
group = "ProtoSvc"
|
||||||
depends = ()
|
|
||||||
dirs = ()
|
dirs = ()
|
||||||
configs = ()
|
configs = ()
|
||||||
startindex = 45
|
|
||||||
startup = ()
|
startup = ()
|
||||||
shutdown = ()
|
shutdown = ()
|
||||||
|
|
||||||
|
@ -49,7 +47,6 @@ class MgenSinkService(NrlService):
|
||||||
name = "MGEN_Sink"
|
name = "MGEN_Sink"
|
||||||
executables = ("mgen",)
|
executables = ("mgen",)
|
||||||
configs = ("sink.mgen",)
|
configs = ("sink.mgen",)
|
||||||
startindex = 5
|
|
||||||
startup = ("mgen input sink.mgen",)
|
startup = ("mgen input sink.mgen",)
|
||||||
validate = ("pidof mgen",)
|
validate = ("pidof mgen",)
|
||||||
shutdown = ("killall mgen",)
|
shutdown = ("killall mgen",)
|
||||||
|
@ -581,15 +578,11 @@ class MgenActor(NrlService):
|
||||||
executables = ("mgen",)
|
executables = ("mgen",)
|
||||||
# you can create your own group here
|
# you can create your own group here
|
||||||
group = "ProtoSvc"
|
group = "ProtoSvc"
|
||||||
# list of other services this service depends on
|
|
||||||
depends = ()
|
|
||||||
# per-node directories
|
# per-node directories
|
||||||
dirs = ()
|
dirs = ()
|
||||||
# generated files (without a full path this file goes in the node's dir,
|
# generated files (without a full path this file goes in the node's dir,
|
||||||
# e.g. /tmp/pycore.12345/n1.conf/)
|
# e.g. /tmp/pycore.12345/n1.conf/)
|
||||||
configs = ('start_mgen_actor.sh',)
|
configs = ('start_mgen_actor.sh',)
|
||||||
# this controls the starting order vs other enabled services
|
|
||||||
startindex = 50
|
|
||||||
# list of startup commands, also may be generated during startup
|
# list of startup commands, also may be generated during startup
|
||||||
startup = ("sh start_mgen_actor.sh",)
|
startup = ("sh start_mgen_actor.sh",)
|
||||||
# list of validation commands
|
# list of validation commands
|
||||||
|
@ -625,7 +618,6 @@ class Arouted(NrlService):
|
||||||
name = "arouted"
|
name = "arouted"
|
||||||
executables = ("arouted",)
|
executables = ("arouted",)
|
||||||
configs = ("startarouted.sh",)
|
configs = ("startarouted.sh",)
|
||||||
startindex = NrlService.startindex + 10
|
|
||||||
startup = ("sh startarouted.sh",)
|
startup = ("sh startarouted.sh",)
|
||||||
shutdown = ("pkill arouted",)
|
shutdown = ("pkill arouted",)
|
||||||
validate = ("pidof arouted",)
|
validate = ("pidof arouted",)
|
||||||
|
|
|
@ -18,7 +18,6 @@ class Zebra(CoreService):
|
||||||
"quaggaboot.sh",
|
"quaggaboot.sh",
|
||||||
"/usr/local/etc/quagga/vtysh.conf"
|
"/usr/local/etc/quagga/vtysh.conf"
|
||||||
)
|
)
|
||||||
startindex = 35
|
|
||||||
startup = ("sh quaggaboot.sh zebra",)
|
startup = ("sh quaggaboot.sh zebra",)
|
||||||
shutdown = ("killall zebra",)
|
shutdown = ("killall zebra",)
|
||||||
validate = ("pidof zebra",)
|
validate = ("pidof zebra",)
|
||||||
|
@ -66,7 +65,7 @@ class Zebra(CoreService):
|
||||||
want_ipv4 = False
|
want_ipv4 = False
|
||||||
want_ipv6 = False
|
want_ipv6 = False
|
||||||
for s in node.services:
|
for s in node.services:
|
||||||
if cls.name not in s.depends:
|
if cls.name not in s.dependencies:
|
||||||
continue
|
continue
|
||||||
ifccfg = s.generatequaggaifcconfig(node, ifc)
|
ifccfg = s.generatequaggaifcconfig(node, ifc)
|
||||||
if s.ipv4_routing:
|
if s.ipv4_routing:
|
||||||
|
@ -92,7 +91,7 @@ class Zebra(CoreService):
|
||||||
cfg += "!\n"
|
cfg += "!\n"
|
||||||
|
|
||||||
for s in node.services:
|
for s in node.services:
|
||||||
if cls.name not in s.depends:
|
if cls.name not in s.dependencies:
|
||||||
continue
|
continue
|
||||||
cfg += s.generatequaggaconfig(node)
|
cfg += s.generatequaggaconfig(node)
|
||||||
return cfg
|
return cfg
|
||||||
|
@ -222,10 +221,8 @@ class QuaggaService(CoreService):
|
||||||
name = None
|
name = None
|
||||||
group = "Quagga"
|
group = "Quagga"
|
||||||
dependencies = ("zebra",)
|
dependencies = ("zebra",)
|
||||||
depends = ("zebra",)
|
|
||||||
dirs = ()
|
dirs = ()
|
||||||
configs = ()
|
configs = ()
|
||||||
startindex = 40
|
|
||||||
startup = ()
|
startup = ()
|
||||||
shutdown = ()
|
shutdown = ()
|
||||||
meta = "The config file for this service can be found in the Zebra service."
|
meta = "The config file for this service can be found in the Zebra service."
|
||||||
|
|
|
@ -12,7 +12,6 @@ class SdnService(CoreService):
|
||||||
Parent class for SDN services.
|
Parent class for SDN services.
|
||||||
"""
|
"""
|
||||||
group = "SDN"
|
group = "SDN"
|
||||||
startindex = 50
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generateconfig(cls, node, filename):
|
def generateconfig(cls, node, filename):
|
||||||
|
@ -23,10 +22,8 @@ class OvsService(SdnService):
|
||||||
name = "OvsService"
|
name = "OvsService"
|
||||||
executables = ("ovs-ofctl", "ovs-vsctl")
|
executables = ("ovs-ofctl", "ovs-vsctl")
|
||||||
group = "SDN"
|
group = "SDN"
|
||||||
depends = ()
|
|
||||||
dirs = ("/etc/openvswitch", "/var/run/openvswitch", "/var/log/openvswitch")
|
dirs = ("/etc/openvswitch", "/var/run/openvswitch", "/var/log/openvswitch")
|
||||||
configs = ('OvsService.sh',)
|
configs = ('OvsService.sh',)
|
||||||
startindex = 50
|
|
||||||
startup = ('sh OvsService.sh',)
|
startup = ('sh OvsService.sh',)
|
||||||
shutdown = ('killall ovs-vswitchd', 'killall ovsdb-server')
|
shutdown = ('killall ovs-vswitchd', 'killall ovsdb-server')
|
||||||
|
|
||||||
|
@ -98,10 +95,8 @@ class RyuService(SdnService):
|
||||||
name = "ryuService"
|
name = "ryuService"
|
||||||
executables = ("ryu-manager",)
|
executables = ("ryu-manager",)
|
||||||
group = "SDN"
|
group = "SDN"
|
||||||
depends = ()
|
|
||||||
dirs = ()
|
dirs = ()
|
||||||
configs = ('ryuService.sh',)
|
configs = ('ryuService.sh',)
|
||||||
startindex = 50
|
|
||||||
startup = ('sh ryuService.sh',)
|
startup = ('sh ryuService.sh',)
|
||||||
shutdown = ('killall ryu-manager',)
|
shutdown = ('killall ryu-manager',)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ class VPNClient(CoreService):
|
||||||
name = "VPNClient"
|
name = "VPNClient"
|
||||||
group = "Security"
|
group = "Security"
|
||||||
configs = ('vpnclient.sh',)
|
configs = ('vpnclient.sh',)
|
||||||
startindex = 60
|
|
||||||
startup = ('sh vpnclient.sh',)
|
startup = ('sh vpnclient.sh',)
|
||||||
shutdown = ("killall openvpn",)
|
shutdown = ("killall openvpn",)
|
||||||
validate = ("pidof openvpn",)
|
validate = ("pidof openvpn",)
|
||||||
|
@ -39,7 +38,6 @@ class VPNServer(CoreService):
|
||||||
name = "VPNServer"
|
name = "VPNServer"
|
||||||
group = "Security"
|
group = "Security"
|
||||||
configs = ('vpnserver.sh',)
|
configs = ('vpnserver.sh',)
|
||||||
startindex = 50
|
|
||||||
startup = ('sh vpnserver.sh',)
|
startup = ('sh vpnserver.sh',)
|
||||||
shutdown = ("killall openvpn",)
|
shutdown = ("killall openvpn",)
|
||||||
validate = ("pidof openvpn",)
|
validate = ("pidof openvpn",)
|
||||||
|
@ -67,7 +65,6 @@ class IPsec(CoreService):
|
||||||
name = "IPsec"
|
name = "IPsec"
|
||||||
group = "Security"
|
group = "Security"
|
||||||
configs = ('ipsec.sh',)
|
configs = ('ipsec.sh',)
|
||||||
startindex = 60
|
|
||||||
startup = ('sh ipsec.sh',)
|
startup = ('sh ipsec.sh',)
|
||||||
shutdown = ("killall racoon",)
|
shutdown = ("killall racoon",)
|
||||||
custom_needed = True
|
custom_needed = True
|
||||||
|
@ -95,7 +92,6 @@ class Firewall(CoreService):
|
||||||
name = "Firewall"
|
name = "Firewall"
|
||||||
group = "Security"
|
group = "Security"
|
||||||
configs = ('firewall.sh',)
|
configs = ('firewall.sh',)
|
||||||
startindex = 20
|
|
||||||
startup = ('sh firewall.sh',)
|
startup = ('sh firewall.sh',)
|
||||||
custom_needed = True
|
custom_needed = True
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,9 @@ UCARP_ETC = "/usr/local/etc/ucarp"
|
||||||
class Ucarp(CoreService):
|
class Ucarp(CoreService):
|
||||||
name = "ucarp"
|
name = "ucarp"
|
||||||
group = "Utility"
|
group = "Utility"
|
||||||
depends = ( )
|
|
||||||
dirs = (UCARP_ETC,)
|
dirs = (UCARP_ETC,)
|
||||||
configs = (
|
configs = (
|
||||||
UCARP_ETC + "/default.sh", UCARP_ETC + "/default-up.sh", UCARP_ETC + "/default-down.sh", "ucarpboot.sh",)
|
UCARP_ETC + "/default.sh", UCARP_ETC + "/default-up.sh", UCARP_ETC + "/default-down.sh", "ucarpboot.sh",)
|
||||||
startindex = 65
|
|
||||||
startup = ("sh ucarpboot.sh",)
|
startup = ("sh ucarpboot.sh",)
|
||||||
shutdown = ("killall ucarp",)
|
shutdown = ("killall ucarp",)
|
||||||
validate = ("pidof ucarp",)
|
validate = ("pidof ucarp",)
|
||||||
|
|
|
@ -18,10 +18,8 @@ class UtilService(CoreService):
|
||||||
"""
|
"""
|
||||||
name = None
|
name = None
|
||||||
group = "Utility"
|
group = "Utility"
|
||||||
depends = ()
|
|
||||||
dirs = ()
|
dirs = ()
|
||||||
configs = ()
|
configs = ()
|
||||||
startindex = 80
|
|
||||||
startup = ()
|
startup = ()
|
||||||
shutdown = ()
|
shutdown = ()
|
||||||
|
|
||||||
|
@ -33,7 +31,6 @@ class UtilService(CoreService):
|
||||||
class IPForwardService(UtilService):
|
class IPForwardService(UtilService):
|
||||||
name = "IPForward"
|
name = "IPForward"
|
||||||
configs = ("ipforward.sh",)
|
configs = ("ipforward.sh",)
|
||||||
startindex = 5
|
|
||||||
startup = ("sh ipforward.sh",)
|
startup = ("sh ipforward.sh",)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -574,7 +571,6 @@ class PcapService(UtilService):
|
||||||
name = "pcap"
|
name = "pcap"
|
||||||
configs = ("pcap.sh",)
|
configs = ("pcap.sh",)
|
||||||
dirs = ()
|
dirs = ()
|
||||||
startindex = 1
|
|
||||||
startup = ("sh pcap.sh start",)
|
startup = ("sh pcap.sh start",)
|
||||||
shutdown = ("sh pcap.sh stop",)
|
shutdown = ("sh pcap.sh stop",)
|
||||||
validate = ("pidof tcpdump",)
|
validate = ("pidof tcpdump",)
|
||||||
|
@ -693,5 +689,4 @@ class UserDefinedService(UtilService):
|
||||||
Dummy service allowing customization of anything.
|
Dummy service allowing customization of anything.
|
||||||
"""
|
"""
|
||||||
name = "UserDefined"
|
name = "UserDefined"
|
||||||
startindex = 50
|
|
||||||
meta = "Customize this service to do anything upon startup."
|
meta = "Customize this service to do anything upon startup."
|
||||||
|
|
|
@ -14,10 +14,8 @@ class XorpRtrmgr(CoreService):
|
||||||
name = "xorp_rtrmgr"
|
name = "xorp_rtrmgr"
|
||||||
executables = ("xorp_rtrmgr",)
|
executables = ("xorp_rtrmgr",)
|
||||||
group = "XORP"
|
group = "XORP"
|
||||||
depends = ()
|
|
||||||
dirs = ("/etc/xorp",)
|
dirs = ("/etc/xorp",)
|
||||||
configs = ("/etc/xorp/config.boot",)
|
configs = ("/etc/xorp/config.boot",)
|
||||||
startindex = 35
|
|
||||||
startup = ("xorp_rtrmgr -d -b %s -l /var/log/%s.log -P /var/run/%s.pid" % (configs[0], name, name),)
|
startup = ("xorp_rtrmgr -d -b %s -l /var/log/%s.log -P /var/run/%s.pid" % (configs[0], name, name),)
|
||||||
shutdown = ("killall xorp_rtrmgr",)
|
shutdown = ("killall xorp_rtrmgr",)
|
||||||
validate = ("pidof xorp_rtrmgr",)
|
validate = ("pidof xorp_rtrmgr",)
|
||||||
|
@ -41,7 +39,7 @@ class XorpRtrmgr(CoreService):
|
||||||
|
|
||||||
for s in node.services:
|
for s in node.services:
|
||||||
try:
|
try:
|
||||||
s.depends.index(cls.name)
|
s.dependencies.index(cls.name)
|
||||||
cfg += s.generatexorpconfig(node)
|
cfg += s.generatexorpconfig(node)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger.exception("error getting value from service: %s", cls.name)
|
logger.exception("error getting value from service: %s", cls.name)
|
||||||
|
@ -79,10 +77,8 @@ class XorpService(CoreService):
|
||||||
executables = ("xorp_rtrmgr",)
|
executables = ("xorp_rtrmgr",)
|
||||||
group = "XORP"
|
group = "XORP"
|
||||||
dependencies = ("xorp_rtrmgr",)
|
dependencies = ("xorp_rtrmgr",)
|
||||||
depends = ("xorp_rtrmgr",)
|
|
||||||
dirs = ()
|
dirs = ()
|
||||||
configs = ()
|
configs = ()
|
||||||
startindex = 40
|
|
||||||
startup = ()
|
startup = ()
|
||||||
shutdown = ()
|
shutdown = ()
|
||||||
meta = "The config file for this service can be found in the xorp_rtrmgr service."
|
meta = "The config file for this service can be found in the xorp_rtrmgr service."
|
||||||
|
|
|
@ -303,9 +303,6 @@ class CoreDocumentWriter0(Document):
|
||||||
s = self.createElement("Service")
|
s = self.createElement("Service")
|
||||||
spn.appendChild(s)
|
spn.appendChild(s)
|
||||||
s.setAttribute("name", str(svc.name))
|
s.setAttribute("name", str(svc.name))
|
||||||
s.setAttribute("startup_idx", str(svc.startindex))
|
|
||||||
if svc.starttime != "":
|
|
||||||
s.setAttribute("start_time", str(svc.starttime))
|
|
||||||
# only record service names if not a customized service
|
# only record service names if not a customized service
|
||||||
if not svc.custom:
|
if not svc.custom:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -681,9 +681,6 @@ class DeviceElement(NamedXmlElement):
|
||||||
s = self.createElement("service")
|
s = self.createElement("service")
|
||||||
spn.appendChild(s)
|
spn.appendChild(s)
|
||||||
s.setAttribute("name", str(svc.name))
|
s.setAttribute("name", str(svc.name))
|
||||||
s.setAttribute("startup_idx", str(svc.startindex))
|
|
||||||
if svc.starttime != "":
|
|
||||||
s.setAttribute("start_time", str(svc.starttime))
|
|
||||||
# only record service names if not a customized service
|
# only record service names if not a customized service
|
||||||
if not svc.custom:
|
if not svc.custom:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"level": "DEBUG",
|
"level": "INFO",
|
||||||
"handlers": ["console"]
|
"handlers": ["console"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,22 +14,22 @@ class MyService(CoreService):
|
||||||
name = "MyService"
|
name = "MyService"
|
||||||
# you can create your own group here
|
# you can create your own group here
|
||||||
group = "Utility"
|
group = "Utility"
|
||||||
|
# list executables that this service requires
|
||||||
|
executables = ()
|
||||||
# list of other services this service depends on
|
# list of other services this service depends on
|
||||||
depends = ()
|
dependencies = ()
|
||||||
# per-node directories
|
# per-node directories
|
||||||
dirs = ()
|
dirs = ()
|
||||||
# generated files (without a full path this file goes in the node's dir,
|
# generated files (without a full path this file goes in the node's dir,
|
||||||
# e.g. /tmp/pycore.12345/n1.conf/)
|
# e.g. /tmp/pycore.12345/n1.conf/)
|
||||||
configs = ('myservice.sh',)
|
configs = ("myservice.sh",)
|
||||||
# this controls the starting order vs other enabled services
|
|
||||||
startindex = 50
|
|
||||||
# list of startup commands, also may be generated during startup
|
# list of startup commands, also may be generated during startup
|
||||||
startup = ('sh myservice.sh',)
|
startup = ("sh myservice.sh",)
|
||||||
# list of shutdown commands
|
# list of shutdown commands
|
||||||
shutdown = ()
|
shutdown = ()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generateconfig(cls, node, filename, services):
|
def generateconfig(cls, node, filename):
|
||||||
"""
|
"""
|
||||||
Return a string that will be written to filename, or sent to the
|
Return a string that will be written to filename, or sent to the
|
||||||
GUI for user customization.
|
GUI for user customization.
|
||||||
|
|
|
@ -8,20 +8,12 @@ from core.service import CoreService
|
||||||
class MyService(CoreService):
|
class MyService(CoreService):
|
||||||
name = "MyService"
|
name = "MyService"
|
||||||
group = "Utility"
|
group = "Utility"
|
||||||
depends = ()
|
configs = ("myservice.sh",)
|
||||||
dirs = ()
|
startup = ("sh myservice.sh",)
|
||||||
configs = ('myservice.sh',)
|
|
||||||
startindex = 50
|
|
||||||
startup = ('sh myservice.sh',)
|
|
||||||
shutdown = ()
|
|
||||||
|
|
||||||
|
|
||||||
class MyService2(CoreService):
|
class MyService2(CoreService):
|
||||||
name = "MyService2"
|
name = "MyService2"
|
||||||
group = "Utility"
|
group = "Utility"
|
||||||
depends = ()
|
configs = ("myservice.sh",)
|
||||||
dirs = ()
|
startup = ("sh myservice.sh",)
|
||||||
configs = ('myservice.sh',)
|
|
||||||
startindex = 50
|
|
||||||
startup = ('sh myservice.sh',)
|
|
||||||
shutdown = ()
|
|
||||||
|
|
|
@ -92,11 +92,8 @@ class TestXml:
|
||||||
interface = ip_prefixes.create_interface(node)
|
interface = ip_prefixes.create_interface(node)
|
||||||
session.add_link(node.objid, ptp_node.objid, interface_one=interface)
|
session.add_link(node.objid, ptp_node.objid, interface_one=interface)
|
||||||
|
|
||||||
# set custom values for node service\
|
# set custom values for node service
|
||||||
custom_start = 50
|
|
||||||
session.services.setcustomservice(node_one.objid, SshService.name)
|
session.services.setcustomservice(node_one.objid, SshService.name)
|
||||||
service = session.services.getcustomservice(node_one.objid, SshService.name)
|
|
||||||
service.startindex = custom_start
|
|
||||||
service_file = SshService.configs[0]
|
service_file = SshService.configs[0]
|
||||||
file_data = "# test"
|
file_data = "# test"
|
||||||
session.services.setservicefile(node_one.objid, SshService.name, service_file, file_data)
|
session.services.setservicefile(node_one.objid, SshService.name, service_file, file_data)
|
||||||
|
@ -135,7 +132,6 @@ class TestXml:
|
||||||
# verify nodes have been recreated
|
# verify nodes have been recreated
|
||||||
assert session.get_object(n1_id)
|
assert session.get_object(n1_id)
|
||||||
assert session.get_object(n2_id)
|
assert session.get_object(n2_id)
|
||||||
assert service.startindex == custom_start
|
|
||||||
assert service.configtxt.get(service_file) == file_data
|
assert service.configtxt.get(service_file) == file_data
|
||||||
|
|
||||||
@pytest.mark.parametrize("version", _XML_VERSIONS)
|
@pytest.mark.parametrize("version", _XML_VERSIONS)
|
||||||
|
|
Loading…
Add table
Reference in a new issue