Exemple #1
0
    def get(self, container_id, content_id, account=None, container_name=None):
        try:
            meta, chunks = self.container_client.content_locate(
                cid=container_id, content=content_id)
        except NotFound:
            raise ContentNotFound("Content %s/%s not found" %
                                  (container_id, content_id))

        chunk_method = meta['chunk_method']
        storage_method = STORAGE_METHODS.load(chunk_method)
        if not account or not container_name:
            container_info = self.container_client.container_get_properties(
                cid=container_id)['system']
            if not account:
                account = container_info['sys.account']
            if not container_name:
                container_name = container_info['sys.user.name']
        cls = ECContent if storage_method.ec else PlainContent
        return cls(self.conf,
                   container_id,
                   meta,
                   chunks,
                   storage_method,
                   account,
                   container_name,
                   container_client=self.container_client)
Exemple #2
0
    def get_by_path_and_version(self, container_id, path, version,
                                account=None, container_name=None):
        try:
            meta, chunks = self.container_client.content_locate(
                cid=container_id, path=path, version=version)
        except NotFound:
            raise ContentNotFound("Content %s/%s/%s not found" % (container_id,
                                  path, str(version)))

        return self._get(container_id, meta, chunks,
                         account=account, container_name=container_name)
Exemple #3
0
    def get(self, container_id, content_id, account=None,
            container_name=None):
        try:
            meta, chunks = self.container_client.content_locate(
                cid=container_id, content=content_id)
        except NotFound:
            raise ContentNotFound("Content %s/%s not found" % (container_id,
                                  content_id))

        return self._get(container_id, meta, chunks,
                         account=account, container_name=container_name)
Exemple #4
0
    def get(self, container_id, content_id):
        try:
            meta, chunks = self.container_client.content_locate(
                cid=container_id, content=content_id)
        except NotFound:
            raise ContentNotFound("Content %s/%s not found" % (container_id,
                                  content_id))

        chunk_method = meta['chunk_method']
        storage_method = STORAGE_METHODS.load(chunk_method)

        cls = ECContent if storage_method.ec else PlainContent
        return cls(self.conf, container_id, meta, chunks, storage_method)
Exemple #5
0
    def get(self, container_id, content_id):
        try:
            meta, chunks = self.container_client.content_show(
                cid=container_id, content=content_id)
        except NotFound:
            raise ContentNotFound("Content %s/%s not found" %
                                  (container_id, content_id))

        pol_type, pol_args = self._extract_datasec(meta['policy'])

        if pol_type == "DUP":
            return DupContent(self.conf, container_id, meta, chunks, pol_args)
        elif pol_type == "RAIN":
            return RainContent(self.conf, container_id, meta, chunks, pol_args)

        raise InconsistentContent("Unknown storage policy")