Exemplo n.º 1
0
def set_dns_service_group(response, dns_record, service_group):
    """Sets the service group to which a record belongs.
    If passed a group name of None, remove the record from any group it is a member of. 

    Arguments:
         dns_hostname -- The dns hostname of a record.
         service_group -- The service group name.

    """
    if service_group:
        group = _get_dns_service_group_instance(response, service_group)
    else:
        group = None

    try:
        record = DNSRecord.objects.get(name=dns_record)
    except ObjectDoesNotExist:
        record = DNSRecord(name=dns_record)

    record.group = group
    record.save()

    return True
Exemplo n.º 2
0
def _update_comments(comments, hg):
    """Store comments in the database and store comment changes in mercurial.
    
    Comments specified need not have actually changed.  In other words, it is 
    acceptable that some comments specified already match those in the 
    database.
    
    Arguments:
        comments -- Dict of DNS name -> comment pairs.
        hg -- A mercurial repository from jinx_api.api.lib.hg.
    """
    
    for record_name, comment in comments.iteritems():
        try:
            record = DNSRecord.objects.get(name=record_name)
        except ObjectDoesNotExist:
            record = DNSRecord(name=record_name)
            
        record.comment = comment
        record.save()
        
        if comment is None:
            comment = ""
        hg.put_file("comments/%s" % record_name, comment)
Exemplo n.º 3
0
    def data(self):
        jinx0 = DNSRecord(name="jinx0.lindenlab.com", comment="Fancy new MX Record")
        jinx0.save()
        
        jinx1 = DNSRecord(name="jinx1.lindenlab.com", comment="Fancy new A Record")
        jinx1.save()

        jinx = DNSService(name="jinx", comment="Fancy Jinx group")
        jinx.save()

        jinx0.group = jinx
        jinx1.group = jinx

        jinx0.save()
        jinx1.save()
        jinx.save()