コード例 #1
0
    def execute_task(self):
        log.debug(u"CreateMapping for notification %s" % self._notification)
        # Determine the public ip address of our instance.
        ip_address = self._get_instance_ip(self._notification.instance_id)
        log.error("IP: %s", ip_address)
        if not ip_address:
            return []

        # Determine the processor_id that is handling our naming
        processor_id = self.get_processor_id()
        # If we couldn't find processor_id, keep message and we'll retry message later.
        log.error('Processor Id: %s', processor_id)
        if not processor_id:
            return []

        # Create the new route.
        processor = DNSProcessor(None, self._table, self._notification.region)
        try:
            delete_notification = processor.add_instance_mapping(processor_id,
                                                                 self._notification.instance_id,
                                                                 ip_address)
        except ValueError:
            log.exception("Invalid mapping to add")
            delete_notification = True

        # Delete our notification
        if delete_notification:
            self._notification.delete()
コード例 #2
0
    def execute_task(self):
        log.debug(u"CreateMapping for notification %s" % self._notification)
        # Determine the public ip address of our instance.
        ip_address = self._get_instance_ip(self._notification.instance_id)
        log.error("IP: %s", ip_address)
        if not ip_address:
            return []

        # Determine the processor_id that is handling our naming
        processor_id = self.get_processor_id()
        # If we couldn't find processor_id, keep message and we'll retry message later.
        log.error('Processor Id: %s', processor_id)
        if not processor_id:
            return []

        # Create the new route.
        processor = DNSProcessor(None, self._table, self._notification.region)
        try:
            delete_notification = processor.add_instance_mapping(
                processor_id, self._notification.instance_id, ip_address)
        except ValueError:
            log.exception("Invalid mapping to add")
            delete_notification = True

        # Delete our notification
        if delete_notification:
            self._notification.delete()
コード例 #3
0
    def execute_task(self):
        log.debug(u"DeleteMapping for notification %s" % self._notification)
        processor_id = self.get_processor_id()
        # If we couldn't find processor_id, keep message and we'll retry message later.
        if not processor_id:
            return []

        # Delete the route.
        processor = DNSProcessor(None, self._table, self._notification.region)
        try:
            delete_notification = processor.remove_instance_mapping(processor_id, self._notification.instance_id)
        except ValueError:
            log.exception("Invalid mapping to remove")
            delete_notification = True

        # Delete our notification
        if delete_notification:
            self._notification.delete()
コード例 #4
0
    def execute_task(self):
        log.debug(u"DeleteMapping for notification %s" % self._notification)
        processor_id = self.get_processor_id()
        # If we couldn't find processor_id, keep message and we'll retry message later.
        if not processor_id:
            return []

        # Delete the route.
        processor = DNSProcessor(None, self._table, self._notification.region)
        try:
            delete_notification = processor.remove_instance_mapping(
                processor_id, self._notification.instance_id)
        except ValueError:
            log.exception("Invalid mapping to remove")
            delete_notification = True

        # Delete our notification
        if delete_notification:
            self._notification.delete()
コード例 #5
0
stack_id = event_obj['StackId']
logical_id = event_obj['LogicalResourceId']
request_id = event_obj['RequestId']
request_type = event_obj['RequestType']

hosted_zone_id = resource_properties.get('HostedZoneId')
dns_pattern = resource_properties.get('DNSPattern')

if not hosted_zone_id:
    raise FatalError(u"HostedZoneId is a required property.")

if not dns_pattern:
    raise FatalError(u"DNSPattern is a required property.")

processor = DNSProcessor(options.topic, options.table_name, options.region)

if request_type == 'Update':
    old_resource_properties = event_obj.get('OldResourceProperties')
    old_physical_id = event_obj['PhysicalResourceId']

    if not old_resource_properties:
        raise FatalError(u"OldResourceProperties not found.")

    print processor.update_processor(old_physical_id, stack_id, logical_id,
                                     request_id, hosted_zone_id, dns_pattern)
elif request_type == 'Create':
    print processor.create_processor(stack_id, logical_id, request_id,
                                     hosted_zone_id, dns_pattern)
elif request_type == 'Delete':
    physical_id = event_obj['PhysicalResourceId']
    raise FatalError(u"ResourceProperties not found.")

stack_id = event_obj['StackId']
logical_id = event_obj['LogicalResourceId']
request_id = event_obj['RequestId']
request_type = event_obj['RequestType']

hosted_zone_id = resource_properties.get('HostedZoneId')
dns_pattern = resource_properties.get('DNSPattern')

if not hosted_zone_id:
    raise FatalError(u"HostedZoneId is a required property.")

if not dns_pattern:
    raise FatalError(u"DNSPattern is a required property.")

processor = DNSProcessor(options.topic, options.table_name, options.region)

if request_type == 'Update':
    old_resource_properties = event_obj.get('OldResourceProperties')
    old_physical_id = event_obj['PhysicalResourceId']

    if not old_resource_properties:
        raise FatalError(u"OldResourceProperties not found.")

    print processor.update_processor(old_physical_id, stack_id, logical_id, request_id, hosted_zone_id, dns_pattern)
elif request_type == 'Create':
    print processor.create_processor(stack_id, logical_id, request_id, hosted_zone_id, dns_pattern)
elif request_type == 'Delete':
    physical_id = event_obj['PhysicalResourceId']
    print processor.delete_processor(physical_id, hosted_zone_id)