Skip to content
Snippets Groups Projects

PSDK test case adaptations

Merged Nithin Mysore Nagesh requested to merge wip/nht4kor/psdk into apertis/v2025dev1
1 file
+ 35
9
Compare changes
  • Side-by-side
  • Inline
+ 35
9
@@ -73,19 +73,42 @@ class PsdkCommands(object):
print(_err.decode())
return exit_status, _output.decode(), _err.decode()
def convert_ova_to_vdi(self,url, old_sdk, new_sdk):
self._run(["tar", "-xvf", url])
zipped = self._run(["find", ".", "-name", "*.gz"],output=True)
zipped=zipped.decode('utf-8').strip()
self._run(["gunzip", zipped])
unzipped=zipped[:-3]
self._run([self.vbox_manage, "clonehd", unzipped, "output.vdi", "--format=VDI"])
self._run(["rm", unzipped])
self._run([self.vbox_manage, "closemedium", "disk", "output.vdi"])
self._run([self.vbox_manage, "closemedium", "disk", unzipped])
shutil.copy("output.vdi", old_sdk)
shutil.copy("output.vdi", new_sdk)
def setup_disk_files(self, url, old_sdk_filename, new_sdk_filename):
if url.startswith("http"):
print("Dowloading %s ..." % url)
try:
response = urllib.request.urlopen(url)
gunzip_response = gzip.GzipFile(fileobj=response)
with open(old_sdk_filename, 'wb') as old_sdk_file, \
open(new_sdk_filename, 'wb') as new_sdk_file:
content = gunzip_response.read(1024*1024)
while (content):
old_sdk_file.write(content)
new_sdk_file.write(content)
if (url.endswith("ova")):
with open('downloaded_file.ova', 'wb') as file:
content = response.read(1024*1024)
while(content):
file.write(content)
content = response.read(1024*1024)
self.convert_ova_to_vdi("downloaded_file.ova", old_sdk_filename, new_sdk_filename)
self._run(["rm", "downloaded_file.ova"])
else:
gunzip_response = gzip.GzipFile(fileobj=response)
with open(old_sdk_filename, 'wb') as old_sdk_file, \
open(new_sdk_filename, 'wb') as new_sdk_file:
content = gunzip_response.read(1024*1024)
while (content):
old_sdk_file.write(content)
new_sdk_file.write(content)
content = gunzip_response.read(1024*1024)
except urllib.error.HTTPError as e:
print("FAILED: Error dowloading image file: ", e.code)
exit(1)
@@ -103,8 +126,11 @@ class PsdkCommands(object):
new_sdk_file.write(content)
content = gunzip_response.read(1024*1024)
else:
shutil.copy(url, old_sdk_filename)
shutil.copy(url, new_sdk_filename)
if(url.endswith("ova")):
self.convert_ova_to_vdi(url, old_sdk_filename, new_sdk_filename)
else:
shutil.copy(url, old_sdk_filename)
shutil.copy(url, new_sdk_filename)
self._run([self.vbox_manage, "internalcommands", "sethduuid",
new_sdk_filename])
Loading