in services/jenkins-autoscaling/lambda_mxnet_ci/autoscaling/handler.py [0:0]
def _custom_get_node_attributes(name, node_attributes):
"""
Custom implementation of node.Node.get_node_attributes() in order to specify more options.
:return: Node attributes dict formatted for Jenkins API request
to create node
"""
launcher = {
# http://javadoc.jenkins.io/archive/jenkins-2.73/index.html?hudson/slaves/JNLPLauncher.html
'stapler-class': 'hudson.slaves.JNLPLauncher',
'tunnel': node_attributes['tunnel'] # Custom option
}
retention = {
'stapler-class': 'hudson.slaves.RetentionStrategy$Always',
'$class': 'hudson.slaves.RetentionStrategy$Always'
}
node_props = {
'stapler-class-bag': 'true'
}
if node_attributes['job_name_restriction_regex']:
node_props['com.synopsys.arc.jenkinsci.plugins.jobrestrictions.nodes.JobRestrictionProperty'] = {
'$plugin': 'job-restrictions@0.7',
'jobRestriction': {
'stapler-class':
'com.synopsys.arc.jenkinsci.plugins.jobrestrictions.restrictions.job.RegexNameRestriction',
'$class': 'com.synopsys.arc.jenkinsci.plugins.jobrestrictions.restrictions.job.RegexNameRestriction',
'regexExpression': node_attributes['job_name_restriction_regex'],
'checkShortName': 'false'
}
}
params = {
'name': name,
'type': 'hudson.slaves.DumbSlave$DescriptorImpl',
'json': json.dumps({
'name': name,
'nodeDescription': node_attributes['node_description'],
'numExecutors': node_attributes['num_executors'],
'remoteFS': node_attributes['remote_fs'],
'labelString': node_attributes['labels'],
'mode': 'EXCLUSIVE' if node_attributes['exclusive'] else 'NORMAL',
'retentionStrategy': retention,
'type': 'hudson.slaves.DumbSlave',
'nodeProperties': node_props,
'launcher': launcher
})
}
return params