def add_host(zone, name, ttl, ip, keyname, keyfile, nameserver, timeout, port=53, keyalgorithm='hmac-md5'):
 res = []
 if (zone in name):
  name = name.replace(zone, '').rstrip('.')
 fqdn = '{0}.{1}'.format(name, zone)
 ret = create(zone, name, ttl, 'A', ip, keyname, keyfile, nameserver, timeout, port, keyalgorithm)
 res.append(ret[fqdn])
 parts = ip.split('.')[::(-1)]
 i = len(parts)
 popped = []
 while (i > 1):
  p = parts.pop(0)
  i -= 1
  popped.append(p)
  zone = '{0}.{1}'.format('.'.join(parts), 'in-addr.arpa.')
  name = '.'.join(popped)
  rev_fqdn = '{0}.{1}'.format(name, zone)
  ret = create(zone, name, ttl, 'PTR', '{0}.'.format(fqdn), keyname, keyfile, nameserver, timeout, port, keyalgorithm)
  if ('Created' in ret[rev_fqdn]):
   res.append(ret[rev_fqdn])
   return {fqdn: res}
 res.append(ret[rev_fqdn])
 return {fqdn: res}

def add_host ( zone , name , ttl , ip , keyname , keyfile , nameserver , timeout , port = 53 , keyalgorithm = 'hmac-md5' ) : res = [ ] if ( zone in name ) : name = name . replace ( zone , '' ) . rstrip ( '.' ) fqdn = '{0}.{1}' . format ( name , zone ) ret = create ( zone , name , ttl , 'A' , ip , keyname , keyfile , nameserver , timeout , port , keyalgorithm ) res . append ( ret [ fqdn ] ) parts = ip . split ( '.' ) [ : : ( - 1 ) ] i = len ( parts ) popped = [ ] while ( i > 1 ) : p = parts . pop ( 0 ) i -= 1 popped . append ( p ) zone = '{0}.{1}' . format ( '.' . join ( parts ) , 'in-addr.arpa.' ) name = '.' . join ( popped ) rev_fqdn = '{0}.{1}' . format ( name , zone ) ret = create ( zone , name , ttl , 'PTR' , '{0}.' . format ( fqdn ) , keyname , keyfile , nameserver , timeout , port , keyalgorithm ) if ( 'Created' in ret [ rev_fqdn ] ) : res . append ( ret [ rev_fqdn ] ) return { fqdn : res } res . append ( ret [ rev_fqdn ] ) return { fqdn : res }
add host .