def bind_render_record(self, pk=False, **kwargs): self.rdtype_clob = kwargs.pop('rdtype', 'INTR') if kwargs.pop('reverse', False): self.template = self.ptr_template self.dns_ip = ip_to_dns_form(self.ip_str) else: self.template = self.a_template return super(StaticInterface, self).bind_render_record(pk=pk, **kwargs)
def render_intr(interface_set): BUILD_STR = '' template = Template("{ip:$ip_just} {ttl} {rclass:$class_just} {rtype:$type_just} {name:$name_just}.\n") template = template.substitute(ip_just=ip_just, class_just=class_just, type_just=type_just, name_just=name_just) for intr in interface_set: if intr.ttl == 3600 or intr.ttl is None: ttl = '' else: ttl = str(intr.ttl) BUILD_STR += template.format( ip=ip_to_dns_form(intr.ip_str), ttl=ttl, rclass='IN', rtype='PTR', name=intr.fqdn) return BUILD_STR
def render_intr(interface_set): BUILD_STR = '' template = Template( "{ip:$ip_just} {ttl} {rclass:$class_just} {rtype:$type_just} {name:$name_just}.\n" ) template = template.substitute(ip_just=ip_just, class_just=class_just, type_just=type_just, name_just=name_just) for intr in interface_set: if intr.ttl == 3600 or intr.ttl is None: ttl = '' else: ttl = str(intr.ttl) BUILD_STR += template.format(ip=ip_to_dns_form(intr.ip_str), ttl=ttl, rclass='IN', rtype='PTR', name=intr.fqdn) return BUILD_STR
def dns_name(self): """Return the cononical name of this ptr that can be placed in a reverse zone file.""" return ip_to_dns_form(self.ip_str, ip_type=self.ip_type)