当前位置: 首页>>代码示例>>Python>>正文


Python direct_client.direct_get_object函数代码示例

本文整理汇总了Python中swift.common.direct_client.direct_get_object函数的典型用法代码示例。如果您正苦于以下问题:Python direct_get_object函数的具体用法?Python direct_get_object怎么用?Python direct_get_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了direct_get_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_quarantine_range_etag

    def run_quarantine_range_etag(self):
        container = 'container-range-%s' % uuid4()
        obj = 'object-range-%s' % uuid4()
        onode, opart, data_file = self._setup_data_file(container, obj,
                                                        'RANGE')

        metadata = read_metadata(data_file)
        metadata['ETag'] = 'badetag'
        write_metadata(data_file, metadata)
        base_headers = {'X-Backend-Storage-Policy-Index': self.policy.idx}
        for header, result in [({'Range': 'bytes=0-2'}, 'RAN'),
                               ({'Range': 'bytes=1-11'}, 'ANGE'),
                               ({'Range': 'bytes=0-11'}, 'RANGE')]:
            req_headers = base_headers.copy()
            req_headers.update(header)
            odata = direct_client.direct_get_object(
                onode, opart, self.account, container, obj,
                headers=req_headers)[-1]
            self.assertEqual(odata, result)

        try:
            direct_client.direct_get_object(
                onode, opart, self.account, container, obj, headers={
                    'X-Backend-Storage-Policy-Index': self.policy.idx})
            raise Exception("Did not quarantine object")
        except ClientException as err:
            self.assertEqual(err.http_status, 404)
开发者ID:harrisonfeng,项目名称:swift,代码行数:27,代码来源:test_object_failures.py

示例2: run_quarantine_range_etag

    def run_quarantine_range_etag(self):
        container = 'container-range-%s' % uuid4()
        obj = 'object-range-%s' % uuid4()
        onode, opart, data_file = self._setup_data_file(container, obj,
                                                        'RANGE')
        with open(data_file) as fp:
            metadata = read_metadata(fp)
        metadata['ETag'] = 'badetag'
        with open(data_file) as fp:
            write_metadata(fp, metadata)
        for header, result in [({'Range': 'bytes=0-2'}, 'RAN'),
                               ({'Range': 'bytes=1-11'}, 'ANGE'),
                               ({'Range': 'bytes=0-11'}, 'RANGE')]:
            odata = direct_client.direct_get_object(onode, opart,
                                              self.account, container, obj,
                                              headers=header)[-1]

            self.assertEquals(odata, result)

        try:
            resp = direct_client.direct_get_object(onode, opart, self.account,
                                                   container, obj)
            raise "Did not quarantine object"
        except client.ClientException, e:
            self.assertEquals(e.http_status, 404)
开发者ID:BillTheBest,项目名称:swift,代码行数:25,代码来源:test_object_failures.py

示例3: run_quarantine

    def run_quarantine(self):
        container = 'container-%s' % uuid4()
        obj = 'object-%s' % uuid4()
        onode, opart, data_file = self._setup_data_file(container, obj,
                                                        'VERIFY')
        # Stash the on disk data for future comparison - this may not equal
        # 'VERIFY' if for example the proxy has crypto enabled
        backend_data = direct_client.direct_get_object(
            onode, opart, self.account, container, obj, headers={
                'X-Backend-Storage-Policy-Index': self.policy.idx})[-1]

        metadata = read_metadata(data_file)
        metadata['ETag'] = 'badetag'
        write_metadata(data_file, metadata)

        odata = direct_client.direct_get_object(
            onode, opart, self.account, container, obj, headers={
                'X-Backend-Storage-Policy-Index': self.policy.idx})[-1]
        self.assertEqual(odata, backend_data)
        try:
            direct_client.direct_get_object(
                onode, opart, self.account, container, obj, headers={
                    'X-Backend-Storage-Policy-Index': self.policy.idx})
            raise Exception("Did not quarantine object")
        except ClientException as err:
            self.assertEqual(err.http_status, 404)
开发者ID:SmartInfrastructures,项目名称:swift,代码行数:26,代码来源:test_object_failures.py

示例4: run_quarantine_range_etag

    def run_quarantine_range_etag(self):
        container = 'container-range-%s' % uuid4()
        obj = 'object-range-%s' % uuid4()
        onode, opart, data_file = self._setup_data_file(container, obj,
                                                        'RANGE')
        # Stash the on disk data for future comparison - this may not equal
        # 'VERIFY' if for example the proxy has crypto enabled
        backend_data = direct_client.direct_get_object(
            onode, opart, self.account, container, obj, headers={
                'X-Backend-Storage-Policy-Index': self.policy.idx})[-1]

        metadata = read_metadata(data_file)
        metadata['ETag'] = 'badetag'
        write_metadata(data_file, metadata)
        base_headers = {'X-Backend-Storage-Policy-Index': self.policy.idx}
        for header, result in [({'Range': 'bytes=0-2'}, backend_data[0:3]),
                               ({'Range': 'bytes=1-11'}, backend_data[1:]),
                               ({'Range': 'bytes=0-11'}, backend_data)]:
            req_headers = base_headers.copy()
            req_headers.update(header)
            odata = direct_client.direct_get_object(
                onode, opart, self.account, container, obj,
                headers=req_headers)[-1]
            self.assertEqual(odata, result)

        try:
            direct_client.direct_get_object(
                onode, opart, self.account, container, obj, headers={
                    'X-Backend-Storage-Policy-Index': self.policy.idx})
            raise Exception("Did not quarantine object")
        except ClientException as err:
            self.assertEqual(err.http_status, 404)
开发者ID:SmartInfrastructures,项目名称:swift,代码行数:32,代码来源:test_object_failures.py

示例5: run_quarantine_range_etag

    def run_quarantine_range_etag(self):
        container = "container-range-%s" % uuid4()
        obj = "object-range-%s" % uuid4()
        onode, opart, data_file = self._setup_data_file(container, obj, "RANGE")

        metadata = read_metadata(data_file)
        metadata["ETag"] = "badetag"
        write_metadata(data_file, metadata)
        base_headers = {"X-Backend-Storage-Policy-Index": self.policy.idx}
        for header, result in [
            ({"Range": "bytes=0-2"}, "RAN"),
            ({"Range": "bytes=1-11"}, "ANGE"),
            ({"Range": "bytes=0-11"}, "RANGE"),
        ]:
            req_headers = base_headers.copy()
            req_headers.update(header)
            odata = direct_client.direct_get_object(onode, opart, self.account, container, obj, headers=req_headers)[-1]
            self.assertEquals(odata, result)

        try:
            direct_client.direct_get_object(
                onode, opart, self.account, container, obj, headers={"X-Backend-Storage-Policy-Index": self.policy.idx}
            )
            raise Exception("Did not quarantine object")
        except ClientException as err:
            self.assertEquals(err.http_status, 404)
开发者ID:heemanshu,项目名称:swift_juno,代码行数:26,代码来源:test_object_failures.py

示例6: test_sync

    def test_sync(self):
        all_objects = []
        # upload some containers
        for policy in ENABLED_POLICIES:
            container = 'container-%s-%s' % (policy.name, uuid.uuid4())
            client.put_container(self.url, self.token, container,
                                 headers={'X-Storage-Policy': policy.name})
            obj = 'object-%s' % uuid.uuid4()
            body = 'test-body'
            client.put_object(self.url, self.token, container, obj, body)
            all_objects.append((policy, container, obj))

        Manager(['container-updater']).once()

        headers = client.head_account(self.url, self.token)

        self.assertEqual(int(headers['x-account-container-count']),
                         len(ENABLED_POLICIES))
        self.assertEqual(int(headers['x-account-object-count']),
                         len(ENABLED_POLICIES))
        self.assertEqual(int(headers['x-account-bytes-used']),
                         len(ENABLED_POLICIES) * len(body))

        part, nodes = self.account_ring.get_nodes(self.account)
        for node in nodes:
            direct_delete_account(node, part, self.account)

        Manager(['account-reaper']).once()

        get_to_final_state()

        for policy, container, obj in all_objects:
            cpart, cnodes = self.container_ring.get_nodes(
                self.account, container)
            for cnode in cnodes:
                try:
                    direct_head_container(cnode, cpart, self.account,
                                          container)
                except ClientException as err:
                    self.assertEquals(err.http_status, 404)
                else:
                    self.fail('Found un-reaped /%s/%s on %r' %
                              (self.account, container, node))
            object_ring = POLICIES.get_object_ring(policy.idx, '/etc/swift/')
            part, nodes = object_ring.get_nodes(self.account, container, obj)
            for node in nodes:
                try:
                    direct_get_object(node, part, self.account,
                                      container, obj)
                except ClientException as err:
                    self.assertEquals(err.http_status, 404)
                else:
                    self.fail('Found un-reaped /%s/%s/%s on %r in %s!' %
                              (self.account, container, obj, node, policy))
开发者ID:gayana06,项目名称:Thesis,代码行数:54,代码来源:test_account_reaper.py

示例7: test_direct_get_object_error

    def test_direct_get_object_error(self):
        with mocked_http_conn(500) as conn:
            with self.assertRaises(ClientException) as raised:
                direct_client.direct_get_object(
                    self.node, self.part,
                    self.account, self.container, self.obj)
            self.assertEqual(conn.host, self.node['ip'])
            self.assertEqual(conn.port, self.node['port'])
            self.assertEqual(conn.method, 'GET')
            self.assertEqual(conn.path, self.obj_path)

        self.assertEqual(raised.exception.http_status, 500)
        self.assertTrue('GET' in str(raised.exception))
开发者ID:jgmerritt,项目名称:swift,代码行数:13,代码来源:test_direct_client.py

示例8: test_direct_get_object_error

    def test_direct_get_object_error(self):
        with mocked_http_conn(500) as conn:
            try:
                direct_client.direct_get_object(
                    self.node, self.part,
                    self.account, self.container, self.obj)
            except ClientException as err:
                pass
            else:
                self.fail('ClientException not raised')
            self.assertEqual(conn.method, 'GET')
            self.assertEqual(conn.path, self.obj_path)

        self.assertEqual(err.http_status, 500)
        self.assertTrue('GET' in str(err))
开发者ID:aureliengoulon,项目名称:swift,代码行数:15,代码来源:test_direct_client.py

示例9: _run

 def _run(self, thread):
     if time.time() - self.heartbeat >= 15:
         self.heartbeat = time.time()
         self._log_status("GETS")
     device, partition, name, container_name = random.choice(self.names)
     with self.connection() as conn:
         try:
             if self.use_proxy:
                 client.get_object(self.url, self.token, container_name, name, http_conn=conn)
             else:
                 node = {"ip": self.ip, "port": self.port, "device": device}
                 direct_client.direct_get_object(node, partition, self.account, container_name, name)
         except client.ClientException, e:
             self.logger.debug(str(e))
             self.failures += 1
开发者ID:Gaurav-Gangalwar,项目名称:UFO,代码行数:15,代码来源:bench.py

示例10: run_quarantine_zero_byte_get

    def run_quarantine_zero_byte_get(self):
        container = 'container-zbyte-%s' % uuid4()
        obj = 'object-zbyte-%s' % uuid4()
        onode, opart, data_file = self._setup_data_file(container, obj, 'DATA')
        metadata = read_metadata(data_file)
        unlink(data_file)

        with open(data_file, 'w') as fpointer:
            write_metadata(fpointer, metadata)
        try:
            direct_client.direct_get_object(onode, opart, self.account,
                                            container, obj, conn_timeout=1,
                                            response_timeout=1)
            raise Exception("Did not quarantine object")
        except client.ClientException as err:
            self.assertEquals(err.http_status, 404)
开发者ID:BlueSkyChina,项目名称:swift,代码行数:16,代码来源:test_object_failures.py

示例11: run_quarantine

    def run_quarantine(self):
        container = "container-%s" % uuid4()
        obj = "object-%s" % uuid4()
        onode, opart, data_file = self._setup_data_file(container, obj, "VERIFY")
        with open(data_file) as fpointer:
            metadata = read_metadata(fpointer)
        metadata["ETag"] = "badetag"
        with open(data_file) as fpointer:
            write_metadata(fpointer, metadata)

        odata = direct_client.direct_get_object(onode, opart, self.account, container, obj)[-1]
        self.assertEquals(odata, "VERIFY")
        try:
            direct_client.direct_get_object(onode, opart, self.account, container, obj)
            raise Exception("Did not quarantine object")
        except client.ClientException as err:
            self.assertEquals(err.http_status, 404)
开发者ID:Dieterbe,项目名称:swift,代码行数:17,代码来源:test_object_failures.py

示例12: run_quarantine

    def run_quarantine(self):
        container = 'container-%s' % uuid4()
        obj = 'object-%s' % uuid4()
        onode, opart, data_file = self._setup_data_file(container, obj,
                                                        'VERIFY')
        metadata = read_metadata(data_file)
        metadata['ETag'] = 'badetag'
        write_metadata(data_file, metadata)

        odata = direct_client.direct_get_object(
            onode, opart, self.account, container, obj)[-1]
        self.assertEquals(odata, 'VERIFY')
        try:
            direct_client.direct_get_object(onode, opart, self.account,
                                            container, obj)
            raise Exception("Did not quarantine object")
        except client.ClientException as err:
            self.assertEquals(err.http_status, 404)
开发者ID:BlueSkyChina,项目名称:swift,代码行数:18,代码来源:test_object_failures.py

示例13: test_direct_get_object

    def test_direct_get_object(self):
        contents = six.StringIO('123456')

        with mocked_http_conn(200, body=contents) as conn:
            resp_header, obj_body = direct_client.direct_get_object(
                self.node, self.part, self.account, self.container, self.obj)
            self.assertEqual(conn.method, 'GET')
            self.assertEqual(conn.path, self.obj_path)
        self.assertEqual(obj_body, contents.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:9,代码来源:test_direct_client.py

示例14: direct_get

 def direct_get(self, node, part):
     req_headers = {'X-Backend-Storage-Policy-Index': int(self.policy)}
     headers, data = direct_client.direct_get_object(
         node, part, self.account, self.container_name,
         self.object_name, headers=req_headers,
         resp_chunk_size=64 * 2 ** 20)
     hasher = md5()
     for chunk in data:
         hasher.update(chunk)
     return hasher.hexdigest()
开发者ID:2015-ucsc-hp,项目名称:swift,代码行数:10,代码来源:test_reconstructor_rebuild.py

示例15: run_quarantine

    def run_quarantine(self):
        container = "container-%s" % uuid4()
        obj = "object-%s" % uuid4()
        onode, opart, data_file = self._setup_data_file(container, obj, "VERIFY")
        metadata = read_metadata(data_file)
        metadata["ETag"] = "badetag"
        write_metadata(data_file, metadata)

        odata = direct_client.direct_get_object(
            onode, opart, self.account, container, obj, headers={"X-Backend-Storage-Policy-Index": self.policy.idx}
        )[-1]
        self.assertEquals(odata, "VERIFY")
        try:
            direct_client.direct_get_object(
                onode, opart, self.account, container, obj, headers={"X-Backend-Storage-Policy-Index": self.policy.idx}
            )
            raise Exception("Did not quarantine object")
        except ClientException as err:
            self.assertEquals(err.http_status, 404)
开发者ID:heemanshu,项目名称:swift_juno,代码行数:19,代码来源:test_object_failures.py


注:本文中的swift.common.direct_client.direct_get_object函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。