From b9f4e141703ebb383d227b942916065e148fa6da Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 18 Apr 2014 14:42:35 -0400 Subject: [PATCH] Fix list_* functions to correctly handle non-existent collections --- confluent/config/configmanager.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/confluent/config/configmanager.py b/confluent/config/configmanager.py index 5b253c06..3543545b 100644 --- a/confluent/config/configmanager.py +++ b/confluent/config/configmanager.py @@ -486,7 +486,10 @@ class ConfigManager(object): def list_users(self): - return self._cfgstore['users'].iterkeys() + try: + return self._cfgstore['users'].iterkeys() + except KeyError: + return [] def get_user(self, name): """Get user information from DB @@ -580,7 +583,10 @@ class ConfigManager(object): return self._cfgstore['groups'].iterkeys() def list_nodes(self): - return self._cfgstore['nodes'].iterkeys() + try: + return self._cfgstore['nodes'].iterkeys() + except KeyError: + return [] def get_nodegroup_attributes(self, nodegroup, attributes=[]): cfgnodeobj = self._cfgstore['groups'][nodegroup]