|
@@ -35,11 +35,25 @@ class BatcaveClient(object):
|
|
|
url = 'node/{0}.json'.format(nodeid)
|
|
|
return self.__load_response(url, 'node \'' + nodeid + '\'')
|
|
|
|
|
|
- def find_node(self, name, fuzzymatch=True, single_match_only=True):
|
|
|
+ def find_node_by_name(self, name, fuzzymatch=True, single_match_only=True):
|
|
|
"""Tries to find a node by given name."""
|
|
|
|
|
|
url = 'find?name=' + name + '&fuzzy=' + ('1' if fuzzymatch else '0')
|
|
|
- matches = self.__load_response(url, 'find=' + name)
|
|
|
+ matches = self.__load_response(url, 'find_name=' + name)
|
|
|
+
|
|
|
+ if single_match_only:
|
|
|
+ if len(matches) == 1:
|
|
|
+ return matches[0]
|
|
|
+ else:
|
|
|
+ return None
|
|
|
+
|
|
|
+ return matches
|
|
|
+
|
|
|
+ def find_node_by_mac(self, mac, single_match_only=True):
|
|
|
+ """Tries to find a node by given MAC address."""
|
|
|
+
|
|
|
+ url = 'find?mac=' + mac
|
|
|
+ matches = self.__load_response(url, 'find_mac=' + mac)
|
|
|
|
|
|
if single_match_only:
|
|
|
if len(matches) == 1:
|