diff --git a/daemon/core/mobility.py b/daemon/core/mobility.py index 46f1f966..abc8bf55 100644 --- a/daemon/core/mobility.py +++ b/daemon/core/mobility.py @@ -471,12 +471,12 @@ class BasicRangeModel(WirelessModel): a.name, b.name, linked, d, self.range) if d > self.range: if linked: - logger.info("was linked, unlinking") + logger.debug("was linked, unlinking") self.wlan.unlink(a, b) self.sendlinkmsg(a, b, unlink=True) else: if not linked: - logger.info("was not linked, linking") + logger.debug("was not linked, linking") self.wlan.link(a, b) self.sendlinkmsg(a, b) except KeyError: diff --git a/daemon/core/netns/vnet.py b/daemon/core/netns/vnet.py index 7a517d08..af5d8ffc 100644 --- a/daemon/core/netns/vnet.py +++ b/daemon/core/netns/vnet.py @@ -440,7 +440,7 @@ class LxBrNet(PyCoreNet): "burst", str(burst), "limit", str(limit)] if bw > 0: 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) netif.setparam("has_tbf", True) changed = True @@ -485,12 +485,12 @@ class LxBrNet(PyCoreNet): return tc[2] = "delete" 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:"]) netif.setparam("has_netem", False) elif len(netem) > 1: 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) netif.setparam("has_netem", True) diff --git a/daemon/core/service.py b/daemon/core/service.py index fa45f149..878e8e58 100644 --- a/daemon/core/service.py +++ b/daemon/core/service.py @@ -45,12 +45,13 @@ class ServiceShim(object): :return: value list string :rtype: str """ - valmap = [service.dirs, service.configs, service.startindex, service.startup, - service.shutdown, service.validate, service.meta, service.starttime] + start_time = 0 + start_index = 0 + valmap = [service.dirs, service.configs, start_index, service.startup, + service.shutdown, service.validate, service.meta, start_time] if not service.custom: - # this is always reached due to classmethod - valmap[valmap.index(service.configs)] = service.getconfigfilenames(node) - valmap[valmap.index(service.startup)] = service.getstartup(node) + valmap[1] = service.getconfigfilenames(node) + valmap[3] = service.getstartup(node) vals = map(lambda a, b: "%s=%s" % (a, str(b)), cls.keys, valmap) return "|".join(vals) @@ -97,8 +98,6 @@ class ServiceShim(object): service.dirs = value elif key == "files": service.configs = value - elif key == "startidx": - service.startindex = value elif key == "cmdup": service.startup = value elif key == "cmddown": @@ -107,8 +106,6 @@ class ServiceShim(object): service.validate = value elif key == "meta": service.meta = value - elif key == "starttime": - service.starttime = value @classmethod def servicesfromopaque(cls, opaque): @@ -422,7 +419,7 @@ class CoreServices(object): result.get() 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: self.bootnodeservice(node, service) @@ -435,7 +432,7 @@ class CoreServices(object): :param CoreService service: service to start :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 for directory in service.dirs: @@ -501,14 +498,14 @@ class CoreServices(object): :return: service validation status :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 if not service.custom: cmds = service.getvalidate(node) status = 0 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: node.check_cmd(cmd) except CoreCommandError: @@ -524,8 +521,7 @@ class CoreServices(object): :param core.netns.nodes.CoreNode node: node to stop services on :return: nothing """ - services = sorted(node.services, key=lambda x: x.startindex) - for service in services: + for service in node.services: self.stopnodeservice(node, service) def stopnodeservice(self, node, service): @@ -651,13 +647,14 @@ class CoreServices(object): :param CoreService service: service to reconfigure :return: nothing """ + logger.info("node(%s) service(%s) creating config files", node.name, service.name) # get values depending on if custom or not file_names = service.configs if not service.custom: file_names = service.getconfigfilenames(node) 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: cfg = service.configtxt.get(file_name) if cfg is None: @@ -715,21 +712,12 @@ class CoreService(object): # group string allows grouping services together group = None - # list name(s) of services that this service depends upon - depends = () - # private, per-node directories required by this service dirs = () # config files written by this service 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 startup = () @@ -762,12 +750,10 @@ class CoreService(object): self.custom = True self.dirs = self.__class__.dirs self.configs = self.__class__.configs - self.startindex = self.__class__.startindex self.startup = self.__class__.startup self.shutdown = self.__class__.shutdown self.validate = self.__class__.validate self.meta = self.__class__.meta - self.starttime = self.__class__.starttime self.configtxt = self.__class__.configtxt @classmethod diff --git a/daemon/core/services/bird.py b/daemon/core/services/bird.py index a869fe7c..381a0390 100644 --- a/daemon/core/services/bird.py +++ b/daemon/core/services/bird.py @@ -12,10 +12,8 @@ class Bird(CoreService): name = "bird" executables = ("bird",) group = "BIRD" - depends = () dirs = ("/etc/bird",) configs = ("/etc/bird/bird.conf",) - startindex = 35 startup = ("bird -c %s" % (configs[0]),) shutdown = ("killall bird",) validate = ("pidof bird",) @@ -78,7 +76,7 @@ protocol device { # Generate protocol specific configurations for s in node.services: - if cls.name not in s.depends: + if cls.name not in s.dependencies: continue cfg += s.generatebirdconfig(node) @@ -95,10 +93,8 @@ class BirdService(CoreService): executables = ("bird",) group = "BIRD" dependencies = ("bird",) - depends = ("bird",) dirs = () configs = () - startindex = 40 startup = () shutdown = () meta = "The config file for this service can be found in the bird service." diff --git a/daemon/core/services/dockersvc.py b/daemon/core/services/dockersvc.py index 797a29e6..e4ee597e 100644 --- a/daemon/core/services/dockersvc.py +++ b/daemon/core/services/dockersvc.py @@ -104,7 +104,7 @@ from core.service import ServiceManager try: from docker import Client except ImportError: - logger.warns("missing python docker bindings") + logger.warn("missing python docker bindings") class DockerService(CoreService): @@ -115,10 +115,8 @@ class DockerService(CoreService): name = "Docker" executables = ("docker",) group = "Docker" - depends = () dirs = ('/var/lib/docker/containers/', '/run/shm', '/run/resolvconf',) configs = ('docker.sh',) - startindex = 50 startup = ('sh docker.sh',) shutdown = ('service docker stop',) # Container image to start diff --git a/daemon/core/services/nrl.py b/daemon/core/services/nrl.py index cf5e1d9c..50b17b38 100644 --- a/daemon/core/services/nrl.py +++ b/daemon/core/services/nrl.py @@ -15,10 +15,8 @@ class NrlService(CoreService): """"" name = None group = "ProtoSvc" - depends = () dirs = () configs = () - startindex = 45 startup = () shutdown = () @@ -49,7 +47,6 @@ class MgenSinkService(NrlService): name = "MGEN_Sink" executables = ("mgen",) configs = ("sink.mgen",) - startindex = 5 startup = ("mgen input sink.mgen",) validate = ("pidof mgen",) shutdown = ("killall mgen",) @@ -581,15 +578,11 @@ class MgenActor(NrlService): executables = ("mgen",) # you can create your own group here group = "ProtoSvc" - # 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 = ('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 startup = ("sh start_mgen_actor.sh",) # list of validation commands @@ -625,7 +618,6 @@ class Arouted(NrlService): name = "arouted" executables = ("arouted",) configs = ("startarouted.sh",) - startindex = NrlService.startindex + 10 startup = ("sh startarouted.sh",) shutdown = ("pkill arouted",) validate = ("pidof arouted",) diff --git a/daemon/core/services/quagga.py b/daemon/core/services/quagga.py index 79e607f2..8919832a 100644 --- a/daemon/core/services/quagga.py +++ b/daemon/core/services/quagga.py @@ -18,7 +18,6 @@ class Zebra(CoreService): "quaggaboot.sh", "/usr/local/etc/quagga/vtysh.conf" ) - startindex = 35 startup = ("sh quaggaboot.sh zebra",) shutdown = ("killall zebra",) validate = ("pidof zebra",) @@ -66,7 +65,7 @@ class Zebra(CoreService): want_ipv4 = False want_ipv6 = False for s in node.services: - if cls.name not in s.depends: + if cls.name not in s.dependencies: continue ifccfg = s.generatequaggaifcconfig(node, ifc) if s.ipv4_routing: @@ -92,7 +91,7 @@ class Zebra(CoreService): cfg += "!\n" for s in node.services: - if cls.name not in s.depends: + if cls.name not in s.dependencies: continue cfg += s.generatequaggaconfig(node) return cfg @@ -222,10 +221,8 @@ class QuaggaService(CoreService): name = None group = "Quagga" dependencies = ("zebra",) - depends = ("zebra",) dirs = () configs = () - startindex = 40 startup = () shutdown = () meta = "The config file for this service can be found in the Zebra service." diff --git a/daemon/core/services/sdn.py b/daemon/core/services/sdn.py index c9769278..4229175c 100644 --- a/daemon/core/services/sdn.py +++ b/daemon/core/services/sdn.py @@ -12,7 +12,6 @@ class SdnService(CoreService): Parent class for SDN services. """ group = "SDN" - startindex = 50 @classmethod def generateconfig(cls, node, filename): @@ -23,10 +22,8 @@ class OvsService(SdnService): name = "OvsService" executables = ("ovs-ofctl", "ovs-vsctl") group = "SDN" - depends = () dirs = ("/etc/openvswitch", "/var/run/openvswitch", "/var/log/openvswitch") configs = ('OvsService.sh',) - startindex = 50 startup = ('sh OvsService.sh',) shutdown = ('killall ovs-vswitchd', 'killall ovsdb-server') @@ -98,10 +95,8 @@ class RyuService(SdnService): name = "ryuService" executables = ("ryu-manager",) group = "SDN" - depends = () dirs = () configs = ('ryuService.sh',) - startindex = 50 startup = ('sh ryuService.sh',) shutdown = ('killall ryu-manager',) diff --git a/daemon/core/services/security.py b/daemon/core/services/security.py index be3db917..177ce71d 100644 --- a/daemon/core/services/security.py +++ b/daemon/core/services/security.py @@ -12,7 +12,6 @@ class VPNClient(CoreService): name = "VPNClient" group = "Security" configs = ('vpnclient.sh',) - startindex = 60 startup = ('sh vpnclient.sh',) shutdown = ("killall openvpn",) validate = ("pidof openvpn",) @@ -39,7 +38,6 @@ class VPNServer(CoreService): name = "VPNServer" group = "Security" configs = ('vpnserver.sh',) - startindex = 50 startup = ('sh vpnserver.sh',) shutdown = ("killall openvpn",) validate = ("pidof openvpn",) @@ -67,7 +65,6 @@ class IPsec(CoreService): name = "IPsec" group = "Security" configs = ('ipsec.sh',) - startindex = 60 startup = ('sh ipsec.sh',) shutdown = ("killall racoon",) custom_needed = True @@ -95,7 +92,6 @@ class Firewall(CoreService): name = "Firewall" group = "Security" configs = ('firewall.sh',) - startindex = 20 startup = ('sh firewall.sh',) custom_needed = True diff --git a/daemon/core/services/ucarp.py b/daemon/core/services/ucarp.py index 80786999..686f3646 100644 --- a/daemon/core/services/ucarp.py +++ b/daemon/core/services/ucarp.py @@ -10,11 +10,9 @@ UCARP_ETC = "/usr/local/etc/ucarp" class Ucarp(CoreService): name = "ucarp" group = "Utility" - depends = ( ) dirs = (UCARP_ETC,) configs = ( UCARP_ETC + "/default.sh", UCARP_ETC + "/default-up.sh", UCARP_ETC + "/default-down.sh", "ucarpboot.sh",) - startindex = 65 startup = ("sh ucarpboot.sh",) shutdown = ("killall ucarp",) validate = ("pidof ucarp",) diff --git a/daemon/core/services/utility.py b/daemon/core/services/utility.py index 79f35c16..ff770a64 100644 --- a/daemon/core/services/utility.py +++ b/daemon/core/services/utility.py @@ -18,10 +18,8 @@ class UtilService(CoreService): """ name = None group = "Utility" - depends = () dirs = () configs = () - startindex = 80 startup = () shutdown = () @@ -33,7 +31,6 @@ class UtilService(CoreService): class IPForwardService(UtilService): name = "IPForward" configs = ("ipforward.sh",) - startindex = 5 startup = ("sh ipforward.sh",) @classmethod @@ -574,7 +571,6 @@ class PcapService(UtilService): name = "pcap" configs = ("pcap.sh",) dirs = () - startindex = 1 startup = ("sh pcap.sh start",) shutdown = ("sh pcap.sh stop",) validate = ("pidof tcpdump",) @@ -693,5 +689,4 @@ class UserDefinedService(UtilService): Dummy service allowing customization of anything. """ name = "UserDefined" - startindex = 50 meta = "Customize this service to do anything upon startup." diff --git a/daemon/core/services/xorp.py b/daemon/core/services/xorp.py index 58668b1f..7bd5b963 100644 --- a/daemon/core/services/xorp.py +++ b/daemon/core/services/xorp.py @@ -14,10 +14,8 @@ class XorpRtrmgr(CoreService): name = "xorp_rtrmgr" executables = ("xorp_rtrmgr",) group = "XORP" - depends = () dirs = ("/etc/xorp",) 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),) shutdown = ("killall xorp_rtrmgr",) validate = ("pidof xorp_rtrmgr",) @@ -41,7 +39,7 @@ class XorpRtrmgr(CoreService): for s in node.services: try: - s.depends.index(cls.name) + s.dependencies.index(cls.name) cfg += s.generatexorpconfig(node) except ValueError: logger.exception("error getting value from service: %s", cls.name) @@ -79,10 +77,8 @@ class XorpService(CoreService): executables = ("xorp_rtrmgr",) group = "XORP" dependencies = ("xorp_rtrmgr",) - depends = ("xorp_rtrmgr",) dirs = () configs = () - startindex = 40 startup = () shutdown = () meta = "The config file for this service can be found in the xorp_rtrmgr service." diff --git a/daemon/core/xml/xmlwriter0.py b/daemon/core/xml/xmlwriter0.py index 41f097fc..57085c5e 100644 --- a/daemon/core/xml/xmlwriter0.py +++ b/daemon/core/xml/xmlwriter0.py @@ -303,9 +303,6 @@ class CoreDocumentWriter0(Document): s = self.createElement("Service") spn.appendChild(s) 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 if not svc.custom: continue diff --git a/daemon/core/xml/xmlwriter1.py b/daemon/core/xml/xmlwriter1.py index 22c03a23..452a395e 100644 --- a/daemon/core/xml/xmlwriter1.py +++ b/daemon/core/xml/xmlwriter1.py @@ -681,9 +681,6 @@ class DeviceElement(NamedXmlElement): s = self.createElement("service") spn.appendChild(s) 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 if not svc.custom: continue diff --git a/daemon/data/logging.conf b/daemon/data/logging.conf index 46de6e92..7f3d496f 100644 --- a/daemon/data/logging.conf +++ b/daemon/data/logging.conf @@ -14,7 +14,7 @@ } }, "root": { - "level": "DEBUG", + "level": "INFO", "handlers": ["console"] } } diff --git a/daemon/examples/myservices/sample.py b/daemon/examples/myservices/sample.py index bc5113ee..a7def96a 100644 --- a/daemon/examples/myservices/sample.py +++ b/daemon/examples/myservices/sample.py @@ -14,22 +14,22 @@ class MyService(CoreService): name = "MyService" # you can create your own group here group = "Utility" + # list executables that this service requires + executables = () # list of other services this service depends on - depends = () + dependencies = () # 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 = ('myservice.sh',) - # this controls the starting order vs other enabled services - startindex = 50 + configs = ("myservice.sh",) # list of startup commands, also may be generated during startup - startup = ('sh myservice.sh',) + startup = ("sh myservice.sh",) # list of shutdown commands shutdown = () @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 GUI for user customization. diff --git a/daemon/tests/myservices/sample.py b/daemon/tests/myservices/sample.py index 80545d29..633670bc 100644 --- a/daemon/tests/myservices/sample.py +++ b/daemon/tests/myservices/sample.py @@ -8,20 +8,12 @@ from core.service import CoreService class MyService(CoreService): name = "MyService" group = "Utility" - depends = () - dirs = () - configs = ('myservice.sh',) - startindex = 50 - startup = ('sh myservice.sh',) - shutdown = () + configs = ("myservice.sh",) + startup = ("sh myservice.sh",) class MyService2(CoreService): name = "MyService2" group = "Utility" - depends = () - dirs = () - configs = ('myservice.sh',) - startindex = 50 - startup = ('sh myservice.sh',) - shutdown = () + configs = ("myservice.sh",) + startup = ("sh myservice.sh",) diff --git a/daemon/tests/test_xml.py b/daemon/tests/test_xml.py index f3fe8660..212f2de9 100644 --- a/daemon/tests/test_xml.py +++ b/daemon/tests/test_xml.py @@ -92,11 +92,8 @@ class TestXml: interface = ip_prefixes.create_interface(node) session.add_link(node.objid, ptp_node.objid, interface_one=interface) - # set custom values for node service\ - custom_start = 50 + # set custom values for node service 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] file_data = "# test" session.services.setservicefile(node_one.objid, SshService.name, service_file, file_data) @@ -135,7 +132,6 @@ class TestXml: # verify nodes have been recreated assert session.get_object(n1_id) assert session.get_object(n2_id) - assert service.startindex == custom_start assert service.configtxt.get(service_file) == file_data @pytest.mark.parametrize("version", _XML_VERSIONS)