Skip to content

Commit

Permalink
Merge pull request CentOS-PaaS-SIG#614 from p3ck/beaker_enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
paas-bot committed Jul 6, 2018
2 parents 62741a8 + cb4d1a0 commit 64509fe
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 11 deletions.
22 changes: 22 additions & 0 deletions config/Dockerfiles/tests.d/beaker/02_beaker_distro
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash -xe

# Verify distro selection in beaker
# distros.exclude: none
# providers.include: beaker
# providers.exclude: none

DISTRO=${1}
PROVIDER=${2}

PINFILE="PinFile.${PROVIDER}.yml"
TARGET="beaker-family"
TMP_FILE=$(mktemp)

function clean_up {
set +e
linchpin -w . -p "${PINFILE}" -v destroy "${TARGET}"
}
trap clean_up EXIT SIGHUP SIGINT SIGTERM

pushd docs/source/examples/workspace
linchpin -w . -p "${PINFILE}" -v up "${TARGET}"
12 changes: 11 additions & 1 deletion docs/source/beaker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ describes the available recipesets options.
+------------------+------------+----------+-----------------------------------------+
| Parameter | required | type | sub-field layout options |
+==================+============+==========+=========================================+
| distro | true | string | N/A |
| distro | false | string | N/A |
+------------------+------------+----------+-----------------------------------------+
| family | false | string | N/A |
+------------------+------------+----------+-----------------------------------------+
| tags | false | list | list of strings |
+------------------+------------+----------+-----------------------------------------+
| name | false | string | N/A |
+------------------+------------+----------+-----------------------------------------+
Expand Down Expand Up @@ -81,6 +85,12 @@ describes the available recipesets options.
| | | | value | false | int / string |
+ + + +-----------+--------------+--------------+
| | | | type | false | string |
+ + +----------+-----------+--------------+--------------+
| | | dict | force | false | string |
+ + +----------+-----------+--------------+--------------+
| | | dict | rawxml | false | string |
+------------------+------------+----------+-----------+--------------+--------------+
| reserve_duration | false | int | N/A |
+------------------+------------+----------+-----------+--------------+--------------+

Additional Dependencies
Expand Down
27 changes: 27 additions & 0 deletions docs/source/examples/workspace/PinFile.beaker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,30 @@
beaker-new:
topology: bkr-new.yml

beaker-family:
topology:
topology_name: beaker-family
resource_groups:
- resource_group_name: "bkr-family"
resource_group_type: beaker
resource_definitions:
- role: bkr_server
# option to set job whiteboard message
whiteboard: Provisioned with linchpin
# options to configure amount of time spent polling beaker:
# 60 attempts with 60 seconds wait time between them,
# provisioning timeout is roughly 3600 seconds
max_attempts: 240
attempt_wait_time: 60
# option to set cancellation message if linchpin cancels provisioning
cancel_message: Job cancelled on account of rain
recipesets:
- family: RedHatEnterpriseLinux7
tags:
- released
name: rheltest
arch: x86_64
count: 1
name: rhel7
hostrequires:
- rawxml: '<hostlabcontroller op="=" value="lab-02.rhts.eng.bos.redhat.com"/>'
29 changes: 20 additions & 9 deletions linchpin/provision/library/bkr_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ def provision(self, *args, **kwargs):
method = kwargs.get("method", "nfs")
priority = kwargs.get("priority", "Normal")
hostrequires = kwargs.get("hostrequires", [])
reserve_duration = kwargs.get("reserve_duration", None)
if reserve_duration:
kwargs.update({"reserve_duration": "%s" % reserve_duration})
tags = kwargs.get("tags", [])
if tags:
kwargs.update({"tag": tags})

requested_tasks = []

Expand Down Expand Up @@ -124,15 +130,20 @@ def provision(self, *args, **kwargs):
recipe_template = BeakerRecipe(*args, **kwargs)

# Add Host Requirements
if 'force' in hostrequires:
# hostRequires element is created by BeakerRecipe, use it
hostrequires_node = recipe_template.node.getElementsByTagName('hostRequires')[0] # noqa E501
# all other filters are ignored if the hostname is forced,
# so the use of 'force' is mutually exclusive with the use
# of any other 'hostRequires' filters
hostrequires_node.setAttribute('force', hostrequires['force'])
else:
for requirement in hostrequires:
for requirement in hostrequires:
if 'force' in requirement:
# hostRequires element is created by BeakerRecipe, use it
hostrequires_node = recipe_template.node.getElementsByTagName('hostRequires')[0] # noqa E501
# all other filters are ignored if the hostname is forced,
# so the use of 'force' is mutually exclusive with the use
# of any other 'hostRequires' filters
hostrequires_node.setAttribute('force',
requirement['force'])
elif 'rawxml' in requirement:
requirement_node = xml.dom.minidom.parseString(
requirement['rawxml']).documentElement
recipe_template.addHostRequires(requirement_node)
else:
# If force is not used, a requirement can be any number
# of differently formatted XML elements, each with their
# own combination of element name and valid attrs. So,
Expand Down
19 changes: 18 additions & 1 deletion linchpin/provision/roles/beaker/files/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,23 @@
"anyof": [{
"type": "dict",
"schema": {
"distro": { "type": "string", "required": true },
"distro": { "type": "string",
"excludes": "family",
"required": true },
"family": { "type": "string",
"excludes": "distro",
"required": true },
"tags": {
"type": "list",
"required": false,
"schema": { "type": "string", "required": true }
},
"name": { "type": "string", "required": false },
"method": { "type": "string", "required": false },
"arch": { "type": "string", "required": false },
"variant": { "type": "string", "required": false },
"ks_meta": { "type": "string", "required": false },
"reserve_duration": { "type": "integer", "required": false },
"taskparam": {
"type": "list",
"required": false,
Expand Down Expand Up @@ -67,6 +78,12 @@
"schema": {
"force": { "type": "string", "required": true }
}
},
{
"type": "dict",
"schema": {
"rawxml": { "type": "string", "required": true }
}
}]
}
},
Expand Down

0 comments on commit 64509fe

Please sign in to comment.