""" 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',
}
import argparse
import sys
import libvirt
-#from jenkinsapi.jenkins import Jenkins
+from jenkinsapi.jenkins import Jenkins
from time import sleep
import paramiko
import select
# 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)
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!")