Skip to content

Commit

Permalink
Use absolute path for ZK schema
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaboniface committed Aug 27, 2024
1 parent 26d0d08 commit 8177d5f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions daemon-common/zkhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
from kazoo.exceptions import NoNodeError


SCHEMA_ROOT_PATH = "/usr/share/pvc/daemon_lib/migrations/versions"


#
# Function decorators
#
Expand Down Expand Up @@ -869,7 +872,7 @@ def load(self, version, quiet=False):
if not quiet:
print(f"Loading schema version {version}")

with open(f"daemon_lib/migrations/versions/{version}.json", "r") as sfh:
with open(f"{SCHEMA_ROOT_PATH}/{version}.json", "r") as sfh:
self.schema = json.load(sfh)
self.version = self.schema.get("version")

Expand Down Expand Up @@ -1218,15 +1221,15 @@ def load_current(cls, zkhandler):
# Write the latest schema to a file
@classmethod
def write(cls):
schema_file = "daemon_lib/migrations/versions/{}.json".format(cls._version)
schema_file = f"{SCHEMA_ROOT_PATH}/{cls._version}.json"
with open(schema_file, "w") as sfh:
json.dump(cls._schema, sfh)

# Static methods for reading information from the files
@staticmethod
def find_all(start=0, end=None):
versions = list()
for version in os.listdir("daemon_lib/migrations/versions"):
for version in os.listdir(SCHEMA_ROOT_PATH):
sequence_id = int(version.split(".")[0])
if end is None:
if sequence_id > start:
Expand All @@ -1242,7 +1245,7 @@ def find_all(start=0, end=None):
@staticmethod
def find_latest():
latest_version = 0
for version in os.listdir("daemon_lib/migrations/versions"):
for version in os.listdir(SCHEMA_ROOT_PATH):
sequence_id = int(version.split(".")[0])
if sequence_id > latest_version:
latest_version = sequence_id
Expand Down

0 comments on commit 8177d5f

Please sign in to comment.