def modify_record_name(domain_name, name, record_id, new_ip_addr): request = UpdateDomainRecordRequest() request.set_accept_format('json') request.set_RecordId(record_id) request.set_RR(name) request.set_Type("A") request.set_Value(new_ip_addr) with open(log_file, "a") as logfile: try: response = client.do_action_with_exception(request) sms.dns_record_update_sms( '.'.join([name, domain_name]).replace(".", "-"), new_ip_addr.replace('.', '-')) serverchan_ip_change_msg(name, "-".join(new_ip_addr.split("."))) logfile.write( "%s \t %s \n" % (str(time.asctime(time.localtime(time.time()))), response)) r_j = json.loads(response.decode()) request_id = r_j["RequestId"] record_id = r_j["RecordId"] insert_change(request_id=request_id, record_id=record_id, domain=domain_name, name=name, ip_addr=new_ip_addr) exist_and_count(domain_name, name, record_id) OK_response("200.3 OK") except Exception as e: logfile.write("%s \t %s \n" % (str(time.asctime(time.localtime( time.time()))), traceback.print_exc())) code = "503.4" serverchan_error_msg(domain_name, code, e) error_response(code)
def describe_full_records(domain_name): request = DescribeDomainRecordsRequest() request.set_accept_format('json') request.set_DomainName(domain_name) try: response = client.do_action_with_exception(request) return json.loads(response.decode()) except Exception as e: code = "503.1" serverchan_error_msg(domain_name, code, e) error_response(code)
def describe_name_record(record_id): request = DescribeDomainRecordInfoRequest() request.set_accept_format('json') request.set_RecordId(record_id) with open(log_file, "a") as logfile: try: response = client.do_action_with_exception(request).decode() ip_value_in_record = json.loads(response)['Value'] return ip_value_in_record except Exception as e: logfile.write("%s \t %s \n" % (str(time.asctime(time.localtime(time.time()))), traceback.print_exc())) code ="503.3" serverchan_error_msg(record_id, code, e) error_response(code)