-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnode.py
More file actions
27 lines (22 loc) · 770 Bytes
/
node.py
File metadata and controls
27 lines (22 loc) · 770 Bytes
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
from scheduler.resources import Resource
from scheduler.exceptions import KubeHTTPException
class Node(Resource):
short_name = 'no'
def get(self, name=None, **kwargs):
"""
Fetch a single Node or a list
"""
url = '/nodes'
args = []
if name is not None:
args.append(name)
url += '/{}'
message = 'get Node "{}" in Nodes'
else:
message = 'get Nodes'
url = self.api(url, *args)
response = self.session.get(url, params=self.query_params(**kwargs))
if self.unhealthy(response.status_code):
args.reverse() # error msg is in reverse order
raise KubeHTTPException(response, message, *args)
return response