Skip to content
This repository has been archived by the owner on Feb 2, 2018. It is now read-only.

Commit

Permalink
containermgr: Added get_node_status to kubernetes handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashcrow committed Dec 7, 2016
1 parent 5a89921 commit 9b6f572
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/commissaire/containermgr/kubernetes/__init__.py
Expand Up @@ -262,7 +262,7 @@ def node_registered(self, name):
return True
return False

def get_host_status(self, address, raw=False):
def get_node_status(self, address, raw=False):
"""
Returns the node status.
Expand All @@ -275,10 +275,12 @@ def get_host_status(self, address, raw=False):
"""
part = '/nodes/{}'.format(address)
resp = self._get(part)
data = resp.json()
if raw:
data = data['status']
return (resp.status_code, data)
if resp.status_code == 200:
data = resp.json()
if raw:
data = data['status']
return data
return False


#: Common name for the class
Expand Down
6 changes: 3 additions & 3 deletions test/test_containermgr_kubernetes.py
Expand Up @@ -126,17 +126,17 @@ def test_remove_node(self):
self.instance.con.delete.assert_called_once_with(
CONTAINER_MGR_CONFIG['server_url'] + 'api/v1/nodes/test')

def test_get_host_status(self):
def test_get_node_status(self):
"""
Verify get_host_status makes the proper remote call.
Verify get_node_status makes the proper remote call.
"""
data = {'data': 'data', 'status': 'status'}
for raw, result in ((True, 'status'), (False, data)):
self.instance.con = mock.MagicMock()
resp = mock.MagicMock(json=mock.MagicMock(return_value=data))
self.instance.con.get.return_value = resp
self.instance.con.get().status_code = 200
self.assertEquals((200, result), self.instance.get_host_status('test', raw))
self.assertEquals(result, self.instance.get_node_status('test', raw))
self.instance.con.get.assert_called_with(
CONTAINER_MGR_CONFIG['server_url'] + 'api/v1/nodes/test')

Expand Down

0 comments on commit 9b6f572

Please sign in to comment.