Beispiel #1
0
    def __create_one_zone_with_subnets_do_not_fit_into_one_netlink_packet(
            self):
        zone_name = 'zone'
        zone_subnet_count_that_not_fit_in_netlink_packet = self._get_netlink_packet_size(
        )
        zone_subnet_family = socket.AF_INET
        zone_subnet_format = '192.168.%d.%d'

        zone_messages = []

        add_zone_message = messages.KZorpAddZoneMessage(
            zone_name,
            subnet_num=zone_subnet_count_that_not_fit_in_netlink_packet)
        zone_messages.append(add_zone_message)

        for subnet_num in range(
                zone_subnet_count_that_not_fit_in_netlink_packet):
            add_zone_subnet_message = messages.KZorpAddZoneSubnetMessage(
                zone_name,
                family=zone_subnet_family,
                address=socket.inet_pton(
                    zone_subnet_family, zone_subnet_format % (
                        subnet_num % (2**16) / 256,
                        subnet_num % (2**8),
                    )),
                mask=socket.inet_pton(
                    zone_subnet_family,
                    testutil.size_to_mask(zone_subnet_family, 32)))
            zone_messages.append(add_zone_subnet_message)

        return zone_messages
 def _addzones(self):
   for zone in self._zones:
       #print "zone=%s\n"%(zone,)
       subnets = zone['subnets']
       self.send_message(messages.KZorpAddZoneMessage(
                         zone['name'],
                         pname=zone['admin_parent'],
                         subnet_num=len(subnets)))
       for subnet in subnets:
         self.send_message(messages.KZorpAddZoneSubnetMessage(
                           zone['name'],
                           family=zone['family'],
                           address = testutil.subnet_base(zone['family'], subnet),
                           mask = testutil.subnet_mask(zone['family'], subnet)))
Beispiel #3
0
    def newSetUp(self):
        self.start_transaction()

        for zone in self._zones:
            add_zone_message = messages.KZorpAddZoneMessage(
                zone['name'], pname=zone['pname'], subnet_num=1)
            self.send_message(add_zone_message)

            family = zone['family']
            add_zone_subnet_message = messages.KZorpAddZoneSubnetMessage(
                zone['name'],
                family=family,
                address=socket.inet_pton(family, zone['address']),
                mask=socket.inet_pton(
                    family, testutil.size_to_mask(family, zone['mask'])))
            self.send_message(add_zone_subnet_message)

        self.end_transaction()
        self._index = -1
        self._add_zone_message = None
        self._add_zone_messages = []
Beispiel #4
0
 def _create_add_zone_subnet_internet(self, name):
     return messages.KZorpAddZoneSubnetMessage(name,
                                               self.internet_subnet_family,
                                               self.internet_subnet_addr,
                                               self.internet_subnet_mask)