Add Zookeeper schema manager to zkhandler
Adds a new class, ZKSchema, to handle schema management in Zookeeper in an automated and consistent way. This should solve several issues: 1. Pain in managing changes to ZK keys 2. Pain in handling those changes during live upgrades 3. Simplifying the codebase to remove hardcoded ZK paths The current master schema for PVC 0.9.19 is committed as version 0. Addresses #129
This commit is contained in:
43
node-daemon/test-schema.py
Executable file
43
node-daemon/test-schema.py
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
import sys
|
||||
import datetime
|
||||
from daemon_lib.zkhandler import ZKHandler, ZKSchema
|
||||
|
||||
ZKSchema.write()
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
print(datetime.datetime.now())
|
||||
zkhandler = ZKHandler({'coordinators': ['hv1.tc', 'hv2.tc', 'hv3.tc']})
|
||||
zkhandler.connect()
|
||||
print(datetime.datetime.now())
|
||||
|
||||
zkschema = ZKSchema.load_current(zkhandler)
|
||||
|
||||
#print(zkschema.path('base.schema.version'))
|
||||
#print(zkschema.path('node.state.daemon', 'hv1'))
|
||||
#print(zkschema.path('domain.state', 'test1'))
|
||||
#print(zkschema.keys('base'))
|
||||
#print(zkschema.keys('node'))
|
||||
|
||||
|
||||
zkschema.validate(zkhandler)
|
||||
zkschema.apply(zkhandler)
|
||||
|
||||
zkschema_latest = ZKSchema()
|
||||
#if zkschema < zkschema_latest:
|
||||
# print("I'm older")
|
||||
#elif zkschema == zkschema_latest:
|
||||
# print("I'm the same")
|
||||
#elif zkschema > zkschema_latest:
|
||||
# print("I'm newer")
|
||||
|
||||
#diff = ZKSchema.key_diff(zkschema, zkschema_latest)
|
||||
zkschema.migrate(zkhandler, zkschema_latest.version)
|
||||
|
||||
#zkschema_earliest = ZKSchema()
|
||||
#zkschema_earliest.load(0)
|
||||
#zkschema.rollback(zkhandler, zkschema_earliest.version)
|
Reference in New Issue
Block a user