示例#1
0
def Devicelist(params):
    #returns a list of firewalls
    SessionID = params['SessionID']
    device_list = []
    device_infor = []
    proxy = 'https://' + sHost + '/AFA/php/ws.php?wsdl'
    namespace = 'https://www.algosec.com/afa-ws'
    server = SOAPProxy(proxy, namespace)
    devices = server.GetDevicesListRequest(
        SessionID=SessionID)  #this makes the call to algosec
    devices = str(devices)
    devices = devices.replace("-", "_")  #cleans the data
    devices = devices.split(',')
    for device in devices:
        if "structType" in device:
            device_list.append(device_infor)
            device_infor = []
        else:
            replacement_list = ["'", "}", "{", " "]  #clean the data
            for x in replacement_list:
                device = device.replace(x, "")
            device = device.split(":")
            device_infor.append(device)

    print device_list
    return device_list
def Devicelist(params):
#returns a list of firewalls optional 
        SessionID = params['SessionID']
        device_list=[]
        device_infor=[]#connection information
        proxy = 'https://'+sHost+'/AFA/php/ws.php?wsdl'
        namespace = 'https://www.algosec.com/afa-ws'
        server = SOAPProxy(proxy, namespace)
        devices=server.GetDevicesListRequest(SessionID=SessionID)
        devices=str(devices)
        devices=devices.split(',')
        for device in devices:
                device_par=device.split(">:")
                if "Types.structType" in device_par[0] or "at" in device_par[0]:
                        device_par.pop(0)
                        try:
                                device_par=device_par[0]
                                replacement_list=[" ","'","]",'"',"{","}"]
                                for items in replacement_list:
                                        device_par=device_par.replace(items,"")
                                device_par=device_par.split(":")
                                #print device_par
                                device_file_list.write(device_par[0]+":"+device_par[1]+"n")
                                if "Policy" in device_par[0]:
                                        device_list.append(device_par[1])
                        except IndexError:
                                pass
                else:
                        try:
                                device_par=device_par[0]
                                replacement_list=[" ","'","]",'"',"{","}"]
                                for items in replacement_list:
                                        device_par=device_par.replace(items,"")
                                device_par=device_par.split(":")
                                #printdevice_par
                                device_file_list.write(device_par[0]+":"+device_par[1]+"\n")
                                if "ID" in device_par[0]:
                                        device_list.append(device_infor)
                                        device_infor=[]
                                        device_infor.append(device_par[0])
                                else:
                                        device_infor.append(device_par[0])
                        except:
                                pass
        #printdevice_list
        return device_list