def openstack(registry, xml_parent, data):
 tag_prefix = 'jenkins.plugins.openstack.compute.'
 if ('instances' in data):
  clouds_build_wrapper = XML.SubElement(xml_parent, (tag_prefix + 'JCloudsBuildWrapper'))
  instances_wrapper = XML.SubElement(clouds_build_wrapper, 'instancesToRun')
  for instance in data['instances']:
   instances_to_run = XML.SubElement(instances_wrapper, (tag_prefix + 'InstancesToRun'))
   try:
    cloud_name = instance['cloud-name']
    template_name = instance['template-name']
   except KeyError as exception:
    raise MissingAttributeError(exception.args[0])
   XML.SubElement(instances_to_run, 'cloudName').text = cloud_name
   if instance.get('manual-template', False):
    XML.SubElement(instances_to_run, 'manualTemplateName').text = template_name
   else:
    XML.SubElement(instances_to_run, 'templateName').text = template_name
   XML.SubElement(instances_to_run, 'count').text = str(instance.get('count', 1))
 if data.get('single-use', False):
  XML.SubElement(xml_parent, (tag_prefix + 'JCloudsOneOffSlave'))

def openstack ( registry , xml_parent , data ) : tag_prefix = 'jenkins.plugins.openstack.compute.' if ( 'instances' in data ) : clouds_build_wrapper = XML . SubElement ( xml_parent , ( tag_prefix + 'JCloudsBuildWrapper' ) ) instances_wrapper = XML . SubElement ( clouds_build_wrapper , 'instancesToRun' ) for instance in data [ 'instances' ] : instances_to_run = XML . SubElement ( instances_wrapper , ( tag_prefix + 'InstancesToRun' ) ) try : cloud_name = instance [ 'cloud-name' ] template_name = instance [ 'template-name' ] except KeyError as exception : raise MissingAttributeError ( exception . args [ 0 ] ) XML . SubElement ( instances_to_run , 'cloudName' ) . text = cloud_name if instance . get ( 'manual-template' , False ) : XML . SubElement ( instances_to_run , 'manualTemplateName' ) . text = template_name else : XML . SubElement ( instances_to_run , 'templateName' ) . text = template_name XML . SubElement ( instances_to_run , 'count' ) . text = str ( instance . get ( 'count' , 1 ) ) if data . get ( 'single-use' , False ) : XML . SubElement ( xml_parent , ( tag_prefix + 'JCloudsOneOffSlave' ) )
yaml: openstack provision slaves from openstack on demand .