Example #1
0
 def set_config(self, config_key, value, sg_name=None):
     """
     Set a configuration item in the zone_cfg table
     """
     # Deal with SA auto-BEGIN - want fresh transaction to see fresh data
     self._begin_op()
     if config_key in ['soa_mname', 'soa_rname']:
         validate_zi_hostname(None, config_key, value)
     if config_key in ['soa_refresh', 'soa_retry', 'soa_expire', 'soa_ttl',
             'zone_ttl']:
         validate_zi_ttl(None, config_key, value)
     if config_key in ['soa_mname',]:
         if not sg_name:
            raise SgNameRequired(config_key)
     else:
         sg_name = None
     zone_cfg.set_row(self.db_session, config_key, value, sg_name=sg_name)
     self._finish_op()
     return {}
Example #2
0
 def check_zi_data():
     """
     Check incoming zi_data attributes for correctness
     """
     for field in ['soa_mname', 'soa_rname']:
         validate_zi_hostname(name, field, zi_data[field])
     for field in ['soa_refresh', 'soa_retry', 'soa_expire',
             'soa_minimum', 'soa_ttl', 'zone_ttl']:
         if field == 'soa_ttl' and not zi_data.get(field):
             # SOA TTL can be None
             continue
         validate_zi_ttl(name, field, zi_data[field])
     for field in ['soa_serial']:
         if field == 'soa_serial' and zi_data.get(field, None) == None:
             # SOA serial can be None
             continue
         # Check incoming data type of soa_serial
         if not isinstance(zi_data['soa_serial'], int):
             raise SOASerialTypeError(name)
         if not ( 0 < zi_data['soa_serial'] <= (2**32-1)):
             # RFC 2136 Section 4.2 AO serial cannot be zero
             raise SOASerialRangeError(name)
Example #3
0
 def check_zi_data():
     """
     Check incoming zi_data attributes for correctness
     """
     for field in ['soa_mname', 'soa_rname']:
         validate_zi_hostname(name, field, zi_data[field])
     for field in [
             'soa_refresh', 'soa_retry', 'soa_expire', 'soa_minimum',
             'soa_ttl', 'zone_ttl'
     ]:
         if field == 'soa_ttl' and not zi_data.get(field):
             # SOA TTL can be None
             continue
         validate_zi_ttl(name, field, zi_data[field])
     for field in ['soa_serial']:
         if field == 'soa_serial' and zi_data.get(field, None) == None:
             # SOA serial can be None
             continue
         # Check incoming data type of soa_serial
         if not isinstance(zi_data['soa_serial'], int):
             raise SOASerialTypeError(name)
         if not (0 < zi_data['soa_serial'] <= (2**32 - 1)):
             # RFC 2136 Section 4.2 AO serial cannot be zero
             raise SOASerialRangeError(name)