Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Meg M Kido committed Sep 2, 2020
1 parent 76c8041 commit 9d66b6e
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@


# Returns hash of filename
def get_hash(filename):
hasher = hashlib.md5()
def get_hash(filename, sles):
# SLES15 uses sha256
if '15sp' in sles:
hasher = hashlib.sha256()
else:
hasher = hashlib.md5()

with open(filename, 'rb') as f:
hasher.update(f.read())

Expand All @@ -18,9 +23,10 @@ def get_hash(filename):
def test_sles_pallet_patched(host, report_output):
total_matched = []
base_dir = '/export/stack/pallets/SLES/'
sles_flavors = os.listdir(base_dir)
if not sles_flavors:
if not os.path.isdir(base_dir):
pytest.skip('No SLES pallet found - skipping patch check')
sles_flavors = os.listdir(base_dir)
assert sles_flavors

# Find out where is stack-sles*images*.rpm file(s)
result = host.run('find /export/stack/pallets/stacki/ -name "*stack-sles-*.rpm"')
Expand Down Expand Up @@ -90,19 +96,16 @@ def test_sles_pallet_patched(host, report_output):
file_to_check = this_list[0]
assert os.path.exists(file_to_check)
hash_value = this_list[3]
# Grab hash for this file in patch directory and compare against hash from img file. They should match
if get_hash(file_to_check) == hash_value:
matched_list.append(file_to_check)

# Grab hash for this file in SLES pallet directory and compare against hash from img file. They should match
# Grab hash for this file in patch directory and SLES pallet directory and compare against hash from img file. They should match
# Need to build the equivalent path first
temp_path_list = file_to_check.split('add-stacki-squashfs')
temp_path = sles_pallet_root + temp_path_list[1]
if get_hash(temp_path) == hash_value:
if get_hash(file_to_check,sles_flavor) == hash_value and get_hash(temp_path, sles_flavor) == hash_value:
matched_list.append(file_to_check)

# Check if we found hash match as expected
if matched_list and len(matched_list) == len(patch_files)*2:
# Check if we found hash match as expected. Should be 4 files.
if matched_list and len(matched_list) == 4:
found_source = True
# trim the string
temp_path = rpm.split('stacki/')[1]
Expand Down

0 comments on commit 9d66b6e

Please sign in to comment.