def render(self, session, service, protocol, dns_domain, priority, weight, target, port, dns_environment, comments, **kwargs): dbdns_env = DnsEnvironment.get_unique_or_default( session, dns_environment) dbdns_domain = DnsDomain.get_unique(session, dns_domain, compel=True) if dbdns_domain.restricted: raise ArgumentError( "{0} is restricted, SRV records are not allowed.".format( dbdns_domain)) # TODO: we could try looking up the port based on the service, but there # are some caveats: # - the protocol name used in SRV record may not match the name used in # /etc/services # - socket.getservent() may return bogus information (like it does for # e.g. 'kerberos') service = service.strip().lower() target = target.strip().lower() dbtarget = Fqdn.get_unique(session, target, compel=True) dbsrv_rec = SrvRecord(service=service, protocol=protocol, priority=priority, weight=weight, target=dbtarget, port=port, dns_domain=dbdns_domain, dns_environment=dbdns_env, comments=comments) session.add(dbsrv_rec) session.flush() return