From 6a0000d29a33b95606d81aa256df98b23c8bf72a Mon Sep 17 00:00:00 2001 From: Niall Donegan Date: Wed, 12 Oct 2016 11:45:57 +0100 Subject: [PATCH 1/2] Check for the existence of all packages in yum before attempting install Fixes #225 --- oz/RedHat.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/oz/RedHat.py b/oz/RedHat.py index f5fff0a7..de35a364 100644 --- a/oz/RedHat.py +++ b/oz/RedHat.py @@ -57,7 +57,7 @@ def __init__(self, tdl, config, auto, output_disk, nicmodel, diskbus, AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE AcceptEnv XMODIFIERS X11Forwarding yes -Subsystem sftp /usr/libexec/openssh/sftp-server +Subsystem sftp /usr/libexec/openssh/sftp-server """ # initrdtype is actually a tri-state: @@ -816,6 +816,20 @@ def _customize_repos(self, guestaddr): def _install_packages(self, guestaddr, packstr): if self.use_yum: + # If passed in multiple packages, yum will still return a zero even if + # some of packages were not available for install. It seems the only + # safe way to check is to do a yum info on each package. + missing_packages = [] + for package in packstr.split(): + # Verify each package is available + try: + self.guest_execute_command(guestaddr, 'yum info %s' % package) + except oz.ozutil.SubprocessException: + missing_packages.append(package) + if missing_packages: + raise oz.OzException.OzException( + 'Failed to find packages: %s' % ' '.join(missing_packages) + ) self.guest_execute_command(guestaddr, 'yum -y install %s' % (packstr)) else: self.guest_execute_command(guestaddr, 'dnf -y install %s' % (packstr)) From 407d393a02d836129eb76024d2a6a99094f09b49 Mon Sep 17 00:00:00 2001 From: Niall Donegan Date: Wed, 12 Oct 2016 11:45:57 +0100 Subject: [PATCH 2/2] Check for the existence of all packages in yum before attempting install Fixes #225 --- oz/RedHat.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/oz/RedHat.py b/oz/RedHat.py index f5fff0a7..de35a364 100644 --- a/oz/RedHat.py +++ b/oz/RedHat.py @@ -57,7 +57,7 @@ def __init__(self, tdl, config, auto, output_disk, nicmodel, diskbus, AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE AcceptEnv XMODIFIERS X11Forwarding yes -Subsystem sftp /usr/libexec/openssh/sftp-server +Subsystem sftp /usr/libexec/openssh/sftp-server """ # initrdtype is actually a tri-state: @@ -816,6 +816,20 @@ def _customize_repos(self, guestaddr): def _install_packages(self, guestaddr, packstr): if self.use_yum: + # If passed in multiple packages, yum will still return a zero even if + # some of packages were not available for install. It seems the only + # safe way to check is to do a yum info on each package. + missing_packages = [] + for package in packstr.split(): + # Verify each package is available + try: + self.guest_execute_command(guestaddr, 'yum info %s' % package) + except oz.ozutil.SubprocessException: + missing_packages.append(package) + if missing_packages: + raise oz.OzException.OzException( + 'Failed to find packages: %s' % ' '.join(missing_packages) + ) self.guest_execute_command(guestaddr, 'yum -y install %s' % (packstr)) else: self.guest_execute_command(guestaddr, 'dnf -y install %s' % (packstr))