Added get_nodes_with_info() function to show information of all the nodes
This function will fetch the information of all the nodes at once, avoiding the overhead of calling the get_node_info() for all the individual nodes and hence, reducing the time to fetch data of all the nodes. Change-Id: I6b7ea235cf0a3a6966c31d548586374502f1e4e3
This commit is contained in:
parent
d1e4696495
commit
8172edd32c
|
@ -1528,6 +1528,36 @@ class Jenkins(object):
|
|||
'executor': executor_number})
|
||||
return builds
|
||||
|
||||
def get_nodes_with_info(self, depth=0):
|
||||
'''Get a list of nodes connected to the Master
|
||||
|
||||
Each node is a dictionary of node info
|
||||
|
||||
:returns: List of nodes
|
||||
'''
|
||||
try:
|
||||
nodes_data = json.loads(self.jenkins_open(
|
||||
requests.Request('GET', self._build_url(NODE_LIST, locals()))))
|
||||
return [
|
||||
{
|
||||
"name": c["displayName"],
|
||||
"description": c["description"],
|
||||
"assignedLabels": c["assignedLabels"],
|
||||
"idle": c["idle"],
|
||||
"offline": c["offline"],
|
||||
"offlineCause": c["offlineCause"],
|
||||
"temporarilyOffline": c["temporarilyOffline"],
|
||||
"icon": c["icon"],
|
||||
}
|
||||
for c in nodes_data["computer"]
|
||||
]
|
||||
except (req_exc.HTTPError, BadStatusLine):
|
||||
raise BadHTTPException("Error communicating with server[%s]"
|
||||
% self.server)
|
||||
except ValueError:
|
||||
raise JenkinsException("Could not parse JSON info for server[%s]"
|
||||
% self.server)
|
||||
|
||||
def get_nodes(self, depth=0):
|
||||
'''Get a list of nodes connected to the Master
|
||||
|
||||
|
|
Loading…
Reference in New Issue