Skip to content

Commit

Permalink
Check for the existence of all packages in yum before attempting install
Browse files Browse the repository at this point in the history
  • Loading branch information
ndonegan committed Oct 12, 2016
1 parent 4228a1c commit 6a0000d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion oz/RedHat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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))
Expand Down

1 comment on commit 6a0000d

@ndonegan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking for existence of yum package before installing.

Please sign in to comment.