From d302d437fb602e58923101d8b70a7e961986d994 Mon Sep 17 00:00:00 2001 From: Daniel Dayley Date: Tue, 18 Aug 2020 09:50:14 -0600 Subject: [PATCH] Removed DC selection in F5 plugin This was legacy functionality that made more sense in the early days of this tool as a command-line only tool. Now that it is a framework, choosing the host to search through can be specified by configuring the lookup. Selecting the DC in the plugin more often than not wasted time and operated somewhat arbitrarily. The plugin's behavior is now more consistent with the other plugins. --- ifxlookup/plugins/f5.py | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/ifxlookup/plugins/f5.py b/ifxlookup/plugins/f5.py index 99d6014..80fef1d 100644 --- a/ifxlookup/plugins/f5.py +++ b/ifxlookup/plugins/f5.py @@ -26,14 +26,8 @@ class ServiceDelegate(ServiceBase) : def lookup(self,subject) : self._return_payload = {} - logincandidates = self.choose_host(subject) - if len(logincandidates) == 0 : - # Idk what to do here, do we give up or do we log in to all of them? - self._error.append('Unable to find an LB to log into to check host ' + str(subject)) - # Search all - logincandidates = {x:x for x in self._hosts} - # Give up - # return None + # Search all + logincandidates = {x:x for x in self._hosts} for host in logincandidates.keys() : auth_header = self.get_iq_auth_header(host,self._config['username'],self._config['key']) @@ -120,31 +114,3 @@ class ServiceDelegate(ServiceBase) : self.debug('Exception getting pool for host ' + host + ': \n' + str(exception),2) return None - def choose_host(self,subject) : - """Given a subject, return the host that we suspect is responsible for the VIP resides in.""" - hosts = {} - # Guess based on hostname - dcmatch = re.search('^[a-zA-Z]*-([a-zA-Z0-9]*)(-.*)*$',subject) - if dcmatch : - potentialdc = dcmatch.group(1) - else : - potentialdc = None - if potentialdc : - for host in self._hosts.keys() : - if potentialdc.lower() in host.lower() : - hosts.update({host:self._hosts[host]}) - if len(hosts) > 0 : - return hosts - self.debug('Unable to determine DC from subject name: ' + subject,3) - # No hostname match, maybe we have info from bluecat? - if 'bluecat' in self.hints and subject in self.hints['bluecat'] and self.hints['bluecat'][subject]['object'] : - if 'locationCode' in self.hints['bluecat'][subject]['object'] : - potentialdc = self.hints['bluecat'][subject]['object']['locationCode'].split(' ')[-1] - elif 'parent' in self.hints['bluecat'][subject] and 'name' in self.hints['bluecat'][subject]['parent'] : - potentialdc = self.hints['bluecat'][subject]['parent']['name'].split(' ')[0] - for host in self._hosts.keys() : - if potentialdc.lower() in host.lower() : - hosts.update({host:self._hosts[host]}) - self.debug('Got additional host info from the BlueCat plugin!',3) - return hosts - return hosts