def render_content(self, ctx, data): interfaces = Utils.getInterfaces() + self.sysconf.EthernetDevices.keys( ) params = Utils.parseNet() d = {} vlans = [] routes = {} types = {} vali = [] for i in interfaces: if not "vlan" in i: if i in d.keys(): pass if i in params.keys(): types[i] = params[i]['type'] routes[i] = [params[i].get('network', '')] if params[i]['type'] == 'static': d[i] = params[i]['ip'] if params[i]['type'] == 'manual': d[i] = "Manual" else: d[i] = "DHCP" else: types[i] = "" routes[i] = "" d[i] = "" else: vlans.append((i, params[i]['ip'], tags.a(title="Edit Interface %s" % i, href="Edit/%s" % i)[tags.img(src="/images/edit.png")])) return ctx.tag[ tags.h3[tags.img(src="/images/netdrive.png"), " Network Setup"], PageHelpers.TabSwitcher((('Interface Configuration', 'panelIface'), ('VLAN Configuration', 'panelVlan'), ('IPv6 Tunnel', 'panelTunnel'))), tags.div(id="panelIface", _class="tabPane")[ tags.h3["Configured Interfaces"], tags.table(cellspacing="0", _class="listing")[tags.thead( background="/images/gradMB.png")[tags.tr[ tags.th['Interface'], tags.th['DHCP'], tags.th['IP'], tags.th['Associated Routes'], tags.th[''], ]], tags.tbody[[ tags.tr[tags.td[i.replace('eth', 'Port ')], tags.td[types[i] == 'dhcp'], tags.td[d[i]], tags.td[[[k, tags.br] for k in routes. get(i, ["None"])]], tags. td[tags.a(title="Edit Interface %s" % i, href="Edit/%s" % i)[tags.img( src="/images/edit.png")]], ] for i in d.keys() if not i == "lo" ]]], tags.br, tags.h3["Add interface"], tags.directive('form addInterface')], tags.div(id="panelVlan", _class="tabPane")[ tags.h3["Configured VLAN Interfaces"], PageHelpers.dataTable(('Interface', 'IP', ''), vlans), tags.br, tags.h3["Add VLAN"], tags.directive('form addVLAN')], tags.div(id="panelTunnel", _class="tabPane")[ tags.h3["Configure IPv6 Tunnel"], tags.directive('form tunnelConf')], PageHelpers.LoadTabSwitcher(), ]
def render_content(self, ctx, data): interfaces = Utils.getInterfaces() + self.sysconf.EthernetDevices.keys( ) params = Utils.parseNet() d = {} vlans = [] routes = {} types = {} vali = [] traffic = {} da = datetime.datetime.now() today = "%s%s%s" % (da.day, da.month, da.year) for i in interfaces: if 'tap' not in i and 'eth' not in i and 'ppp' not in i and 'vlan' not in i: continue if not "vlan" in i: if i in d.keys(): pass if i in params.keys(): types[i] = params[i]['type'] routes[i] = [params[i].get('network', '')] if params[i]['type'] == 'static': d[i] = params[i]['ip'] if params[i]['type'] == 'manual': d[i] = "Manual" else: d[i] = "DHCP" else: types[i] = "" routes[i] = "" d[i] = "" else: vlans.append((i, params[i]['ip'], tags.a(title="Edit Interface %s" % i, href="Edit/%s" % i)[tags.img(src="/images/edit.png")])) # Read the traffic counters try: p = open('/usr/local/tcs/tums/rrd/iface_%s_%stotal.nid' % (i, today)).read().split(':') traffic[i] = (float(p[0]), float(p[1])) except: traffic[i] = (0, 0) return ctx.tag[ tags.h3[tags.img(src="/images/stock-disconnect.png"), self.text.toolsMenuNetconf], PageHelpers.TabSwitcher(( ('Interface Configuration', 'panelIface'), ('VLAN Configuration', 'panelVlan'), ('IPv6 Tunnel', 'panelTunnel'), ('Advanced', 'panelAdvanced'), )), tags.div(id="panelIface", _class="tabPane")[ tags.h3["Interfaces"], tags.table(width="95%")[[ tags.tr[[ tags.td[self.roundedBlock(j, [ tags.img(src="/images/graphs/iface-%sFS.png" % j), tags. table[tags.tr(valign="top")[ tags.td[tags.strong["Traffic Out (24h): "]], tags.td[Utils.intToH(traffic[j][1])]], tags.tr( valign="top" )[tags.td[tags.strong["Traffic In (24h): "]], tags.td[Utils.intToH(traffic[j][0])]], tags.tr(valign="top")[ tags.td[tags. strong["Configuration Type: "]], tags.td[types[j] == 'dhcp' and 'DHCP' or 'Static']], tags.tr(valign="top")[ tags.td[tags. strong["Associated Routes: "]], tags.td[[[k, tags.br] for k in routes. get(j, ["None"])]]], tags.tr( valign="top" )[tags.td[tags.a(title="Edit Interface %s" % j, href="Edit/%s" % j)[tags.img( src="/images/edit.png"), " Edit Settings"]], tags.td[""]]] ])] for j in i if j ]] for i in WebUtils.runIter(1, d.keys()) ]], tags.br, #tags.h3["Add interface"], #tags.directive('form addInterface') ], tags.div(id="panelVlan", _class="tabPane")[ tags.h3["Configured VLAN Interfaces"], PageHelpers.dataTable(('Interface', 'IP', ''), vlans), tags.br, tags.h3["Add VLAN"], tags.directive('form addVLAN')], tags.div(id="panelTunnel", _class="tabPane")[ tags.h3["Configure IPv6 Tunnel"], tags.directive('form tunnelConf')], tags.div(id="panelAdvanced", _class="tabPane") [tags.h3["Advanced Settings"], tags. p["If you are unsure of any of these settings you should almost certainly not change them"], tags.directive('form advanced')], PageHelpers.LoadTabSwitcher(), ]