Renamed _debug to debug
This commit is contained in:
parent
91f42d8cd5
commit
081b2c2a42
@ -27,9 +27,9 @@ class ServiceDelegate(ServiceBase) :
|
||||
self.start_session(self.config['host'],self.config['username'],self.config['key'])
|
||||
listquery = 'backend-observer-sta-19'
|
||||
sortfield = 'client_user_name'
|
||||
self._debug("Retrieving list of Aruba hosts...",1)
|
||||
self.debug("Retrieving list of Aruba hosts...",1)
|
||||
self.perform_list_query(listquery,self.bigdata_fields,sortfield)
|
||||
self._debug("Searching Aruba hosts...",1)
|
||||
self.debug("Searching Aruba hosts...",1)
|
||||
|
||||
def perform_lookup(self,host_tuple) :
|
||||
# Lookup by IP
|
||||
@ -96,7 +96,7 @@ class ServiceDelegate(ServiceBase) :
|
||||
num_rows.text = str(self.query_page_size)
|
||||
datapayload = "".join(['query=',tostring(aruba_queries).decode(),'&UIDARUBA=',self.session_key])
|
||||
page = self.api_session.post("https://" + self.host + "/screens/cmnutil/execUiQuery.xml",verify=False,timeout=1,data=datapayload)
|
||||
self._debug("Got a page of results from Aruba host...",3)
|
||||
self.debug("Got a page of results from Aruba host...",3)
|
||||
if page.status_code == 100 or page.status_code == 200 :
|
||||
pagecontents = ElementTree.fromstring(page.text)
|
||||
rows = pagecontents.iter('row')
|
||||
@ -120,5 +120,5 @@ class ServiceDelegate(ServiceBase) :
|
||||
else :
|
||||
finish = True
|
||||
self.aruba_hosts = allitems
|
||||
self._debug("Retrieved " + str((len(allitems))) + " hosts from Aruba host",2)
|
||||
self.debug("Retrieved " + str((len(allitems))) + " hosts from Aruba host",2)
|
||||
|
||||
|
@ -19,7 +19,7 @@ class ServiceDelegate(ServiceBase) :
|
||||
return
|
||||
self.host = self.config['host']
|
||||
self.current_auth_header = self.get_bc_auth_header(self.config['host'],self.config['username'],self.config['key'])
|
||||
self._debug("Searching BlueCat for hosts...",1)
|
||||
self.debug("Searching BlueCat for hosts...",1)
|
||||
|
||||
def perform_lookup(self,host_tuple) :
|
||||
self.return_payload = {}
|
||||
|
@ -21,7 +21,7 @@ class ServiceDelegate(ServiceBase) :
|
||||
self.error.appendupdate('Missing required config option ' + requirement)
|
||||
return
|
||||
self.hosts = self.config['hosts']
|
||||
self._debug("Logging into F5's and searching for hosts, this make take some time.",1)
|
||||
self.debug("Logging into F5's and searching for hosts, this make take some time.",1)
|
||||
|
||||
def perform_lookup(self,host_tuple) :
|
||||
self.return_payload = {}
|
||||
@ -42,7 +42,7 @@ class ServiceDelegate(ServiceBase) :
|
||||
vips = self.get_vip(host,auth_header);
|
||||
# If it's a VIP, return it and the host and let's be done
|
||||
if vips :
|
||||
self._debug("Got vips from " + host,3)
|
||||
self.debug("Got vips from " + host,3)
|
||||
vip_match = [ x for x in vips if x['destination'].split('/' + self._partition + '/')[1].startswith(host_tuple[2][0])]
|
||||
all_vips = [ x['destination'] for x in vips ]
|
||||
if len(vip_match) > 0 :
|
||||
@ -54,9 +54,9 @@ class ServiceDelegate(ServiceBase) :
|
||||
self.return_payload.update(pool_info)
|
||||
break
|
||||
else :
|
||||
self._debug("Unable to find VIP in VIPs from host " + host,2)
|
||||
self.debug("Unable to find VIP in VIPs from host " + host,2)
|
||||
else :
|
||||
self._debug("Unable to get VIPs from " + host,2)
|
||||
self.debug("Unable to get VIPs from " + host,2)
|
||||
# If it's a VIP, return it and the host and let's be done
|
||||
# Otherwise, get all nodes.
|
||||
# If it's in the nodes, we have to start all over and find where.
|
||||
@ -79,7 +79,7 @@ class ServiceDelegate(ServiceBase) :
|
||||
if 'token' in json.loads(login.text) :
|
||||
token = json.loads(login.text)['token']['token']
|
||||
except Exception as exception:
|
||||
self._debug("Exception getting auth header for host " + host + ": \n" + str(exception),2)
|
||||
self.debug("Exception getting auth header for host " + host + ": \n" + str(exception),2)
|
||||
return None
|
||||
if token :
|
||||
return { "X-F5-Auth-Token" : token }
|
||||
@ -89,15 +89,15 @@ class ServiceDelegate(ServiceBase) :
|
||||
def get_vip(self,host,header) :
|
||||
"""Given a host and an authorization header, gets all the vips for that host"""
|
||||
# Please don't give me empty auth headers, I don't want to check it everywhere
|
||||
self._debug("Trying VIP info for " + host,2)
|
||||
self.debug("Trying VIP info for " + host,2)
|
||||
try :
|
||||
vips = requests.get("https://" + host + '/mgmt/tm/ltm/virtual',headers=header,verify=False,timeout=10)
|
||||
if vips.status_code == 200 :
|
||||
return json.loads(vips.text)['items']
|
||||
self._debug("Response not OK for " + vips.history[0].url,3)
|
||||
self.debug("Response not OK for " + vips.history[0].url,3)
|
||||
return None
|
||||
except Exception as exception :
|
||||
self._debug("Exception getting VIPs for host " + host + ": \n" + str(exception),2)
|
||||
self.debug("Exception getting VIPs for host " + host + ": \n" + str(exception),2)
|
||||
return None
|
||||
|
||||
def get_pool(self,host,header,pool) :
|
||||
@ -111,10 +111,10 @@ class ServiceDelegate(ServiceBase) :
|
||||
membersobj = json.loads(members.text)['items']
|
||||
return {'pool':poolobj,'members':membersobj}
|
||||
return {'pool':poolobj}
|
||||
elf._debug("Response not OK for " + pool.history[0].url,3)
|
||||
elf.debug("Response not OK for " + pool.history[0].url,3)
|
||||
return None
|
||||
except Exception as exception:
|
||||
self._debug("Exception getting pool for host " + host + ": \n" + str(exception),2)
|
||||
self.debug("Exception getting pool for host " + host + ": \n" + str(exception),2)
|
||||
return None
|
||||
|
||||
def choose_host(self,host_tuple) :
|
||||
|
@ -35,7 +35,7 @@ class ServiceBase :
|
||||
self.shutdown()
|
||||
return finaldictionary
|
||||
|
||||
def _debug(self,message,verbosity_level) :
|
||||
def debug(self,message,verbosity_level) :
|
||||
if self.namespace.debug and self.namespace.debug >= verbosity_level :
|
||||
print(message,file=sys.stderr)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user