def fds_for_command(self, command, fds): fds_got = [] class DummyLauncher(object): def spawn(self2, job, spec): self.assertEquals(spec["args"], ["foo"]) fds_got.append(spec["fds"]) job_spawner = None shell.run_command(job_spawner, DummyLauncher(), command, {"fds": fds, "cwd": shell.GlobalCwdTracker()}) self.assertEquals(len(fds_got), 1) return fds_got[0]
def update_uefi(BMC_HOST, BMC_USER, BMC_PASS, FTP_IP, FTP_USER, FTP_PASS, UEFI_FILE): connection_command = 'ipmitool -H %s -I lanplus -U %s -P %s sol activate' % ( BMC_HOST, BMC_USER, BMC_PASS) disconnction_command = 'ipmitool -H %s -I lanplus -U %s -P %s sol deactivate' % ( BMC_HOST, BMC_USER, BMC_PASS) power_off_command = 'ipmitool -H %s -I lanplus -U %s -P %s power off' % ( BMC_HOST, BMC_USER, BMC_PASS) power_on_command = 'ipmitool -H %s -I lanplus -U %s -P %s power on' % ( BMC_HOST, BMC_USER, BMC_PASS) update_uefi_command = 'provision %s -u %s -p %s -f %s -a 0x100000' % ( FTP_IP, FTP_USER, FTP_PASS, UEFI_FILE) shell.run_command(disconnction_command.split(' '), allow_fail=True) time.sleep(3) shell.run_command(power_off_command.split(' '), allow_fail=True) time.sleep(5) print "start ipmi connection !" shell.run_command(power_on_command.split(' '), allow_fail=True) time.sleep(2) connection = shell.ipmi_connection(connection_command, 9000) connection.prompt_str = ['seconds to stop automatical booting'] connection.wait() print "uefi interrupt prompt find !" connection.sendline("#") # update uefi # depends on ftp connection.prompt_str = ['Move Highlight'] connection.wait() print "uefi entry !" operate(connection, 'down') operate(connection, 'down') operate(connection, 'enter') operate(connection, 'up') operate(connection, 'enter') connection.prompt_str = ['D05 >', 'Please send feedback'] connection.wait() operate(connection, 'enter') connection.sendline(update_uefi_command) connection.prompt_str = ['Input the index:'] connection.wait() connection.sendline("3") operate(connection, 'enter') connection.prompt_str = ['D05 >', 'succ!', 'WriteFlashCmd'] connection.wait() operate(connection, 'enter') connection.sendline("spiwfmem 0x100000 0x0000000 0x300000") operate(connection, 'enter') connection.wait() operate(connection, 'enter') connection.wait() operate(connection, 'enter') time.sleep(3) connection.sendline("exit") connection.disconnect("close") shell.run_command(disconnction_command.split(' '), allow_fail=True) shell.run_command(power_off_command.split(' '), allow_fail=True)
def boot_device(BMC_HOST, BMC_USER, BMC_PASS): connection_command = 'ipmitool -H %s -I lanplus -U %s -P %s sol activate' % ( BMC_HOST, BMC_USER, BMC_PASS) disconnction_command = 'ipmitool -H %s -I lanplus -U %s -P %s sol deactivate' % ( BMC_HOST, BMC_USER, BMC_PASS) power_off_command = 'ipmitool -H %s -I lanplus -U %s -P %s power off' % ( BMC_HOST, BMC_USER, BMC_PASS) power_on_command = 'ipmitool -H %s -I lanplus -U %s -P %s power on' % ( BMC_HOST, BMC_USER, BMC_PASS) pxe_boot_command = 'ipmitool -H %s -I lanplus -U %s -P %s chassis bootdev pxe' % ( BMC_HOST, BMC_USER, BMC_PASS) shell.run_command(pxe_boot_command.split(' '), allow_fail=True) time.sleep(5) shell.run_command(disconnction_command.split(' '), allow_fail=True) time.sleep(5) shell.run_command(power_off_command.split(' '), allow_fail=True) time.sleep(5) print "start ipmi connection !" shell.run_command(power_on_command.split(' '), allow_fail=True) time.sleep(2) connection = shell.ipmi_connection(connection_command, 6000) connection.prompt_str = ['seconds to stop automatical booting'] connection.wait() print "uefi interrupt prompt find !" # don't wait grub. linaro install don't have grub # connection.prompt_str = ['GNU GRUB'] # connection.wait() # print "grub interrupt prompt find !" # TODO: retry login connection.prompt_str = ['login:'******'Password:'******'root@debian:~#', 'root@centos ~', 'root@ubuntu:', 'root@localhost ~' ] connection.wait() # fix the root login sshd config # ubuntu connection.sendline( 'sed -i "s/PermitRootLogin without-password/PermitRootLogin yes/" /etc/ssh/sshd_config' ) # centos connection.sendline( 'sed -i "s/#PermitRootLogin yes/PermitRootLogin yes/" /etc/ssh/sshd_config' ) connection.wait() connection.sendline("service sshd restart") connection.wait() connection.sendline("sleep 2") connection.wait() connection.disconnect("close")
def boot_device(DEPLOY_TYPE, BMC_HOST, BMC_USER, BMC_PASS): connection_command = 'ipmitool -H %s -I lanplus -U %s -P %s sol activate' % ( BMC_HOST, BMC_USER, BMC_PASS) disconnction_command = 'ipmitool -H %s -I lanplus -U %s -P %s sol deactivate' % ( BMC_HOST, BMC_USER, BMC_PASS) power_off_command = 'ipmitool -H %s -I lanplus -U %s -P %s power off' % ( BMC_HOST, BMC_USER, BMC_PASS) power_on_command = 'ipmitool -H %s -I lanplus -U %s -P %s power on' % ( BMC_HOST, BMC_USER, BMC_PASS) pxe_boot_command = 'ipmitool -H %s -I lanplus -U %s -P %s chassis bootdev pxe' % ( BMC_HOST, BMC_USER, BMC_PASS) iso_boot_command = 'ipmitool -H %s -I lanplus -U %s -P %s chassis bootdev cdrom' % ( BMC_HOST, BMC_USER, BMC_PASS) if DEPLOY_TYPE == "BOOT_PXE": shell.run_command(pxe_boot_command.split(' '), allow_fail=True) elif DEPLOY_TYPE == "BOOT_ISO": shell.run_command(iso_boot_command.split(' '), allow_fail=True) else: print "ERROR: don't support this BOOT TYPE " + DEPLOY_TYPE exit(-1) time.sleep(5) shell.run_command(disconnction_command.split(' '), allow_fail=True) time.sleep(5) shell.run_command(power_off_command.split(' '), allow_fail=True) time.sleep(5) print "start ipmi connection !" shell.run_command(power_on_command.split(' '), allow_fail=True) time.sleep(2) # set the install timeout 50 minutes. because lava action timeout is 1 hour connection = shell.ipmi_connection(connection_command, 3000) time.sleep(2) # connection.prompt_str = ['seconds to stop automatical booting'] # connection.wait() # print "uefi interrupt prompt find !" # don't wait grub. linaro install don't have grub # connection.prompt_str = ['GNU GRUB'] # connection.wait() # print "grub interrupt prompt find !" # connection.prompt_str = ['on an aarch64'] # connection.wait() # connection.sendline("") # TODO: retry login connection.prompt_str = ['login:'******'Password:'******'root@debian:~#', 'root@centos ~', 'root@ubuntu:', 'root@ubuntu:~#', 'root@localhost ~', 'root@unassigned-hostname:~#' ] connection.wait() # WORKAROUND: fix the root login sshd config # ubuntu 14.04 connection.sendline( 'sed -i "s/PermitRootLogin without-password/PermitRootLogin yes/" /etc/ssh/sshd_config' ) # new ubuntu 16.04 connection.sendline( 'sed -i "s/PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config' ) # centos connection.sendline( 'sed -i "s/#PermitRootLogin yes/PermitRootLogin yes/" /etc/ssh/sshd_config' ) connection.wait() connection.sendline("service sshd restart") connection.wait() connection.sendline("sleep 2") connection.wait() connection.disconnect("close")