def form_statroutes(self, data): form = formal.Form() form.addField( 'dest', formal.String(required=True, strip=True, validators=[PageHelpers.IPMaskValidator()]), label="Destination network", description= "Destination network in CIDR or '0.0.0.0/0' for the default route." ) form.addField('gate', formal.String(validators=[PageHelpers.IPValidator()]), label="Gateway", description="Gateway to forward this network to") ifs = [] for i in Utils.getInterfaces(): if 'eth' or 'ppp': # Only allow ppp and eth binds... ifs.append((i, i)) form.addField( 'device', formal.String(), formal.widgetFactory(formal.SelectChoice, options=ifs), label="Device", description= "Device to forward this traffic to, or the interface to assign this route to" ) form.addAction(self.submitRoute) return form
def form_statroutes(self, data): form = formal.Form() form.addField('dest', formal.String(required=True, strip=True, validators=[PageHelpers.IPMaskValidator()]), label = "Destination network", description = "Destination network in CIDR") form.addField('gate', formal.String(validators=[PageHelpers.IPValidator()]), label = "Gateway", description = "Gateway to forward this network to") ifs = [(i,i) for i in self.sysconf.WANDevices.keys()] form.addField('device', formal.String(), formal.widgetFactory(formal.SelectChoice, options = ifs), label = "Device", description = "Device to forward this traffic to - do not specify a gateway as well as this field") form.addAction(self.submitRoute) return form
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
def addForm(self, form): form.addField('network', formal.String(required=True, validators=[PageHelpers.IPMaskValidator() ]), label="Network")