Esempio n. 1
0
def update_dns(public_ip):
    client = pygodaddy.GoDaddyClient()
    client.login(GODADDY_USERNAME, GODADDY_PASSWORD)

    for domain in client.find_domains():
        for dns_record in client.find_dns_records(domain):
            logging.debug("Domain '{0}' DNS records: {1}".format(
                domain, client.find_dns_records(domain)))
            # only update the bluewolf subdomain
            if dns_record.hostname == 'bluewolf':
                if public_ip != dns_record.value:
                    if client.update_dns_record(
                            dns_record.hostname + "." + domain, public_ip):
                        logging.info(
                            "Host '{0}' public IP set to '{1}'".format(
                                dns_record.hostname, public_ip))
                        # update our local copy of IP
                        write_ip_file()
                        break
                    else:
                        logging.info(
                            "Failed to update Host '{0}' IP to '{1}'".format(
                                dns_record.hostname, public_ip))
                else:
                    logging.info("Nothing was changed")
                    # We are 90% only here because there is no current_ip file. So, we write it now.
                    write_ip_file()
            else:
                logging.info("Not Bluewolf: '{0}', skipping".format(
                    dns_record.hostname))
    return
Esempio n. 2
0
def update_dns(config, public_ip):
    client = pygodaddy.GoDaddyClient()
    client.login(config['godaddy_username'], config['godaddy_password'])

    for domain in client.find_domains():
        for dns_record in client.find_dns_records(domain):
            logging.debug("Domain '{0}' DNS records: {1}".format(
                domain, client.find_dns_records(domain)))
            # only update the bluewolf subdomain
            if dns_record.hostname == config['record_hostname']:
                if public_ip != dns_record.value:
                    if client.update_dns_record(
                            dns_record.hostname + "." + domain, public_ip):
                        logging.info(
                            "Host '{0}' public IP set to '{1}'".format(
                                dns_record.hostname, public_ip))
                        # update our local copy of IP
                        write_ip_file(config, public_ip)
                    else:
                        logging.info(
                            "Failed to update Host '{0}' IP to '{1}'".format(
                                dns_record.hostname, public_ip))
                else:
                    logging.info("Nothing was changed")
                    write_ip_file(config, public_ip)
            else:
                logging.info("Not {0}: '{1}', skipping".format(
                    config['record_hostname'], dns_record.hostname))
    return
Esempio n. 3
0
    def __init__(self, config, logger, network):
        self.client = pygodaddy.GoDaddyClient()
        self.config = config
        self.logger = logger
        self.network = network

        # Log into GoDaddy
        self.client.login(config['username'], config['password'])
Esempio n. 4
0
def get_godaddy_client():
   config = configparser.ConfigParser()
   config.read('godaddy-dyndns.conf')

   client = pygodaddy.GoDaddyClient()
   is_logged_in = client.login(config.get('godaddy', 'username'),
                               config.get('godaddy', 'password'))
   if not is_logged_in:
      raise RuntimeError('Could not log in into GoDaddy')

   return client
Esempio n. 5
0
logging.getLogger("requests").setLevel(logging.DEBUG)

public_ip = pif.get_public_ip()
logging.info("INFO : ip_address = %s", str(public_ip))

ipfile = open(ip_address_file, 'r')
old_public_ip = ipfile.read()
ipfile.close()

if public_ip == old_public_ip:
    logging.info("INFO : ip address %s not changed", str(old_public_ip))
    quit()

logging.info("INFO : Updating ip address")

client = pygodaddy.GoDaddyClient()
U = "username"
P = "password"
success = client.login(U, P)

if success:
    domains = client.find_domains()
    for domain in domains:
        logging.info("INFO : Domain - %s", str(domain))
        dns_records = client.find_dns_records(domain)
        for record in dns_records:
            logging.info("INFO : processing >>> %s", str(record))
            if record.hostname == 'home':
                logging.info("INFO : Found domain - home | updating...")
                if record.value != public_ip:
                    client.update_dns_record('home.jayantkumar.in', public_ip)