Enable autostart of API client on Primary

Adds a config flag that turns on the API client following the Primary
coordinator. The retcode of the start/stop commands is ignore so this
can fail gracefully if e.g. the client isn't installed.
This commit is contained in:
Joshua Boniface 2019-07-06 02:42:56 -04:00
parent 837b47c366
commit 8216125b02
3 changed files with 7 additions and 0 deletions

View File

@ -21,6 +21,8 @@ pvc:
enable_networking: True enable_networking: True
# enable_storage: Enable or disable Ceph storage management functionality # enable_storage: Enable or disable Ceph storage management functionality
enable_storage: True enable_storage: True
# enable_api: Enable or disable the API client, if installed, when node is Primary
enable_api: True
# cluster: Cluster-level configuration # cluster: Cluster-level configuration
cluster: cluster:
# coordinators: The list of cluster coordinator hostnames # coordinators: The list of cluster coordinator hostnames

View File

@ -139,6 +139,7 @@ def readConfig(pvcd_config_file, myhostname):
'enable_hypervisor': o_config['pvc']['functions']['enable_hypervisor'], 'enable_hypervisor': o_config['pvc']['functions']['enable_hypervisor'],
'enable_networking': o_config['pvc']['functions']['enable_networking'], 'enable_networking': o_config['pvc']['functions']['enable_networking'],
'enable_storage': o_config['pvc']['functions']['enable_storage'], 'enable_storage': o_config['pvc']['functions']['enable_storage'],
'enable_api': o_config['pvc']['functions']['enable_api'],
'dynamic_directory': o_config['pvc']['system']['configuration']['directories']['dynamic_directory'], 'dynamic_directory': o_config['pvc']['system']['configuration']['directories']['dynamic_directory'],
'log_directory': o_config['pvc']['system']['configuration']['directories']['log_directory'], 'log_directory': o_config['pvc']['system']['configuration']['directories']['log_directory'],
'console_log_directory': o_config['pvc']['system']['configuration']['directories']['console_log_directory'], 'console_log_directory': o_config['pvc']['system']['configuration']['directories']['console_log_directory'],

View File

@ -254,6 +254,8 @@ class NodeInstance(object):
self.logger.out('Setting router {} to secondary state'.format(self.name), state='i') self.logger.out('Setting router {} to secondary state'.format(self.name), state='i')
self.logger.out('Network list: {}'.format(', '.join(self.network_list))) self.logger.out('Network list: {}'.format(', '.join(self.network_list)))
time.sleep(2) time.sleep(2)
if self.config['enable_api']:
common.run_os_command("systemctl stop pvc-api.service")
for network in self.d_network: for network in self.d_network:
self.d_network[network].stopDHCPServer() self.d_network[network].stopDHCPServer()
self.d_network[network].removeGateways() self.d_network[network].removeGateways()
@ -269,6 +271,8 @@ class NodeInstance(object):
for network in self.d_network: for network in self.d_network:
self.d_network[network].createGateways() self.d_network[network].createGateways()
self.d_network[network].startDHCPServer() self.d_network[network].startDHCPServer()
if self.config['enable_api']:
common.run_os_command("systemctl start pvc-api.service")
time.sleep(1) time.sleep(1)
# Force Patroni to switch to the local instance # Force Patroni to switch to the local instance
self.logger.out('Setting Patroni leader to this node', state='i') self.logger.out('Setting Patroni leader to this node', state='i')