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

        months = [(m + 1, Utils.months[m + 1]) for m in range(12)]
        days = [(0, 'Whole Month')] + [(m + 1, m + 1) for m in range(31)]
        yearLim = datetime.datetime.now().year
        years = [(y, y) for y in reversed(range(yearLim - 3, yearLim + 1))]

        form.addField('day',
                      formal.Integer(),
                      formal.widgetFactory(formal.SelectChoice, options=days),
                      label="Day")

        form.addField('month',
                      formal.Integer(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=months),
                      label="Month")

        form.addField('year',
                      formal.Integer(required=True),
                      formal.widgetFactory(formal.SelectChoice, options=years),
                      label="Year")

        form.data['month'] = self.month
        form.data['day'] = self.day
        form.data['year'] = self.year

        form.addAction(self.selectDate)
        return form
コード例 #2
0
 def _create_port_forward_list_entry(index):
     g = formalutils.CollapsibleGroup(str(index), label='')
     g.setCollapsed(collapsed=False)
     g.add(
         formalutils.Field('new_fw_protocol',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.SelectChoice,
                               options=txt.new_fw_protocol_options),
                           label=txt.new_fw_protocol_label))
     g.add(
         formalutils.Field(
             'new_fw_port_in',
             formal.Integer(
                 required=True,
                 validators=[formal.RangeValidator(min=0, max=65535)]),
             label=txt.new_fw_port_in_label))
     g.add(
         formalutils.Field('new_fw_ip_out',
                           dt.FormIPv4Address(required=True),
                           label=txt.new_fw_ip_out_label))
     g.add(
         formalutils.Field(
             'new_fw_port_out',
             formal.Integer(
                 required=True,
                 validators=[formal.RangeValidator(min=0, max=65535)]),
             label=txt.new_fw_port_out_label))
     return g
コード例 #3
0
    def form_newXen(self, data):
        form = formal.Form()
        if os.path.exists("/usr/lib/xen-tools"):

            tools = os.listdir("/usr/lib/xen-tools/")
            dists = ['hvm']
            for n in tools:
                if n[-2:] == '.d':
                    dists.append(n.split('.')[0])

            distSelect = [(i, i.capitalize()) for i in dists]
        else:
            distSelect = [("ERROR", "Xen not active!")]

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

        #form.addField('lva', formal.String(), label = "Volume Group", description = "The LVM VG to use (blank to use an image)")

        form.addField('distribution',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=distSelect),
                      label="Distribution",
                      description="Xen image type")

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

        form.addField('disk',
                      formal.Integer(required=True),
                      label="Disk",
                      description="Amount of disk space in GB")

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

        form.addField(
            'password',
            formal.String(),
            label="Password",
            description="A root password for the machine (leave blank on HVM)."
        )

        form.data['distribution'] = 'etch'

        form.addAction(self.submitNewXen)
        return form
コード例 #4
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
コード例 #5
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
コード例 #6
0
ファイル: DNS.py プロジェクト: calston/tums
    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
コード例 #7
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
コード例 #8
0
ファイル: Routing.py プロジェクト: calston/tums
    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
コード例 #9
0
    def form_advanced(self, data):
        form = formal.Form()
        form.addField('selack',
                      formal.Boolean(),
                      label="Selective ACK",
                      description="Enable selective ACK windowing")
        form.addField('maxwin',
                      formal.Integer(),
                      label="Window Max",
                      description="Maximum TCP Window")
        form.addField('backlog',
                      formal.String(),
                      label="Backlog",
                      description="Maximum Device Backlog")

        form.addField(
            'gige',
            formal.Boolean(),
            label="Auto-Tune GigE",
            description=
            "Apply automatic tuning for GigE (overrides the settings above)")

        form.addField(
            'cookies',
            formal.Boolean(),
            label="SYN Cookies",
            description=
            "Enable SYN-Cookies. This is handy if you're at risk of DDoS SYN floods."
        )
        form.addField('proxyarp',
                      formal.Boolean(),
                      label="Proxy ARP",
                      description="Enable Proxy ARP.")

        form.data['cookies'] = self.sysconf.General.get('tuning', {}).get(
            'syn-cookies', False)
        form.data['proxyarp'] = self.sysconf.General.get('tuning', {}).get(
            'proxyarp', False)

        gen = self.sysconf.General.get('tuning', {}).get('tcp-hp', False)
        if gen:
            form.data['maxwin'] = gen.get('max-window', '16777216')
            form.data['backlog'] = gen.get('backlog', '250000')
            form.data['selack'] = gen.get('selective-ack', True)
            # Test the settings against our defaults
            if gen.get('backlog', False) == '250000' and gen.get(
                    'max-window', False) == '16777216':
                # if they are default we assume auto-tune mode is active
                form.data['gige'] = True
        else:
            form.data['selack'] = True
            form.data['maxwin'] = 110592
            form.data['backlog'] = 1000
            form.data['gige'] = False

        form.addAction(self.submitAdvForm)
        return form
コード例 #10
0
ファイル: PageHelpers.py プロジェクト: calston/tums
 def formAdd(self, data):
     form = formal.Form()
     
     form.addField('editIndexNode', formal.Integer(), widgetFactory=formal.Hidden)
     self.addForm(form)
     
     form.addAction(self.submitAdd)
     
     return form
コード例 #11
0
    def form_mailConfig(self, data):
        form = formal.Form()

        form.addField('maxsize', formal.String(), label = self.text.eximMaxMailSize, 
            description = self.text.eximMaxSizeDescription)

        form.addField('blockedFiles', formal.String(), label = self.text.eximBlockedAttachment,
            description = self.text.eximBlockedDescription)

        form.addField('blockMovies', formal.Boolean(), label = self.text.eximBlockedMovies, 
            description = self.text.eximBlockedMovieDescription)

        form.addField('blockHarm', formal.Boolean(), label = self.text.eximBlockHarmful,
            description = self.text.eximBlockHarmfulDescription)

        form.addField('greylisting', formal.Boolean(), label = self.text.eximGreylisting,
            description = self.text.eximGreylistingDescription)

        form.addField('spamscore', formal.Integer(), label = self.text.eximSpamScore,
            description = self.text.eximSpamScoreDescription)

        form.addField('smtprelay', formal.String(), label = self.text.eximSMTPRelay, 
            description = self.text.eximSMTPRelayDescription)

        form.addField('smtpinterface', formal.String(), label = "External IP", 
            description = "Specify an external IP for outgoing SMTP")

        form.addField('relayfrom', formal.String(), label = "Relay From",
            description = "Comma separated list of networks from which we will accept mail (IP bound to LAN is included by default)")

        form.addField('copyall', formal.String(), label = self.text.eximMailCopy, 
            description = self.text.eximMailCopyDescription)

        form.addField('rpfilter', formal.Boolean(), label = "Send Filter", 
            description = "Enable local sender filtering. This will enforce a rule such that any relay host or local host is forced to send as a known local domain or authorised sender")


        form.addField('ratelimit', formal.Boolean(), label = "Rate Limiter", 
            description = "Enable local rate limiting. This will enforce a rate limit on the number of mails that can be sent in an hour from any address that is not local.")

        mailConf = self.sysconf.Mail
        form.data['maxsize'] = mailConf['mailsize']
        form.data['blockedFiles'] = ', '.join(mailConf['blockedfiles'])
        form.data['greylisting']  = mailConf.get('greylisting', True)
        form.data['smtprelay'] = self.sysconf.SMTPRelay
        form.data['smtpinterface'] = mailConf.get('smtpinterface', '')
        form.data['copyall'] = mailConf.get('copytoall', "")
        form.data['spamscore'] = int(mailConf.get('spamscore', "70"))
        form.data['relayfrom'] = ','.join(mailConf.get('relay-from', []))

        form.data['rpfilter'] = not mailConf.get('disablerpfilter', False)
        form.data['ratelimit'] = not mailConf.get('disableratelimit', False)

        form.addAction(self.submitForm)
        return form
コード例 #12
0
ファイル: userconfig.py プロジェクト: zeus911/vpnease-l2tp
 def create_radius_group(self, ctx, form):
     g = formalutils.CollapsibleGroup('radius', label='RADIUS Servers')
     g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseRadius))
     g.add(
         formalutils.Field('server1',
                           formal.String(required=False),
                           label='Primary RADIUS server address'))
     g.add(
         formalutils.Field(
             'serverport1',
             formal.Integer(
                 required=False,
                 validators=[formal.RangeValidator(min=1, max=65535)]),
             label='Primary RADIUS server port'))
     g.add(
         formalutils.Field('secret1',
                           formal.String(required=False),
                           formal.widgetFactory(
                               formalutils.SemiHiddenPassword),
                           label='Primary RADIUS shared secret'))
     g.add(
         formalutils.Field('server2',
                           formal.String(required=False),
                           label='Secondary RADIUS server address'))
     g.add(
         formalutils.Field(
             'serverport2',
             formal.Integer(
                 required=False,
                 validators=[formal.RangeValidator(min=1, max=65535)]),
             label='Secondary RADIUS server port'))
     g.add(
         formalutils.Field('secret2',
                           formal.String(required=False),
                           formal.widgetFactory(
                               formalutils.SemiHiddenPassword),
                           label='Secondary RADIUS shared secret'))
     g.add(
         formalutils.Field('nasidentifier',
                           formal.String(required=False),
                           label='NAS Identifier'))
     return g
コード例 #13
0
 def testInteger(self):
     self.assertEquals(formal.Integer().validate(None), None)
     self.assertEquals(formal.Integer().validate(0), 0)
     self.assertEquals(formal.Integer().validate(1), 1)
     self.assertEquals(formal.Integer().validate(-1), -1)
     self.assertEquals(formal.Integer(missing=1).validate(None), 1)
     self.assertEquals(formal.Integer(missing=1).validate(2), 2)
     self.assertRaises(formal.FieldValidationError,
                       formal.Integer(required=True).validate, None)
コード例 #14
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
コード例 #15
0
 def form_example(self, ctx):
     form = formal.Form()
     form.addField('aString', formal.String())
     form.addField('aInteger', formal.Integer())
     form.addField('aFloat', formal.Float())
     if haveDecimal:
         form.addField('aDecimal', formal.Decimal())
     form.addField('aBoolean', formal.Boolean())
     form.addField('aDate', formal.Date())
     form.addField('aTime', formal.Time())
     form.addAction(self.submitted)
     return form
コード例 #16
0
    def form_mailConfig(self, data):
        form = formal.Form()

        form.addField('maxsize',
                      formal.String(),
                      label=self.text.eximMaxMailSize,
                      description=self.text.eximMaxSizeDescription)

        form.addField('blockedFiles',
                      formal.String(),
                      label=self.text.eximBlockedAttachment,
                      description=self.text.eximBlockedDescription)

        form.addField('blockMovies',
                      formal.Boolean(),
                      label=self.text.eximBlockedMovies,
                      description=self.text.eximBlockedMovieDescription)

        form.addField('blockHarm',
                      formal.Boolean(),
                      label=self.text.eximBlockHarmful,
                      description=self.text.eximBlockHarmfulDescription)

        form.addField('greylisting',
                      formal.Boolean(),
                      label=self.text.eximGreylisting,
                      description=self.text.eximGreylistingDescription)

        form.addField('spamscore',
                      formal.Integer(),
                      label=self.text.eximSpamScore,
                      description=self.text.eximSpamScoreDescription)

        form.addField('smtprelay',
                      formal.String(),
                      label=self.text.eximSMTPRelay,
                      description=self.text.eximSMTPRelayDescription)

        form.addField('copyall',
                      formal.String(),
                      label=self.text.eximMailCopy,
                      description=self.text.eximMailCopyDescription)

        mailConf = self.sysconf.Mail
        form.data['maxsize'] = mailConf['mailsize']
        form.data['blockedFiles'] = ', '.join(mailConf['blockedfiles'])
        form.data['greylisting'] = mailConf.get('greylisting', True)
        form.data['smtprelay'] = self.sysconf.SMTPRelay
        form.data['copyall'] = mailConf.get('copytoall', "")
        form.data['spamscore'] = int(mailConf.get('spamscore', "70"))

        form.addAction(self.submitForm)
        return form
コード例 #17
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
コード例 #18
0
 def create_internet_connection_group(self, form, ctx):
     txt = self.nc_uitexts
     g = formalutils.CollapsibleGroup('ic_group',
                                      label=txt.ic_group_caption)
     g.setCollapsed(
         uihelpers.collapse_setting(ns_ui.collapseInternetConnection))
     g.add(
         formalutils.Field('if',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.SelectChoice,
                               options=uihelpers.interface_options()),
                           label=txt.if_label))
     g.add(
         formalutils.Field('ip_address_selection',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.RadioChoice,
                               options=txt.ip_selection_options),
                           label=txt.ip_selection_label))
     g.add(
         formalutils.Field('ip_address',
                           dt.FormIPv4AddressSubnet(required=False),
                           label=txt.ip_label))
     g.add(
         formalutils.Field('subnet_mask',
                           dt.FormSubnetMask(required=False),
                           label=txt.subnet_label))
     g.add(
         formalutils.Field('default_gateway',
                           dt.FormIPv4Address(required=False),
                           label=txt.default_gw_label))
     g.add(
         formalutils.Field(
             'mtu',
             formal.Integer(
                 required=True,
                 validators=[formal.RangeValidator(min=576, max=1500)]),
             label=txt.mtu_label))
     g.add(
         formalutils.Field(
             'uplink',
             dt.FormFloat(required=False,
                          validators=[formal.RangeValidator(min=0.128)]),
             label=txt.uplink_label))
     g.add(
         formalutils.Field('client_traffic',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.RadioChoice,
                               options=txt.client_traffic_options),
                           label=txt.client_traffic_label))
     return g
コード例 #19
0
ファイル: hidden.py プロジェクト: zeus911/vpnease-l2tp
 def form_example(self, ctx):
     form = formal.Form()
     form.addField('hiddenString',
                   formal.String(),
                   widgetFactory=formal.Hidden)
     form.addField('hiddenInt',
                   formal.Integer(),
                   widgetFactory=formal.Hidden)
     form.addField('visibleString', formal.String())
     form.addAction(self.submitted)
     form.data = {
         'hiddenString': 'foo',
         'hiddenInt': 1,
     }
     return form
コード例 #20
0
ファイル: validator.py プロジェクト: zeus911/vpnease-l2tp
 def form_example(self, ctx):
     form = formal.Form()
     # This actually installs a RequiredValidator for you.
     form.addField('required', formal.String(required=True))
     # Exactly the same as above, only with a "manually" installed validator.
     form.addField('required2', formal.String(validators=[formal.RequiredValidator()]))
     # Check for a minimum length, if anything entered.
     form.addField('atLeastFiveChars', formal.String(validators=[formal.LengthValidator(min=5)]))
     # Check for a minimum length, if anything entered.
     form.addField('ipAddress', formal.String(strip=True, validators=[formal.PatternValidator(regex=IP_ADDRESS_PATTERN)]))
     # Check for the word 'silly'
     form.addField('silly', formal.String(validators=[SillyValidator()]))
     # Check age is between 18 and 30
     form.addField('ohToBeYoungAgain', formal.Integer(validators=[formal.RangeValidator(min=18, max=30)]))
     form.addAction(self.submitted)
     return form
コード例 #21
0
ファイル: debugconfig.py プロジェクト: zeus911/vpnease-l2tp
 def create_debug_group(self, form, ctx):
     debug_group = formalutils.CollapsibleGroup('debug_group',
                                                label='Debug')
     debug_group.setCollapsed(False)
     debug_group.add(
         formal.Field('debug',
                      formal.Integer(
                          required=True,
                          validators=[formal.RangeValidator(min=0, max=2)]),
                      label='Debug mode (0=normal, 1=light, 2=heavy)'))
     ui_root = db.get_db().getRoot().getS(ns_ui.uiConfig,
                                          rdf.Type(ns_ui.UiConfig))
     # Default false if no entry found from the database.
     debug_fda = formalutils.FormDataAccessor(form, ['debug_group'], ctx)
     if ui_root.hasS(ns_ui.debug):
         debug_fda['debug'] = ui_root.getS(ns_ui.debug, rdf.Integer)
     else:
         debug_fda['debug'] = 0
     return debug_group
コード例 #22
0
    def form_management(self, ctx):
        form = formal.Form()
        fda = formalutils.FormDataAccessor(form, [], ctx)
        tzhelp = uihelpers.TimezoneHelper()
        txt = self.mng_uitexts

        ### License

        g = formalutils.CollapsibleGroup('license_group',
                                         label=txt.license_group_caption)
        g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseLicense))
        g.add(
            formalutils.Field('license_key',
                              formal.String(required=False),
                              label=txt.license_key_label))
        form.add(g)

        ### Locale

        tzoptions = []
        for tzname in tzhelp.get_timezones():
            tzoptions.append((tzname, tzname))

        def _tz_cmp(x, y):
            x_name, x_label = x
            y_name, y_label = y
            return unicode.__cmp__(unicode(x_label), unicode(y_label))

        tzoptions.sort(cmp=_tz_cmp)

        # XXX: keymap values are truncated because they are so long
        keymapoptions = []
        for gname, gname_escaped, human in gnomeconfig.get_keymap_list():
            keymapoptions.append(
                (gname_escaped, uihelpers.ui_truncate(human, 56)))

        def _km_cmp(x, y):
            x_name, x_label = x
            y_name, y_label = y
            return unicode.__cmp__(unicode(x_label), unicode(y_label))

        keymapoptions.sort(cmp=_km_cmp)

        g = formalutils.CollapsibleGroup('locale_group',
                                         label='Locale Settings')
        g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseLocale))
        g.add(
            formalutils.Field('timezone',
                              formal.String(required=True),
                              formal.widgetFactory(formal.SelectChoice,
                                                   options=tzoptions),
                              label='Timezone'))
        g.add(
            formalutils.Field('keymap',
                              formal.String(required=True),
                              formal.widgetFactory(formal.SelectChoice,
                                                   options=keymapoptions),
                              label='Keyboard layout'))

        # XXX: it would be good if we could show a time example using the timezone
        # admin has selected.

        form.add(g)

        ### Reboots

        g = formalutils.CollapsibleGroup('reboot_group',
                                         label=txt.reboot_group_caption)
        g.setCollapsed(
            uihelpers.collapse_setting(ns_ui.collapseProductMaintenance))
        g.add(
            formalutils.Field('reboot_day',
                              formal.Integer(required=True),
                              formal.widgetFactory(
                                  formal.SelectChoice,
                                  options=txt.reboot_day_options),
                              label=txt.reboot_day_label))
        g.add(
            formalutils.Field('reboot_time',
                              formal.Integer(required=True),
                              formal.widgetFactory(
                                  formal.SelectChoice,
                                  options=txt.reboot_time_options),
                              label=txt.reboot_time_label))
        # Information about the periodic reboot consequences (about 5 minutes downtime).
        g.add(
            formalutils.Field('automatic_updates',
                              formal.Boolean(required=True),
                              label=txt.automatic_update_label))
        form.add(g)

        ### SNMP

        g = formalutils.CollapsibleGroup('snmp_group', label='SNMP Monitoring')
        g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseSnmp))
        g.add(
            uihelpers.create_access_control_dropdown('snmp_access',
                                                     'SNMP read-only access'))
        g.add(
            formalutils.Field('snmp_community',
                              formal.String(required=False),
                              formal.widgetFactory(
                                  formalutils.SemiHiddenPassword),
                              label='SNMP community string (password)'))
        form.add(g)

        ### Remote management

        g = formalutils.CollapsibleGroup('remote_group',
                                         label=txt.remote_group_caption)
        g.setCollapsed(
            uihelpers.collapse_setting(ns_ui.collapseRemoteManagement))
        g.add(
            uihelpers.create_access_control_dropdown('www_administration',
                                                     'Web administration'))
        g.add(
            uihelpers.create_access_control_dropdown('ssh_connection',
                                                     'SSH connection'))
        g.add(
            formalutils.Field('root_password1',
                              formal.String(required=False),
                              formal.widgetFactory(formalutils.HiddenPassword),
                              label='Set root password'))
        g.add(
            formalutils.Field('root_password2',
                              formal.String(required=False),
                              formal.widgetFactory(formalutils.HiddenPassword),
                              label='Re-enter root password'))
        form.add(g)

        ### Admin e-mails

        # XXX: not yet implemented
        #g = formalutils.CollapsibleGroup('email_group', label='Administrator E-mail')
        #g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseAdminEmail))
        #g.add(formalutils.Field('smtp_server', formal.String(required=False), label='SMTP server'))
        #g.add(formalutils.Field('smtp_from', formal.String(required=False), label='FROM address'))
        #g.add(formalutils.Field('smtp_to', formal.String(required=False), label='TO address(es) (comma separated)'))
        #form.add(g)

        ### SSL certificate

        g = formalutils.CollapsibleGroup('ssl_group', label='SSL Certificate')
        g.setCollapsed(uihelpers.collapse_setting(
            ns_ui.collapseSslCertificate))
        g.add(
            formalutils.Field(
                'ssl_certificate_chain',
                formal.String(required=False),
                formal.widgetFactory(formal.TextArea, cols=80, rows=10),
                label=
                'SSL Certificate Chain (PEM format, server certificate first)')
        )
        g.add(
            formalutils.Field('ssl_private_key',
                              formal.String(required=False),
                              formal.widgetFactory(formal.TextArea,
                                                   cols=80,
                                                   rows=10),
                              label='SSL Private Key (PEM format)'))
        form.add(g)

        ### Submit buttons

        sg = formalutils.SubmitFieldGroup('buttons')
        sg.add(
            formalutils.SubmitField('submit',
                                    formal.String(),
                                    label='Save changes'))
        form.add(sg)
        form.addAction(self.submitted, name='submit', validate=False)

        ### Fill data to form

        try:
            self.fill_management(ctx, fda)
        except:
            # ignore failure so user has chance to edit the form
            _log.exception('fill_form_data failed, ignoring')

        return form
コード例 #23
0
    def form_editForm(self, data):

        domains = []
        if self.avatarId.isAdmin:
            for i in self.flatFil:
                thisdom = i.split('dm=')[-1].split(',')[0]
                if not thisdom in domains:
                    domains.append(thisdom)

        # Form population

        userData = self.lc.getUser(self.cid)

        devList = []
        #extList = []
        rouList = []
        UserExtForm = []
        fkeyForm = []
        if Settings.sambaDN and self.domain == Settings.defaultDomain and PBXUtils.enabled(
        ):
            includeList = []
            includeList = self.sysconf.PBXExtensions.get(
                userData['uid'][0], {'extensions': []})['extensions']
            devIncList = self.sysconf.PBXExtensions.get(
                userData['uid'][0], {'devices': []})['devices']
            extList = PBXUtils.getAvaExtenNumSelect(True, includeList)
            #for ext in PBXUtils.getAvailibleExtensions():
            #    extList.append((str(ext), str(ext)))
            for dev in PBXUtils.getAllAvaExtDeviceEndPoints(devIncList):
                devList.append((str(dev), str(dev)))
            queueList = [
                (queue, queue)
                for queue in self.sysconf.PBX.get('queues', {}).keys()
            ]

            rouList = self.sysconf.PBXRouters.keys()

            extensionWidget = formal.widgetFactory(formal.SelectChoice,
                                                   options=extList)
            deviceWidget = formal.widgetFactory(formal.SelectChoice,
                                                options=devList)
            #queueWidget = formal.widgetFactory(formal.SelectChoice, options = queueList)

            userExtensions = PBXUtils.getExtensionSelect()

            queueOptions = formal.widgetFactory(formal.SelectChoice,
                                                options=[(1, "Level 1 Member"),
                                                         (2, "Level 2 Member"),
                                                         (3, "Level 3 Member")
                                                         ])
            queues = []
            for queue in self.sysconf.PBX.get('queues', {}).keys()[0:-1]:
                queues.append(
                    formal.Field('queue%s' % queue,
                                 formal.Integer(),
                                 queueOptions,
                                 label="Queue %s" % queue))

            try:
                queue = self.sysconf.PBX.get('queues', {}).keys()[-1]
            except:
                queue = None

            if queue:
                queues.append(
                    formal.Field(
                        'queue%s' % queue,
                        formal.Integer(),
                        queueOptions,
                        label="Queue %s" % queue,
                        description=
                        "Each extension may be part of many queues, each queue membersip has a specific weighting. The weighting determines the order in which calls may be seeded. Level 2 members only get calls seeded to them once Level 1 has been saturated etc."
                    ))

            fKeyOptions = formal.widgetFactory(formal.SelectChoice,
                                               options=userExtensions)
            fKeys = []
            maxKeys = 54

            for i in range(maxKeys):
                fKeys.append(
                    formal.Field('fkeys%s' % i,
                                 formal.String(),
                                 fKeyOptions,
                                 label="Key %s" % i))

            fKeys.append(
                formal.Field(
                    'fkeys%s' % maxKeys,
                    formal.String(),
                    fKeyOptions,
                    label="Key %s" % maxKeys,
                    description=
                    "Select the extensions for the function keys above"))

            userExtFormContent = [
                formal.Field('userExtEnabled',
                             formal.Boolean(),
                             label=self.text.userFormLabelExtEnabled),
                formal.Field('userExtOutbound',
                             formal.Sequence(formal.String()),
                             formal.widgetFactory(formal.CheckboxMultiChoice,
                                                  options=[(i, i)
                                                           for i in rouList]),
                             label=self.text.userFormLabelOutbound,
                             description=self.text.userFormDescOutbound),
                #formal.Field('userExtQueues', formal.Sequence(formal.String()),
                #    formal.widgetFactory(formal.CheckboxMultiChoice,
                #        options = queueList),
                #    label = self.text.userFormLabelQueues,
                #    description = self.text.userFormDescQueues),
            ]
            userExtFormContent.extend(queues)

            userExtFormContent.extend([
                formal.Field(
                    'userLowBW',
                    formal.Boolean(),
                    label="Low Bandwidth",
                    description=
                    'Indicates that the devices(if applicable) should use a low bandwidth codec'
                ),
                formal.Field(
                    'userExtTimeout',
                    formal.Integer(),
                    label="Timeout",
                    description=
                    "How many seconds should we wait before giving up on this extension, note that setting this to 0 will force the extension to use the default timeout"
                ),
                formal.Field(
                    'userExtqTimeout',
                    formal.Integer(),
                    label="Queue Timeout",
                    description=
                    "How many seconds should we wait before giving up on this queue member, 0 will indicate to use the default"
                ),
                formal.Field('userExtCallerID',
                             formal.String(),
                             label=self.text.userFormLabelCallID),
                formal.Field('userExtNumber0',
                             formal.String(),
                             extensionWidget,
                             label=self.text.userFormLabelExtNumber),
                formal.Field('userExtNumber1',
                             formal.String(),
                             extensionWidget,
                             label=""),
                formal.Field('userExtNumber2',
                             formal.String(),
                             extensionWidget,
                             label=""),
                formal.Field('userExtNumber3',
                             formal.String(),
                             extensionWidget,
                             label=""),
                formal.Field('userExtNumber4',
                             formal.String(),
                             extensionWidget,
                             label=""),
                formal.Field('userExtNumber5',
                             formal.String(),
                             extensionWidget,
                             label=""),
                formal.Field('userExtNumber6',
                             formal.String(),
                             extensionWidget,
                             label=""),
                formal.Field('userExtNumber7',
                             formal.String(),
                             extensionWidget,
                             label=""),
                formal.Field('userExtNumber8',
                             formal.String(),
                             extensionWidget,
                             label=""),
                formal.Field('userExtNumber9',
                             formal.String(),
                             extensionWidget,
                             label=""),
                tags.div(_class="userLine")[tags.a(
                    href="#",
                    onclick="addExten();")[self.text.userFormLabelAddExt]],
                #formal.Field('userExtFwdUA', formal.String(), label = self.text.userFormLabelRedNoAnswer,
                #    description = self.text.userFormDescRedNoAnswer),
                formal.Field('userExtDev0',
                             formal.String(),
                             deviceWidget,
                             label=self.text.userFormLabelDev),
                formal.Field('userExtDev1',
                             formal.String(),
                             deviceWidget,
                             label=""),
                formal.Field('userExtDev2',
                             formal.String(),
                             deviceWidget,
                             label=""),
                formal.Field('userExtDev3',
                             formal.String(),
                             deviceWidget,
                             label=""),
                formal.Field('userExtDev4',
                             formal.String(),
                             deviceWidget,
                             label=""),
                formal.Field('userExtDev5',
                             formal.String(),
                             deviceWidget,
                             label=""),
                formal.Field('userExtDev6',
                             formal.String(),
                             deviceWidget,
                             label=""),
                formal.Field('userExtDev7',
                             formal.String(),
                             deviceWidget,
                             label=""),
                formal.Field('userExtDev8',
                             formal.String(),
                             deviceWidget,
                             label=""),
                formal.Field('userExtDev9',
                             formal.String(),
                             deviceWidget,
                             label=""),
                tags.div(_class="userLine")[tags.a(
                    href="#",
                    onclick="addExtDev();")[self.text.userFormLabelAddDev]],
                formal.Field('userExtVoiceMail',
                             formal.Boolean(),
                             label=self.text.userFormLabelVoiceMail),
                formal.Field('userExtVoiceMailPin',
                             formal.String(),
                             label=self.text.userFormLabelVoiceMailPin),
            ])
            UserExtForm = formal.Group('userExtension')[userExtFormContent]
            fkeyForm = formal.Group('userFKeys')[fKeys]

        form = formal.Form(
            self.submitForm
        )[formal.Group('userSettings')[tags.div(_class="field")[
            tags.label[self.text.userFormLabelEmailAddress],
            tags.div(id="emailAd", _class="inputs")["%s@%s" %
                                                    (self.cid, self.domain)]],
                                       formal.Field('uid',
                                                    formal
                                                    .String(required=True,
                                                            validators=Base
                                                            .UserNameValidators),
                                                    label=self.text.
                                                    userFormLabelUsername),
                                       formal.Field('givenName',
                                                    formal.String(
                                                        required=True),
                                                    label=self.text.
                                                    userFormLabelName),
                                       formal.Field('sn',
                                                    formal.String(),
                                                    label=self.text.
                                                    userFormLabelSurname),
                                       formal.Field('userPassword',
                                                    formal.String(),
                                                    formal.CheckedPassword,
                                                    label=self.text.
                                                    userFormLabelPass), ],
          formal.Group('mailSettings')
          [formal.Field('mailForwardingAddress0',
                        formal.String(),
                        label=self.
                        text.userFormLabelForward),
           formal.Field('mailForwardingAddress1', formal.String(), label=""),
           formal.Field('mailForwardingAddress2', formal.String(), label=""),
           formal.Field('mailForwardingAddress3', formal.String(), label=""),
           formal.Field('mailForwardingAddress4', formal.String(), label=""),
           formal.Field('mailForwardingAddress5', formal.String(), label=""),
           formal.Field('mailForwardingAddress6', formal.String(), label=""),
           formal.Field('mailForwardingAddress7', formal.String(), label=""),
           formal.Field('mailForwardingAddress8', formal.String(), label=""),
           formal.Field('mailForwardingAddress9', formal.String(), label=""),
           tags.div(
               _class="userLine")[tags.a(href="#", onclick="addForward();"
                                         )[self.text.userFormLabelAddline]],
           formal.Field('mailAlternateAddress0',
                        formal.String(),
                        label=self.text.userFormLabelAlias),
           formal.Field('mailAlternateAddress1', formal.String(), label=""),
           formal.Field('mailAlternateAddress2', formal.String(), label=""),
           formal.Field('mailAlternateAddress3', formal.String(), label=""),
           formal.Field('mailAlternateAddress4', formal.String(), label=""),
           formal.Field('mailAlternateAddress5', formal.String(), label=""),
           formal.Field('mailAlternateAddress6', formal.String(), label=""),
           formal.Field('mailAlternateAddress7', formal.String(), label=""),
           formal.Field('mailAlternateAddress8', formal.String(), label=""),
           formal.Field('mailAlternateAddress9', formal.String(), label=""),
           tags.div(
               _class="userLine")[tags.a(href="#", onclick="addAlias();"
                                         )[self.text.userFormLabelAddline]],
           formal.Field('vacen',
                        formal.Boolean(),
                        label=self.text.userFormLabelVacationActive,
                        description=self.text.userFormTextVacationNote),
           formal.Field('vacation',
                        formal.String(),
                        formal.TextArea,
                        label=self.text.userFormLabelVacation),
           formal.Field('vacvalidity',
                        formal.Date(),
                        label="Valid until",
                        description=
                        "Disable the vacation note automatically on this date"
                        )],
          formal.Group('userPermissions')[
              formal.Field('employeeType',
                           formal.Boolean(),
                           label=self.text.userFormLabelWeb),
              formal.Field('accountStatus',
                           formal.Boolean(),
                           label=self.text.userFormLabelEmail),
              formal.Field('tumsAdmin',
                           formal.Boolean(),
                           label=self.text.userFormLabelAdmin),
              formal.Field('tumsUser',
                           formal.Sequence(formal.String()),
                           formal.widgetFactory(formal.CheckboxMultiChoice, [(
                               i, i) for i in domains]),
                           label=self.text.userFormLabelDomainAdmin),
              formal.Field('tumsReports',
                           formal.Boolean(),
                           label=self.text.userFormLabelReports),
              formal.Field('copyto',
                           formal.String(),
                           label=self.text.userFormLabelCopy,
                           description=self.text.userFormTextCopy)],
          formal.Group('userAccess')[
              formal.Field('vpnEnabled',
                           formal.Boolean(),
                           label=self.text.userFormLabelVPN,
                           description=self.text.userFormTextVPN),
              formal.Field('ftpEnabled',
                           formal.Boolean(),
                           label=self.text.userFormLabelFTP,
                           description=self.text.userFormTextFTP),
              formal.Field('ftpGlobal',
                           formal.Boolean(),
                           label=self.text.userFormLabelGlobalFTP,
                           description=self.text.userFormTextGlobal)],
          UserExtForm, fkeyForm]

        form.addAction(self.submitForm)

        tData = copy.deepcopy(userData)
        tData['userSettings.uid'] = tData['uid'][0]
        tData['userSettings.givenName'] = tData.get('givenName', [""])[0]
        tData['userSettings.sn'] = tData.get('sn', [""])[0]

        if tData.get('loginShell'):
            if '/bin/bash' in tData['loginShell']:
                tData['userAccess.ftpEnabled'] = True

        if self.sysconf.FTP.get('globals'):
            if tData['uid'][0] in self.sysconf.FTP['globals']:
                tData['userAccess.ftpGlobal'] = True

        tData['userSettings.userPassword'] = ''  # Strip password
        address = "%s@%s" % (tData['uid'][0], self.domain)

        for i in os.listdir('/etc/openvpn/keys/'):
            if "%s.%s" % (self.cid, self.domain) in i and "key" in i:
                tData['userAccess.vpnEnabled'] = True

        if self.sysconf.Mail.get('copys', []):
            for addr, dest in self.sysconf.Mail['copys']:
                if addr == address:
                    tData['userPermissions.copyto'] = dest

        if userData.get('accountStatus', False):
            tData['userPermissions.accountStatus'] = True
        else:
            tData['userPermissions.accountStatus'] = False

        if userData.get('mailForwardingAddress', False):
            for cnt, address in enumerate(userData['mailForwardingAddress']):
                tData['mailSettings.mailForwardingAddress%s' % cnt] = address

        if userData.get('mailAlternateAddress', False):
            for cnt, address in enumerate(userData['mailAlternateAddress']):
                tData['mailSettings.mailAlternateAddress%s' % cnt] = address

        emp = userData.get('employeeType', [False])

        if 'squid' in emp:
            tData['userPermissions.employeeType'] = True
        else:
            tData['userPermissions.employeeType'] = False

        if 'tumsAdmin' in emp:
            tData['userPermissions.tumsAdmin'] = True
        else:
            tData['userPermissions.tumsAdmin'] = False

        if 'tumsReports' in emp:
            tData['userPermissions.tumsReports'] = True
        else:
            tData['userPermissions.tumsReports'] = False

        if emp[0]:
            for i in emp:
                if 'tumsUser[' in i:
                    tData['userPermissions.tumsUser'] = i.split('[')[-1].split(
                        ']')[0].split(',')

        try:
            vac = open(
                "/var/spool/mail/vacation/%s@%s.txt" % (self.cid, self.domain),
                'r')
            tData['mailSettings.vacation'] = vac.read()
            tData['mailSettings.vacen'] = True
        except:
            pass  # No vacation note

        try:
            vac = open(
                "/var/spool/mail/vacation/DISABLED%s@%s.txt" %
                (self.cid, self.domain), 'r')
            tData['mailSettings.vacation'] = vac.read()
            tData['mailSettings.vacen'] = False
        except:
            pass  # No disabled note either.

        if os.path.exists('/var/spool/mail/vacation/%s@%s.validity' %
                          (self.cid, self.domain)):
            n = open('/var/spool/mail/vacation/%s@%s.validity' %
                     (self.cid, self.domain)).read().strip('\n')
            d = datetime.date(*[int(i) for i in n.split('-')])
            tData['mailSettings.vacvalidity'] = d

        #Populate Userextension Data
        if PBXUtils.enabled():
            ext = self.sysconf.PBXExtensions.get(
                tData['uid'][0], {
                    'enabled': False,
                    'lowbw': False,
                    'outbound': [],
                    'callerID': "",
                    'voiceMail': False,
                    'voiceMailPin': '',
                    'fkeys': [],
                    'extensions': [],
                    'devices': [],
                    'queues': {}
                })
            tData['userExtension.userExtEnabled'] = ext['enabled']
            tData['userExtension.userExtOutbound'] = ext['outbound']
            tData['userExtension.userExtTimeout'] = ext.get('timeout', 0)
            tData['userExtension.userExtqTimeout'] = ext.get('qtimeout', 0)
            #tData['userExtension.userExtQueues'] = ext.get('queues', [])
            queueSettings = ext.get('queues', {})
            if type(queueSettings) == list:
                n = {}
                for queue in queueSettings:
                    n[queue] = 1
                queueSettings = n
            for queue in self.sysconf.PBX.get('queues', {}).keys():
                tData['userExtension.queue%s' % queue] = queueSettings.get(
                    queue, None)
            tData['userExtension.userExtCallerID'] = ext['callerID']
            tData['userExtension.userExtVoiceMail'] = ext['voiceMail']
            tData['userExtension.userExtVoiceMailPin'] = ext['voiceMailPin']
            tData['userExtension.userLowBW'] = ext.get('lowbw', False)
            for i in range(0, 9):
                try:
                    tData['userExtension.userExtNumber%s' %
                          i] = ext['extensions'][i]
                except:
                    pass
                try:
                    tData['userExtension.userExtDev%s' % i] = ext['devices'][i]
                except:
                    pass
            for i in range(54):
                try:
                    tData['userFKeys.fkeys%s' % i] = ext['fkeys'][i]
                except:
                    pass

        form.data = tData
        return form
コード例 #24
0
    def form_modInterface(self, data):
        form = formal.Form()

        form.addField('dhcp', formal.Boolean(), label="DHCP")
        form.addField(
            'interior',
            formal.Boolean(),
            label="Interior",
            description=
            "Tick this if the interface in question is an interior LAN interface"
        )

        form.addField(
            'ip',
            formal.String(strip=True,
                          validators=[PageHelpers.IPMaskValidator()]),
            label="IP Address",
            description="IP address for this interface as CIDR (x.x.x.x/y)")

        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:
            # No capability setting
            pass
        form.addField(
            'gateway',
            formal.String(strip=True, validators=[PageHelpers.IPValidator()]),
            label="Default Gateway",
            description=
            "IP Address that should be used to route default traffic from this server. This will over-write any other default gateways configured in this profile."
        )
        form.addField(
            'netmask',
            formal.String(strip=True,
                          validators=[PageHelpers.IPMaskValidator()]),
            label="Network Address",
            description=
            "Network address for this interface (Required if DHCP selected)")
        form.addField(
            'ipAlias',
            formal.String(),
            label="IP Alias",
            description=
            "Alias for this interface as CIDR (x.x.x.x/y). Separate multiple aliases with a comma"
        )

        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.addField('firewallPolicy',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=[('ACCEPT', 'Accept All'),
                                                    ('DROP', 'Deny All')]),
                      label="Default firewall policy")

        form.addField('firewallZone',
                      formal.String(required=True),
                      formal.widgetFactory(formal.SelectChoice,
                                           options=self.getZones()),
                      label="Firewall Zone")

        form.data = {}
        lp = self.sysconf.LANPrimary
        if self.iface in lp:
            form.data['interior'] = True

        ifDetail = self.sysconf.EthernetDevices.get(self.iface, {})
        print ifDetail
        if ifDetail.get('type', '') == "dhcp":
            form.data['dhcp'] = True

        form.data['dhcpserver'] = ifDetail.get('dhcpserver', False)

        if ifDetail.get('ip', False):
            form.data['ip'] = ifDetail.get('ip', '')

        if ifDetail.get('network', False):
            form.data['netmask'] = ifDetail.get('network', '')

        if ifDetail.get('routes', False):
            routes = ifDetail.get('routes', False)
            for dest, gw in routes:
                if dest == "default":
                    form.data['gateway'] = gw
                    break

        if ifDetail.get('aliases', False):
            form.data['ipAlias'] = ', '.join(ifDetail['aliases'])

        try:
            if Settings.capabilities.get('ipv6', False):
                if ifDetail.get('ipv6', False):
                    form.data['ipv6'] = ifDetail['ipv6']
                if ifDetail.get('ipv6adv', False):
                    form.data['ipv6adv'] = True
        except:
            pass

        wallZones = self.sysconf.Shorewall['zones']
        for i, v in wallZones.items():
            for k in v['interfaces']:
                if self.iface in k:
                    form.data['firewallZone'] = i
                    form.data['firewallPolicy'] = wallZones[i]['policy']

        form.addAction(self.submitForm)
        return form