コード例 #1
0
ファイル: Firewall.py プロジェクト: calston/tums
    def form_addNAT(self, data):
        form = formal.Form()

        ifs = []
        for i in Utils.getInterfaces():
            if i[:3] in ['eth', 'ppp', 'tap', 'tun']: # Only allow tap and eth binds...
                ifs.append((i, i))

        form.addField('dstif', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options = ifs), label = "External Interface",
            description = "The interface to which this traffic will be NATed.")

        form.addField('srcif', formal.String(), formal.widgetFactory(formal.SelectChoice, options = ifs), label = "Source Interface",
            description = "The interface which will have NAT applied to it")

        form.addField('destip', formal.String(), label = "Destination IP", description = ["Destination IP or network (Leave blank for ANY). ", 
        "This is the destination network you would like to NAT to"])

        form.addField('srcip', formal.String(), label = "Source IP", description = ["Source IP or network (Leave blank for ANY). ", 
        "This is the source network you would like to NAT from."])

        form.addField('natip', formal.String(), label = "NAT IP", description = ["The IP address that you would like to NAT the connections as.",
            "Leave this blank to let the firewall decide based on the interface configuration."])

        form.addField('proto', formal.String(), formal.widgetFactory(formal.SelectChoice, options = self.protocols), 
            label = "Protocol", description = "Protocol to NAT")
        form.addField('srcport', formal.String(strip=True, validators=[PageHelpers.PortRangeValidator()]), label = "Source port", description = "TCP/UDP port to NAT.")

        form.addAction(self.submitNAT)

        return form
コード例 #2
0
ファイル: Routing.py プロジェクト: calston/tums
    def form_parp(self, data):
        form = formal.Form()

        ifs = []
        for i in Utils.getInterfaces():
            if 'eth' in i or 'tap' in i:  # Only allow tap and eth binds...
                ifs.append((i, i))

        form.addField('ip',
                      formal.String(required=True,
                                    strip=True,
                                    validators=[PageHelpers.IPValidator()]),
                      label="IP Address")

        form.addField(
            'extif',
            formal.String(required=True),
            formal.widgetFactory(formal.SelectChoice, options=ifs),
            label="External Interface",
            description=
            "The interface where this server will advertise availability of this IP address"
        )

        form.addField(
            'intif',
            formal.String(required=True),
            formal.widgetFactory(formal.SelectChoice, options=ifs),
            label="Internal Interface",
            description=
            "The interface to which this IP address will be routed (Where the server binding this IP address is)"
        )

        form.addAction(self.submitProxyARP)
        return form
コード例 #3
0
ファイル: Routing.py プロジェクト: calston/tums
    def form_statroutes(self, data):
        form = formal.Form()

        form.addField(
            'dest',
            formal.String(required=True,
                          strip=True,
                          validators=[PageHelpers.IPMaskValidator()]),
            label="Destination network",
            description=
            "Destination network in CIDR or '0.0.0.0/0' for the default route."
        )
        form.addField('gate',
                      formal.String(validators=[PageHelpers.IPValidator()]),
                      label="Gateway",
                      description="Gateway to forward this network to")

        ifs = []
        for i in Utils.getInterfaces():
            if 'eth' or 'ppp':  # Only allow ppp and eth binds...
                ifs.append((i, i))

        form.addField(
            'device',
            formal.String(),
            formal.widgetFactory(formal.SelectChoice, options=ifs),
            label="Device",
            description=
            "Device to forward this traffic to, or the interface to assign this route to"
        )

        form.addAction(self.submitRoute)

        return form
コード例 #4
0
ファイル: Firewall.py プロジェクト: calston/tums
    def form_addSNAT(self, data):
        form = formal.Form()

        ifs = []
        for i in Utils.getInterfaces():
            if 'eth' in i or 'tap' in i: # Only allow tap and eth binds...
                ifs.append((i, i))

        form.addField('dstif', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options = ifs), label = "External Interface",
            description = "The interface to which this traffic will be NATed. (Generaly the outside/internet interface)")

        form.addField('dstip', formal.String(required=True, validators=[PageHelpers.IPValidator()]), label = "External IP",
            description = "The IP to which this traffic will be NATed")

        form.addField('srcip', formal.String(required=True, strip=True, validators=[PageHelpers.IPValidator()]), label = "Source IP", description = ["The source IP you would like to NAT to and from."])

        form.addField('all', formal.Boolean(), label = "Any Interface", 
            description = "Tick this if the rule should apply to all interfaces and not just the External Interface.")

        form.addField('local', formal.Boolean(), label = "Use Internal", description = "Apply this NAT rule to this servers traffic as well.")

        form.data['local'] = False
        form.data['all'] = False

        form.addAction(self.submitSNAT)

        return form
コード例 #5
0
ファイル: Network.py プロジェクト: calston/tums
    def form_addVLAN(self, data):
        form = formal.Form()

        form.addField('interface',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=[
                                               (i, i.replace('eth', 'Port '))
                                               for i in Utils.getInterfaces()
                                               if not i == "lo"
                                           ]),
                      label="Attached Interface")

        form.addField('vlan', formal.Integer(), label="VLAN Number")
        form.addField('ip', formal.String(), label="IP Address")
        form.addField('netmask',
                      formal.String(),
                      label="Netmask",
                      description="Netmask or CIDR bitmask for this range")
        form.addField('dhcpserver',
                      formal.Boolean(),
                      label="DHCP Server",
                      description="Serve DHCP on this interface")
        form.addAction(self.submitVlan)
        return form
コード例 #6
0
ファイル: Routing.py プロジェクト: calston/tums
    def addForm(self, form):
        ifs = []
        for i in Utils.getInterfaces():
            if 'eth' in i or 'tap' in i: # Only allow tap and eth binds...
                ifs.append((i, i))

        form.addField('iface', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options = ifs), label = "Interface",)
コード例 #7
0
ファイル: Firewall.py プロジェクト: calston/tums
    def addForm(self, form):
        ifaces = [(i,i) for i in Utils.getInterfaces()]

        form.addField('iface', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options = ifaces), label = "Interface")
        form.addField('dhcp', formal.Boolean(), label = "DHCP", description="Check this if DHCP is performed on this interface")
        form.addField('routeback', formal.Boolean(), label = "Check this if route reflection is allowed on this interface")

        form.data['iface'] = ifaces[0][0]
コード例 #8
0
    def form_addInterface(self, data):
        form = formal.Form()

        form.addField('interface',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=[
                                               (i, i)
                                               for i in Utils.getInterfaces()
                                               if not i == "lo"
                                           ]),
                      label="Interface")

        form.addField(
            'dhcp',
            formal.Boolean(),
            label="DHCP",
            description="Use DHCP to discover an IP address for this interface"
        )

        form.addField('ip',
                      formal.String(strip=True,
                                    validators=[PageHelpers.IPValidator()]),
                      label="IP Address")
        try:
            if Settings.capabilities.get('ipv6', False):
                form.addField('ipv6',
                              formal.String(),
                              label="IPv6 Address",
                              description="IPv6 address for this interface")
                form.addField('ipv6adv',
                              formal.Boolean(),
                              label="Announce prefix",
                              description="Announce prefix on this interface")
        except:
            pass

        form.addField('netmask',
                      formal.String(),
                      label="Netmask",
                      description="Netmask or CIDR bitmask for this range")
        form.addField(
            'mtu',
            formal.Integer(),
            label="MTU",
            description=
            "Set this interfaces MTU. Value must be between 1200 and 1500.")
        form.addField('dhcpserver',
                      formal.Boolean(),
                      label="DHCP Server",
                      description="Serve DHCP on this interface")

        form.addAction(self.submitForm)
        return form
コード例 #9
0
ファイル: Traffic.py プロジェクト: calston/tums
    def form_createClass(self, data):
        form = formal.Form()

        form.addField('interface',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=[
                                               (i, i)
                                               for i in Utils.getInterfaces()
                                           ]),
                      label="Interface",
                      description="The interface to which this class applies")

        form.addField('name',
                      formal.String(required=True),
                      label="Name",
                      description="A name for this class")

        form.addField(
            'baserate',
            formal.String(),
            label="Base Rate",
            description=[
                "The basic rate for this class,",
                " preceded by the unit mbit or kbit (for example '768kbit')"
            ])

        form.addField(
            'maxrate',
            formal.String(),
            label="Maximum Rate",
            description=[
                "The maximum rate for this class,",
                " preceded by the unit mbit or kbit (for example '2mbit')"
            ])

        form.addField('prio',
                      formal.Integer(),
                      label="Priority",
                      description="Priority of this traffic")

        form.addField(
            'default',
            formal.Boolean(),
            label="Default class",
            description=[
                "Tick if this is the default class to use for all traffic",
                " Every interface must have a default class."
            ])

        form.addAction(self.submitTransProxy)

        return form
コード例 #10
0
ファイル: Network.py プロジェクト: calston/tums
    def form_addRoute(self, data):
        form = formal.Form()
        form.addField('destination', formal.String(), label="Destination")
        form.addField('mask', formal.String(), label="Netmask")
        form.addField('gateway', formal.String(), label="Gateway")
        form.addField('interface',
                      formal.String(),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=[
                                               (i, i.replace('eth', 'Port '))
                                               for i in Utils.getInterfaces()
                                               if not i == "lo"
                                           ]),
                      label="Interface")

        form.addAction(self.submitRouteForm)
        return form
コード例 #11
0
    def render_content(self, ctx, seg):
        interfaces = Utils.getInterfaces()
        stat = {}
        da = datetime.datetime.now()
        month = "%s%s" % (da.month, da.year)

        lastmonth = "%s%s" % (
            (da.month - 1) or 12,  # 12th month if current month is 1
            (da.month - 1) and da.year
            or da.year - 1  # Previous year if current month is 1
        )
        today = "%s%s%s" % (da.day, da.month, da.year)
        for i in interfaces:
            if not 'tap' in i and not 'eth' in i and not 'ppp' in i:
                continue
            stat[i] = {'24': [0, 0], 'month': [0, 0], 'lastmonth': [0, 0]}
            # Read the traffic counters
            try:
                p = open('/usr/local/tcs/tums/rrd/iface_%s_%stotal.nid' %
                         (i, today)).read().split(':')
                stat[i]['24'] = (float(p[0]), float(p[1]))  # Last 24 Hours
                # Try figure out the whole day

                for fi in os.listdir('/usr/local/tcs/tums/rrd/'):

                    if 'iface_%s' % i in fi and "%stotal.nid" % month in fi:
                        p = open('/usr/local/tcs/tums/rrd/' +
                                 fi).read().split(':')
                        for j in xrange(2):
                            stat[i]['month'][j] += float(p[j])

                    if 'iface_%s' % i in fi and "%stotal.nid" % lastmonth in fi:
                        p = open('/usr/local/tcs/tums/rrd/' +
                                 fi).read().split(':')
                        for j in xrange(2):
                            stat[i]['lastmonth'][j] += float(p[j])

            except Exception, e:
                stat[i]['24'] = (0, 0)
                stat[i]['month'] = (0, 0)
コード例 #12
0
ファイル: Network.py プロジェクト: calston/tums
    def form_addInterface(self, data):
        form = formal.Form()

        form.addField('interface',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=[
                                               (i, i.replace('eth', 'Port '))
                                               for i in Utils.getInterfaces()
                                               if not i == "lo"
                                           ]),
                      label="Interface")

        form.addField('dhcp', formal.Boolean(), label="DHCP")

        form.addField('ip', formal.String(), label="IP Address")
        if Settings.capabilities.get('ipv6', False):
            form.addField('ipv6',
                          formal.String(),
                          label="IPv6 Address",
                          description="IPv6 address for this interface")
            form.addField('ipv6adv',
                          formal.Boolean(),
                          label="Announce prefix",
                          description="Announce prefix on this interface")

        form.addField('netmask',
                      formal.String(),
                      label="Netmask",
                      description="Netmask or CIDR bitmask for this range")
        form.addField('dhcpserver',
                      formal.Boolean(),
                      label="DHCP Server",
                      description="Serve DHCP on this interface")

        form.addAction(self.submitForm)
        return form
コード例 #13
0
    def getStats(self):
        # Get rolling monthly stats for 12 months on each interface
        interfaces = Utils.getInterfaces()
        stat = {}
        da = datetime.datetime.now()

        year = da.year

        stats = os.listdir('/usr/local/tcs/tums/rrd/')

        for n in stats:
            if not ((str(year) in n) or (str(year - 1) in n)):
                # Ditch superflous years without hesitation
                continue

            if not 'total' in n:
                continue

            if n[-4:] != ".nid":
                continue
            # Figure out interface
            iface = n.split('_')[1]
            date = n.split('_')[2].replace('total.nid', '')
            segYear = int(date[-4:])

            date = time.localtime(
                os.stat('/usr/local/tcs/tums/rrd/%s' % n).st_mtime)

            if segYear == date[0]:
                # Probably ok
                segMonth = date[1]
            else:
                # Someone has messed with the time stamp on the file :(
                sm = date[-6:-4]
                if int(sm) > 12:
                    segMonth = int(sm[1])
                else:
                    segMonth = int(sm)

            # Grab the contents...
            l = open('/usr/local/tcs/tums/rrd/%s' % n)
            try:
                iin, iout = [
                    int(float(i) / 1000000)
                    for i in l.read().strip('\n').strip().split(':')
                ]
            except:
                inn, iout = (0, 0)

            if iface not in stat:
                stat[iface] = {}

            stamp = "%s%.2d" % (segYear, segMonth)
            if stamp in stat[iface]:
                stat[iface][stamp][0] += iin
                stat[iface][stamp][1] += iout
            else:
                stat[iface][stamp] = [iin, iout, segYear, segMonth]
        newstat = {}
        for iface, detail in stat.items():
            dlist = detail.keys()
            dlist.sort()
            # Pick the most recent 12
            ourlist = dlist[-12:]
            newstat[iface] = []

            # Reconstruct an ordered set for each interface instead of an unordered dictionary
            for n in ourlist:
                newstat[iface].append(detail[n])

        return newstat
コード例 #14
0
ファイル: Dashboard.py プロジェクト: calston/tums
    def render_network(self, ctx, data):
        interfaces = []

        for i in Utils.getInterfaces():
            if i[:3] in ['eth', 'ppp']:
                interfaces.append(i)

        interfaces.sort()
        procs = []
        for i in interfaces:
            procs.append(
                WebUtils.system(';'.join([
                    'rrdtool fetch /usr/local/tcs/tums/rrd/iface_%s_in.rrd AVERAGE -s -2h | tail -n 20'
                    % i,
                    'rrdtool fetch /usr/local/tcs/tums/rrd/iface_%s_out.rrd AVERAGE -s -2h | tail -n 20'
                    % i
                ])))

        def ret(r):
            story = []
            s = "/chart?type=line2&layout=tight&width=300&height=160&ylab=KB/s&xticks=10"

            green = "#29b25c"

            for c, i in enumerate(interfaces):
                iface = i
                # Grab two data sets and split them
                data = r[c][1].strip('\n').split('\n')
                data_in = self.cleanRRData(data[:20])
                data_out = self.cleanRRData(data[20:])

                gra = s
                gra += "&set=In&data=%s" % '+'.join(
                    ["%0.2f" % (j / 1024) for j in data_in])

                gra += "&set=Out&data=%s" % '+'.join(
                    ["%0.2f" % (j / 1024) for j in data_out])

                for k, i in enumerate(reversed(range(20))):
                    if k % 2 == 0:
                        i = " "
                    else:
                        i = "%ss" % i
                    gra += "&lables=%s" % i

                ctype = "Unknown"
                if 'eth' in iface:
                    media = tags.invisible(render=tags.directive('ethMedia'),
                                           data=iface)
                    state = tags.invisible(render=tags.directive('ethMedia'),
                                           data=[iface, 'state'])
                    netConfig = "/auth/Network/Edit/%s/" % iface
                if 'ppp' in iface:
                    media = "Link"
                    state = [
                        tags.td[tags.img(src='/images/state-running.png')],
                        tags.td(
                            width="100%")[entities.nbsp,
                                          tags.span(
                                              style="color: %s" %
                                              green)["PPP connection (%s)" %
                                                     (iface)]],
                    ]
                    netConfig = "/auth/PPP/"

                if c < 1:
                    scriptExtra = ""
                else:
                    scriptExtra = tags.script(
                        type="text/javascript")["rollNet(\"%s\");" % iface]

                block = tags.table(
                    _class="interfaceTable", cellspacing="0", cellpadding="0"
                )[tags.tr[state,
                          tags.td[tags.img(src='/images/block-minus.png',
                                           id='roller%s' % iface,
                                           onclick="rollNet('%s')" % iface)]],
                  tags.tr[tags.td(style="border-bottom:2px solid #999")[""],
                          tags.td(style="border-bottom:2px solid #999")[
                              entities.nbsp, tags.table[
                                  tags.tr[tags.td['Media: '], tags.td[media]],
                                  tags.tr[tags.td['IP Address: '], tags.
                                          td[tags.invisible(render=tags.
                                                            directive('ethIP'),
                                                            data=iface)]], ]],
                          tags.td[""]], tags.tr[tags.td[""], tags.td[tags.div(
                              id="con%s" %
                              iface)[tags.img(src=gra), tags.br,
                                     tags.a(href=netConfig)[tags.img(
                                         src="/images/services-small.png"),
                                                            " Configure"]]],
                                                tags.td[""]]]

                story.append(block)
                story.append(scriptExtra)
                story.append(tags.br)

            return ctx.tag[story]

        return defer.DeferredList(procs).addBoth(ret)
コード例 #15
0
    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(), ]
コード例 #16
0
ファイル: VPN.py プロジェクト: calston/tums
    def render_content(self, ctx, data):
        keys = [i for i in os.listdir('/etc/openvpn/keys/') if '.key' in i]

        keys.sort()
        for key in ['vpn.key', 'ca.key']:
            try:
                keys.remove(key)
            except:
                pass

        # Build a list of tunnels
        types={}
        # reprocess the configuration
        for name, conf in self.sysconf.Tunnel.items():
            if name == "ipv6":
                continue
            cnf = conf
            cnf['name'] = str(name)
            if types.get(str(cnf['type'])):
                types[str(cnf['type'])].append(cnf)
            else:
                types[str(cnf['type'])] = [cnf]
                
        # Check vpn is configured
        if os.path.exists('/etc/openvpn/vpn.conf'):
            userForm = tags.directive('form addUser')
        else:
            userForm = tags.strong["Please configure the VPN in order to add new users"]

        tuns = []
        # Call the handler functions with the stores
        ifs = Utils.getInterfaces()
        for k,v in types.items():
            if v:
                v.sort()
                for c,tun in enumerate(v):
                    status = tags.a(href='Start/%s/' % tun['name'])["Disconnected"]
                    if k == 'openvpn':
                        # Hunt TAP interfaces
                        if 'tap%s' % (c+1) in ifs:
                            status = tags.a(href='Stop/%s/' % tun['name'])["Connected"]

                    tuns.append((
                        status, 
                        tun['name'], 
                        tun['type'], 
                        tun['endpoint'], 
                        tags.a(href="Delete/%s/" % (tun['name']))["Delete"]
                    ))

        return ctx.tag[
                tags.h3[tags.img(src="/images/vpn.png"), self.text.vpnConfig],
                PageHelpers.TabSwitcher((
                    (self.text.vpnTabWindows, 'panelWindows'),
                    (self.text.vpnTabTCS, 'panelOpenVPN'),
                    (self.text.vpnTabUsers, 'panelVPNUsers'),
                    (self.text.vpnTabTun, 'panelTun')
                )),
                tags.div(id="panelWindows", _class="tabPane")[
                    tags.h3[self.text.vpnHeadingWindows],
                    tags.directive('form winForm'),
                ],
                tags.div(id="panelTun", _class="tabPane")[
                    tags.h3["Tunnels"],
                    PageHelpers.dataTable(['Status', 'Name', 'Type', 'Endpoint', ''], tuns),
                    tags.h3["Add tunnel"],
                    tags.directive('form addTun'), tags.br,
                ],
                tags.div(id="panelOpenVPN", _class="tabPane")[
                    tags.h3[self.text.vpnHeadingTCS],
                    tags.directive('form vpnForm'), tags.br,
                ],
                tags.div(id="panelVPNUsers", _class="tabPane")[
                    tags.h3[self.text.vpnHeadingTCSUsers],
                    tags.table(cellspacing=0,  _class='sortable')[
                        tags.thead(background="/images/gradMB.png")[
                            tags.tr[
                                tags.th(colformat="str")[self.text.vpnCertificateName],
                                tags.th[""],
                            ]
                        ],
                        tags.tbody[
                        [
                            tags.tr[
                                tags.td['.'.join(i.split('.')[:-1])],
                                tags.td[
                                    tags.a(
                                        href="Revoke/%s/" % '.'.join(i.split('.')[:-1]), 
                                        onclick="return confirm('%s');" % self.text.vpnConfirmRevoke
                                    )[ 
                                        tags.img(src="/images/ex.png")
                                    ]
                                ]
                            ]
                        for i in keys],
                        ]
                    ], tags.br,
                    tags.h3[self.text.vpnHeadingAddUser],

                    userForm
                ],
                PageHelpers.LoadTabSwitcher()
            ]
コード例 #17
0
ファイル: Network.py プロジェクト: calston/tums
    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(), ]