Skip to content

Instantly share code, notes, and snippets.

@thescouser89
Created May 16, 2017 03:10
Show Gist options
  • Save thescouser89/9a0fc204df959e30edd68932a1e2782f to your computer and use it in GitHub Desktop.
Save thescouser89/9a0fc204df959e30edd68932a1e2782f to your computer and use it in GitHub Desktop.
Jenkins migration from 1.585 to 1.609 -> Move OVirt node definitions to the nodes folder
import xml.etree.ElementTree as ET
import os
tree = ET.parse('config.xml')
root = tree.getroot()
slave = root.find('slaves')
ovirt_slaves = slave.findall('org.jenkinsci.plugins.ovirt.OVirtVMSlave')
if not os.path.exists('nodes'):
os.makedirs('nodes')
header = "<?xml version='1.0' encoding='UTF-8'?>"
for ovirt_slave in ovirt_slaves:
node_name = ovirt_slave.find("name")
content = header + "\n" + ET.tostring(ovirt_slave)
if not os.path.exists('nodes/' + node_name.text):
os.makedirs('nodes/' + node_name.text)
with open('nodes/' + node_name.text + '/config.xml', 'w') as f:
f.write(content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment