[PATCH 3/3] KVM test: Add implementation of network based unattended installation
This patch could let the unattended installation to be done through the following method: - unattended.cdrom: the original method which does the installation from cdrom - unattended.url: installing the linux guest from http or ftp, tree url was specified through url - unattended.nfs: installing the linux guest from nfs. the server address was specified through nfs_server, and the director was specified through nfs_dir - unattended.remote_ks: installing the linux guest through a remote kickstart file For url and nfs installation, the extra_params need to be configurated to specify the location of unattended files: - If the unattended file in the tree is used, extra_parmas= append ks=floppy and unattended_file params need to be specified in the configuration file. - If the unattended file located at remote server is used, unattended_file option must be none and extram_params= append ks=http://xxx; need to be speficied in the configuration file and don't forget the add the finish nofitication part. The --kernel and --initrd were used directly for the network installation instead of the tftp/bootp param because user mode network is too slow to do this. Only the unattended files for RHEL and Fedora gues ts are modified, others are kept unmodified and could do the installation from cdrom. Signed-off-by: Jason Wang jasow...@redhat.com --- client/tests/kvm/scripts/unattended.py | 107 +++- client/tests/kvm/tests_base.cfg.sample | 172 +++--- client/tests/kvm/unattended/Fedora-10.ks |2 client/tests/kvm/unattended/Fedora-11.ks |2 client/tests/kvm/unattended/Fedora-12.ks |2 client/tests/kvm/unattended/Fedora-8.ks |2 client/tests/kvm/unattended/Fedora-9.ks |2 client/tests/kvm/unattended/RHEL-3-series.ks |2 client/tests/kvm/unattended/RHEL-4-series.ks |2 client/tests/kvm/unattended/RHEL-5-series.ks |2 10 files changed, 206 insertions(+), 89 deletions(-) diff --git a/client/tests/kvm/scripts/unattended.py b/client/tests/kvm/scripts/unattended.py index fdadd03..0377d83 100755 --- a/client/tests/kvm/scripts/unattended.py +++ b/client/tests/kvm/scripts/unattended.py @@ -50,8 +50,9 @@ 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') -flopy_name = os.environ['KVM_TEST_floppy'] -self.floppy_img = os.path.join(kvm_test_dir, flopy_name) +self.nfs_mount = tempfile.mkdtemp(prefix='nfs_', dir='/tmp') +floppy_name = os.environ['KVM_TEST_floppy'] +self.floppy_img = os.path.join(kvm_test_dir, floppy_name) floppy_dir = os.path.dirname(self.floppy_img) if not os.path.isdir(floppy_dir): os.makedirs(floppy_dir) @@ -60,6 +61,16 @@ class UnattendedInstall(object): self.pxe_image = os.environ.get('KVM_TEST_pxe_image', '') self.pxe_initrd = os.environ.get('KVM_TEST_pxe_initrd', '') +self.medium = os.environ.get('KVM_TEST_medium', '') +self.url = os.environ.get('KVM_TEST_url', '') +self.kernel = os.environ.get('KVM_TEST_kernel', '') +self.initrd = os.environ.get('KVM_TEST_initrd', '') +self.nfs_server = os.environ.get('KVM_TEST_nfs_server', '') +self.nfs_dir = os.environ.get('KVM_TEST_nfs_dir', '') +self.image_path = kvm_test_dir +self.kernel_path = os.path.join(self.image_path, self.kernel) +self.initrd_path = os.path.join(self.image_path, self.initrd) + def create_boot_floppy(self): @@ -106,7 +117,8 @@ class UnattendedInstall(object): dest = os.path.join(self.floppy_mount, dest_fname) # Replace KVM_TEST_CDKEY (in the unattended file) with the cdkey -# provided for this test +# provided for this test and replace the KVM_TEST_MEDIUM with +# the tree url or nfs address provided for this test. unattended_contents = open(self.unattended_file).read() dummy_cdkey_re = r'\bKVM_TEST_CDKEY\b' real_cdkey = os.environ.get('KVM_TEST_cdkey') @@ -117,7 +129,20 @@ class UnattendedInstall(object): else: print (WARNING: 'cdkey' required but not specified for this unattended installation) + +dummy_re = r'\bKVM_TEST_MEDIUM\b' +if self.medium == cdrom: +content = cdrom +elif self.medium == url: +content = url --url %s % self.url +elif self.medium == nfs: +content = nfs --server=%s --dir=%s % (self.nfs_server, self.nfs_dir) +else: +raise SetupError(Unexpected installation medium %s % self.url) + +unattended_contents =
Re: [PATCH 3/3] KVM test: Add implementation of network based unattended installation
On Wed, 2010-05-19 at 17:20 +0800, Jason Wang wrote: This patch could let the unattended installation to be done through the following method: - cdrom: the original method which does the installation from cdrom - url: installing the linux guest from http or ftp, tree url was specified through url - nfs: installing the linux guest from nfs. the server address was specified through nfs_server, and the director was specified through nfs_dir For url and nfs installation, the extra_params need to be configurated to specify the location of unattended files: - If the unattended file in the tree is used, extra_parmas= append ks=floppy and unattended_file params need to be specified in the configuration file. - If the unattended file located at remote server is used, unattended_file option must be none and extram_params= append ks=http://xxx; need to be speficied in the configuration file and don't forget the add the finish nofitication part. The --kernel and --initrd were used directly for the network installation instead of the tftp/bootp param because the user mode network is too slow to do this. Hi Jason, I had reviewed your patchset, implemented the suggestions I pointed out, and I have one more thing we need to work out before we commit this - We absolutely need to provide examples on the config file, decently commented. So, could you please provide examples: * HTTP install using remote kickstart * NFS install using local kickstart And re-send the patchset? I will send the patchset with my modifications directly to you and will wait on your follow up. Thanks! -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] KVM test: Add implementation of network based unattended installation
This patch could let the unattended installation to be done through the following method: - cdrom: the original method which does the installation from cdrom - url: installing the linux guest from http or ftp, tree url was specified through url - nfs: installing the linux guest from nfs. the server address was specified through nfs_server, and the director was specified through nfs_dir For url and nfs installation, the extra_params need to be configurated to specify the location of unattended files: - If the unattended file in the tree is used, extra_parmas= append ks=floppy and unattended_file params need to be specified in the configuration file. - If the unattended file located at remote server is used, unattended_file option must be none and extram_params= append ks=http://xxx; need to be speficied in the configuration file and don't forget the add the finish nofitication part. The --kernel and --initrd were used directly for the network installation instead of the tftp/bootp param because the user mode network is too slow to do this. Only the unattended files for RHEL and Fedora gues ts are modified, others are kept unmodified and could do the installation from cdrom. Signed-off-by: Jason Wang jasow...@redhat.com --- client/tests/kvm/scripts/unattended.py | 103 +- client/tests/kvm/tests_base.cfg.sample |1 client/tests/kvm/unattended/Fedora-10.ks |2 - client/tests/kvm/unattended/Fedora-11.ks |2 - client/tests/kvm/unattended/Fedora-12.ks |2 - client/tests/kvm/unattended/Fedora-8.ks |2 - client/tests/kvm/unattended/Fedora-9.ks |2 - client/tests/kvm/unattended/RHEL-3-series.ks |2 - client/tests/kvm/unattended/RHEL-4-series.ks |2 - client/tests/kvm/unattended/RHEL-5-series.ks |2 - 10 files changed, 107 insertions(+), 13 deletions(-) diff --git a/client/tests/kvm/scripts/unattended.py b/client/tests/kvm/scripts/unattended.py index fdadd03..b738e3f 100755 --- a/client/tests/kvm/scripts/unattended.py +++ b/client/tests/kvm/scripts/unattended.py @@ -50,6 +50,7 @@ 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.nfs_mount = tempfile.mkdtemp(prefix='nfs_', dir='/tmp') flopy_name = os.environ['KVM_TEST_floppy'] self.floppy_img = os.path.join(kvm_test_dir, flopy_name) floppy_dir = os.path.dirname(self.floppy_img) @@ -60,6 +61,16 @@ class UnattendedInstall(object): self.pxe_image = os.environ.get('KVM_TEST_pxe_image', '') self.pxe_initrd = os.environ.get('KVM_TEST_pxe_initrd', '') +self.medium = os.environ.get('KVM_TEST_medium', '') +self.url = os.environ.get('KVM_TEST_url', '') +self.kernel = os.environ.get('KVM_TEST_kernel', '') +self.initrd = os.environ.get('KVM_TEST_initrd', '') +self.nfs_server = os.environ.get('KVM_TEST_nfs_server', '') +self.nfs_dir = os.environ.get('KVM_TEST_nfs_dir', '') +self.image_path = kvm_test_dir +self.kernel_path = os.path.join(self.image_path, self.kernel) +self.initrd_path = os.path.join(self.image_path, self.initrd) + def create_boot_floppy(self): @@ -106,7 +117,8 @@ class UnattendedInstall(object): dest = os.path.join(self.floppy_mount, dest_fname) # Replace KVM_TEST_CDKEY (in the unattended file) with the cdkey -# provided for this test +# provided for this test and replace the KVM_TEST_MEDIUM with +# the tree url or nfs address provided for this test. unattended_contents = open(self.unattended_file).read() dummy_cdkey_re = r'\bKVM_TEST_CDKEY\b' real_cdkey = os.environ.get('KVM_TEST_cdkey') @@ -117,7 +129,20 @@ class UnattendedInstall(object): else: print (WARNING: 'cdkey' required but not specified for this unattended installation) + +dummy_re = r'\bKVM_TEST_MEDIUM\b' +if self.medium == cdrom: +content = cdrom +elif self.medium == url: +content = url --url %s % self.url +elif self.medium == nfs: +content = nfs --server=%s --dir=%s % (self.nfs_server, self.nfs_dir) +else: +raise SetupError(Unexpected installation medium %s % self.url) + +unattended_contents = re.sub(dummy_re, content, unattended_contents) +print unattended_contents # Write the unattended file contents to 'dest' open(dest, 'w').write(unattended_contents) @@ -216,6 +241,58 @@ class UnattendedInstall(object): print PXE boot successfuly set +def setup_url(self):