From: Michael Jeanson Date: Wed, 9 Sep 2015 18:42:57 +0000 (-0400) Subject: Add jenkinsapi support to update_standalone.py X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=85edba54afe6b3850d5e565c80870aa2ad47cf0d;p=lttng-ci.git Add jenkinsapi support to update_standalone.py --- diff --git a/automation/update_standalone.py b/automation/update_standalone.py index 6f7094c..f10f470 100644 --- a/automation/update_standalone.py +++ b/automation/update_standalone.py @@ -19,7 +19,7 @@ """ This script is used to upgrade the base snapshot of standalone ci slaves """ USERNAME = '' -PASSWORD = '' +APIKEY = '' JENKINS_URL = 'https://ci.lttng.org' DISTRO_LIST = ['el', 'sles', 'ubuntu'] @@ -43,7 +43,7 @@ SNAPSHOTXML = """ import argparse import sys import libvirt -#from jenkinsapi.jenkins import Jenkins +from jenkinsapi.jenkins import Jenkins from time import sleep import paramiko import select @@ -69,13 +69,25 @@ def main(): # Get jenkibs connexion - #jenkins = Jenkins(JENKINS_URL, username=USERNAME, password=PASSWORD) + jenkins = Jenkins(JENKINS_URL, username=USERNAME, password=APIKEY) # Get jenkins node - #node = jenkins.get_node(instance_name) + print("Getting node %s from Jenkins..." % instance_name) + node = jenkins.get_node(instance_name) + + if not node: + print("Could not get node %s on %s" % (instance_name, JENKINS_URL)) + sys.exit(1) + + # Check if node is idle + if not node.is_idle: + print("Node %s is not idle" % instance_name) + sys.exit(1) + # Set node temporarily offline - #node.toggle_temporarily_offline('Down for upgrade to base snapshot') + if not node.is_temporarily_offline(): + node.toggle_temporarily_offline('Down for upgrade to base snapshot') # Get libvirt connexion print("Opening libvirt connexion to %s..." % vmhost_name) @@ -182,6 +194,10 @@ def main(): print("Failed to create new snapshot.") sys.exit(1) + # Set node online in jenkins + if node.is_temporarily_offline(): + node.toggle_temporarily_offline() + # And we're done! print("All done!")