Created
April 2, 2014 04:36
-
-
Save mccun934/9928000 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import commands | |
# print commands.getstatusoutput('wc -l file') | |
def check_rpm_list(rpm_array, search_strings): | |
conflict_count = 0 | |
for rpm in rpm_array: | |
for s in search_strings: | |
if rpm.find(s) >= 0: | |
print " Conflicting package found, recommend removing: %s" % rpm | |
conflict_count += 1 | |
if conflict_count > 0: | |
print "\nCONFLICT DETECTED: Found [%s] conflicting packages, recommend removal." % conflict_count | |
return 1 | |
else: | |
print "OK: No conflicting packages detected" | |
return 0 | |
def check_registration(): | |
output = commands.getstatusoutput("subscription-manager identity") | |
retcode = output[0] | |
if retcode != 0: | |
print "WARNING: Your system is not registered via subscription-manager" | |
print "and may not have access to required packages to complete installation." | |
print "Recommend using the 'subscription-manager' command to properly register your system" | |
return 1 | |
else: | |
print "OK: Registered via subscription-manager" | |
return 0 | |
def check_packages(): | |
output = commands.getstatusoutput('rpm -qa') | |
javarpms = output[1].strip().split('\n') | |
return check_rpm_list(javarpms, ['oracle', 'sun', 'ibm', 'puppet', 'katello', 'pulp']) | |
def check_repos(): | |
output = commands.getstatusoutput("yum -v repolist enabled | grep \"Repo-id\"") | |
repo_ids = output[1] | |
# Check for rhel6-server | |
if not "rhel-6-server-rpms" in repo_ids: | |
print "WARNING: rhel-6-server-rpms is not an enabled yum repository. Your system needs" | |
print "access to Red Hat Enterprise Linux 6 RPMs. If your system has access to this software" | |
print "via other means you can ignore this." | |
if not "rhel-server-6-satellite-6-mdp-2-rpms" in repo_ids: | |
print "WARNING: rhel-server-6-satellite-6-mdp-2-rpms is not an enabled yum repository. Your" | |
print "system needs access to the MDP2 repository. If you are installing via ISO you can ignore this." | |
return 1 | |
else: | |
print "OK: Your system has the correct yum repository configuration" | |
return 0 | |
def check_network(): | |
output = commands.getstatusoutput("curl -X GET http://www.redhat.com/") | |
retcode = output[0] | |
if retcode != 0: | |
print "WARNING: Your system does not have access to http://www.redhat.com. You" | |
print "may be disconnected from the internet or require an HTTP proxy to access" | |
print "the outside network. If you are using a HTTP PROXY please take note of" | |
print "proxy options during katello-configure:" | |
print "" | |
print " --proxy-url=PROXY_URL" | |
print " --proxy-port=PROXY_PORT" | |
print " --proxy-user=PROXY_USER" | |
print " --proxy-pass=PROXY_PASS" | |
return 1 | |
else: | |
print "OK: Unrestricted access to redhat.com allowed." | |
return 0 | |
retval = 0 | |
print "\n1) Checking installed packages for possible conflicts\n" | |
retval += check_packages() | |
print "\n2) Checking system registration via subscription-manager\n" | |
retval += check_registration() | |
print "\n3) Checking configured yum repositories\n" | |
retval += check_repos() | |
print "\n4) Checking access to redhat.com\n" | |
retval += check_network() | |
print "\nDONE, please see above warnings and indications." | |
exit(retval) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment