예제 #1
0
 def address(self, value):
     if not self.family:
         self.family = 'inet'
     ip = None
     mask = None
     if '/' in value:
         ip, mask = value.split('/', 1)
     else:
         ip = value
     if not self.method:
         if ip or mask:
             self.method = 'static'
         else:
             self.method = 'manual'
     if ip:
         self.ip = ip
     if mask:
         if is_netmask(mask):
             self.netmask = mask
         elif is_cidr(mask):
             self.cidr = mask
         else:
             raise ValueError('%s is not a valid netmask or cidr' % mask)
예제 #2
0
 def cidr(self, value):
     if not is_cidr(value):
         raise ValueError('%s is not a valid cidr' % value)
     self.netmask = cidr_to_netmask(value)