Пример #1
0
    def form_authentication(self, data):
        form = formal.Form()

        form.addField('ldapauth',
                      formal.Boolean(),
                      label="Default local authentication")

        form.addField('adauth',
                      formal.Boolean(),
                      label="Active Directory authentication")

        form.addField('adserv',
                      formal.String(),
                      label="Active Directory Server")
        form.addField('addom',
                      formal.String(),
                      label="Active Directory Domain")

        form.addAction(self.submitAuth)

        k = self.sysconf.ProxyConfig
        data = {}
        if k.get('adauth', ''):
            data['ldapauth'] = False
            data['adauth'] = True
        else:
            data['ldapauth'] = True
            data['adauth'] = False

        data['adserv'] = k.get('adserver', u'').encode()
        data['addom'] = k.get('addom', u'').encode()

        form.data = data

        return form
Пример #2
0
    def form_addZone(self, data):
        form = formal.Form()

        form.addField('zone',
                      formal.String(required=True),
                      label="Zone name",
                      description="The name of this zone")

        form.addField(
            'policy',
            formal.String(required=True),
            formal.widgetFactory(formal.SelectChoice,
                                 options=[('ACCEPT', 'ACCEPT'),
                                          ('DROP', 'DROP')]),
            label="Policy",
            description=
            "The default action to take on traffic not matching any rule")

        form.addField(
            'log',
            formal.String(),
            label="Log",
            description=
            "Advanced: Logging target for dropped packets. Usualy $log if policy is ACCEPT"
        )

        #form.addField('interfaces', formal.String(), label = "Interface members", description = "Advanced: Comma separated list of interface defenitions.")

        form.data['policy'] = "ACCEPT"

        form.addAction(self.submitZone)

        return form
Пример #3
0
    def addForm(self, form):
        acls = []

        for ip, i in self.sysconf.ProxyConfig.get('srcacls', []):
            if (not i in acls):
                acls.append((i, i))

        for n, i in self.sysconf.ProxyConfig.get('aclusers', []):
            if (not i in acls):
                acls.append((i, i))

        for n, i in self.sysconf.ProxyConfig.get('domacls', []):
            if (not i in acls):
                acls.append((i, i))

        for i in self.sysconf.ProxyConfig.get('adacls', []):
            if (not i[2] in acls):
                acls.append((i[2], i[2]))

        form.addField('acl',
                      formal.String(),
                      formal.widgetFactory(formal.SelectChoice, options=acls),
                      label="ACL Name",
                      description="Select the ACL to apply this rule to"),

        #form.addField('acl', formal.String(required=True), label = "ACL Name")
        form.addField(
            'gateway',
            formal.String(required=True),
            label="Bind IP",
            description="Local internet IP address to bind for this ACL")
Пример #4
0
    def form_nameservers(self, data):
        form = formal.Form()
        form.addField(
            'forward',
            formal.String(),
            label="DNS Forward",
            description=
            "DNS forwarders (comma separated) that the Vulani internal DNS server should use for non-authoritive requests. This is usualy your upstream DNS"
        )

        form.addField(
            'sysresolv',
            formal.String(),
            label="DNS Servers",
            description=
            "The DNS server which this server should perform it's own lookups from. This is usualy itself (127.0.0.1) or if the internal DNS is unused then it is the upstream DNS servers"
        )

        form.data['forward'] = ','.join(self.sysconf.ForwardingNameservers)

        if self.sysconf.General.get('sysresolv', []):
            form.data['sysresolv'] = ','.join(
                self.sysconf.General['sysresolv'])
        else:
            form.data['sysresolv'] = '127.0.0.1'

        form.addAction(self.submitNSForm)
        return form
Пример #5
0
    def form_userSettings(self, ctx):
        form = formal.Form()

        form.addField('userPassword', formal.String(), formal.CheckedPassword, label="Password")
        form.addField('mailForwardingAddress', formal.String(), formal.TextArea, label="Forward mail to")
        form.addField('vacen', formal.Boolean(), label = "Vacation note active", description="Tick this to enable/disable the vacation note")
        form.addField('vacation', formal.String(), formal.TextArea, label="Vacation Note")

        form.addAction(self.submitForm)
        print self.avatarId.username, self.avatarId.domains[0]

        tData = {}
        l = LDAP.createLDAPConnection(Settings.LDAPServer, 'o='+Settings.LDAPBase, Settings.LDAPManager, Settings.LDAPPass)
        dc = "%s,%s,o=%s" % (Settings.LDAPPeople, LDAP.domainToDC(self.avatarId.domains[0]), Settings.LDAPBase)
        userData =  LDAP.getUsers(l, dc, 'uid='+self.avatarId.username)

        if userData[0].get('mailForwardingAddress', False):
            tData['mailForwardingAddress'] = '\n'.join(userData[0]['mailForwardingAddress'])

        try:
            vac = open("/var/spool/mail/vacation/%s@%s.txt" % (self.avatarId.username, self.avatarId.domains[0]), 'r')
            tData['vacation'] = vac.read()
            tData['vacen'] = True
        except Exception, e :
            print e, "in read vac note"
            pass # No vacation note
Пример #6
0
 def _create_user_list_entry(self, index):
     g = formalutils.CollapsibleGroup(str(index), label='')
     g.setCollapsed(False)
     g.add(
         formalutils.Field('username',
                           formal.String(required=True),
                           label='Username'))
     g.add(
         formalutils.Field('password',
                           formal.String(required=False),
                           formal.widgetFactory(
                               formalutils.SemiHiddenPassword),
                           label='Set password'))
     g.add(
         formalutils.Field('fixed_ip',
                           dt.FormIPv4Address(required=False),
                           label='Fixed IP address'))
     g.add(
         formalutils.Field('admin_rights',
                           formal.Boolean(required=True),
                           label='Allow VPNease administration'))
     g.add(
         formalutils.Field('vpn_rights',
                           formal.Boolean(required=True),
                           label='Allow VPN access'))
     return g
Пример #7
0
    def form_addUps(self, data):

        ports = self.getSers()

        drivers = [('apcsmart', 'APC'), ('belkin', 'Belkin'),
                   ('belkinunv', 'Belkin Universal UPS'),
                   ('mge-shut', 'MGE Ellipse/Esprit'),
                   ('newmge-shut', 'MGE Ellipse/Esprit V2'),
                   ('mge-utalk', 'MGE Pulsar E/Comet'),
                   ('powercom', 'Powercom')]

        form = formal.Form()
        form.addField('name', formal.String(required=True), label="Name")
        form.addField('desc',
                      formal.String(required=True),
                      label="Description")
        form.addField('driver',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=drivers),
                      label="Driver")
        form.addField('port',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice, options=ports),
                      label="Port")
        form.addAction(self.submitForm)
        return form
Пример #8
0
    def form_editDomain(self, data):
        form = formal.Form()

        form.addField('name',
                      formal.String(required=True),
                      label="Server name",
                      description="Server Name")

        form.addField(
            'memory',
            formal.Integer(),
            label="Memory",
            description=
            "Amount of reserved memory in MB (swap is always equal to this)")

        form.addField('ip',
                      formal.String(strip=True,
                                    validators=[PageHelpers.IPValidator()]),
                      label="IP",
                      description="IP address (leave blank to use DHCP).")

        form.data = self.sysconf.General.get('xen',
                                             {}).get('images',
                                                     {}).get(self.name, {})
        form.data['name'] = self.name

        form.addAction(self.submitDomain)
        return form
Пример #9
0
    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
Пример #10
0
 def _create_fwrule_list_entry(index):
     g = formalutils.CollapsibleGroup(str(index), label='')
     g.setCollapsed(collapsed=False)
     g.add(
         formalutils.Field('ip_subnet',
                           dt.FormIPv4Subnet(required=True),
                           label='IP address or subnet'))
     g.add(
         formalutils.Field('protocol',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.SelectChoice,
                               options=txt.fw_protocol_select_options),
                           label='Protocol'))
     g.add(
         formalutils.Field(
             'port',
             formal.Integer(
                 required=False,
                 validators=[formal.RangeValidator(min=0, max=65535)]),
             label='Port'))
     g.add(
         formalutils.Field('action',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.SelectChoice,
                               options=txt.fw_protocol_action_options),
                           label='Action'))
     return g
Пример #11
0
    def form_addTime(self, data):
        acls = []

        for ip, i in self.sysconf.ProxyConfig.get('srcacls', []):
            acls.append((i,i))

        for n, i in self.sysconf.ProxyConfig.get('aclusers', []):
            acls.append((i,i))

        for n, i in self.sysconf.ProxyConfig.get('domacls', []):
            acls.append((i,i))

        form = formal.Form(self.submitTime)[        
            formal.Field('allow', formal.Boolean(), label = "Allow",
                description = "Allow traffic at these times"),
            formal.Field('from', formal.Time(required=True), label = "From time", 
                description = "Starting time (24 hour format)"),
            formal.Field('to', formal.Time(required=True), label = "To time", 
                description = "Ending time (24 hour format), must be later than the starting time and must not overlap midnight"),

            formal.Field('domain', formal.String(), label = "Domain", 
                description = "Apply this rule to a specific domain"), 

            formal.Field('exacl', formal.String(), formal.widgetFactory(formal.SelectChoice, options = acls), label = "Extra ACL", 
                description = "Apply this rule to a specific other ACL"),
            
            formal.Group('Days')[
                [ formal.Field(i, formal.Boolean(), label = i) for i in PageHelpers.days ]
            ]
        ]
        form.data['from'] = datetime.time(0,0)
        form.data['to'] = datetime.time(23,59)
        form.addAction(self.submitTime)
        return form
Пример #12
0
 def create_source_routing_group(self, form, ctx):
     txt = self.route_uitexts
     g = formalutils.CollapsibleGroup('sr_group',
                                      label=txt.source_routing_caption)
     g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseSourceRouting))
     g.add(
         formalutils.Field('source_routing_selection',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.RadioChoice,
                               options=txt.source_routing_select_options),
                           label=txt.source_routing_select_label))
     g.add(
         formalutils.Field('network_connection',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.SelectChoice,
                               options=txt.routing_nw_options),
                           label=txt.routing_nw_label))
     g.add(
         formalutils.Field('gateway_selection',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.RadioChoice,
                               options=txt.routing_gw_select_options),
                           label=txt.routing_gw_select_label))
     g.add(
         formalutils.Field('gateway',
                           dt.FormIPv4Address(required=False),
                           label=txt.routing_gw_label))
     return g
Пример #13
0
 def _create_route_list_entry(index):
     g = formalutils.CollapsibleGroup(str(index), label='')
     g.setCollapsed(False)
     g.add(
         formalutils.Field('subnet',
                           dt.FormIPv4Subnet(required=True),
                           label=txt.routing_subnet))
     g.add(
         formalutils.Field('network_connection',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.SelectChoice,
                               options=txt.routing_nw_options),
                           label=txt.routing_nw_label))
     g.add(
         formalutils.Field('gateway_selection',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.RadioChoice,
                               options=txt.routing_gw_select_options),
                           label=txt.routing_gw_select_label))
     g.add(
         formalutils.Field('gateway',
                           dt.FormIPv4Address(required=False),
                           label=txt.routing_gw_label))
     return g
Пример #14
0
    def form_source(self, data):
        form = formal.Form()
        zones = []

        # Read zones available for balancing
        i = 1
        for bal in self.sysconf.ShorewallBalance:
            zones.append((i, bal[0]))
            i+= 1

        protocols = [
            ('-', 'Any'),
            ('tcp', 'TCP'),
            ('udp', 'UDP'),
            ('47', 'PPTP'),
            ('icmp', 'ICMP')
        ]

        form.addField('zone', formal.Integer(required=True), formal.widgetFactory(formal.SelectChoice, options = zones), 
            label = "Destination Zone",
            description = "Route packets matching this rule to this zone")

        form.addField('source', formal.String(), label = "Source", description = "Source CIDR network or IP. For anywhere leave blank.")

        form.addField('dest',   formal.String(), label = "Destination", description = "Destination CIDR network or IP. For anywhere leave blank.")

        form.addField('protocol', formal.String(required=True),formal.widgetFactory(formal.SelectChoice, options = protocols), label = "Protocol")
        form.addField('port', formal.String(), label = "Port", description = "TCP/UDP port, or sub-protocol type. Leave blank for a source-only policy")

        form.addAction(self.submitSource)
        return form
Пример #15
0
    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
Пример #16
0
    def form_neigh(self, data):
        form = formal.Form()

        form.addField('ip',
                      formal.String(required=True,
                                    validators=[PageHelpers.IPValidator()]),
                      label="Remote IP")
        form.addField(
            'asn',
            formal.String(),
            label="Remote AS",
            description=
            "Remote AS number of peer. Leave blank for the same AS as this router"
        )
        #form.addField('hold', formal.Integer(required=True), label = "Hold time", description="Override the Hold timer for this peer (default 120)")

        #form.data['hold'] = 120

        form.addField(
            'multihop',
            formal.Boolean(),
            label="EBGP Multihop",
            description="Set this if the peer is more than 1 hop away")

        form.addField(
            'nexthop',
            formal.String(),
            label="Next-Hop",
            description=
            "Set this to an IP if you want to rewrite the next-hop of routes coming in from this peer. This is useful for route servers."
        )

        form.addAction(self.submitNeigh)
        return form
Пример #17
0
    def addForm(self, form):
        form.addField('name', formal.String(required=True), label="Name")

        form.addField('key',
                      formal.String(required=True),
                      formal.TextArea,
                      label="Key")
Пример #18
0
    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
Пример #19
0
    def form_addDrive(self, data):
        form = formal.Form()

        # Make a list of drive letters F - Z
        AvailLetters = [chr(i) for i in range(70,91)]
        # Remove letters that are used already
        for letter in [i[1] for i in self.getMaps()]:
            del AvailLetters[AvailLetters.index(letter)]

        # Get groups on system
        l = LDAP.createLDAPConnection(Settings.LDAPServer, 'o='+Settings.LDAPBase, Settings.LDAPManager, Settings.LDAPPass)
        dc = "%s,o=%s" % (LDAP.domainToDC(Settings.defaultDomain), Settings.LDAPBase)

        groups = LDAP.getGroups(l, dc)
        groups.sort()

        form.addField('sharepath', formal.String(required=True), label = "Share Path", 
            description = "Network path to the share, for example \\\\tcs\\Public\\")
            
        form.addField('loginGroup', formal.String(required=True),
            formal.widgetFactory(formal.SelectChoice, options = [(i[1],i[1]) for i in groups]), label = "Login Group", 
            description = "Requred login group for this network drive")

        form.addField('driveletter', formal.String(required=True),
            formal.widgetFactory(formal.SelectChoice, options = [(i,i) for i in AvailLetters]), label = "Drive Letter")

        form.data['driveletter'] = AvailLetters[0]
        form.data['loginGroup']  = "Domain Users"

        form.addAction(self.submitDriveForm)
        return form
Пример #20
0
    def form_confirm_installation(self, ctx):
        form = formal.Form()

        sg = formalutils.SubmitFieldGroup('buttons')
        sg.add(
            formalutils.SubmitField('confirm',
                                    formal.String(),
                                    label='Start installation'))
        sg.add(
            formalutils.SubmitField('reselect', formal.String(), label='Back'))
        sg.add(
            formalutils.SubmitField('cancel', formal.String(), label='Cancel'))
        form.add(sg)

        form.addAction(self.submitted_confirm_installation,
                       name='confirm',
                       label='Start installation',
                       validate=False)
        form.addAction(self.submitted_reselect,
                       name='reselect',
                       label='Back',
                       validate=False)
        form.addAction(self.submitted_cancel_installation,
                       name='cancel',
                       label='Cancel',
                       validate=False)

        return form
Пример #21
0
    def form_editZone(self, data):
        form = formal.Form()

        form.addField('master', formal.Boolean(), label="Master")
        form.addField('notify', formal.Boolean(), label="Notify slaves")
        form.addField(
            'update',
            formal.String(),
            label="Update",
            description=
            "Comma sepparated list of hosts allowed to update this zone")

        form.addField(
            'ns',
            formal.String(),
            label="Nameservers",
            description=
            "Comma sepparated list of authoritive servers for this zone")

        # populate form
        Z = self.sysconf.General['zones'][self.domain]

        form.data['ns'] = ', '.join(Z['ns'])
        form.data['update'] = ', '.join(Z['update'])

        form.data['master'] = "type master" in Z['options']
        form.data['notify'] = "notify no" not in Z['options']

        form.addAction(self.submitZone)
        return form
Пример #22
0
    def form_mailRewrite(self, data):
        form = formal.Form()
        form.addField('ffrom',
                      formal.String(required=True),
                      label="Domain",
                      description="Domain to modify")

        form.addField('tto',
                      formal.String(required=True),
                      label="Rewrite to",
                      description="Domain to rewrite to")

        form.addField('tos',
                      formal.Boolean(),
                      label="To header",
                      description="Rewrite email To header")
        form.addField('froms',
                      formal.Boolean(),
                      label="From header",
                      description="Rewrite email From header")
        form.addField('bcr',
                      formal.Boolean(),
                      label="BCC, CC and Recipient",
                      description="Rewrite all other headers")
        form.addAction(self.submitRewrite)
        return form
Пример #23
0
    def form_addRecord(self, data):
        recordTypes = ["CNAME", "A", "AAAA", "NS", "MX"]

        form = formal.Form()

        form.addField('type',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=[(i, i)
                                                    for i in recordTypes]),
                      label="Type")
        form.addField(
            'host',
            formal.String(),
            label="Host",
            description="Hostname or blank for a record in the base FQDN")
        form.addField('data',
                      formal.String(),
                      label="Data",
                      description="Content of the record")
        form.addField('prio',
                      formal.Integer(),
                      label="Priority",
                      description="Priority of MX record")

        form.addAction(self.submitRecForm)
        return form
Пример #24
0
 def form_changepassword(self, ctx):
     form = formal.Form()
     g = formalutils.CollapsibleGroup('changepassword',
                                      label='Change Password')
     g.setCollapsed(False)
     g.add(
         formal.Field('pw1',
                      formal.String(required=True),
                      formal.widgetFactory(formalutils.HiddenPassword),
                      label='Old password'))
     g.add(
         formal.Field('pw2',
                      formal.String(required=True),
                      formal.widgetFactory(formalutils.HiddenPassword),
                      label='New password'))
     g.add(
         formal.Field('pw3',
                      formal.String(required=True),
                      formal.widgetFactory(formalutils.HiddenPassword),
                      label='New password (again)'))
     sg = formalutils.SubmitFieldGroup('buttons')
     sg.add(
         formalutils.SubmitField('changepassword',
                                 formal.String(),
                                 label='Change password'))
     g.add(sg)
     form.add(g)
     form.addAction(self.submitted, name='changepassword', validate=False)
     return form
Пример #25
0
    def form_confZone(self, data):
        form = formal.Form()

        form.addField(
            'policy',
            formal.String(required=True),
            formal.widgetFactory(formal.SelectChoice,
                                 options=[('ACCEPT', 'ACCEPT'),
                                          ('DROP', 'DROP')]),
            label="Policy",
            description=
            "The default action to take on traffic not matching any rule")

        form.addField(
            'log',
            formal.String(),
            label="Log",
            description=
            "Advanced: Logging target for dropped packets. Usualy $log if policy is ACCEPT"
        )

        form.addAction(self.confZone)

        k = self.sysconf.Shorewall
        zdef = k.get('zones', {}).get(self.zone)
        form.data['log'] = zdef.get('log', '')
        form.data['policy'] = zdef.get('policy', '')

        return form
Пример #26
0
 def gotResolved(res):
     form = formal.Form()
     addr = []
     for address in entries:
         if address[0] in res:
             nam = (address[1], res[address[0]])
         else:
             nam = (address[1], address[0])
         addr.append((address[1], "%s(%s)" % nam))
     userWidgetFactory = formal.widgetFactory(formal.SelectChoice,
                                              options=self.getUsers())
     addressWidgetFactory = formal.widgetFactory(formal.SelectChoice,
                                                 options=addr)
     form.addField('userSelect',
                   formal.String(),
                   userWidgetFactory,
                   label="User")
     form.addField('user', formal.String(), label="")
     form.addField('addrSelect',
                   formal.String(),
                   addressWidgetFactory,
                   label="Network Address")
     form.addField('addr', formal.String(), label="")
     form.addAction(handleSubmit)
     return form
Пример #27
0
    def form_addShare(self, data):
        form = formal.Form()

        form.addField('share',
                      formal.String(required=True),
                      label="Shared Folder")
        form.addField('path',
                      formal.String(required=True),
                      label="Shared Path",
                      description="Path to be shared")
        form.addField('comment', formal.String(required=True), label="Comment")

        form.addField('public', formal.Boolean(), label="Public")
        form.addField('writable', formal.Boolean(), label="Writable")

        l = LDAP.createLDAPConnection(Settings.LDAPServer,
                                      'o=' + Settings.LDAPBase,
                                      Settings.LDAPManager, Settings.LDAPPass)
        dc = "%s,o=%s" % (LDAP.domainToDC(
            Settings.defaultDomain), Settings.LDAPBase)

        groups = LDAP.getGroups(l, dc)
        groups.sort()

        form.addField('group',
                      formal.String(),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=[(i[1], i[1])
                                                    for i in groups]),
                      label="Required Group")

        form.addAction(self.submitForm)

        return form
Пример #28
0
    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
Пример #29
0
    def addForm(self, form):
        acls = []

        for ip, i in self.sysconf.ProxyConfig.get('srcacls', []):
            if (not i in acls):
                acls.append((i, i))

        for n, i in self.sysconf.ProxyConfig.get('aclusers', []):
            if (not i in acls):
                acls.append((i, i))

        for n, i in self.sysconf.ProxyConfig.get('domacls', []):
            if (not i in acls):
                acls.append((i, i))

        for i in self.sysconf.ProxyConfig.get('adacls', []):
            if (not i[2] in acls):
                acls.append((i[2], i[2]))

        form.addField('acl',
                      formal.Sequence(formal.String()),
                      formal.widgetFactory(formal.CheckboxMultiChoice,
                                           options=acls),
                      label="ACLs",
                      description="Select the ACL(s) to apply this rule to"),

        #form.addField('acl', formal.String(required=True), label = "ACL Name")
        form.addField('perms',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=[('deny', 'deny'),
                                                    ('allow', 'allow')]),
                      label="Permission")

        form.data['perms'] = 'deny'
Пример #30
0
    def form_forwardPort(self, data):
        form = formal.Form()
        form.addField(
            'port',
            formal.String(),
            label="Port",
            description=
            "TCP/UDP port to forward. Blank for protocol forward (like PPTP).")
        form.addField('destip',
                      formal.String(required=True),
                      label="Target IP",
                      description="Destination IP address to forward to")
        form.addField(
            'dstport',
            formal.String(),
            label="Target Port",
            description="TCP/UDP port to forward to. Blank for the same port.")
        form.addField('sourceip',
                      formal.String(),
                      label="Destination IP",
                      description="External IP to forward from")
        form.addField('proto',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=self.protocols),
                      label="Protocol")
        form.data['proto'] = 'tcp'

        form.addAction(self.submitForwardPort)
        return form