X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=automation%2Fupdate_standalone.py;h=d29afd9a3e200ad6dd86bd1611c9d77259bfebf0;hb=0c54f726b3d830ccbfa1e1d19aaebe8a6b17a187;hp=6f7094c88fabd3d2d864a500024dd5b765481d03;hpb=92150710909225057c6855dca21e1c9269a68f43;p=lttng-ci.git diff --git a/automation/update_standalone.py b/automation/update_standalone.py index 6f7094c..d29afd9 100644 --- a/automation/update_standalone.py +++ b/automation/update_standalone.py @@ -19,13 +19,13 @@ """ 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'] DEFAULT_DISTRO = 'ubuntu' DISTRO_COMMAND = { - 'el': 'yum update -y && yum clean all', + 'el': 'yum update -y && package-cleanup -y --oldkernels --count=2 && yum clean all', 'sles': 'zypper --non-interactive refresh && zypper --non-interactive patch --auto-agree-with-licenses --with-interactive', 'ubuntu': 'apt-get update && apt-get dist-upgrade -V -y && apt-get clean && apt-get --purge autoremove -y', } @@ -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!")