Move configuration keys to /config tree

This commit is contained in:
2021-06-01 10:40:32 -04:00
parent d6a8cf9780
commit 33a54cf7f2
9 changed files with 67 additions and 32 deletions

View File

@ -268,7 +268,7 @@ class API_Initialize(Resource):
"""
Initialize a new PVC cluster
If the 'overwrite' option is not True, the cluster will return 400 if the `/primary_node` key is found. If 'overwrite' is True, the existing cluster
If the 'overwrite' option is not True, the cluster will return 400 if the `/config/primary_node` key is found. If 'overwrite' is True, the existing cluster
data will be erased and new, empty data written in its place.
All node daemons should be stopped before running this command, and the API daemon started manually to avoid undefined behavior.

View File

@ -46,15 +46,16 @@ def initialize_cluster(zkhandler, overwrite=False):
Initialize a new cluster
"""
# Abort if we've initialized the cluster before
if zkhandler.exists('/primary_node') and not overwrite:
if zkhandler.exists('/config/primary_node') and not overwrite:
return False
if overwrite:
# Delete the existing keys; ignore any errors
status = zkhandler.delete([
'/primary_node',
'/upstream_ip',
'/maintenance',
'/config'
'/config/primary_node',
'/config/upstream_ip',
'/config/maintenance',
'/nodes',
'/domains',
'/networks',
@ -76,9 +77,10 @@ def initialize_cluster(zkhandler, overwrite=False):
# Create the root keys
status = zkhandler.write([
('/primary_node', 'none'),
('/upstream_ip', 'none'),
('/maintenance', 'False'),
('/config', ''),
('/config/primary_node', 'none'),
('/config/upstream_ip', 'none'),
('/config/maintenance', 'False'),
('/nodes', ''),
('/domains', ''),
('/networks', ''),