Ejemplo n.º 1
0
 def dhcp_subnet(self, action, name, subnet="", suffix=[]):
     dhcp_params = [name]
     if subnet:
         if not vld.testip(subnet):
             return False
         dhcp_params.extend(["subnet", subnet + "/24"] + suffix)
     return self.dhcp_config(action, dhcp_params)
Ejemplo n.º 2
0
 def set_interface_route(self, dst_subnet, next_iface):
     if not vld.testip(dst_subnet) or not vld.testiface(next_iface):
         return False
     interface_params = [
         dst_subnet + "/24", "next-hop-interface", next_iface
     ]
     return self.route("set", "interface-route", interface_params)
Ejemplo n.º 3
0
 def dhcp_subnet(self,action,name,subnet="",suffix=[]):
     dhcp_params=[name]
     if subnet:
         if not vld.testip(subnet):
             return False
         dhcp_params.extend(["subnet",subnet+"/24"]+suffix)
     return self.dhcp_config(action,dhcp_params)
Ejemplo n.º 4
0
 def dhcp_dnsserver_default_router(self,action,service,name,addr):
     if not vld.testip(addr) or not vld.addrvalidation(addr):
         return False
     if service == 'default_router':
         suffix=["default-router",addr]
     elif service == "dns_server":
         suffix=["dns-server",addr]
     subnet=self.get_subnet_from_name(name)
     return self.dhcp_subnet(action,name,subnet,suffix)
Ejemplo n.º 5
0
 def dhcp_dnsserver_default_router(self, action, service, name, addr):
     if not vld.testip(addr) or not vld.addrvalidation(addr):
         return False
     if service == 'default_router':
         suffix = ["default-router", addr]
     elif service == "dns_server":
         suffix = ["dns-server", addr]
     subnet = self.get_subnet_from_name(name)
     return self.dhcp_subnet(action, name, subnet, suffix)
Ejemplo n.º 6
0
 def addr_interface(self,
                    action,
                    interface,
                    addr,
                    vlan_label="",
                    vlan_id=''):
     if not vld.testip(addr):
         return False
     address = [interface, vlan_label, vlan_id, "address", addr + "/24"]
     self.ethernet_config(action, address)
Ejemplo n.º 7
0
 def add_addr_route(self,dst_subnet,nexthop=""):
     if not vld.testip(dst_subnet):
         return False
     addr_params=[dst_subnet+"/24"]
     if nexthop=="":
         addr_params.append("blackhole distance 1")
     else:
         if not vld.addrvalidation(nexthop):
             return False
         addr_params.extend(["next-hop",nexthop])
     return self.route("set","route",addr_params)
Ejemplo n.º 8
0
 def add_addr_route(self, dst_subnet, nexthop=""):
     if not vld.testip(dst_subnet):
         return False
     addr_params = [dst_subnet + "/24"]
     if nexthop == "":
         addr_params.append("blackhole distance 1")
     else:
         if not vld.addrvalidation(nexthop):
             return False
         addr_params.extend(["next-hop", nexthop])
     return self.route("set", "route", addr_params)
Ejemplo n.º 9
0
 def delete_interface_route(self,dst_subnet):
     if not vld.testip(dst_subnet):
         return False
     return self.route("delete","interface-route",dst_subnet+"/24")
Ejemplo n.º 10
0
 def set_interface_route(self,dst_subnet,next_iface):
     if not vld.testip(dst_subnet) or not vld.testiface(next_iface):
         return False
     interface_params=[dst_subnet+"/24","next-hop-interface",next_iface]
     return self.route("set","interface-route",interface_params)
Ejemplo n.º 11
0
 def delete_addr_route(self,dst_subnet):
     if not vld.testip(dst_subnet):
         return False
     return self.route("delete","route",dst_subnet+"/24")
Ejemplo n.º 12
0
 def server_range_addr(self,action,iface,subnet):
     if not vld.testip(subnet):
         return False
     suffix=["server subnet",subnet+"/24"]
     return self.openvpn_config(iface,action,suffix)
Ejemplo n.º 13
0
 def access_route_vpn(self,action,iface,dst_subnet):
     if not vld.testip(dst_subnet):
         return False
     self.RS.set_interface_route(dst_subnet,iface)
     return True
Ejemplo n.º 14
0
 def set_range_adresses(self, name, subnet, adr_start, adr_stop):
     if not vld.testip(subnet) or not vld.testip(
             adr_start) or not vld.testip(adr_stop):
         return False
     range = ["start", adr_start, "stop", adr_stop]
     return self.dhcp_subnet('set', name, subnet, range)
Ejemplo n.º 15
0
 def set_range_adresses (self,name,subnet,adr_start,adr_stop):
     if not vld.testip(subnet) or not vld.testip(adr_start) or not vld.testip(adr_stop):
         return False
     range=["start",adr_start,"stop",adr_stop]
     return self.dhcp_subnet('set',name,subnet,range)
Ejemplo n.º 16
0
 def addr_interface(self,action,interface,addr,vlan_label="",vlan_id=''):
     if  not vld.testip(addr):
         return False
     address = [interface,vlan_label,vlan_id,"address",addr+"/24"]
     self.ethernet_config(action,address)
Ejemplo n.º 17
0
 def push_route_subnet(self,action,iface,subnet):
     if not vld.testip(subnet):
         return False
     suffix=["server push-route",subnet+"/24"]
     return self.openvpn_config(iface,action,suffix)
Ejemplo n.º 18
0
 def push_root_nameserver(self,action,iface,nameserver):
     if not vld.testip(nameserver):
         return False
     suffix=["server name-server",nameserver]
     return self.openvpn_config(iface,action,suffix)
Ejemplo n.º 19
0
 def delete_addr_route(self, dst_subnet):
     if not vld.testip(dst_subnet):
         return False
     return self.route("delete", "route", dst_subnet + "/24")
Ejemplo n.º 20
0
 def endpoint_local_remote_vaddr(self,action,pos,iface,vaddr):
     if not vld.testip(vaddr) or pos not in self.pos:
         return False
     suffix=[pos+"-address",vaddr]
     return self.openvpn_config(iface,action,suffix)
Ejemplo n.º 21
0
 def delete_interface_route(self, dst_subnet):
     if not vld.testip(dst_subnet):
         return False
     return self.route("delete", "interface-route", dst_subnet + "/24")
Ejemplo n.º 22
0
 def name_server(self,action,nameserver):
     if not vld.testip(nameserver):
         return False
     return self.dns_config(action,["name-server",nameserver])