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

Kubernetes container handler #68

Merged
merged 22 commits into from Dec 8, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b4cbcd8
containermgr: Added _fix_path to kubernetes handler.
ashcrow Dec 6, 2016
7c06d35
containermgr: Added _put to kubernetes handler.
ashcrow Dec 6, 2016
299fecb
containermgr: Added ContainerManagerError base exception class.
ashcrow Dec 7, 2016
f553aad
containermgr: Added register_node to kubernetes handler.
ashcrow Dec 6, 2016
5d04eb3
containermgr: Added remove_node to kubernetes handler.
ashcrow Dec 7, 2016
e39b29a
containermgr: Added get_node_status to kubernetes handler.
ashcrow Dec 7, 2016
2e83bba
doc: api docs for containermgr/service.
ashcrow Dec 7, 2016
60b1011
fixup! containermgr: Added _fix_path to kubernetes handler.
ashcrow Dec 7, 2016
7a3a5e8
fixup! containermgr: Added _put to kubernetes handler.
ashcrow Dec 7, 2016
dae9aff
fixup! containermgr: Added register_node to kubernetes handler.
ashcrow Dec 7, 2016
f59001c
fixup! containermgr: Added register_node to kubernetes handler.
ashcrow Dec 7, 2016
6d20245
fixup! containermgr: Added ContainerManagerError base exception class.
ashcrow Dec 7, 2016
24b5ac1
fixup! containermgr: Added remove_node to kubernetes handler.
ashcrow Dec 7, 2016
96b564c
fixup! containermgr: Added get_node_status to kubernetes handler.
ashcrow Dec 7, 2016
131864a
containermgr: Updated node_registered to work like other methods.
ashcrow Dec 7, 2016
2b7ca59
test: Fix tests for the kubernetes containermgr.
ashcrow Dec 7, 2016
83e3a74
fixup! containermgr: Updated node_registered to work like other methods.
ashcrow Dec 8, 2016
866776f
vagrant: Auto starting commissaire-containermgr
ashcrow Dec 8, 2016
0b4aa3d
fixup! containermgr: Added register_node to kubernetes handler.
ashcrow Dec 8, 2016
0baf7fc
fixup! containermgr: Added remove_node to kubernetes handler.
ashcrow Dec 8, 2016
e8abc82
fixup! containermgr: Added get_node_status to kubernetes handler.
ashcrow Dec 8, 2016
7554b75
fixup! containermgr: Updated node_registered to work like other methods.
ashcrow Dec 8, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/commissaire/containermgr/kubernetes/__init__.py
Expand Up @@ -93,6 +93,22 @@ def check_config(cls, config):
'Server URL scheme must be "https" when using client '
'side certificates (got "{}")'.format(url.scheme))

def _fix_part(self, part):
"""
Fixes part if it doesn't start with a slash.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearer wording: Ensures the URI part starts with a slash.


:param part: The URI part. EG: /nodes
:type part: str
:returns: The part in the proper format.
:rtype: str
"""
if not part.startswith('/'):
self.logger.debug(
'Part given without starting slash. Adding...')
part = '/{}'.format(part)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This could just be part = '/' + part. Optional; not gonna block over it.


return part

def _get(self, part, *args, **kwargs):
"""
Get information from the Kubernetes apiserver.
Expand All @@ -105,12 +121,7 @@ def _get(self, part, *args, **kwargs):
:type kwargs: dict
:returns: requests.Response
"""
# Fix part if it doesn't start with a slash
if not part.startswith('/'):
self.logger.debug(
'Part given without starting slash. Adding...')
part = '/{}'.format(part)

part = self._fix_part(part)
self.logger.debug('Executing GET for {}'.format(part))
resp = self.con.get(
'{}{}'.format(self.base_uri, part), *args, **kwargs)
Expand Down
16 changes: 16 additions & 0 deletions test/test_containermgr_kubernetes.py
Expand Up @@ -98,3 +98,19 @@ def test_get_host_status(self):
self.instance.con.get.assert_called_with(
CONTAINER_MGR_CONFIG['server_url'] + 'api/v1/nodes/test')

def test__fix_part_with_valid_part(self):
"""
Verify that when a valid part is given it is returned without modification.
"""
expected = '/test'
self.assertEquals(
expected,
self.instance._fix_part(expected))

def test__fix_part_with_invalid_part(self):
"""
Verify that when an invalid part it is fixed.
"""
self.assertEquals(
'/test',
self.instance._fix_part('test'))