Skip to content
Snippets Groups Projects
Commit cea35d65 authored by Nithin Mysore Nagesh's avatar Nithin Mysore Nagesh Committed by Nithin Mysore Nagesh
Browse files

PSDK test case failure fix


Adaptations done to convert ova file to vdi file as the test cases expect vdi file
Implement authorization for http links given as input to the script

Signed-off-by: default avatarNithin M N <MN.Nithin@in.bosch.com>


(cherry picked from commit fe7a98ed)
parent 2d4c4c7d
No related branches found
No related tags found
No related merge requests found
Pipeline #659167 failed
...@@ -73,19 +73,42 @@ class PsdkCommands(object): ...@@ -73,19 +73,42 @@ class PsdkCommands(object):
print(_err.decode()) print(_err.decode())
return exit_status, _output.decode(), _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): def setup_disk_files(self, url, old_sdk_filename, new_sdk_filename):
if url.startswith("http"): if url.startswith("http"):
print("Dowloading %s ..." % url) print("Dowloading %s ..." % url)
try: try:
response = urllib.request.urlopen(url) response = urllib.request.urlopen(url)
gunzip_response = gzip.GzipFile(fileobj=response) if (url.endswith("ova")):
with open(old_sdk_filename, 'wb') as old_sdk_file, \ with open('downloaded_file.ova', 'wb') as file:
open(new_sdk_filename, 'wb') as new_sdk_file: content = response.read(1024*1024)
content = gunzip_response.read(1024*1024) while(content):
while (content): file.write(content)
old_sdk_file.write(content) content = response.read(1024*1024)
new_sdk_file.write(content) 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) 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: except urllib.error.HTTPError as e:
print("FAILED: Error dowloading image file: ", e.code) print("FAILED: Error dowloading image file: ", e.code)
exit(1) exit(1)
...@@ -103,8 +126,11 @@ class PsdkCommands(object): ...@@ -103,8 +126,11 @@ class PsdkCommands(object):
new_sdk_file.write(content) new_sdk_file.write(content)
content = gunzip_response.read(1024*1024) content = gunzip_response.read(1024*1024)
else: else:
shutil.copy(url, old_sdk_filename) if(url.endswith("ova")):
shutil.copy(url, new_sdk_filename) 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", self._run([self.vbox_manage, "internalcommands", "sethduuid",
new_sdk_filename]) new_sdk_filename])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment