Blame tests/0_common/000_centos_default_repos.py

Athmane Madjoudj 509fd6
#!/usr/bin/python
Athmane Madjoudj 509fd6
# Author: Athmane Madjoudj <athmanem@gmail.com>
Karanbir Singh d76413
#         Karanbir Singh <kbsingh@karan.org>
Athmane Madjoudj 509fd6
# Test default CentOS repos
Karanbir Singh 32fd86
# Note: since the -qa and CI setup will modify the
Karanbir Singh 32fd86
#       local repos, we need to run this tests
Karanbir Singh 32fd86
#       before those changes are made
Athmane Madjoudj 509fd6
Athmane Madjoudj 509fd6
import yum
Athmane Madjoudj 509fd6
import sys 
Athmane Madjoudj 6bb5a8
import datetime
9a5ec9
import os
Athmane Madjoudj 509fd6
Athmane Madjoudj 509fd6
yb = yum.YumBase()
9a5ec9
9a5ec9
try:
9a5ec9
    fasttrack = int(os.environ['FASTTRACK'])
9a5ec9
except KeyError:
9a5ec9
    fasttrack = 0
9a5ec9
953e60
try:
953e60
    centosplus = int(os.environ['CENTOSPLUS'])
953e60
except KeyError:
953e60
    centosplus = 0
953e60
	    
9a5ec9
if fasttrack:
2b3708
    centos_default_repos = ['base','extras','updates','cr','fasttrack','centos-kernel']
953e60
elif centosplus:
953e60
    centos_default_repos = ['base','extras','updates','cr','centosplus','centos-kernel']
9a5ec9
else:
2b3708
    centos_default_repos = ['base','extras','updates','cr','centos-kernel']
9a5ec9
Athmane Madjoudj 6bb5a8
now = lambda: datetime.datetime.today().strftime("%c")
Athmane Madjoudj 6bb5a8
print "[+] %s -> Check if non default repo is enabled" % now() 
Athmane Madjoudj 509fd6
for repo in yb.repos.listEnabled():
Athmane Madjoudj 509fd6
    if not repo.id in centos_default_repos:
Karanbir Singh d76413
        print '%s is enabled, should be disabled at this stage' % repo.id
Athmane Madjoudj 6bb5a8
        print '[+] %s -> FAIL' % now()
Athmane Madjoudj 509fd6
        sys.exit(1)
Athmane Madjoudj 6bb5a8
print '[+] %s -> PASS' % now()
Athmane Madjoudj 509fd6
sys.exit(0)
Athmane Madjoudj 509fd6