Esempio n. 1
0
 def render(self, data):
     r = []
     i = 0
     notpresent = T.td(_class="notpresent")[T.acronym(
         title="Unable to get IP from ARP tables")["N/A"]]
     for row in data:
         mac = T.td[T.span(data=row[0], render=T.directive("mac"))]
         if row[1] is not None:
             r.append(
                 T.tr(_class=(i % 2) and "odd" or "even")
                 [mac,
                  T.td[T.invisible(data=row[1], render=T.directive("ip"))]])
         else:
             r.append(
                 T.tr(_class=(i % 2) and "odd" or "even")[mac, notpresent])
         i += 1
     if len(r) == 1:
         return [('FDB', [
             T.span(data=data[0][0],
                    render=T.directive("mac")), data[0][1] and
             [", ", T.span(data=data[0][1], render=T.directive("ip"))] or ""
         ], 1)]
     return [('FDB', [
         len(r) == 20 and "20+" or len(r),
         T.span(render=T.directive("tooltip"),
                data=T.table(_class="mac")[T.thead[T.td["MAC"], T.td["IP"]],
                                           r])
     ], len(r) == 20 and 21 or len(r))]
Esempio n. 2
0
 def render(self, data):
     r = []
     i = 0
     notpresent = T.td(_class="notpresent")[
         T.acronym(title="Unable to get IP from ARP tables")["N/A"]]
     for row in data:
         mac = T.td[T.span(data=row[0], render=T.directive("mac"))]
         if row[1] is not None:
             r.append(T.tr(_class=(i%2) and "odd" or "even")
                      [mac, T.td[T.invisible(data=row[1],
                                             render=T.directive("ip"))]])
         else:
             r.append(T.tr(_class=(i%2) and "odd" or "even")
                      [mac, notpresent])
         i += 1
     if len(r) == 1:
         return [('FDB',
                  [T.span(data=data[0][0], render=T.directive("mac")),
                   data[0][1] and [", ", T.span(data=data[0][1],
                                                render=T.directive("ip"))] or ""],
                  1)]
     return [('FDB',
              [len(r) == 20 and "20+" or len(r),
               T.span(render=T.directive("tooltip"),
                      data=T.table(_class="mac")[
                     T.thead[T.td["MAC"], T.td["IP"]], r])],
              len(r) == 20 and 21 or len(r))]
Esempio n. 3
0
 def render(self, data):
     r = []
     i = 0
     vlanlist = []
     notpresent = T.td(_class="notpresent")[T.acronym(
         title="Not present or no information from remote")["N/A"]]
     for row in data:
         if row[1] is not None:
             vlanlist.append(str(row[0]))
         vid = T.td[T.span(data=row[0], render=T.directive("vlan"))]
         if row[1] is None:
             r.append(
                 T.tr(_class=(i % 2) and "odd" or "even")[vid, notpresent,
                                                          T.td[row[2]]])
         elif row[2] is None:
             r.append(
                 T.tr(_class=(i % 2) and "odd" or "even")[vid, T.td[row[1]],
                                                          notpresent])
         elif row[1] == row[2]:
             r.append(
                 T.tr(_class=(i % 2) and "odd" or "even")[
                     vid, T.td(colspan=2)[row[1]]])
         else:
             r.append(
                 T.tr(_class=(i % 2) and "odd" or "even")[vid, T.td[row[1]],
                                                          T.td[row[2]]])
         i += 1
     vlantable = T.table(_class="vlan")[T.thead[T.td["VID"], T.td["Local"],
                                                T.td["Remote"]], r]
     return [('VLAN', [[[T.span(data=v, render=T.directive("vlan")), " "]
                        for v in vlanlist],
                       T.span(render=T.directive("tooltip"),
                              data=vlantable)], ", ".join(vlanlist))]
Esempio n. 4
0
 def render(self, data):
     r = []
     i = 0
     vlanlist = []
     notpresent = T.td(_class="notpresent")[
         T.acronym(title="Not present or no information from remote")["N/A"]]
     for row in data:
         if row[1] is not None:
             vlanlist.append(str(row[0]))
         vid = T.td[T.span(data=row[0], render=T.directive("vlan"))]
         if row[1] is None:
             r.append(T.tr(_class=(i%2) and "odd" or "even")[
                     vid, notpresent,
                     T.td[row[2]]])
         elif row[2] is None:
             r.append(T.tr(_class=(i%2) and "odd" or "even")
                      [vid, T.td[row[1]], notpresent])
         elif row[1] == row[2]:
             r.append(T.tr(_class=(i%2) and "odd" or "even")
                      [vid, T.td(colspan=2)[row[1]]])
         else:
             r.append(T.tr(_class=(i%2) and "odd" or "even")
                      [vid, T.td[row[1]], T.td[row[2]]])
         i += 1
     vlantable = T.table(_class="vlan")[
         T.thead[T.td["VID"], T.td["Local"], T.td["Remote"]], r]
     return [('VLAN',
              [[ [T.span(data=v, render=T.directive("vlan")), " "]
                 for v in vlanlist ],
               T.span(render=T.directive("tooltip"),
                      data=vlantable)],
              ", ".join(vlanlist))]