def _addzones(self):
   for zone in self._zones:
       #print "zone=%s\n"%(zone,)
       subnets = zone['subnets']
       if len(subnets) == 0 :
            self.send_message(kznl.KZorpAddZoneMessage(
               zone['uname'],
               family=zone['family'],
               uname=zone['name'],
               pname=zone['admin_parent']))
       elif len(subnets) == 1 :
            self.send_message(kznl.KZorpAddZoneMessage(
               zone['uname'],
               family=zone['family'],
               uname=zone['uname'],
               pname=zone['admin_parent'],
               address = testutil.subnet_base(zone['family'], zone['subnets'][0]),
               mask = testutil.subnet_mask(zone['family'], zone['subnets'][0])))
       else:
           self.send_message(kznl.KZorpAddZoneMessage(
               zone['uname'],
               family=zone['family'],
               uname=zone['uname'],
               pname=zone['admin_parent']))
           for index,subnet in enumerate(subnets):
             self.send_message(kznl.KZorpAddZoneMessage(
               zone['uname'],
               family=zone['family'],
               uname="%s-#%u" % (zone['uname'], index+1),
               pname=zone['uname'],
               address = testutil.subnet_base(zone['family'], subnet),
               mask = testutil.subnet_mask(zone['family'], subnet)))
 def test_subnet_arith(self):
     self.assertEqual(
         socket.inet_pton(socket.AF_INET, '192.168.1.1'),
         testutil.subnet_base(socket.AF_INET, '192.168.1.1/24'))
     self.assertEqual(
         socket.inet_pton(socket.AF_INET, '255.255.255.0'),
         testutil.subnet_mask(socket.AF_INET, '192.168.1.1/24'))
     self.assertEqual(
         socket.inet_pton(socket.AF_INET6, 'fd00:bb:1030:1100:cc::'),
         testutil.subnet_base(socket.AF_INET6, 'fd00:bb:1030:1100:cc::/80'))
     self.assertEqual(
         socket.inet_pton(socket.AF_INET6,
                          'ffff:ffff:ffff:ffff:ffff:0000:0000:0000'),
         testutil.subnet_mask(socket.AF_INET6, 'fd00:bb:1030:1100:cc::/80'))
 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)))
 def _addzones(self):
     for zone in self._zones:
         #print "zone=%s\n"%(zone,)
         subnets = zone['subnets']
         if len(subnets) == 0:
             self.send_message(
                 kznl.KZorpAddZoneMessage(zone['uname'],
                                          family=zone['family'],
                                          uname=zone['name'],
                                          pname=zone['admin_parent']))
         elif len(subnets) == 1:
             self.send_message(
                 kznl.KZorpAddZoneMessage(
                     zone['uname'],
                     family=zone['family'],
                     uname=zone['uname'],
                     pname=zone['admin_parent'],
                     address=testutil.subnet_base(zone['family'],
                                                  zone['subnets'][0]),
                     mask=testutil.subnet_mask(zone['family'],
                                               zone['subnets'][0])))
         else:
             self.send_message(
                 kznl.KZorpAddZoneMessage(zone['uname'],
                                          family=zone['family'],
                                          uname=zone['uname'],
                                          pname=zone['admin_parent']))
             for index, subnet in enumerate(subnets):
                 self.send_message(
                     kznl.KZorpAddZoneMessage(
                         zone['uname'],
                         family=zone['family'],
                         uname="%s-#%u" % (zone['uname'], index + 1),
                         pname=zone['uname'],
                         address=testutil.subnet_base(
                             zone['family'], subnet),
                         mask=testutil.subnet_mask(zone['family'], subnet)))
 def test_subnet_arith(self):
     self.assertEqual(socket.inet_pton(socket.AF_INET,'192.168.1.1'), testutil.subnet_base(socket.AF_INET,'192.168.1.1/24'))
     self.assertEqual(socket.inet_pton(socket.AF_INET,'255.255.255.0'), testutil.subnet_mask(socket.AF_INET,'192.168.1.1/24'))
     self.assertEqual(socket.inet_pton(socket.AF_INET6,'fd00:bb:1030:1100:cc::'), testutil.subnet_base(socket.AF_INET6,'fd00:bb:1030:1100:cc::/80'))
     self.assertEqual(socket.inet_pton(socket.AF_INET6,'ffff:ffff:ffff:ffff:ffff:0000:0000:0000'), testutil.subnet_mask(socket.AF_INET6,'fd00:bb:1030:1100:cc::/80'))