Ejemplo n.º 1
0
    def execute(self, responders, retry_sleep_time, project_id, service_id):
        service_controller, dns = memoized_controllers.task_controllers("poppy", "dns")
        dns_responder = dns.create(responders)
        for provider_name in dns_responder:
            if "error" in dns_responder[provider_name]:
                msg = "Create DNS for {0} " "failed!".format(provider_name)
                LOG.info(msg)
                if "error_class" in dns_responder[provider_name]:
                    exception_repr = dns_responder[provider_name]["error_class"]
                    exception_class = exc_loader(exception_repr)

                    if any([exception_class == exception for exception in dns._driver.retry_exceptions]):
                        LOG.info(
                            "Due to {0} Exception, "
                            "Task {1} will "
                            "be retried".format(exception_class, self.__class__)
                        )
                        raise exception_class(msg)
            else:
                LOG.info(
                    "DNS Creation Successful "
                    "for Provider {0} : "
                    "{1}".format(provider_name, dns_responder[provider_name])
                )
        return dns_responder
Ejemplo n.º 2
0
    def execute(self, responders, retry_sleep_time, service_old, service_obj):
        service_controller, dns = \
            memoized_controllers.task_controllers('poppy', 'dns')
        service_obj_json = json.loads(service_obj)
        service_obj = service.load_from_json(service_obj_json)
        service_old_json = json.loads(service_old)
        service_old = service.load_from_json(service_old_json)
        dns_responder = dns.update(service_old, service_obj, responders)

        for provider_name in dns_responder:
            try:
                if 'error' in dns_responder[provider_name]:
                    msg = 'Update DNS for {0} ' \
                          'failed!'.format(provider_name)
                    LOG.info(msg)
                    if 'error_class' in dns_responder[provider_name]:
                        exception_repr = \
                            dns_responder[provider_name]['error_class']
                        exception_class = exc_loader(exception_repr)

                        if any([isinstance(exception_class(), exception) for
                                exception in dns._driver.retry_exceptions]):
                            LOG.info('Due to {0} Exception, '
                                     'Task {1} will '
                                     'be retried'.format(exception_class,
                                                         self.__class__))
                            raise exception_class(msg)
            except KeyError:
                # NOTE(TheSriram): This means the provider updates failed, and
                # just access_urls were returned
                pass

        return dns_responder
Ejemplo n.º 3
0
    def execute(self, responders, retry_sleep_time, project_id, service_id):
        service_controller, dns = \
            memoized_controllers.task_controllers('poppy', 'dns')

        dns_responder = dns.create(responders)
        for provider_name in dns_responder:
            if 'error' in dns_responder[provider_name]:
                msg = 'Create DNS for {0} ' \
                      'failed!'.format(provider_name)
                LOG.info(msg)
                if 'error_class' in dns_responder[provider_name]:
                    exception_repr = \
                        dns_responder[provider_name]['error_class']
                    exception_class = exc_loader(exception_repr)

                    if any([
                            exception_class == exception
                            for exception in dns._driver.retry_exceptions
                    ]):
                        LOG.info('Due to {0} Exception, '
                                 'Task {1} will '
                                 'be retried'.format(exception_class,
                                                     self.__class__))
                        raise exception_class(msg)
            else:
                LOG.info("DNS Creation Successful "
                         "for Provider {0} : "
                         "{1}".format(provider_name,
                                      dns_responder[provider_name]))
        return dns_responder
Ejemplo n.º 4
0
    def execute(self, responders, retry_sleep_time, project_id, service_id):
        service_controller, dns = \
            memoized_controllers.task_controllers('poppy', 'dns')

        dns_responder = dns.create(responders)
        for provider_name in dns_responder:
            if 'error' in dns_responder[provider_name]:
                msg = 'Create DNS for {0} ' \
                      'failed!'.format(provider_name)
                LOG.info(msg)
                if 'error_class' in dns_responder[provider_name]:
                    exception_repr = \
                        dns_responder[provider_name]['error_class']
                    exception_class = exc_loader(exception_repr)

                    if any([exception_class == exception for
                            exception in dns._driver.retry_exceptions]):
                        LOG.info('Due to {0} Exception, '
                                 'Task {1} will '
                                 'be retried'.format(exception_class,
                                                     self.__class__))
                        raise exception_class(msg)
            else:
                LOG.info("DNS Creation Successful "
                         "for Provider {0} : "
                         "{1}".format(provider_name,
                                      dns_responder[provider_name]))
        return dns_responder
Ejemplo n.º 5
0
    def execute(self, provider_details, retry_sleep_time):
        service_controller, dns = memoized_controllers.task_controllers("poppy", "dns")

        provider_details = json.loads(provider_details)
        for provider in provider_details:
            provider_details[provider] = req_provider_details.load_from_json(provider_details[provider])

        # delete associated cname records from DNS
        dns_responder = dns.delete(provider_details)
        for provider_name in dns_responder:
            if "error" in dns_responder[provider_name]:
                msg = "Delete DNS for {0} " "failed!".format(provider_name)
                LOG.info(msg)
                if "error_class" in dns_responder[provider_name]:
                    exception_repr = dns_responder[provider_name]["error_class"]
                    exception_class = exc_loader(exception_repr)

                    if any([isinstance(exception_class(), exception) for exception in dns._driver.retry_exceptions]):
                        LOG.info(
                            "Due to {0} Exception, "
                            "Task {1} will "
                            "be retried".format(exception_class, self.__class__)
                        )
                        raise exception_class(msg)

        return dns_responder
Ejemplo n.º 6
0
    def execute(self, service_obj, project_id, retry_sleep_time):
        """Break the DNS chain for service.

        While updating the service state break the link between CNAME
        created at rackspace DNS.

        :param unicode service_obj: json object of the service
        :param unicode project_id: project id of the user
        :param int retry_sleep_time: sleep time
        """
        service_obj_json = json.loads(service_obj)
        service_obj = service.load_from_json(service_obj_json)

        service_controller, dns = \
            memoized_controllers.task_controllers('poppy', 'dns')

        LOG.info(u'Starting to disable service - '
                 u'service_id: {0}, '
                 u'project_id: {1}'.format(service_obj.service_id, project_id))
        dns_responder = dns.disable(service_obj)
        for provider_name in dns_responder:
            try:
                if 'error' in dns_responder[provider_name]:
                    msg = 'Breaking DNS Chain for {0} ' \
                          'failed!'.format(provider_name)
                    LOG.info(msg)
                    if 'error_class' in dns_responder[provider_name]:
                        exception_repr = \
                            dns_responder[provider_name]['error_class']
                        exception_class = exc_loader(exception_repr)

                        if any([
                                exception_class == exception
                                for exception in dns._driver.retry_exceptions
                        ]):
                            LOG.info('Due to {0} Exception, '
                                     'Task {1} will '
                                     'be retried'.format(
                                         exception_class, self.__class__))
                            raise exception_class(msg)
                else:
                    LOG.info("Breaking DNS Chain Successful "
                             "for Provider {0} : "
                             "{1}".format(provider_name,
                                          dns_responder[provider_name]))
            except KeyError:
                # NOTE(TheSriram): This means the provider updates failed, and
                # just access_urls were returned
                pass

        LOG.info(u'Disabled service - '
                 u'service_id: {0}, '
                 u'project_id: {1}'.format(service_obj.service_id, project_id))

        return
Ejemplo n.º 7
0
    def execute(self, responders, retry_sleep_time,
                service_old, service_obj, project_id, service_id):
        """Updates the mapping between dns service and provider url.

        Update mapping of CNAME and provider url and returns the access url.

        :param list[dict] responders: list of dict of responder
        :param int retry_sleep_time: sleep time
        :param unicode service_old: json object of the old service
        :param unicode service_obj: json object of the service
        :param unicode project_id: project id of user
        :param unicode service_id: uuid of the service

        :return: dict of dns_responder
        :rtype: dict
        """
        service_controller, dns = \
            memoized_controllers.task_controllers('poppy', 'dns')
        service_obj_json = json.loads(service_obj)
        service_obj = service.load_from_json(service_obj_json)
        service_old_json = json.loads(service_old)
        service_old = service.load_from_json(service_old_json)
        dns_responder = dns.update(service_old, service_obj, responders)

        for provider_name in dns_responder:
            try:
                if 'error' in dns_responder[provider_name]:
                    msg = 'Update DNS for {0} ' \
                          'failed!'.format(provider_name)
                    LOG.info(msg)
                    if 'error_class' in dns_responder[provider_name]:
                        exception_repr = \
                            dns_responder[provider_name]['error_class']
                        exception_class = exc_loader(exception_repr)

                        if any([exception_class == exception for
                                exception in dns._driver.retry_exceptions]):
                            LOG.info('Due to {0} Exception, '
                                     'Task {1} will '
                                     'be retried'.format(exception_class,
                                                         self.__class__))
                            raise exception_class(msg)
                else:
                    LOG.info("DNS Update Successful "
                             "for Provider {0} : "
                             "{1}".format(provider_name,
                                          dns_responder[provider_name]))
            except KeyError:
                # NOTE(TheSriram): This means the provider updates failed, and
                # just access_urls were returned
                pass

        return dns_responder
Ejemplo n.º 8
0
    def execute(self, provider_details, retry_sleep_time, responders,
                project_id, service_id):
        """Deletes the mapping between dns service and provider url.

        The result is assiciation of cname created at rackspace dns
        which used by customer for their by vanity domain will be removed.

        :param unicode provider_details: json of providers
        :param int retry_sleep_time: sleep time
        :param list[dict] responders: list of responder
        :param unicode project_id: project id of the user
        :param unicode service_id: uuid of the service

        :return: dict of dns_responder
        :rtype: dict
        """
        service_controller, dns = \
            memoized_controllers.task_controllers('poppy', 'dns')

        provider_details = json.loads(provider_details)
        for provider in provider_details:
            provider_details[provider] = (req_provider_details.load_from_json(
                provider_details[provider]))

        # delete associated cname records from DNS
        dns_responder = dns.delete(provider_details)
        for provider_name in dns_responder:
            if 'error' in dns_responder[provider_name]:
                msg = 'Delete DNS for {0} ' \
                      'failed!'.format(provider_name)
                LOG.info(msg)
                if 'error_class' in dns_responder[provider_name]:
                    exception_repr = \
                        dns_responder[provider_name]['error_class']
                    exception_class = exc_loader(exception_repr)

                    if any([
                            exception_class == exception
                            for exception in dns._driver.retry_exceptions
                    ]):
                        LOG.info('Due to {0} Exception, '
                                 'Task {1} will '
                                 'be retried'.format(exception_class,
                                                     self.__class__))
                        raise exception_class(msg)
            else:
                LOG.info("DNS Deletion Successful "
                         "for Provider {0} : "
                         "{1}".format(provider_name,
                                      dns_responder[provider_name]))

        return dns_responder
    def execute(self, service_obj, project_id, retry_sleep_time):
        service_obj_json = json.loads(service_obj)
        service_obj = service.load_from_json(service_obj_json)

        service_controller, dns = \
            memoized_controllers.task_controllers('poppy', 'dns')

        LOG.info(u'Starting to disable service - '
                 u'service_id: {0}, '
                 u'project_id: {1}'.format(service_obj.service_id,
                                           project_id))
        dns_responder = dns.disable(service_obj)
        for provider_name in dns_responder:
            try:
                if 'error' in dns_responder[provider_name]:
                    msg = 'Breaking DNS Chain for {0} ' \
                          'failed!'.format(provider_name)
                    LOG.info(msg)
                    if 'error_class' in dns_responder[provider_name]:
                        exception_repr = \
                            dns_responder[provider_name]['error_class']
                        exception_class = exc_loader(exception_repr)

                        if any([exception_class == exception for
                                exception in dns._driver.retry_exceptions]):
                            LOG.info('Due to {0} Exception, '
                                     'Task {1} will '
                                     'be retried'.format(exception_class,
                                                         self.__class__))
                            raise exception_class(msg)
                else:
                    LOG.info("Breaking DNS Chain Successful "
                             "for Provider {0} : "
                             "{1}".format(provider_name,
                                          dns_responder[provider_name]))
            except KeyError:
                # NOTE(TheSriram): This means the provider updates failed, and
                # just access_urls were returned
                pass

        LOG.info(u'Disabled service - '
                 u'service_id: {0}, '
                 u'project_id: {1}'.format(service_obj.service_id,
                                           project_id))

        return
Ejemplo n.º 10
0
    def execute(self, service_obj, project_id, retry_sleep_time):
        service_obj_json = json.loads(service_obj)
        service_obj = service.load_from_json(service_obj_json)

        service_controller, dns = \
            memoized_controllers.task_controllers('poppy', 'dns')

        LOG.info(u'Starting to enable service - '
                 u'service_id: {0}, '
                 u'project_id: {1}'.format(service_obj.service_id, project_id))
        dns_responder = dns.enable(service_obj)

        for provider_name in dns_responder:
            try:
                if 'error' in dns_responder[provider_name]:
                    msg = 'Fixing DNS Chain for {0} ' \
                          'failed!'.format(provider_name)
                    LOG.info(msg)
                    if 'error_class' in dns_responder[provider_name]:
                        exception_repr = \
                            dns_responder[provider_name]['error_class']
                        exception_class = exc_loader(exception_repr)

                        if any([
                                exception_class == exception
                                for exception in dns._driver.retry_exceptions
                        ]):
                            LOG.info('Due to {0} Exception, '
                                     'Task {1} will '
                                     'be retried'.format(
                                         exception_class, self.__class__))
                            raise exception_class(msg)
                else:
                    LOG.info("Fixing DNS Chain Successful "
                             "for Provider {0} : "
                             "{1}".format(provider_name,
                                          dns_responder[provider_name]))
            except KeyError:
                # NOTE(TheSriram): This means the provider updates failed, and
                # just access_urls were returned
                pass

        LOG.info(u'Enabled service - '
                 u'service_id: {0}, '
                 u'project_id: {1}'.format(service_obj.service_id, project_id))
Ejemplo n.º 11
0
    def execute(self, responders, retry_sleep_time, project_id, service_id):
        """Creates the mapping between dns service and provider url.

        The resulting domain is the cname created at rackspace dns which
        used by customer for their by vanity domain.

        :param list[dict] responders: list of responder
        :param int retry_sleep_time: sleep time
        :param unicode project_id: project id of the user
        :param unicode service_id: uuid

        :return: dict of dns_responder
        :rtype: dict
        """
        service_controller, dns = \
            memoized_controllers.task_controllers('poppy', 'dns')

        dns_responder = dns.create(responders)
        for provider_name in dns_responder:
            if 'error' in dns_responder[provider_name]:
                msg = 'Create DNS for {0} ' \
                      'failed!'.format(provider_name)
                LOG.info(msg)
                if 'error_class' in dns_responder[provider_name]:
                    exception_repr = \
                        dns_responder[provider_name]['error_class']
                    exception_class = exc_loader(exception_repr)

                    if any([exception_class == exception for
                            exception in dns._driver.retry_exceptions]):
                        LOG.info('Due to {0} Exception, '
                                 'Task {1} will '
                                 'be retried'.format(exception_class,
                                                     self.__class__))
                        raise exception_class(msg)
            else:
                LOG.info("DNS Creation Successful "
                         "for Provider {0} : "
                         "{1}".format(provider_name,
                                      dns_responder[provider_name]))
        return dns_responder
Ejemplo n.º 12
0
    def execute(self, provider_details, retry_sleep_time,
                responders, project_id, service_id):
        service_controller, dns = \
            memoized_controllers.task_controllers('poppy', 'dns')

        provider_details = json.loads(provider_details)
        for provider in provider_details:
            provider_details[provider] = (
                req_provider_details.load_from_json(provider_details[provider])
                )

        # delete associated cname records from DNS
        dns_responder = dns.delete(
            provider_details)
        for provider_name in dns_responder:
            if 'error' in dns_responder[provider_name]:
                msg = 'Delete DNS for {0} ' \
                      'failed!'.format(provider_name)
                LOG.info(msg)
                if 'error_class' in dns_responder[provider_name]:
                    exception_repr = \
                        dns_responder[provider_name]['error_class']
                    exception_class = exc_loader(exception_repr)

                    if any([exception_class == exception for
                            exception in dns._driver.retry_exceptions]):
                        LOG.info('Due to {0} Exception, '
                                 'Task {1} will '
                                 'be retried'.format(exception_class,
                                                     self.__class__))
                        raise exception_class(msg)
            else:
                LOG.info("DNS Deletion Successful "
                         "for Provider {0} : "
                         "{1}".format(provider_name,
                                      dns_responder[provider_name]))

        return dns_responder
Ejemplo n.º 13
0
    def execute(self, provider_details, retry_sleep_time, responders,
                project_id, service_id):
        service_controller, dns = \
            memoized_controllers.task_controllers('poppy', 'dns')

        provider_details = json.loads(provider_details)
        for provider in provider_details:
            provider_details[provider] = (req_provider_details.load_from_json(
                provider_details[provider]))

        # delete associated cname records from DNS
        dns_responder = dns.delete(provider_details)
        for provider_name in dns_responder:
            if 'error' in dns_responder[provider_name]:
                msg = 'Delete DNS for {0} ' \
                      'failed!'.format(provider_name)
                LOG.info(msg)
                if 'error_class' in dns_responder[provider_name]:
                    exception_repr = \
                        dns_responder[provider_name]['error_class']
                    exception_class = exc_loader(exception_repr)

                    if any([
                            exception_class == exception
                            for exception in dns._driver.retry_exceptions
                    ]):
                        LOG.info('Due to {0} Exception, '
                                 'Task {1} will '
                                 'be retried'.format(exception_class,
                                                     self.__class__))
                        raise exception_class(msg)
            else:
                LOG.info("DNS Deletion Successful "
                         "for Provider {0} : "
                         "{1}".format(provider_name,
                                      dns_responder[provider_name]))

        return dns_responder