Skip to content

Commit

Permalink
Merge pull request #95 from gsr-shanks/dev
Browse files Browse the repository at this point in the history
Exit if git, koji or restraint-client rpm is not installed
  • Loading branch information
gsr-shanks committed Mar 3, 2015
2 parents 3b60851 + bbeb02b commit 3205e35
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 16 deletions.
31 changes: 22 additions & 9 deletions nexus/plugins/restraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,27 @@ def restraint_update_xml(self):
sys.exit(2)

def execute_restraint(self):
"""
Check for the length of resources and build appropriate restraint
command for both single and multi host execution.
"""

subprocess.check_call(['cat', self.restraint_xml])
if len(self.existing_nodes) == 1:
host1 = ("1=%s:8081" % self.existing_nodes[0])
returncode = subprocess.check_call(['restraint', '-j', \
self.restraint_xml, '-t', host1, '-v', '-v'])
return returncode
try:
subprocess.check_call(['restraint', '-j', \
self.restraint_xml, '-t', host1, '-v', '-v'])
except subprocess.CalledProcessError as e:
exit(e.returncode)
else:
rest_command = "restraint" + " " + "-j" + " " + self.restraint_xml \
+ " " + self.restraint_hosts + " " + "-v" + " " + "-v"
logger.log.info(rest_command)
returncode = subprocess.check_call(rest_command.split(), shell=False)
return returncode
try:
subprocess.check_call(rest_command.split(), shell=False)
except subprocess.CalledProcessError as e:
exit(e.returncode)

def restraint_junit(self):
"""convert job.xml to junit.xml"""
Expand Down Expand Up @@ -182,12 +190,17 @@ def restraint_html(self):

logger.log.info("Get index.html from test directory to workspace")
index_html = glob.glob("*/index.html")
logger.log.info("index.html found at %s" % index_html)

src = index_html[0]
dst = "restraint_results.html"
if os.path.exists(index_html):

logger.log.info("index.html found at %s" % index_html)

shutil.copyfile(src, dst)
src = index_html[0]
dst = "restraint_results.html"

shutil.copyfile(src, dst)
else:
logger.log.warn("index.html not found.")


def run_restraint(self, options, conf_dict):
Expand Down
36 changes: 29 additions & 7 deletions nexus/tasks/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import os
import sys
import yum
import argparse
import ConfigParser
from nexus.lib import logger
Expand Down Expand Up @@ -135,16 +136,37 @@ def setup_conf(options):

def execute(options, conf_dict):

yb = yum.YumBase()

if options.command == 'git':
git = Git(options, conf_dict)
git.get_archive()
if yb.rpmdb.searchNevra(name='git'):
logger.log.info("Git rpm found.")

git = Git(options, conf_dict)
git.get_archive()
else:
logger.log.error("Git rpm not installed.")
sys.exit(2)
elif options.command == 'brew':
brew = Brew(options, conf_dict)
brew.get_latest(options, conf_dict)
if yb.rpmdb.searchNevra(name='koji'):
logger.log.info("Koji rpm found.")

brew = Brew(options, conf_dict)
brew.get_latest(options, conf_dict)
else:
logger.log.error("Koji rpm not installed.")
sys.exit(2)

elif options.command == 'restraint':
restraint = Restraint(options, conf_dict)
restraint.run_restraint(options, conf_dict)
restraint.restraint_junit()
if yb.rpmdb.searchNevra(name='restraint-client'):
logger.log.info("restraint-client rpm found.")
restraint = Restraint(options, conf_dict)
restraint.run_restraint(options, conf_dict)
restraint.restraint_junit()
else:
logger.log.error("restraint-client rpm not installed.")
sys.exit(2)

elif options.command == 'errata':
errata = Errata(options, conf_dict)
errata.download_errata_builds()
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def readme():
install_requires=[
'pbr',
'wget',
'yum',
'glob2',
'paramiko',
'argparse',
Expand Down

0 comments on commit 3205e35

Please sign in to comment.