コード例 #1
0
 def _add_answers_to_args(self, data, key, existing_answers, row_data):
     args = data[key]
     updated_answers = self._build_answers(existing_answers, key, row_data)
     if updated_answers:
         args['answers'] = updated_answers
     log("record_request_{}".format(key), args)
     return args
コード例 #2
0
 def get_or_create_zone(self, zone_name):
     try:
         log("zone_request_load", zone_name)
         zone, source = yield nsone_async.loadZone(zone_name), "LOAD"
     except ResourceException as e:
         if e.message == "server error: zone not found":
             log("zone_request_create", zone_name)
             zone, source = yield nsone_async.createZone(
                 zone_name), "CREATE"
         else:
             raise e
     defer.returnValue({"zone": zone, "source": source})
コード例 #3
0
 def build_args(self, key, row_data, existing_answers=[]):
     if existing_answers:
         log("existing_answers", existing_answers)
     data = {
         "load": {
             "domain": row_data['Zone'],
             "rtype": row_data['Type']
         },
         "update": {
             "rtype": row_data['Type'],
             "data": row_data['Data'],
             "ttl": row_data['TTL'],
             "answers": []
         },
         "create": {
             "domain": row_data['Zone'],
             "answers": row_data['Data'],
             "ttl": row_data['TTL'],
             "name": row_data['Name']
         }
     }
     return self._add_answers_to_args(data, key, existing_answers, row_data)
コード例 #4
0
import os
import sys
import json

from shared.config.loader import set_config, get_config
from shared.logger import JsonLogger as log

logger = log(__file__)


def handler(event, context):
    try:
        set_config()
        environment = os.environ.get("environment", "")
        if environment == "local":
            logger.set_request_id("local")
        else:
            logger.set_request_id(context.aws_request_id)

        logger.log("incoming event: " + json.dumps(event))
        return "hello world!"
    except Exception:
        logger.log_error(sys.exc_info())
        error_message = "failure"
        logger.log(error_message)
        raise RuntimeError(error_message)


######
######
# For local testing
コード例 #5
0
 def gotRecord(self, record_result, row_data):
     log("record_{}".format(record_result['source']),
         record_result['record'])
     self.remove_record_from_zone_record_queue(row_data)
     self.terminate_reactor_if_done()
コード例 #6
0
 def gotZone(self, zone_result):
     zone_record = zone_result['zone']
     zone_name = zone_record.zone
     zone_store.zone_records[zone_name] = zone_record
     log("zone_{}".format(zone_result['source']), zone_record)