Removed redundant imports in Aruba plugin
This commit is contained in:
parent
3220276b7a
commit
e00894c122
@ -1,6 +1,5 @@
|
||||
from servicebase import ServiceBase
|
||||
import requests
|
||||
from xml.etree.ElementTree import Element, SubElement, Comment, tostring
|
||||
import xml.etree.ElementTree as ElementTree
|
||||
|
||||
|
||||
@ -90,36 +89,36 @@ class ServiceDelegate(ServiceBase) :
|
||||
# Build the basic object for our list query. Takes the parameters that the Aruba controller needs for it's
|
||||
# XML api, performs the query, and returns a list of results.
|
||||
sortdir = 'asc'
|
||||
aruba_queries = Element('aruba_queries')
|
||||
query = SubElement(aruba_queries,'query')
|
||||
qname = SubElement(query,'qname')
|
||||
aruba_queries = ElementTree.Element('aruba_queries')
|
||||
query = ElementTree.SubElement(aruba_queries,'query')
|
||||
qname = ElementTree.SubElement(query,'qname')
|
||||
qname.text = queryname
|
||||
type = SubElement(query,'type')
|
||||
type = ElementTree.SubElement(query,'type')
|
||||
type.text = 'list'
|
||||
|
||||
list_query = SubElement(query,'list_query')
|
||||
device_type = SubElement(list_query,'device_type')
|
||||
list_query = ElementTree.SubElement(query,'list_query')
|
||||
device_type = ElementTree.SubElement(list_query,'device_type')
|
||||
device_type.text = devicetype
|
||||
requested_columns = SubElement(list_query,'requested_columns')
|
||||
requested_columns = ElementTree.SubElement(list_query,'requested_columns')
|
||||
requested_columns.text = ' '.join(columnlist)
|
||||
sort_by_field = SubElement(list_query,'sort_by_field')
|
||||
sort_by_field = ElementTree.SubElement(list_query,'sort_by_field')
|
||||
sort_by_field.text = sortfield
|
||||
sort_order = SubElement(list_query,'sort_order')
|
||||
sort_order = ElementTree.SubElement(list_query,'sort_order')
|
||||
sort_order.text = sortdir
|
||||
pagination = SubElement(list_query,'pagination')
|
||||
start_row = SubElement(pagination,'start_row')
|
||||
num_rows = SubElement(pagination,'num_rows')
|
||||
pagination = ElementTree.SubElement(list_query,'pagination')
|
||||
start_row = ElementTree.SubElement(pagination,'start_row')
|
||||
num_rows = ElementTree.SubElement(pagination,'num_rows')
|
||||
|
||||
filter = SubElement(query,'filter')
|
||||
global_operator = SubElement(filter,'global_operator')
|
||||
filter = ElementTree.SubElement(query,'filter')
|
||||
global_operator = ElementTree.SubElement(filter,'global_operator')
|
||||
global_operator.text = 'and'
|
||||
filter_list = SubElement(filter,'filter_list')
|
||||
filter_item_entry = SubElement(filter_list,'filter_item_entry')
|
||||
field_name = SubElement(filter_item_entry,'field_name')
|
||||
filter_list = ElementTree.SubElement(filter,'filter_list')
|
||||
filter_item_entry = ElementTree.SubElement(filter_list,'filter_item_entry')
|
||||
field_name = ElementTree.SubElement(filter_item_entry,'field_name')
|
||||
field_name.text = queryfilter.split(' ')[0]
|
||||
comp_operator = SubElement(filter_item_entry,'comp_operator')
|
||||
comp_operator = ElementTree.SubElement(filter_item_entry,'comp_operator')
|
||||
comp_operator.text = queryfilter.split(' ')[1]
|
||||
value = SubElement(filter_item_entry,'value')
|
||||
value = ElementTree.SubElement(filter_item_entry,'value')
|
||||
value.text = queryfilter.split(' ')[2]
|
||||
|
||||
# Repeat with page size on the query, aggregating results
|
||||
@ -129,7 +128,7 @@ class ServiceDelegate(ServiceBase) :
|
||||
while not finished :
|
||||
start_row.text = str(nextstart)
|
||||
num_rows.text = str(self._query_page_size)
|
||||
datapayload = ''.join(['query=',tostring(aruba_queries).decode(),'&UIDARUBA=',self._session_key])
|
||||
datapayload = ''.join(['query=',ElementTree.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)
|
||||
if page.status_code == 100 or page.status_code == 200 :
|
||||
|
Loading…
Reference in New Issue
Block a user