예제 #1
0
    def _return_base_data(self,
                          url,
                          container,
                          container_object=None,
                          container_headers=None,
                          object_headers=None):
        """Return headers and a parsed url.

        :param url:
        :param container:
        :param container_object:
        :param container_headers:
        :return: ``tuple``
        """
        headers = self.job_args['base_headers']
        headers.update({'X-Auth-Token': self.job_args['os_token']})

        _container_uri = url.geturl().rstrip('/')

        if container:
            _container_uri = '%s/%s' % (_container_uri,
                                        cloud_utils.quoter(container))

        if container_object:
            _container_uri = '%s/%s' % (_container_uri,
                                        cloud_utils.quoter(container_object))

        if object_headers:
            headers.update(object_headers)

        if container_headers:
            headers.update(container_headers)

        return headers, urlparse.urlparse(_container_uri)
예제 #2
0
    def _return_base_data(self, url, container, container_object=None,
                          container_headers=None, object_headers=None):
        """Return headers and a parsed url.

        :param url:
        :param container:
        :param container_object:
        :param container_headers:
        :return: ``tuple``
        """
        headers = self.job_args['base_headers']
        headers.update({'X-Auth-Token': self.job_args['os_token']})

        _container_uri = url.geturl().rstrip('/')

        if container:
            _container_uri = '%s/%s' % (
                _container_uri, cloud_utils.quoter(container)
            )

        if container_object:
            _container_uri = '%s/%s' % (
                _container_uri, cloud_utils.quoter(container_object)
            )

        if object_headers:
            headers.update(object_headers)

        if container_headers:
            headers.update(container_headers)

        return headers, urlparse.urlparse(_container_uri)
예제 #3
0
    def _list_getter(self, uri, headers, last_obj=None, spr=False):
        """Get a list of all objects in a container.

        :param uri:
        :param headers:
        :return list:
        :param spr: "single page return" Limit the returned data to one page
        :type spr: ``bol``
        """

        # Quote the file path.
        base_path = marked_path = ('%s?limit=10000&format=json' % uri.path)

        if last_obj:
            marked_path = self._last_marker(
                base_path=base_path, last_object=cloud_utils.quoter(last_obj))

        file_list = self._obj_index(uri=uri,
                                    base_path=base_path,
                                    marked_path=marked_path,
                                    headers=headers,
                                    spr=spr)

        LOG.debug('Found [ %d ] entries(s) at [ %s ]', len(file_list),
                  uri.geturl())

        if spr:
            return file_list
        else:
            return cloud_utils.unique_list_dicts(dlist=file_list, key='name')
예제 #4
0
    def _list_getter(self, uri, headers, last_obj=None, spr=False):
        """Get a list of all objects in a container.

        :param uri:
        :param headers:
        :return list:
        :param spr: "single page return" Limit the returned data to one page
        :type spr: ``bol``
        """

        # Quote the file path.
        base_path = marked_path = ('%s?limit=10000&format=json' % uri.path)

        if last_obj:
            marked_path = self._last_marker(
                base_path=base_path,
                last_object=cloud_utils.quoter(last_obj)
            )

        file_list = self._obj_index(
            uri=uri,
            base_path=base_path,
            marked_path=marked_path,
            headers=headers,
            spr=spr
        )

        LOG.debug(
            'Found [ %d ] entries(s) at [ %s ]',
            len(file_list),
            uri.geturl()
        )

        if spr:
            return file_list
        else:
            return cloud_utils.unique_list_dicts(
                dlist=file_list, key='name'
            )