Esempio n. 1
0
    def register_dns(self):
        d = dme(self.conf.get('dme', 'KEY'), self.conf.get('dme', 'SECRET'))
        d.baseurl = "http://api.dnsmadeeasy.com/V1.2/" # Go live now.

        data =  {
                "name" : self.subdomain,
                "type" : "A",
                "data" : self.instance.ip_address,
                "gtdLocation" : "Default",
                "ttl" : self.conf.get('dme', 'TTL')
                }

        # Create main record.
        try:
            result = d.add_record(self.conf.get('dme', 'DOMAIN'), json.dumps(data, separators=(',', ':')))
        except Exception as e:
            raise DeplomatException(6, "Unable to add record to DNSMadeEasy: %s" % (e,))
        else:
            print "MobilityServer DNS entry registered successfuly: %s.%s" % (self.subdomain, self.conf.get('dme', 'DOMAIN'))


        # Create MSAdmin record.
        data['name'] = 'a.%s' % (self.subdomain,)
        try:
            result = d.add_record(self.conf.get('dme', 'DOMAIN'), json.dumps(data, separators=(',', ':')))
        except Exception as e:
            raise DeplomatException(6, "Unable to add record to DNSMadeEasy: %s" % (e,))
        else:
            print "MSAdmin DNS entry registered successfuly: a.%s.%s" % (self.subdomain, self.conf.get('dme', 'DOMAIN'))

        return True
Esempio n. 2
0
def main():
    # Sandbox Auth info
    dns = dme("API KEY", "SECRET KEY")

    #    # Example use of 'list_domains' returns a list of all domains
    print("\nList all domains: \n")
    domains = dns.list_domains()
    for d in domains:
        print(d)

    # Example of using 'list_records' on a single domain
    print("\nList records for a single domain:")
    records = dns.get_records('test1.com')
    for record in records:
        print("")
        for (key, value) in record.items():
            print(key + " : " + str(value))

    # Example of using 'get_domain' on a single domain
    print("\nGet general info about a single domain: \n")
    domain_info = dns.get_domain('test1.com')
    for items in domain_info:
        if type(items[1]) is list:
            for ns in items[1]:
                print(ns)
        else:
            print(items[0] + " : " + str(items[1]))

    # Example of deleting a domain:

    print("Delete domain: \n")
    result = dns.delete_domain("testdomain2.com")
    print(result['status'])

    # Example of adding a domain:

    print("\nAdd domain")
    content = dns.add_domain("testdomain5.com")
    print(content['name'] + " added!")

    # Example of adding a single record to a domain:

    print("\nAdd record to domain: \n")
    data = json.dumps(
        {
            "name": "dummycname",
            "type": "A",
            "data": "208.94.147.96",
            "gtdLocation": "Default",
            "ttl": 1800
        },
        separators=(',', ':'))
    result = dns.add_record('testdomain1.com', data)
    print(result)
    record = dns.get_record_byid('testdomain1.com', '6883496')
    print(record)

    #    record = dns.delete_record_byid('test1.com', '6883496')

    data = json.dumps(
        {
            "name": "",
            "type": "MX",
            "data": "10 mail",
            "gtdLocation": "DEFAULT",
            "ttl": 1800
        },
        separators=(',', ':'))
    record = dns.update_record_byid('testdomain1.com', '6883496', data)
    print(record)
Esempio n. 3
0
def main():
    # Sandbox Auth info
    dns = dme("API KEY", "SECRET KEY")
        
#    # Example use of 'list_domains' returns a list of all domains
    print("\nList all domains: \n")
    domains = dns.list_domains()
    for d in domains:
        print(d)
    
    # Example of using 'list_records' on a single domain
    print("\nList records for a single domain:")
    records = dns.get_records('test1.com')
    for record in records:
        print("")
        for (key, value) in record.items():
            print(key + " : " + str(value))
    
    # Example of using 'get_domain' on a single domain
    print("\nGet general info about a single domain: \n")
    domain_info = dns.get_domain('test1.com')
    for items in domain_info:
        if type(items[1]) is list:
            for ns in items[1]:
                print(ns)
        else:
            print(items[0] + " : " + str(items[1]))

    
    # Example of deleting a domain:
    
    print("Delete domain: \n")
    result = dns.delete_domain("testdomain2.com")
    print(result['status'])
    
    # Example of adding a domain:
    
    print("\nAdd domain")
    content = dns.add_domain("testdomain5.com")
    print(content['name'] + " added!")
    
    # Example of adding a single record to a domain:
    
    print("\nAdd record to domain: \n")
    data =  json.dumps({
                "name":"dummycname",
                "type":"A",
                "data":"208.94.147.96",
                "gtdLocation":"Default",
                "ttl":1800
            }, separators=(',', ':'))    
    result = dns.add_record('testdomain1.com', data)
    print(result) 
    record = dns.get_record_byid('testdomain1.com','6883496')
    print(record)
    
#    record = dns.delete_record_byid('test1.com', '6883496')
    
    
    data =  json.dumps({
            "name":"",
            "type":"MX",
            "data":"10 mail",
            "gtdLocation":"DEFAULT",
            "ttl":1800
    }, separators=(',', ':'))
    record = dns.update_record_byid('testdomain1.com', '6883496', data)
    print(record)