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
44 lines
1.0 KiB
Python
Executable File
44 lines
1.0 KiB
Python
Executable File
#!/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)
|