/usr/lib/python2.7/dist-packages/jenkinsapi/nodes.py is in python-jenkinsapi 0.2.16-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | """
Module for jenkinsapi nodes
"""
import logging
from jenkinsapi.node import Node
from jenkinsapi.custom_exceptions import UnknownNode
from jenkinsapi.jenkinsbase import JenkinsBase
log = logging.getLogger(__name__)
class Nodes(JenkinsBase):
"""
Class to hold information on a collection of nodes
"""
def __init__(self, baseurl, jenkins_obj):
"""
Handy access to all of the nodes on your Jenkins server
"""
self.jenkins = jenkins_obj
JenkinsBase.__init__(self, baseurl)
def get_jenkins_obj(self):
return self.jenkins
def __str__(self):
return 'Nodes @ %s' % self.baseurl
def __contains__(self, node_name):
return node_name in self.keys()
def iterkeys(self):
for item in self._data['computer']:
yield item['displayName']
def keys(self):
return list(self.iterkeys())
def iteritems(self):
for item in self._data['computer']:
nodename = item['displayName']
if nodename.lower() == 'master':
nodeurl = '%s/(%s)' % (self.baseurl, nodename)
else:
nodeurl = '%s/%s' % (self.baseurl, nodename)
try:
yield item['displayName'], Node(nodeurl, nodename, self.jenkins)
except Exception:
import ipdb
ipdb.set_trace()
def __getitem__(self, nodename):
self_as_dict = dict(self.iteritems())
if nodename in self_as_dict:
return self_as_dict[nodename]
else:
raise UnknownNode(nodename)
def __len__(self):
return len(self.iteritems())
|