Skip to content

Commit

Permalink
#69 IDArray injection works when IDArray is local and keystore is ext…
Browse files Browse the repository at this point in the history
…ernal
  • Loading branch information
PackeTsar committed Jun 18, 2020
1 parent 2e0d5ca commit 5b8aa3b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ztp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
##### https://github.com/packetsar/freeztp #####

##### Inform FreeZTP version here #####
version = "v1.4.0a"
version = "v1.4.0b"


##### Import native modules #####
Expand Down Expand Up @@ -695,14 +695,23 @@ def merge_test(self, iden, template):
console(j2template.render(kvalues))
console("##############################")
def pull_keystore_values(self, path, keystore_id):
if keystore_id not in path["idarrays"]:
if (keystore_id not in path["idarrays"]) and (keystore_id not in list(config.running["idarrays"])):
return self._global_keystore_merge(path["keyvalstore"][keystore_id])
else:
log("cfact.pull_keystore_values: Inserting IDArray keys")
base_vals = dict(path["keyvalstore"][keystore_id])
ida_vals = path["idarrays"][keystore_id]
# Grab values from selected path first
if keystore_id in path["idarrays"]:
ida_vals = path["idarrays"][keystore_id]
else: # Otherwise grab from local config
ida_vals = config.running["idarrays"][keystore_id]
# If it doesn't exist at all, inject it
if "idarray" not in base_vals:
base_vals.update({"idarray": ida_vals})
# It it exists but is empty
elif not base_vals["idarray"]:
# Replace empty data with the local data
base_vals.update({"idarray": ida_vals})
index = 1
for value in ida_vals:
key = "idarray_{}".format(index)
Expand Down

0 comments on commit 5b8aa3b

Please sign in to comment.