Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding in safety checks for yum package install. #239

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -812,6 +812,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