예제 #1
0
 def set_addr_from_match(self, addr1, cidr1, addr2, _cidr2, standby,
                         _standby_cidr, secondary):
     addr = device.Addr(addr1)
     if cidr1 != None:
         addr.cidr = int(cidr1)
     else:
         addr.cidr = iptools.mask_to_cidr(addr2)
     addr.standby = standby
     addr.secondary = secondary == 'secondary'
     self.interface.add_addr(addr)
예제 #2
0
    def get_nat_addr(self, nat, addr, object_name):
        if addr != None:
            nat_addr = device.Object(addr=device.Addr(addr))
        elif object_name == 'interface':
            nat_addr = device.Object(nat.outside_interface.custom_name)
            nat_addr.addr = nat.outside_interface.primary_addr()
            if nat_addr.addr == None:
                self.parser.error(
                    f'Interface "{nat.outside_interface.custom_name}" '
                    'used in nat without primary address.')
        elif object_name == 'any':
            nat_addr = device.Object('any')
            nat_addr.addr = device.Addr('0.0.0.0', 0)
        else:
            nat_addr = self.parser.device.get_object(object_name)
            if nat_addr == None:
                nat_addr = device.Object(object_name)
                self.parser.error(f'Network object "{object_name}" '
                                  'not found.')

        if nat_addr.type == None:
            nat_addr.type = device.ObjectType.NETWORK
        return nat_addr
예제 #3
0
 def add_host_from_match(self, addr, _cidr, addr6, _cidr6, name):
     cidr = 32
     type = 4
     if addr != None:
         address = addr
     elif addr6 != None:
         address = addr6
         cidr = 128
         type = 6
     else:
         address = self.parser.device.get_object(name)
         if address == None:
             address = name
     self.object.add_item(device.Addr(address, cidr, 6))
예제 #4
0
    def add_subnet_from_match(self, addr1, cidr1, name, addr2, _cidr2, addr6_1,
                              cidr6):
        if addr2 != None:  # set cidr
            cidr = iptools.mask_to_cidr(addr2)
            type = 4
        else:
            cidr = cidr6
            type = 6

        if addr1 != None:  # set addr
            addr = addr1
        elif addr6_1 != None:
            addr = addr6_1
        else:
            addr = self.parser.device.get_object(name)
            if addr == None:
                addr = name
        self.object.add_item(device.Addr(addr, cidr, type))
예제 #5
0
 def set_host(self):
     self.object.addr = device.Addr(self.parser.token_at(1))
예제 #6
0
 def name_object_from_match(self, addr, _cidr, name, description):
     self.object.addr = device.Addr(addr)
     self.object.name = name
     if description != None:
         self.object.description = description
예제 #7
0
 def set_range_from_match(self, addr1, _cidr1, addr2, _cidr2):
     self.object.addr = [device.Addr(addr1), device.Addr(addr2)]
예제 #8
0
 def set_subnet_from_match(self, addr1, cidr1, addr2, _cidr2):
     self.object.addr = device.Addr(addr1)
     if cidr1 != None:
         self.object.addr.cidr = int(cidr1)
     else:
         self.object.addr.cidr = iptools.mask_to_cidr(addr2)