def create_ppp_firewall_group(self, form, ctx):
        txt = self.route_uitexts
        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
            
        fwrule_list = formalutils.DynamicList('fwrule_group', 'VPN Traffic Firewall Rules', childCreationCallback=_create_fwrule_list_entry)
        fwrule_list.setCollapsible(True)
        fwrule_list.setCollapsed(uihelpers.collapse_setting(ns_ui.collapsePppFirewallRules))

        try:
            ui_root = helpers.get_ui_config()
            if ui_root.hasS(ns_ui.pppFirewallRules):
                fwrule_index = 0
                for fwrule in ui_root.getS(ns_ui.pppFirewallRules, rdf.Seq(rdf.Type(ns_ui.PppFirewallRule))):
                    fwrule_list.add(_create_fwrule_list_entry(fwrule_index))
                    fwrule_index += 1
        except:
            _log.exception('failed to create dynamic ppp firewall rule list')

        return fwrule_list
    def create_dynamic_dns_group(self, form, ctx):
        txt = self.nc_uitexts
        g = formalutils.CollapsibleGroup('ddns_group', label=txt.ddns_group_caption)
        g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseDynamicDns))
        # XXX: provider is required, but 'none' option is 'disabled'
        g.add(formalutils.Field('ddns_provider', formal.String(required=True),
                                formal.widgetFactory(formal.SelectChoice, options=txt.ddns_providers),
                                label=txt.ddns_providers_label))
        g.add(formalutils.Field('ddns_username', formal.String(required=False), label=txt.ddns_username_label))
        g.add(formalutils.Field('ddns_password', formal.String(required=False),
                                formal.widgetFactory(formalutils.SemiHiddenPassword),
                                label=txt.ddns_password_label))
        g.add(formalutils.Field('ddns_hostname', formal.String(required=False), label=txt.ddns_hostname_label))

        ddns_address_options = [
            ('interface', 'Use Internet connection IP address'),
            ('natted', 'Use NATted Internet connection IP address'),
            ('static', 'Use the following IP address'),
            ]
        g.add(formalutils.Field('ddns_address_type', formal.String(required=False),
                                formal.widgetFactory(formal.RadioChoice, options=ddns_address_options),
                                label='IP address to update'))

        g.add(formalutils.Field('ddns_address', formal.String(required=False), label='Static IP address'))
        return g
    def create_firewall_group(self, form, ctx):
        txt = self.fw_uitexts

        g = formalutils.CollapsibleGroup('firewall', label=txt.firewall_group_caption)
        g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseFirewall))
        g.add(formalutils.Field('firewall_in_use', formal.Boolean(required=True), label=txt.enable_routing_label))
        return g
    def create_port_forwarding_group(self, form, ctx):
        txt = self.fw_uitexts
        
        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
        
        pf_list = formalutils.DynamicList('port_forwards', label=txt.port_forwards_group_caption, childCreationCallback=_create_port_forward_list_entry)
        pf_list.setCollapsible(True)
        pf_list.setCollapsed(uihelpers.collapse_setting(ns_ui.collapsePortForwardingRules))

        try:
            ui_root = helpers.get_ui_config()
            if ui_root.hasS(ns_ui.portForwards):
                pf_index = 0
                for pf in ui_root.getS(ns_ui.portForwards, rdf.Seq(rdf.Type(ns_ui.PortForward))):
                    pf_list.add(_create_port_forward_list_entry(pf_index))
                    pf_index += 1
        except:
            _log.exception('failed to create dynamic port forwardings list')

        return pf_list
    def create_additional_routes_group(self, form, ctx):
        txt = self.route_uitexts

        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
            
        # Dynamic route list.
        routes_list = formalutils.DynamicList('ar_group', label=txt.additional_routes_caption, childCreationCallback=_create_route_list_entry)
        routes_list.setCollapsible(True)
        routes_list.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseAdditionalRoutes))

        try:
            ui_root = helpers.get_ui_config()
            if ui_root.hasS(ns_ui.routes):
                route_index = 0
                for route in ui_root.getS(ns_ui.routes, rdf.Seq(rdf.Type(ns_ui.Route))):
                    routes_list.add(_create_route_list_entry(str(route_index)))
                    route_index += 1
        except:
            _log.exception('failed to create dynamic routes list')

        return routes_list
 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
 def create_iface_count_group(self, form, ctx):
     txt = self.nc_uitexts
     g = formalutils.CollapsibleGroup('ifcount_group', label='Network Setup')
     g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseInterfaceCount))
     g.add(formalutils.Field('interface_count', formal.String(required=True),
                             formal.widgetFactory(formal.RadioChoice, options=txt.ifcount_options), 
                             label=txt.ifcount_label))
     return g
 def create_dns_group(self, form, ctx):
     txt = self.nc_uitexts
     g = formalutils.CollapsibleGroup('dns_group', label=txt.dns_group_caption)
     g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseDns))
     g.add(formalutils.Field('dns_selection', formal.String(required=True),
                             formal.widgetFactory(formal.RadioChoice, options=txt.dns_select_options),
                             label=txt.dns_select_label))
     g.add(formalutils.Field('dns_1', dt.FormIPv4Address(required=False), label=txt.primary_dns_label))
     g.add(formalutils.Field('dns_2', dt.FormIPv4Address(required=False), label=txt.secondary_dns_label))
     return g
Beispiel #9
0
 def create_client_connection_group():
     cc_group = formalutils.CollapsibleGroup('client_connection',
                                             label=txt.cc_group_caption)
     cc_group.setCollapsed(
         uihelpers.collapse_setting(ns_ui.collapseClientConnection))
     #cc_group.add(formalutils.Field('server_name', formal.String(required=False), label=txt.server_address_label))
     cc_group.add(
         formalutils.Field('psk_1',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formalutils.SemiHiddenPassword),
                           label='Primary pre-shared key'))
     cc_group.add(
         formalutils.Field('psk_2',
                           formal.String(required=False),
                           formal.widgetFactory(
                               formalutils.SemiHiddenPassword),
                           label='Secondary pre-shared key'))
     cc_group.add(
         formalutils.Field('dns',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.RadioChoice,
                               options=txt.client_dns_options),
                           label=txt.client_dns_options_label))
     cc_group.add(
         formalutils.Field('dns_1',
                           dt.FormIPv4Address(required=False),
                           label=txt.primary_dns_label))
     cc_group.add(
         formalutils.Field('dns_2',
                           dt.FormIPv4Address(required=False),
                           label=txt.secondary_dns_label))
     cc_group.add(
         formalutils.Field('wins_1',
                           dt.FormIPv4Address(required=False),
                           label=txt.primary_wins_label))
     cc_group.add(
         formalutils.Field('wins_2',
                           dt.FormIPv4Address(required=False),
                           label=txt.secondary_wins_label))
     cc_group.add(
         formalutils.Field('client_subnet',
                           dt.FormIPv4Subnet(required=True),
                           label=txt.client_subnet_label))
     cc_group.add(
         formalutils.Field('client_address_range',
                           dt.FormIPv4AddressRange(required=True),
                           label=txt.client_address_range_label))
     cc_group.add(
         formalutils.Field('client_compression',
                           formal.Boolean(required=True),
                           label='VPN client traffic compression'))
     return cc_group
Beispiel #10
0
    def create_firewall_group(self, form, ctx):
        txt = self.fw_uitexts

        g = formalutils.CollapsibleGroup('firewall',
                                         label=txt.firewall_group_caption)
        g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseFirewall))
        g.add(
            formalutils.Field('firewall_in_use',
                              formal.Boolean(required=True),
                              label=txt.enable_routing_label))
        return g
Beispiel #11
0
    def create_ppp_firewall_group(self, form, ctx):
        txt = self.route_uitexts

        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

        fwrule_list = formalutils.DynamicList(
            'fwrule_group',
            'VPN Traffic Firewall Rules',
            childCreationCallback=_create_fwrule_list_entry)
        fwrule_list.setCollapsible(True)
        fwrule_list.setCollapsed(
            uihelpers.collapse_setting(ns_ui.collapsePppFirewallRules))

        try:
            ui_root = helpers.get_ui_config()
            if ui_root.hasS(ns_ui.pppFirewallRules):
                fwrule_index = 0
                for fwrule in ui_root.getS(
                        ns_ui.pppFirewallRules,
                        rdf.Seq(rdf.Type(ns_ui.PppFirewallRule))):
                    fwrule_list.add(_create_fwrule_list_entry(fwrule_index))
                    fwrule_index += 1
        except:
            _log.exception('failed to create dynamic ppp firewall rule list')

        return fwrule_list
Beispiel #12
0
    def create_port_forwarding_group(self, form, ctx):
        txt = self.fw_uitexts

        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

        pf_list = formalutils.DynamicList(
            'port_forwards',
            label=txt.port_forwards_group_caption,
            childCreationCallback=_create_port_forward_list_entry)
        pf_list.setCollapsible(True)
        pf_list.setCollapsed(
            uihelpers.collapse_setting(ns_ui.collapsePortForwardingRules))

        try:
            ui_root = helpers.get_ui_config()
            if ui_root.hasS(ns_ui.portForwards):
                pf_index = 0
                for pf in ui_root.getS(ns_ui.portForwards,
                                       rdf.Seq(rdf.Type(ns_ui.PortForward))):
                    pf_list.add(_create_port_forward_list_entry(pf_index))
                    pf_index += 1
        except:
            _log.exception('failed to create dynamic port forwardings list')

        return pf_list
Beispiel #13
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
 def create_default_route_group(self, form, ctx):
     txt = self.route_uitexts
     g = formalutils.CollapsibleGroup('dr_group', label=txt.default_route_caption)
     g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseDefaultRoute))
     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
Beispiel #15
0
    def create_additional_routes_group(self, form, ctx):
        txt = self.route_uitexts

        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

        # Dynamic route list.
        routes_list = formalutils.DynamicList(
            'ar_group',
            label=txt.additional_routes_caption,
            childCreationCallback=_create_route_list_entry)
        routes_list.setCollapsible(True)
        routes_list.setCollapsed(
            uihelpers.collapse_setting(ns_ui.collapseAdditionalRoutes))

        try:
            ui_root = helpers.get_ui_config()
            if ui_root.hasS(ns_ui.routes):
                route_index = 0
                for route in ui_root.getS(ns_ui.routes,
                                          rdf.Seq(rdf.Type(ns_ui.Route))):
                    routes_list.add(_create_route_list_entry(str(route_index)))
                    route_index += 1
        except:
            _log.exception('failed to create dynamic routes list')

        return routes_list
Beispiel #16
0
 def create_iface_count_group(self, form, ctx):
     txt = self.nc_uitexts
     g = formalutils.CollapsibleGroup('ifcount_group',
                                      label='Network Setup')
     g.setCollapsed(uihelpers.collapse_setting(
         ns_ui.collapseInterfaceCount))
     g.add(
         formalutils.Field('interface_count',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.RadioChoice,
                               options=txt.ifcount_options),
                           label=txt.ifcount_label))
     return g
Beispiel #17
0
 def create_private_network_group(self, form, ctx):
     txt = self.nc_uitexts
     g = formalutils.CollapsibleGroup('pn_group', label=txt.pn_group_caption)
     g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapsePrivateNetwork))
     g.add(formalutils.Field('if', formal.String(required=False),
                             formal.widgetFactory(formal.SelectChoice, options=uihelpers.interface_options()),
                             label=txt.if_label))
     g.add(formalutils.Field('ip_address_selection', formal.String(required=False),
                             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('client_traffic', formal.String(required=False),
                             formal.widgetFactory(formal.RadioChoice, options=txt.client_traffic_options),
                             label=txt.client_traffic_label))
     return g
Beispiel #18
0
    def create_dynamic_dns_group(self, form, ctx):
        txt = self.nc_uitexts
        g = formalutils.CollapsibleGroup('ddns_group',
                                         label=txt.ddns_group_caption)
        g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseDynamicDns))
        # XXX: provider is required, but 'none' option is 'disabled'
        g.add(
            formalutils.Field('ddns_provider',
                              formal.String(required=True),
                              formal.widgetFactory(formal.SelectChoice,
                                                   options=txt.ddns_providers),
                              label=txt.ddns_providers_label))
        g.add(
            formalutils.Field('ddns_username',
                              formal.String(required=False),
                              label=txt.ddns_username_label))
        g.add(
            formalutils.Field('ddns_password',
                              formal.String(required=False),
                              formal.widgetFactory(
                                  formalutils.SemiHiddenPassword),
                              label=txt.ddns_password_label))
        g.add(
            formalutils.Field('ddns_hostname',
                              formal.String(required=False),
                              label=txt.ddns_hostname_label))

        ddns_address_options = [
            ('interface', 'Use Internet connection IP address'),
            ('natted', 'Use NATted Internet connection IP address'),
            ('static', 'Use the following IP address'),
        ]
        g.add(
            formalutils.Field('ddns_address_type',
                              formal.String(required=False),
                              formal.widgetFactory(
                                  formal.RadioChoice,
                                  options=ddns_address_options),
                              label='IP address to update'))

        g.add(
            formalutils.Field('ddns_address',
                              formal.String(required=False),
                              label='Static IP address'))
        return g
Beispiel #19
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
Beispiel #20
0
 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
Beispiel #21
0
 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
Beispiel #22
0
 def create_dns_group(self, form, ctx):
     txt = self.nc_uitexts
     g = formalutils.CollapsibleGroup('dns_group',
                                      label=txt.dns_group_caption)
     g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseDns))
     g.add(
         formalutils.Field('dns_selection',
                           formal.String(required=True),
                           formal.widgetFactory(
                               formal.RadioChoice,
                               options=txt.dns_select_options),
                           label=txt.dns_select_label))
     g.add(
         formalutils.Field('dns_1',
                           dt.FormIPv4Address(required=False),
                           label=txt.primary_dns_label))
     g.add(
         formalutils.Field('dns_2',
                           dt.FormIPv4Address(required=False),
                           label=txt.secondary_dns_label))
     return g
Beispiel #23
0
 def create_client_connection_group():
     cc_group = formalutils.CollapsibleGroup('client_connection', label=txt.cc_group_caption)
     cc_group.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseClientConnection))
     #cc_group.add(formalutils.Field('server_name', formal.String(required=False), label=txt.server_address_label))
     cc_group.add(formalutils.Field('psk_1', formal.String(required=True),
                                    formal.widgetFactory(formalutils.SemiHiddenPassword),
                                    label='Primary pre-shared key'))
     cc_group.add(formalutils.Field('psk_2', formal.String(required=False),
                                    formal.widgetFactory(formalutils.SemiHiddenPassword),
                                    label='Secondary pre-shared key'))
     cc_group.add(formalutils.Field('dns', formal.String(required=True),
                                    formal.widgetFactory(formal.RadioChoice, options=txt.client_dns_options),
                                    label=txt.client_dns_options_label))
     cc_group.add(formalutils.Field('dns_1', dt.FormIPv4Address(required=False), label=txt.primary_dns_label))
     cc_group.add(formalutils.Field('dns_2', dt.FormIPv4Address(required=False), label=txt.secondary_dns_label))
     cc_group.add(formalutils.Field('wins_1', dt.FormIPv4Address(required=False), label=txt.primary_wins_label))
     cc_group.add(formalutils.Field('wins_2', dt.FormIPv4Address(required=False), label=txt.secondary_wins_label))
     cc_group.add(formalutils.Field('client_subnet', dt.FormIPv4Subnet(required=True), label=txt.client_subnet_label))
     cc_group.add(formalutils.Field('client_address_range', dt.FormIPv4AddressRange(required=True), label=txt.client_address_range_label))
     cc_group.add(formalutils.Field('client_compression', formal.Boolean(required=True), label='VPN client traffic compression'))
     return cc_group
Beispiel #24
0
 def create_private_network_group(self, form, ctx):
     txt = self.nc_uitexts
     g = formalutils.CollapsibleGroup('pn_group',
                                      label=txt.pn_group_caption)
     g.setCollapsed(uihelpers.collapse_setting(
         ns_ui.collapsePrivateNetwork))
     g.add(
         formalutils.Field('if',
                           formal.String(required=False),
                           formal.widgetFactory(
                               formal.SelectChoice,
                               options=uihelpers.interface_options()),
                           label=txt.if_label))
     g.add(
         formalutils.Field('ip_address_selection',
                           formal.String(required=False),
                           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('client_traffic',
                           formal.String(required=False),
                           formal.widgetFactory(
                               formal.RadioChoice,
                               options=txt.client_traffic_options),
                           label=txt.client_traffic_label))
     return g
Beispiel #25
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
Beispiel #26
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