diff --git a/psdk-test/90proxy b/psdk-test/90proxy index a6194991747eba1b466a0a161f7136c2667c0e0c..26f5784ff3259b1c842d4ecf2cae6c145689c449 100644 --- a/psdk-test/90proxy +++ b/psdk-test/90proxy @@ -1,2 +1,2 @@ -Acquire::http::Proxy "http://10.168.128.45:3128"; -Acquire::https::Proxy "http://10.168.128.45:3128"; +Acquire::http::Proxy "http://10.47.96.180:3128"; +Acquire::https::Proxy "http://10.47.96.180:3128"; diff --git a/psdk-test/psdk-test b/psdk-test/psdk-test index 0badf801bc0f8b8db4b66e984b3c0c52b23a5ccd..fb55dcb10ec6bb9c6d9cd6e10d115eb72a5a6c46 100755 --- a/psdk-test/psdk-test +++ b/psdk-test/psdk-test @@ -63,6 +63,7 @@ class PsdkTest(object): self.user_test_file = "psdk_test_file" self.proxy_test_file = "90proxy" self.apt_conf_d = "/etc/apt/apt.conf.d/" + self.proxy_ip = "" self.proxy_test_file_location = \ os.path.join(self.apt_conf_d, self.proxy_test_file) self.cmd = PsdkCommands(self.old_sdk, self.new_sdk, self.user_test_file, @@ -80,7 +81,11 @@ class PsdkTest(object): self.cmd.start_vm(self.old_sdk) if self.test_type == 'sysroot': - self.cmd.run_ade_sysroot(self.release, 'install') + self.proxy_ip = input("Enter the proxy ip: ") + self.cmd.copy_file(self.proxy_test_file) + self.cmd.move_proxy_file(self.proxy_test_file, self.apt_conf_d) + print("Wait for sometime as installation might take time") + self.cmd.run_ade_sysroot(self.release, self.proxy_ip, 'install') elif self.test_type == 'user': self._generate_file(self.user_test_file) self.cmd.copy_file(self.user_test_file) @@ -97,7 +102,8 @@ class PsdkTest(object): def stage2(self): if self.test_type == 'sysroot': - self.cmd.run_ade_sysroot(self.release) + self.cmd.psdk_add_file(self.proxy_test_file_location) + self.cmd.run_ade_sysroot(self.release, self.proxy_ip) elif self.test_type == 'etc': self.cmd.psdk_add_file(self.proxy_test_file_location) @@ -109,7 +115,7 @@ class PsdkTest(object): def stage3(self): if self.test_type == 'sysroot': - self.cmd.run_ade_sysroot(self.release) + self.cmd.run_ade_sysroot(self.release, self.proxy_ip) _result_msg('sysroot', "sdk-persistent-disk") elif self.test_type == 'user': self.cmd.check_file(os.path.join("/home/user/", self.user_test_file)) diff --git a/psdk-test/psdk_commands.py b/psdk-test/psdk_commands.py index a65984124dcd9f2ca5cd6658b58a612a8d3a0158..1635232e94f1cbaa5c440390ec9190b2286b42d7 100644 --- a/psdk-test/psdk_commands.py +++ b/psdk-test/psdk_commands.py @@ -8,14 +8,17 @@ from subprocess import check_call, check_output, CalledProcessError import os import time +import paramiko class PsdkCommands(object): def __init__(self, old_sdk, new_sdk, user_test_file, debug): - self.vbox_manage = "/usr/bin/vboxmanage" + #vbox_manage path will change in case of Linux it is /usr/bin/vboxmanage + self.vbox_manage = "C:\Program Files (x86)\Sun xVM VirtualBox\VBoxManage.exe" self.ssh_id_file = "ssh/sdk_id_rsa" self.local_host = "user@127.0.0.1" + self.hostname = "127.0.0.1" self.local_port = "2222" self.old_sdk = old_sdk self.new_sdk = new_sdk @@ -59,8 +62,8 @@ class PsdkCommands(object): return [ "scp", "-i", self.ssh_id_file, "-P", self.local_port ] + ssh_opts + lst else: - return [ "ssh", self.local_host, "-i", self.ssh_id_file, "-p", - self.local_port ] + ssh_opts + lst + return [ "ssh", self.local_host, "-i", self.ssh_id_file,"-p", + self.local_port] + ssh_opts + lst def create_vm(self, vm): print("Creating Initial VM (%s) ..." % vm) @@ -75,6 +78,24 @@ class PsdkCommands(object): ("apertis,tcp,,%s,,22" % self.local_port) ] ) + def execute_ssh_command(self, command): + print ("executing ssh command") + ssh_client = None + ssh_client = paramiko.SSHClient() + ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy) + ssh_client.connect(self.hostname, self.local_port, 'user', 'user') + + stdin, stdout, stderr = ssh_client.exec_command(command) + while not stdout.channel.exit_status_ready() and not stdout.channel.recv_ready(): + time.sleep(1) + for line in stdout.read().splitlines(): + print(line) + for line in stderr.read().splitlines(): + print(line) + if ssh_client is not None: + print("Connection closed successfully") + ssh_client.close() + def start_vm(self, vm, vmtype='headless'): self._run(([self.vbox_manage, "startvm", vm, "--type", vmtype])) @@ -90,11 +111,12 @@ class PsdkCommands(object): "--type", "hdd", "--medium", vdi_path ]) def create_persistent_disk(self, pdisk_path): - print("Creating persistent disk: %s" % pdisk_path) + print("Creating persistent disk: %s \n" % pdisk_path) self._run([ self.vbox_manage, "createhd", "--size", "40000", "--variant", "Standard", "--filename", pdisk_path ]) def attach_persistent_disk(self, vm, pdisk_path): + print("\n Attaching persistent disk: %s" % pdisk_path) self._run([ self.vbox_manage, "storageattach", vm, "--storagectl", '"SATA Controller"', "--port", "1", "--device", "0", "--type", "hdd", "--medium", pdisk_path ]) @@ -105,27 +127,32 @@ class PsdkCommands(object): print("Waiting 5 secs ...") time.sleep(5) - def run_ade_sysroot(self, release, op='update'): - self._run(self._ssh([ "ade", "sysroot", op, "--release", release ]), - ssh=True) + def run_ade_sysroot(self, release, proxy_ip='10.47.96.180', op='update'): + print("proxy ip value is", proxy_ip) + self.execute_ssh_command("export http_proxy="+ proxy_ip + ":3128 ;" + + "export https_proxy="+ proxy_ip + ":3128 ;" + + "ade sysroot " + op + " --release " + release + ";") def copy_file(self, cfile): self._run(self._ssh([cfile, (self.local_host + ":/home/user/") ], copy_file=True), ssh=True) + + def copy_proxy_file(self, cfile): + self._run(self._ssh([cfile, (self.local_host + ":/home/user/etc/apt/apt.conf.d/") ], + copy_file=True), ssh=True) def move_proxy_file(self, proxy_test_file, apt_conf_dir): - self._run(self._ssh(["sudo", "mv", - os.path.join("/home/user/", proxy_test_file), - apt_conf_dir]), ssh=True) + proxy_file_move = os.path.join("/home/user/", proxy_test_file) + self.execute_ssh_command("sudo mv " + proxy_file_move + " " + apt_conf_dir) def check_file(self, file_path): print(f"\nChecking file contents for {file_path}:\n" \ "===========================================================") - self._run(self._ssh([ "cat", file_path ]), ssh=True) + self.execute_ssh_command("cat " + file_path) print("===========================================================") def psdk_add_file(self, file_path): - self._run(self._ssh([ "psdk", "-e", file_path ]), ssh=True) + self.execute_ssh_command("psdk -e " + file_path) def delete_vm(self, vm): print("Deleting VM %s ..." % vm)