Ejemplo n.º 1
0
def formatARP(values):
    if not values: return None
    values = Quasar.Status.StatusDict(values, prefix="ARP_")
    idx = QTools.Counter()
    dict = {}

    num_entries = values['NumberOfEntries']
    dict['NumberOfEntries'] = (idx.inc(), "Number of Entries", num_entries)
    dict['LengthOfThisBlock'] = (idx.inc(), "Length of this Block", "%d bytes" % values['LengthOfThisBlock'])

    for i in range(0, num_entries):
        key_ip = "IPAddress_%d" % i
        key_mac_high_32 = "MACAddressHigh32_%d" % i
        key_mac_low_16 = "MACAddressLow16_%d" % i
        key_mac = "MACAddress_%d" % i
        key_timeout = "TimeoutInSeconds_%d" % i
        value_ip = values[key_ip]
        value_mac_high_32 = int(values[key_mac_high_32])
        value_mac_low_16 = int(values[key_mac_low_16])
        value_timeout = int(values[key_timeout])
        dict[key_ip] = (idx.inc(), "IP Address", QTools.format_ip(value_ip))
        dict[key_mac] = (idx.inc(), "MAC Address", QTools.format_mac((value_mac_high_32, value_mac_low_16)))
        dict[key_timeout] = (idx.inc(), "Timeout", "%d seconds" % values[key_timeout])
        #dict[key_mac_high_32] = (idx.inc(), "MAC Address High 32", value_mac_high)
        #dict[key_mac_low_16] = (idx.inc(), "MAC Address Low 16", value_mac_low)

    return dict
Ejemplo n.º 2
0
def formatDynamicIP(values):
    if not values: return None
    values = Quasar.Status.StatusDict(values, prefix="DynamicIP_")
    idx = QTools.Counter()
    dict = {}

    value_ip = int(values['Serial1IPAddress'])
    dict['Serial1IPAddress'] = (idx.inc(), "Serial 1 IP Address", QTools.format_ip(value_ip))

    value_ip = int(values['Serial2IPAddress'])
    dict['Serial2IPAddress'] = (idx.inc(), "Serial 2 IP Address", QTools.format_ip(value_ip))
    dict['Reserved'] = (idx.inc(), "Reserved", "N/A")

    value_ip = int(values['EthernetIPAddress'])
    dict['EthernetIPAddress'] = (idx.inc(), "Ethernet IP Address", QTools.format_ip(value_ip))

    return dict