コード例 #1
0
ファイル: delete_service_tasks.py プロジェクト: jc7998/poppy
    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
コード例 #2
0
ファイル: purge_service_tasks.py プロジェクト: yunhaia/poppy
    def execute(self, service_obj, hard, provider_details, purge_url):
        service_controller = memoized_controllers.task_controllers('poppy')
        service_json = json.loads(service_obj)
        service_obj = service.load_from_json(service_json)
        hard = json.loads(hard)
        provider_details = json.loads(provider_details)

        responders = []
        # try to purge all service from each provider presented
        # in provider_details
        for provider in provider_details:
            # NOTE(tonytan4ever): if the purge_url is None, it means to purge
            # all content, else only purge a specific purge url
            provider_details[provider] = (req_provider_details.load_from_json(
                provider_details[provider]))

            LOG.info('Starting to purge service from {0},'
                     'purge_url: {1}'.format(
                         provider, 'all' if purge_url is None else purge_url))

            responder = service_controller.provider_wrapper.purge(
                service_controller._driver.providers[provider.lower()],
                service_obj,
                provider_details,
                hard=hard,
                purge_url=purge_url)
            responders.append(responder)

            LOG.info('Purge service {0}  on  {1} complete...'.format(
                provider, 'all' if purge_url is None else purge_url))

        return responders
コード例 #3
0
    def execute(self, provider_details, project_id):
        """Create responder from provider details.

        Initiated request to akamai to remove associated service.

        :param unicode provider_details: details of the provider
        :param unicode project_id: project_id os the user

        :return: list of responder
        :rtype: list[dict]
        """
        service_controller = memoized_controllers.task_controllers('poppy')
        provider_details = json.loads(provider_details)

        responders = []
        # try to delete all service from each provider presented
        # in provider_details
        for provider in provider_details:
            provider_details[provider] = (req_provider_details.load_from_json(
                provider_details[provider]))
            LOG.info('Starting to delete service from {0}'.format(provider))
            responder = service_controller.provider_wrapper.delete(
                service_controller._driver.providers[provider.lower()],
                provider_details, project_id)
            responders.append(responder)
            LOG.info('Deleting service from {0} complete...'.format(provider))
        return responders
コード例 #4
0
    def execute(self, responders, dns_responder, provider_details):
        provider_details = json.loads(provider_details)
        for provider in provider_details:
            provider_details[provider] = (
                req_provider_details.load_from_json(provider_details[provider])
                )

        for responder in responders:
            provider_name = list(responder.items())[0][0]

            if 'error' in responder[provider_name]:
                LOG.info('Delete service from {0}'
                         'failed'.format(provider_name))
                # stores the error info for debugging purposes.
                provider_details[provider_name].error_info = (
                    responder[provider_name].get('error_info'))
            elif 'error' in dns_responder[provider_name]:
                LOG.info('Delete service from DNS failed')
                # stores the error info for debugging purposes.
                provider_details[provider_name].error_info = (
                    dns_responder[provider_name].get('error_info'))
                if 'error_class' in dns_responder[provider_name]:
                    # stores the error class for debugging purposes.
                    provider_details[provider_name].error_class = (
                        dns_responder[provider_name].get('error_class'))
            else:
                # delete service successful, remove this provider detail record
                del provider_details[provider_name]

        for provider in provider_details:
            provider_details[provider] = provider_details[provider].to_dict()

        return provider_details
コード例 #5
0
    def execute(self, responders, dns_responder, provider_details):
        provider_details = json.loads(provider_details)
        for provider in provider_details:
            provider_details[provider] = (req_provider_details.load_from_json(
                provider_details[provider]))

        for responder in responders:
            provider_name = list(responder.items())[0][0]

            if 'error' in responder[provider_name]:
                LOG.info('Delete service from {0}'
                         'failed'.format(provider_name))
                # stores the error info for debugging purposes.
                provider_details[provider_name].error_info = (
                    responder[provider_name].get('error_info'))
            elif 'error' in dns_responder[provider_name]:
                LOG.info('Delete service from DNS failed')
                # stores the error info for debugging purposes.
                provider_details[provider_name].error_info = (
                    dns_responder[provider_name].get('error_info'))
                if 'error_class' in dns_responder[provider_name]:
                    # stores the error class for debugging purposes.
                    provider_details[provider_name].error_class = (
                        dns_responder[provider_name].get('error_class'))
            else:
                # delete service successful, remove this provider detail record
                del provider_details[provider_name]

        for provider in provider_details:
            provider_details[provider] = provider_details[provider].to_dict()

        return provider_details
コード例 #6
0
def load_from_json(json_data):
    service_id = json_data.get('service_id', uuid.uuid4())

    name = json_data.get("name")
    origins = json_data.get("origins", [])
    domains = json_data.get("domains", [])
    flavor_id = json_data.get("flavor_id")
    restrictions = json_data.get("restrictions", [])
    project_id = json_data.get("project_id")
    pd = json_data.get("provider_details", {})
    log_delivery = json_data.get("log_delivery", {})

    # load caching rules json string from input
    origins = [origin.load_from_json(o) for o in origins]
    domains = [domain.load_from_json(d) for d in domains]
    restrictions = [restriction.load_from_json(r) for r in restrictions]
    log_delivery = ld.load_from_json(log_delivery)

    # convert caching rule json string list into object list
    caching = json_data.get("caching", [])
    caching = [cachingrule.load_from_json(c) for c in caching]

    r = service.Service(service_id=service_id,
                        name=name,
                        domains=domains,
                        origins=origins,
                        flavor_id=flavor_id,
                        caching=caching,
                        restrictions=restrictions,
                        log_delivery=log_delivery,
                        project_id=project_id)

    r.provider_details = dict([(k, provider_details.load_from_json(v))
                               for k, v in pd.items()])
    return r
コード例 #7
0
ファイル: purge_service_tasks.py プロジェクト: jc7998/poppy
    def execute(self, provider_details, purge_url):
        service_controller = memoized_controllers.task_controllers('poppy')

        provider_details = json.loads(provider_details)
        purge_url = None if purge_url == 'None' else purge_url

        responders = []
        # try to purge all service from each provider presented
        # in provider_details
        for provider in provider_details:
            # NOTE(tonytan4ever): if the purge_url is None, it means to purge
            # all content, else only purge a specific purge url
            provider_details[provider] = (
                req_provider_details.load_from_json(
                    provider_details[provider]))

            LOG.info('Starting to purge service from {0},'
                     'purge_url: {1}'.format(provider,
                                             'all' if purge_url is None
                                             else purge_url))

            responder = service_controller.provider_wrapper.purge(
                service_controller._driver.providers[provider.lower()],
                provider_details,
                purge_url)
            responders.append(responder)

            LOG.info('Purge service {0}  on  {1} complete...'.format(
                     provider,
                     'all' if purge_url is None else purge_url))

        return responders
コード例 #8
0
ファイル: common.py プロジェクト: yunhaia/poppy
    def execute(self, responders, service_id, provider_details, hard):
        provider_details = json.loads(provider_details)
        for provider in provider_details:
            # NOTE(tonytan4ever): if the purge_url is None, it means to purge
            # all content, else only purge a specific purge url
            provider_details[provider] = (
                req_provider_details.load_from_json(
                    provider_details[provider]))

        # Find any failed attempt of purging, and stores it in provider
        # detail for future debugging purpose
        changed_provider_details_dict = {}
        for responder in responders:
            # this is the item of responder, if there's "error"
            # key in it, it means the purging for this provider failed.
            # in that case we will need to update the provider detail
            # info for the service from poppy storage.
            provider_name = list(responder.items())[0][0]

            if 'error' in responder[provider_name]:
                LOG.info('Purging content from {0} '
                         'failed'.format(provider_name))
                LOG.info('Updating provider detail '
                         'status of {0} for {1}'.format(provider_name,
                                                        service_id))
                # stores the error info for debugging purposes.
                changed_provider_details_dict[provider_name] = (
                    provider_details[provider_name]
                )
                changed_provider_details_dict[provider_name].error_info = (
                    responder[provider_name].get('error_detail')
                )
                changed_provider_details_dict[provider_name].error_message = (
                    responder[provider_name].get('error')
                )
                if not json.loads(hard):
                    changed_provider_details_dict[provider_name].status = \
                        'failed'
            else:
                changed_provider_details_dict[provider_name] = (
                    provider_details[provider_name]
                )
                changed_provider_details_dict[provider_name].status = (
                    'deployed')
                changed_provider_details_dict[provider_name].error_info = \
                    None
                changed_provider_details_dict[provider_name].error_message = \
                    None
        # serialize changed_provider_details_dict
        for provider_name in changed_provider_details_dict:
            changed_provider_details_dict[provider_name] = (
                changed_provider_details_dict[provider_name].to_dict())

        return changed_provider_details_dict
コード例 #9
0
    def execute(self, responders, service_id, provider_details, hard):
        provider_details = json.loads(provider_details)
        for provider in provider_details:
            # NOTE(tonytan4ever): if the purge_url is None, it means to purge
            # all content, else only purge a specific purge url
            provider_details[provider] = (
                req_provider_details.load_from_json(
                    provider_details[provider]))

        # Find any failed attempt of purging, and stores it in provider
        # detail for future debugging purpose
        changed_provider_details_dict = {}
        for responder in responders:
            # this is the item of responder, if there's "error"
            # key in it, it means the purging for this provider failed.
            # in that case we will need to update the provider detail
            # info for the service from poppy storage.
            provider_name = list(responder.items())[0][0]

            if 'error' in responder[provider_name]:
                LOG.info('Purging content from {0} '
                         'failed'.format(provider_name))
                LOG.info('Updating provider detail '
                         'status of {0} for {1}'.format(provider_name,
                                                        service_id))
                # stores the error info for debugging purposes.
                changed_provider_details_dict[provider_name] = (
                    provider_details[provider_name]
                )
                changed_provider_details_dict[provider_name].error_info = (
                    responder[provider_name].get('error_detail')
                )
                changed_provider_details_dict[provider_name].error_message = (
                    responder[provider_name].get('error')
                )
                if not json.loads(hard):
                    changed_provider_details_dict[provider_name].status = \
                        'failed'
            else:
                changed_provider_details_dict[provider_name] = (
                    provider_details[provider_name]
                )
                changed_provider_details_dict[provider_name].status = (
                    'deployed')
                changed_provider_details_dict[provider_name].error_info = \
                    None
                changed_provider_details_dict[provider_name].error_message = \
                    None
        # serialize changed_provider_details_dict
        for provider_name in changed_provider_details_dict:
            changed_provider_details_dict[provider_name] = (
                changed_provider_details_dict[provider_name].to_dict())

        return changed_provider_details_dict
コード例 #10
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
コード例 #11
0
ファイル: delete_service_tasks.py プロジェクト: jc7998/poppy
    def execute(self, provider_details):
        service_controller = memoized_controllers.task_controllers("poppy")
        provider_details = json.loads(provider_details)

        responders = []
        # try to delete all service from each provider presented
        # in provider_details
        for provider in provider_details:
            provider_details[provider] = req_provider_details.load_from_json(provider_details[provider])
            LOG.info("Starting to delete service from {0}".format(provider))
            responder = service_controller.provider_wrapper.delete(
                service_controller._driver.providers[provider.lower()], provider_details
            )
            responders.append(responder)
            LOG.info("Deleting service from {0} complete...".format(provider))
        return responders
コード例 #12
0
    def execute(self, provider_details):
        service_controller = memoized_controllers.task_controllers('poppy')
        provider_details = json.loads(provider_details)

        responders = []
        # try to delete all service from each provider presented
        # in provider_details
        for provider in provider_details:
            provider_details[provider] = (req_provider_details.load_from_json(
                provider_details[provider]))
            LOG.info('Starting to delete service from {0}'.format(provider))
            responder = service_controller.provider_wrapper.delete(
                service_controller._driver.providers[provider.lower()],
                provider_details)
            responders.append(responder)
            LOG.info('Deleting service from {0} complete...'.format(provider))
        return responders
コード例 #13
0
    def execute(self, service_obj, hard, provider_details, purge_url):
        """delete/abruptly remove details of service.

        If purge url is not provided delete all the content, else
        delete only the content of the purge url provided.

        :param unicode service_obj: json of service dict
        :param unicode hard: passed by user if wants to hard purge all content
        :param unicode provider_details: json of the provider dict
        :param unicode purge_url: url need to purge

        :return: list of responder
        :rtype: list[dict]
        """
        service_controller = memoized_controllers.task_controllers('poppy')
        service_json = json.loads(service_obj)
        service_obj = service.load_from_json(service_json)
        hard = json.loads(hard)
        provider_details = json.loads(provider_details)

        responders = []
        # try to purge all service from each provider presented
        # in provider_details
        for provider in provider_details:
            # NOTE(tonytan4ever): if the purge_url is None, it means to purge
            # all content, else only purge a specific purge url
            provider_details[provider] = (req_provider_details.load_from_json(
                provider_details[provider]))

            LOG.info('Starting to purge service from {0},'
                     'purge_url: {1}'.format(
                         provider, 'all' if purge_url is None else purge_url))

            responder = service_controller.provider_wrapper.purge(
                service_controller._driver.providers[provider.lower()],
                service_obj,
                provider_details,
                hard=hard,
                purge_url=purge_url)
            responders.append(responder)

            LOG.info('Purge service {0}  on  {1} complete...'.format(
                provider, 'all' if purge_url is None else purge_url))

        return responders
コード例 #14
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]:
                if 'DNS Exception'\
                        in dns_responder[provider_name]['error']:
                    msg = 'Deleting DNS for {0} failed!'.format(provider_name)
                    LOG.info(msg)
                    raise Exception(msg)

        return dns_responder
コード例 #15
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
コード例 #16
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
コード例 #17
0
def service_delete_worker(provider_details,
                          project_id, service_id):
    LOG.logger.setLevel(logging.INFO)
    bootstrap_obj = bootstrap.Bootstrap(conf)
    service_controller = bootstrap_obj.manager.services_controller
    provider_details = json.loads(provider_details)

    responders = []
    # try to delete all service from each provider presented
    # in provider_details
    for provider in provider_details:
        provider_details[provider] = (
            req_provider_details.load_from_json(provider_details[provider]))
        LOG.info('Starting to delete service from %s' % provider)
        responder = service_controller.provider_wrapper.delete(
            service_controller._driver.providers[provider.lower()],
            provider_details)
        responders.append(responder)
        LOG.info('Deleting service from %s complete...' % provider)

    # delete associated cname records from DNS
    dns_responder = service_controller.dns_controller.delete(provider_details)

    for responder in responders:
        provider_name = list(responder.items())[0][0]

        if 'error' in responder[provider_name]:
            LOG.info('Delete service from %s failed' % provider_name)
            LOG.info('Updating provider detail status of %s for %s' %
                     (provider_name, service_id))
            # stores the error info for debugging purposes.
            provider_details[provider_name].error_info = (
                responder[provider_name].get('error_info'))
        elif 'error' in dns_responder[provider_name]:
            LOG.info('Delete service from DNS failed')
            LOG.info('Updating provider detail status of %s for %s'.format(
                     (provider_name, service_id)))
            # stores the error info for debugging purposes.
            provider_details[provider_name].error_info = (
                dns_responder[provider_name].get('error_info'))
        else:
            # delete service successful, remove this provider detail record
            del provider_details[provider_name]

        service_controller.storage_controller._driver.connect()

    if provider_details != {}:
        # Store failed provider details with error infomation for further
        # action, maybe for debug and/or support.
        LOG.info('Delete failed for one or more providers'
                 'Updating poppy service provider details for %s' %
                 service_id)
        service_controller.storage_controller.update_provider_details(
            project_id,
            service_id,
            provider_details)

    # always delete from Poppy.  Provider Details will contain
    # any provider issues that may have occurred.
    LOG.info('Deleting poppy service %s from all providers successful'
             % service_id)
    service_controller.storage_controller.delete(project_id, service_id)
    service_controller.storage_controller._driver.close_connection()
    LOG.info('Deleting poppy service %s succeeded' % service_id)
    LOG.info('Delete service worker process %s complete...' %
             str(os.getpid()))
コード例 #18
0
ファイル: service.py プロジェクト: jqxin2006/poppy
    name = json_data.get("name")
    origins = json_data.get("origins", [])
    domains = json_data.get("domains", [])
    flavor_id = json_data.get("flavor_id")
    restrictions = json_data.get("restrictions", [])
    pd = json_data.get("provider_details", {})

    # load caching rules json string from input
    origins = [origin.load_from_json(o) for o in origins]
    domains = [domain.load_from_json(d) for d in domains]
    restrictions = [restriction.load_from_json(r) for r in restrictions]

    # convert caching rule json string list into object list
<<<<<<< HEAD
    caching = json_data.get("caching", [])
=======
>>>>>>> master
    caching = [cachingrule.load_from_json(c) for c in caching]

    r = service.Service(service_id,
                        name,
                        domains,
                        origins,
                        flavor_id,
                        caching,
                        restrictions)

    r.provider_details = dict([(k, provider_details.load_from_json(v))
                               for k, v in pd.items()])
    return r