Merge "Add support for Jenkins OpenStack Cloud Plugin"

This commit is contained in:
Jenkins 2016-05-17 16:21:25 +00:00 committed by Gerrit Code Review
commit cca8a45670
7 changed files with 121 additions and 0 deletions

View File

@ -1108,6 +1108,67 @@ def jclouds(parser, xml_parent, data):
'JCloudsOneOffSlave')
def openstack(parser, xml_parent, data):
"""yaml: openstack
Provision slaves from OpenStack on demand. Requires the Jenkins
:jenkins-wiki:`Openstack Cloud Plugin <Openstack+Cloud+Plugin>`.
:arg list instances: List of instances to be launched at the beginning of
the build.
:instances:
* **cloud-name** (`str`) -- The name of the cloud profile which
contains the specified cloud instance template (required).
* **template-name** (`str`) -- The name of the cloud instance
template to create an instance from(required).
* **manual-template** (`bool`) -- If True, instance template name
will be put in 'Specify Template Name as String' option. Not
specifying or specifying False, instance template name will be
put in 'Select Template from List' option. To use parameter
replacement, set this to True. (default: False)
* **count** (`int`) -- How many instances to create (default: 1).
:arg bool single-use: Whether or not to terminate the slave after use
(default: False).
Example:
.. literalinclude:: /../../tests/wrappers/fixtures/openstack001.yaml
"""
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 build_user_vars(parser, xml_parent, data):
"""yaml: build-user-vars
Set environment variables to the value of the user that started the build.

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<jenkins.plugins.openstack.compute.JCloudsBuildWrapper>
<instancesToRun>
<jenkins.plugins.openstack.compute.InstancesToRun>
<cloudName>mycloud1</cloudName>
<templateName>jenkins-dev-slave</templateName>
<count>1</count>
</jenkins.plugins.openstack.compute.InstancesToRun>
<jenkins.plugins.openstack.compute.InstancesToRun>
<cloudName>mycloud2</cloudName>
<manualTemplateName>jenkins-test-slave</manualTemplateName>
<count>2</count>
</jenkins.plugins.openstack.compute.InstancesToRun>
</instancesToRun>
</jenkins.plugins.openstack.compute.JCloudsBuildWrapper>
<jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
</buildWrappers>
</project>

View File

@ -0,0 +1,11 @@
wrappers:
- openstack:
instances:
- cloud-name: mycloud1
template-name: jenkins-dev-slave
count: 1
- cloud-name: mycloud2
template-name: jenkins-test-slave
manual-template: True
count: 2
single-use: True

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<jenkins.plugins.openstack.compute.JCloudsBuildWrapper>
<instancesToRun>
<jenkins.plugins.openstack.compute.InstancesToRun>
<cloudName>mycloud1</cloudName>
<templateName>jenkins-dev-slave</templateName>
<count>1</count>
</jenkins.plugins.openstack.compute.InstancesToRun>
</instancesToRun>
</jenkins.plugins.openstack.compute.JCloudsBuildWrapper>
</buildWrappers>
</project>

View File

@ -0,0 +1,6 @@
wrappers:
- openstack:
instances:
- cloud-name: mycloud1
template-name: jenkins-dev-slave
count: 1

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
</buildWrappers>
</project>

View File

@ -0,0 +1,3 @@
wrappers:
- openstack:
single-use: True