updates to use dependency based startup logic

This commit is contained in:
Blake J. Harnden 2018-06-21 11:20:08 -07:00
parent 08956e7b93
commit b868454b5e
5 changed files with 15 additions and 16 deletions

View file

@ -414,18 +414,9 @@ class CoreServices(object):
results = []
services = sorted(node.services, key=lambda x: x.startindex)
for service in services:
if len(str(service.starttime)) > 0:
try:
starttime = float(service.starttime)
if starttime > 0.0:
fn = self.bootnodeservice
self.session.event_loop.add_event(starttime, fn, node, service, services, False)
continue
except ValueError:
logger.exception("error converting start time to float")
# self.bootnodeservice(node, service, services)
result = pool.apply_async(self.bootnodeservice, (node, service, services))
boot_paths = self.node_service_dependencies(services)
for boot_path in boot_paths:
result = pool.apply_async(self.boot_node_dependencies, (node, boot_path, services))
results.append(result)
pool.close()
@ -433,6 +424,11 @@ class CoreServices(object):
for result in results:
result.get()
def boot_node_dependencies(self, node, boot_path, all_services):
logger.info("booting node service dependencies: %s", boot_path)
for service in boot_path:
self.bootnodeservice(node, service, all_services)
def bootnodeservice(self, node, service, services):
"""
Start a service on a node. Create private dirs, generate config
@ -518,11 +514,11 @@ class CoreServices(object):
status = 0
for cmd in cmds:
logger.info("validating service %s using: %s", service.name, cmd)
logger.info("validating service(%s) using: %s", service.name, cmd)
try:
node.check_cmd(cmd)
except CoreCommandError:
logger.exception("validate command failed")
except CoreCommandError as e:
logger.exception("node(%s) service(%s) validate command failed", node.name, service.name)
status = -1
return status

View file

@ -94,6 +94,7 @@ class BirdService(CoreService):
name = None
executables = ("bird",)
group = "BIRD"
dependencies = ("bird",)
depends = ("bird",)
dirs = ()
configs = ()

View file

@ -104,7 +104,7 @@ from core.service import ServiceManager
try:
from docker import Client
except ImportError:
logger.error("failure to import docker")
logger.warns("missing python docker bindings")
class DockerService(CoreService):

View file

@ -222,6 +222,7 @@ class QuaggaService(CoreService):
"""
name = None
group = "Quagga"
dependencies = ("zebra",)
depends = ("zebra",)
dirs = ()
configs = ()

View file

@ -78,6 +78,7 @@ class XorpService(CoreService):
name = None
executables = ("xorp_rtrmgr",)
group = "XORP"
dependencies = ("xorp_rtrmgr",)
depends = ("xorp_rtrmgr",)
dirs = ()
configs = ()