2013-08-12 13:27:50 -07:00
|
|
|
# Copyright 2013 OpenStack Foundation
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2014-06-19 10:41:35 -07:00
|
|
|
import re
|
|
|
|
|
2013-09-20 14:58:20 -07:00
|
|
|
|
2013-07-29 10:46:53 -07:00
|
|
|
def set_log_url(item, job, params):
|
2013-07-09 10:53:27 -07:00
|
|
|
if hasattr(item.change, 'refspec'):
|
2014-12-12 14:54:41 +11:00
|
|
|
path = "%s/%s/%s/%s/" % (
|
2013-07-09 10:53:27 -07:00
|
|
|
params['ZUUL_CHANGE'][-2:], params['ZUUL_CHANGE'],
|
|
|
|
params['ZUUL_PATCHSET'], params['ZUUL_PIPELINE'])
|
2013-08-01 15:54:12 -07:00
|
|
|
elif hasattr(item.change, 'ref'):
|
2014-12-12 14:54:41 +11:00
|
|
|
path = "%s/%s/%s/" % (
|
2013-07-09 10:53:27 -07:00
|
|
|
params['ZUUL_NEWREV'][:2], params['ZUUL_NEWREV'],
|
|
|
|
params['ZUUL_PIPELINE'])
|
2013-08-01 15:54:12 -07:00
|
|
|
else:
|
2015-03-10 11:55:24 -07:00
|
|
|
path = params['ZUUL_PIPELINE'] + '/'
|
2013-07-09 10:53:27 -07:00
|
|
|
params['BASE_LOG_PATH'] = path
|
2014-12-17 12:09:59 +11:00
|
|
|
params['LOG_PATH'] = path + '%s/%s/' % (job.name,
|
|
|
|
params['ZUUL_UUID'][:7])
|
2013-08-12 13:27:50 -07:00
|
|
|
|
|
|
|
|
2014-06-19 10:41:35 -07:00
|
|
|
def reusable_node(item, job, params):
|
|
|
|
if 'OFFLINE_NODE_WHEN_COMPLETE' in params:
|
|
|
|
del params['OFFLINE_NODE_WHEN_COMPLETE']
|
|
|
|
|
|
|
|
|
|
|
|
def devstack_params(item, job, params):
|
2014-06-23 17:06:52 -07:00
|
|
|
change = item.change
|
|
|
|
# Note we can't fallback on the default labels because
|
|
|
|
# jenkins uses 'devstack-precise || devstack-trusty'.
|
|
|
|
# This is necessary to get the gearman plugin to register
|
|
|
|
# gearman jobs with both node labels.
|
2014-10-07 09:08:49 -07:00
|
|
|
# Remove this when we are done doing prelimindary dib testing.
|
|
|
|
if 'icehouse-dibtest' in job.name:
|
|
|
|
params['ZUUL_NODE'] = 'devstack-precise-dib'
|
2015-07-15 08:52:38 -04:00
|
|
|
elif 'multinode' in job.name and 'dibtest' in job.name:
|
|
|
|
params['ZUUL_NODE'] = 'ubuntu-trusty-2-node'
|
2015-07-10 19:40:18 +00:00
|
|
|
elif 'dibtest' in job.name:
|
2015-06-27 11:22:09 -04:00
|
|
|
params['ZUUL_NODE'] = 'ubuntu-trusty'
|
2014-10-07 09:08:49 -07:00
|
|
|
elif ((hasattr(change, 'branch') and
|
|
|
|
change.branch == 'stable/icehouse') or
|
|
|
|
('icehouse' in job.name or
|
|
|
|
'precise' in job.name)):
|
2014-06-23 17:06:52 -07:00
|
|
|
params['ZUUL_NODE'] = 'devstack-precise'
|
2014-07-31 12:37:53 +00:00
|
|
|
elif 'centos7' in job.name:
|
|
|
|
params['ZUUL_NODE'] = 'devstack-centos7'
|
2015-04-14 20:09:41 -04:00
|
|
|
elif 'multinode' in job.name:
|
2015-07-14 16:25:55 -07:00
|
|
|
params['ZUUL_NODE'] = 'devstack-trusty-2-node'
|
2014-06-23 17:06:52 -07:00
|
|
|
else:
|
|
|
|
params['ZUUL_NODE'] = 'devstack-trusty'
|
2014-06-19 10:41:35 -07:00
|
|
|
|
|
|
|
|
|
|
|
def default_params_precise(item, job, params):
|
2014-06-24 11:46:16 -07:00
|
|
|
if 'trusty' in job.name:
|
|
|
|
params['ZUUL_NODE'] = 'bare-trusty'
|
|
|
|
else:
|
|
|
|
params['ZUUL_NODE'] = 'bare-precise'
|
2014-06-19 10:41:35 -07:00
|
|
|
|
|
|
|
|
|
|
|
def default_params_trusty(item, job, params):
|
|
|
|
change = item.change
|
|
|
|
# Note we can't fallback on the default labels because
|
|
|
|
# jenkins uses 'bare-precise || bare-trusty'.
|
|
|
|
# This is necessary to get the gearman plugin to register
|
|
|
|
# gearman jobs with both node labels.
|
2014-06-24 11:46:16 -07:00
|
|
|
if ((hasattr(change, 'branch') and
|
2014-09-29 23:14:12 +00:00
|
|
|
change.branch == 'stable/icehouse') or
|
|
|
|
('icehouse' in job.name or
|
2014-06-24 11:46:16 -07:00
|
|
|
'precise' in job.name)):
|
2014-06-19 10:41:35 -07:00
|
|
|
params['ZUUL_NODE'] = 'bare-precise'
|
2015-07-10 19:40:18 +00:00
|
|
|
elif job.name == 'bindep-nova-python27':
|
|
|
|
params['ZUUL_NODE'] = 'ubuntu-trusty'
|
2014-06-19 10:41:35 -07:00
|
|
|
else:
|
|
|
|
params['ZUUL_NODE'] = 'bare-trusty'
|
|
|
|
|
|
|
|
|
|
|
|
def set_node_options(item, job, params, default):
|
|
|
|
# Set up log url paramter for all jobs
|
2013-08-12 13:27:50 -07:00
|
|
|
set_log_url(item, job, params)
|
2014-06-19 10:41:35 -07:00
|
|
|
# Default to single use node. Potentially overriden below.
|
|
|
|
# Select node to run job on.
|
2013-08-12 13:27:50 -07:00
|
|
|
params['OFFLINE_NODE_WHEN_COMPLETE'] = '1'
|
2015-09-22 15:14:04 +10:00
|
|
|
proposal_re = r'^.*(merge-release-tags|(propose|upstream)-(.*?)-(constraints-.*|updates?))$' # noqa
|
2015-07-03 18:35:42 +00:00
|
|
|
release_re = r'^.*-(forge|jenkinsci|mavencentral|pypi-(both|wheel))-upload$'
|
2015-07-28 12:28:50 -04:00
|
|
|
hook_re = r'^hook-(.*?)-(rtfd)$'
|
2014-07-22 10:51:46 -07:00
|
|
|
python26_re = r'^.*-(py(thon)?)?26.*$'
|
2014-06-24 11:46:16 -07:00
|
|
|
centos6_re = r'^.*-centos6.*$'
|
2014-12-11 12:03:13 +11:00
|
|
|
f21_re = r'^.*-f21.*$'
|
2014-06-19 10:41:35 -07:00
|
|
|
tripleo_re = r'^.*-tripleo.*$'
|
2015-08-14 15:27:28 -07:00
|
|
|
kolla_image_re = r'^.*-kolla-build-images-.*$'
|
2015-07-10 16:08:36 -05:00
|
|
|
openstack_ansible_re = r'^.*-openstack-ansible-.*$'
|
2014-06-19 10:41:35 -07:00
|
|
|
devstack_re = r'^.*-dsvm.*$'
|
2015-06-04 00:17:54 +00:00
|
|
|
puppetunit_re = (
|
|
|
|
r'^gate-(puppet-.*|system-config)-puppet-(lint|syntax|unit).*$')
|
2014-06-19 10:41:35 -07:00
|
|
|
# jobs run on the proposal worker
|
2015-07-28 12:28:50 -04:00
|
|
|
if (re.match(proposal_re, job.name) or re.match(release_re, job.name) or
|
|
|
|
re.match(hook_re, job.name)):
|
2014-06-19 10:41:35 -07:00
|
|
|
reusable_node(item, job, params)
|
|
|
|
# Jobs needing python26
|
|
|
|
elif re.match(python26_re, job.name):
|
|
|
|
# Pass because job specified label is always correct.
|
|
|
|
pass
|
2015-08-14 15:27:28 -07:00
|
|
|
# Kolla build image jobs always have the correct node label.
|
|
|
|
# Put before distro specific overrides as they list distros in
|
|
|
|
# the jobs names unrelated to where job should run.
|
|
|
|
elif re.match(kolla_image_re, job.name):
|
|
|
|
pass
|
2014-06-24 11:46:16 -07:00
|
|
|
# Jobs needing centos6
|
|
|
|
elif re.match(centos6_re, job.name):
|
|
|
|
# Pass because job specified label is always correct.
|
|
|
|
pass
|
2014-12-11 12:03:13 +11:00
|
|
|
# Jobs needing fedora 21
|
|
|
|
elif re.match(f21_re, job.name):
|
|
|
|
# Pass because job specified label is always correct.
|
|
|
|
pass
|
2014-06-19 10:41:35 -07:00
|
|
|
# Jobs needing tripleo slaves
|
|
|
|
elif re.match(tripleo_re, job.name):
|
|
|
|
# Pass because job specified label is always correct.
|
|
|
|
pass
|
2015-08-19 17:30:02 +01:00
|
|
|
# openstack-ansible jobs
|
2015-08-19 21:02:25 +00:00
|
|
|
elif re.match(openstack_ansible_re, job.name):
|
2015-08-19 17:30:02 +01:00
|
|
|
# Pass because job specified label is always correct.
|
|
|
|
pass
|
2014-10-20 12:58:49 -07:00
|
|
|
# Puppet-OpenStack jobs
|
|
|
|
elif re.match(puppetunit_re, job.name):
|
|
|
|
pass
|
2014-06-19 10:41:35 -07:00
|
|
|
# Jobs needing devstack slaves
|
|
|
|
elif re.match(devstack_re, job.name):
|
|
|
|
devstack_params(item, job, params)
|
|
|
|
elif default == 'trusty':
|
|
|
|
default_params_trusty(item, job, params)
|
|
|
|
else:
|
|
|
|
default_params_precise(item, job, params)
|
2014-02-14 22:37:59 +00:00
|
|
|
|
|
|
|
|
2014-06-19 10:41:35 -07:00
|
|
|
def set_node_options_default_precise(item, job, params):
|
|
|
|
set_node_options(item, job, params, 'precise')
|
|
|
|
|
|
|
|
|
|
|
|
def set_node_options_default_trusty(item, job, params):
|
|
|
|
set_node_options(item, job, params, 'trusty')
|