Skip to content

Commit

Permalink
temp hash
Browse files Browse the repository at this point in the history
  • Loading branch information
kimpaller committed Oct 11, 2024
1 parent 9003fad commit 00e9f9e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
7 changes: 6 additions & 1 deletion nebula/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,9 @@ def retry_session(
def download(self, url, fname):
resp = self.retry_session().get(url, stream=True)
if not resp.ok:
raise Exception(fname.lstrip("outs/") + " - File not found!")
raise Exception(os.path.basename(fname) + " - File not found!")
total = int(resp.headers.get("content-length", 0))
sha256_hash = hashlib.sha256()
with open(fname, "wb") as file, tqdm(
desc=fname,
total=total,
Expand All @@ -1057,7 +1058,11 @@ def download(self, url, fname):
) as bar:
for data in resp.iter_content(chunk_size=1024):
size = file.write(data)
sha256_hash.update(data)
bar.update(size)
hash = sha256_hash.hexdigest()
with open(os.path.join(os.path.dirname(fname),"hashes.txt"),"a") as h:
h.write(f"{os.path.basename(fname)},{hash}\n")

def check(self, fname, ref):
hash_md5 = hashlib.md5()
Expand Down
3 changes: 3 additions & 0 deletions nebula/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ def board_reboot_uart_net_pdu(
# Check is networking is working
self.network_check()

# verify bootfiles
self.verify_checksum()

print("Home sweet home")
self.monitor[0].stop_log()

Expand Down
14 changes: 13 additions & 1 deletion nebula/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def __init__(
self.update_defaults_from_yaml(
yamlfilename, __class__.__name__, board_name=board_name
)
props = ["dutip", "dutusername", "dutpassword", "dhcp", "nic", "nicip"]
for prop in props:
if eval(prop) is not None:
setattr(self, prop, eval(prop))
Expand Down Expand Up @@ -405,3 +404,16 @@ def run_diagnostics(self):
# fetch file
self._dl_file(report_file_name)
log.info("Diagnostic report {} collected".format(report_file_name))

def verify_checksum(self, file_path, reference, algo="sha256"):
self.check_board_booted()
if algo == "sha256":
ssh_command = f"python -c \"import hashlib; print(hashlib.sha256(open('{file_path}', 'rb').read()).hexdigest())\""
self.run_ssh_command(command=ssh_command, print_result_to_file=False)

if __name__=="__main__":
board = network(dutusername="analog",
dutpassword="analog",
yamlfilename="../../sdg-nuc-01",
board_name="zynq-zc702-adv7511-ad9361-fmcomms2-3")
board.check_board_booted()

0 comments on commit 00e9f9e

Please sign in to comment.