From aee130f65f6becc98ff478608b62eafbc6d3bd36 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Sun, 17 Mar 2019 01:45:17 -0400 Subject: [PATCH] Handle the starting of all daemons better --- node-daemon/pvcd/Daemon.py | 49 +++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/node-daemon/pvcd/Daemon.py b/node-daemon/pvcd/Daemon.py index 1f1e8e02..3c92a4cb 100644 --- a/node-daemon/pvcd/Daemon.py +++ b/node-daemon/pvcd/Daemon.py @@ -365,7 +365,7 @@ if enable_networking: common.run_os_command('ip route add default via {} dev {}'.format(upstream_dev_gateway, upstream_dev)) ############################################################################### -# PHASE 3 - Determine coordinator mode and start Zookeeper on coordinators +# PHASE 3a - Determine coordinator mode ############################################################################### # What is the list of coordinator hosts @@ -375,12 +375,37 @@ if myhostname in coordinator_nodes: # We are indeed a coordinator host config['daemon_mode'] = 'coordinator' # Start the zookeeper service using systemctl - logger.out('Node is a ' + logger.fmt_blue + 'coordinator' + logger.fmt_end +'; starting Zookeeper daemon', state='i') - common.run_os_command('systemctl start zookeeper.service') - time.sleep(1) + logger.out('Node is a ' + logger.fmt_blue + 'coordinator' + logger.fmt_end, state='i') else: config['daemon_mode'] = 'hypervisor' +############################################################################### +# PHASE 3b - Start system daemons +############################################################################### +if config['daemon_mode'] == 'coordinator': + logger.out('Starting Zookeeper daemon', state='i') + common.run_os_command('systemctl start zookeeper.service') + +if enable_hypervisor: + logger.out('Starting Libvirt daemon', state='i') + common.run_os_command('systemctl start libvirtd.service') + +if enable_networking: + if config['daemon_mode'] == 'coordinator': + logger.out('Starting MariaDB daemon', state='i') + common.run_os_command('systemctl start mariadb.service') + logger.out('Starting FRRouting daemon', state='i') + common.run_os_command('systemctl start frr.service') + +if enable_storage: + if config['daemon_mode'] == 'coordinator': + logger.out('Starting Ceph monitor daemon', state='i') + common.run_os_command('systemctl start ceph-mon@{}'.format(myhostname)) + logger.out('Starting Ceph manager daemon', state='i') + common.run_os_command('systemctl start ceph-mgr@{}'.format(myhostname)) + +time.sleep(1) + ############################################################################### # PHASE 4 - Attempt to connect to the coordinators and start zookeeper client ############################################################################### @@ -527,15 +552,10 @@ else: zkhandler.writedata(zk_conn, { '/primary_node': myhostname }) ############################################################################### -# PHASE 7a - Ensure Libvirt is running on the local host +# PHASE 7 - Ensure Libvirt is working ############################################################################### if enable_hypervisor: - # Start the zookeeper service using systemctl - logger.out('Starting Libvirt daemon', state='i') - common.run_os_command('systemctl start libvirtd.service') - time.sleep(1) - # Check that libvirtd is listening TCP libvirt_check_name = "qemu+tcp://127.0.0.1:16509/system" logger.out('Connecting to Libvirt daemon at {}'.format(libvirt_check_name), state='i') @@ -546,15 +566,6 @@ if enable_hypervisor: logger.out('ERROR: Failed to connect to Libvirt daemon: {}'.format(e), state='e') exit(1) -############################################################################### -# PHASE 7b - Ensure Ceph is running on the local host -############################################################################### - -if enable_storage: - if config['daemon_mode'] == 'coordinator': - common.run_os_command('systemctl start ceph-mon@{}'.format(myhostname)) - common.run_os_command('systemctl start ceph-mgr@{}'.format(myhostname)) - ############################################################################### # PHASE 7c - Ensure NFT is running on the local host ###############################################################################