@@ -59,8 +59,11 @@ class UnattendedInstall(object):
self.cdrom_iso = os.path.join(kvm_test_dir, cdrom_iso)
self.floppy_mount = tempfile.mkdtemp(prefix='floppy_', dir='/tmp')
self.cdrom_mount = tempfile.mkdtemp(prefix='cdrom_', dir='/tmp')
- self.floppy_img = os.path.join(images_dir, 'floppy.img')
-
+ flopy_name = os.path.basename(os.environ['KVM_TEST_floppy'])
+ self.floppy_img = os.path.join(images_dir, flopy_name)
+ self.pxe_dir = os.environ['KVM_TEST_pxe_dir']
+ self.pxe_image = os.environ['KVM_TEST_pxe_image']
+ self.pxe_initrd = os.environ['KVM_TEST_pxe_initrd']
def create_boot_floppy(self):
"""
@@ -96,7 +99,10 @@ class UnattendedInstall(object):
elif self.unattended_file.endswith('.ks'):
dest_fname = 'ks.cfg'
elif self.unattended_file.endswith('.xml'):
- dest_fname = "autounattend.xml"
+ if self.tftp_root is '':
+ dest_fname = "autounattend.xml"
+ else:
+ dest_fname = "autoinst.xml"
dest = os.path.join(self.floppy_mount, dest_fname)
@@ -166,21 +172,20 @@ class UnattendedInstall(object):
raise SetupError('Could not mount CD image %s.' %
self.cdrom_iso)
- p = os.path.join('images', 'pxeboot')
- pxe_dir = os.path.join(self.cdrom_mount, p)
- pxe_image = os.path.join(pxe_dir, 'vmlinuz')
- pxe_initrd = os.path.join(pxe_dir, 'initrd.img')
+ pxe_dir = os.path.join(self.cdrom_mount, self.pxe_dir)
+ pxe_image = os.path.join(pxe_dir, self.pxe_image)
+ pxe_initrd = os.path.join(pxe_dir, self.pxe_initrd)
if not os.path.isdir(pxe_dir):
raise SetupError('The ISO image does not have a %s dir. The '
'script assumes that the cd has a %s dir '
'where to search for the vmlinuz image.' %
- (p, p))
+ (self.pxe_dir, self.pxe_dir))
if not os.path.isfile(pxe_image) or not os.path.isfile(pxe_initrd):
raise SetupError('The location %s is lacking either a vmlinuz '
'or a initrd.img file. Cannot find a PXE '
- 'image to proceed.' % pxe_dir)
+ 'image to proceed.' % self.pxe_dir)
tftp_image = os.path.join(self.tftp_root, 'vmlinuz')
tftp_initrd = os.path.join(self.tftp_root, 'initrd.img')
@@ -13,11 +13,11 @@ def run_unattended_install(test, params, env):
@param params: Dictionary with the test parameters.
@param env: Dictionary with test environment.
"""
+ buf = 1024
vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
- server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- server.bind(('', 12323))
- server.listen(1)
+ port = vm.get_port(int(params.get("guest_port_unattend_shell")))
+ addr = ('localhost', port)
install_timeout = float(params.get("timeout", 3000))
logging.info("Starting unattended install watch process. "
@@ -26,21 +26,19 @@ def run_unattended_install(test, params, env):
start_time = time.time()
while True:
- server.settimeout(install_timeout)
+ client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
- (client, addr) = server.accept()
- except socket.timeout:
- server.close()
- raise error.TestFail('Timeout elapsed while waiting for install to '
- 'finish.')
- msg = client.recv(1024)
- logging.debug("Received '%s' from %s", msg, addr)
- if msg == 'done':
- end_time = time.time()
- time_elapsed = int(end_time - start_time)
- logging.info('Guest reported successful installation after %ds '
- '(%d min)', time_elapsed, time_elapsed/60)
- server.close()
- break
- else:
- logging.error('Got invalid string from client: %s.' % msg)
+ client.connect(addr)
+ msg = client.recv(1024)
+ if msg == 'thank u for connecting':
+ break
+ else:
+ raise Exception
+ except:
+ time.sleep(1)
+ client.close()
+
+ end_time = time.time()
+ time_elapsed = int(end_time - start_time)
+ logging.info('Guest reported successful installation after %ds '
+ '(%d min)', time_elapsed, time_elapsed/60)
@@ -33,6 +33,7 @@ used_mem = 512
# Port redirections
redirs = remote_shell
guest_port_remote_shell = 22
+guest_port_unattend_shell = 12323
# NIC parameters
nic_mode = user
@@ -515,6 +516,9 @@ variants:
block_hotplug:
modprobe_module = acpiphp
unattended_install:
+ pxe_dir = "images/pxeboot"
+ pxe_image = "vmlinuz"
+ pxe_initrd = "initrd.img"
tftp = "images/tftpboot"
extra_params += " -bootp /pxelinux.0 -boot n"
kernel_args = "ks=floppy nicdelay=60"
@@ -614,6 +618,8 @@ variants:
md5sum_1m = 0dbeb8f58d213752d8c029e8601abfbb
unattended_install:
unattended_file = unattended/RHEL-5-series.ks
+ tftp = "images/rhel54-32/tftpboot"
+ floppy = "images/rhel54-32floppy.img"
- 5.4.x86_64:
no setup
@@ -623,6 +629,8 @@ variants:
md5sum_1m = 3e74112003e88a966754849dbb8f5c3f
unattended_install:
unattended_file = unattended/RHEL-5-series.ks
+ tftp = "images/rhel54-64/tftpboot"
+ floppy = "images/rhel54-64floppy.img"
# Windows section
- @Windows:
@@ -28,10 +28,10 @@ os.system('dhclient')
os.system('chkconfig sshd on')
os.system('iptables -F')
os.system('echo 0 > /selinux/enforce')
-port = 12323
-buf = 1024
-addr = ('10.0.2.2', port)
-client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-client.connect(addr)
-client.sendto('done', addr)
+os.system('dhclient eth0')
+server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+server.bind(('', 12323))
+server.listen(1)
+(client, addr) = server.accept()
+client.send("thank u for connecting")
client.close()