LIBRADOS

LIBRADOS(PYTHON)

rados模块是一个很薄的Python包装器librados

安装

要为Ceph安装Python库,请参阅为Python获取librados

入门

您可以使用Python创建自己的Ceph客户端。以下教程将向您展示如何导入Ceph Python模块,连接到Ceph集群,并以client.admin用户身份执行对象操作。

注意

要使用Ceph Python绑定,您必须有权访问正在运行的Ceph集群。要快速设置,请参阅入门

<dl class="docutils" style="margin-bottom: 15px;">

<dt>首先,为您的Ceph客户端创建一个Python源文件。::</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| linenos: | sudo vim client.py |

</dd>

</dl>

导入模块

要使用该rados模块,请将其导入到源文件中。

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 5px 0px; background-color: transparent; color: rgb(170, 170, 170); line-height: 1.2em; border: 0px; font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">1</pre>

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;"> 导入 rados
</pre>

|

配置群集句柄

在连接到Ceph存储群集之前,创建一个群集句柄。默认情况下,集群句柄假定一个名为集群ceph(即,部署工具的默认集合以及我们的入门指南)以及一个 client.admin用户名。您可以更改这些默认值以满足您的需求。

要连接Ceph存储集群,您的应用程序需要知道在哪里可以找到Ceph Monitor。通过指定Ceph配置文件的路径,将该信息提供给您的应用程序,该文件包含初始Ceph监视器的位置。

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 5px 0px; background-color: transparent; color: rgb(170, 170, 170); line-height: 1.2em; border: 0px; font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">1 2 3 4 五 6</pre>

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;"> 导入 rados , sys

 #创建句柄示例。
 cluster  =  rados 。拉多什(的ConfFile = 'ceph.conf' )
 簇 =  地区反兴奋剂组织。拉多什(的ConfFile = SYS 。ARGV [ 1 ])
 簇 =  地区反兴奋剂组织。拉多什(的ConfFile  =  'ceph.conf' , CONF  =  字典 (钥匙圈 =  '/路径/到/钥匙圈' ))

</pre>

|

确保conffile参数提供Ceph配置文件的路径和文件名。您可以使用该sys模块来避免硬编码Ceph配置路径和文件名。

您的Python客户端还需要客户端密钥环。对于这个例子,我们client.admin默认使用这个 键。如果您想在创建群集句柄时指定密钥环,则可以使用conf参数。或者,您可以在Ceph配置文件中指定密钥环路径。例如,你可以添加如下行到你的Ceph配置文件:

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">keyring = / path / to / ceph 。客户。管理员。钥匙圈
</pre>

有关通过Python修改配置的更多详细信息,请参阅配置

连接到群集

一旦配置了集群句柄,就可以连接到集群。通过连接到集群,您可以执行返回有关集群信息的方法。

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 5px 0px; background-color: transparent; color: rgb(170, 170, 170); line-height: 1.2em; border: 0px; font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;"> 1 2 3 4 五 6 7 8 9 10 11 12 13 14 15</pre>

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;"> 导入 rados , sys

 cluster  =  rados 。拉多什(的ConfFile = 'ceph.conf' )
 打印 “ \ n librados版本:”  +  STR (簇。版本())
 打印 “将尝试连接到:”  +  STR (簇。conf_get ('周一初始成员' ))

集群。connect () 打印 “ \ n 群集ID:” + 群集。get_fsid ()

 打印 “ \ n \ n 群集统计” 
 打印 “==================” 
 cluster_stats  =  群集。get_cluster_stats ()

 对于 关键的, 价值 在 cluster_stats 。iteritems ():
         打印 键, 值

</pre>

|

默认情况下,Ceph认证是on。您的应用程序需要知道钥匙圈的位置。该python-ceph模块没有默认位置,因此您需要指定密钥环路径。指定密钥环的最简单方法是将其添加到Ceph配置文件中。以下Ceph配置文件示例使用client.admin您生成的密钥环 ceph-deploy

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 5px 0px; background-color: transparent; color: rgb(170, 170, 170); line-height: 1.2em; border: 0px; font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">1 2 3</pre>

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;"> [global]
#...省略配置
密钥环= /path/to/keyring/ceph.client.admin.keyring
</pre>

|

管理池

当连接到群集时,该RadosAPI允许您管理池。您可以列出池,检查是否存在池,创建池并删除池。

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 5px 0px; background-color: transparent; color: rgb(170, 170, 170); line-height: 1.2em; border: 0px; font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;"> 1 2 3 4 五 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26</pre>

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;"> 打印 “ \ n \ n 池操作”
打印 “===============”

 打印 “ \ n 可用池” 
 print  “----------------” 

pools = cluster 。list_pools ()用于池中的池:打印池

 打印 “ \ n 创建”测试“池” 
 打印 “------------------” 

群集。create_pool ('测试' )打印“ \ n 普尔名为'测试'存在:” + STR (簇。pool_exists ('测试' ))打印“ \ n 验证'测试'池中存在” 打印“------- ------------------“ pools = cluster 。list_pools ()用于池中的池:

 打印 “ \ n 删除'测试'池' 
 打印 ”------------------“ 

群集。delete_pool ('测试' )打印“ \ n 普尔名为'测试'存在:” + STR (簇。pool_exists ('测试' ))
</pre>

|

输入/输出上下文

读取和写入Ceph存储集群需要输入/输出上下文(ioctx)。您可以用创建ioctx open_ioctx()open_ioctx2()该方法Rados的类。该ioctx_name参数是池的名称,pool_id是您希望使用的池的ID。

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 5px 0px; background-color: transparent; color: rgb(170, 170, 170); line-height: 1.2em; border: 0px; font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">1</pre>

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;"> ioctx = 集群。open_ioctx ('data' )
</pre>

|

要么

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 5px 0px; background-color: transparent; color: rgb(170, 170, 170); line-height: 1.2em; border: 0px; font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">1</pre>

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;"> ioctx = 集群。open_ioctx2 (pool_id )
</pre>

|

一旦拥有I / O上下文,就可以读取/写入对象,扩展属性并执行其他一些操作。完成操作后,请确保关闭连接。例如:

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 5px 0px; background-color: transparent; color: rgb(170, 170, 170); line-height: 1.2em; border: 0px; font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">1 2</pre>

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;"> 打印 “ \ n 关闭连接。”
ioctx 。close ()
</pre>

|

写入,读取和删除对象

一旦创建了I / O上下文,就可以将对象写入群集。如果你写一个不存在的对象,Ceph创建它。如果你写一个存在的对象,Ceph会覆盖它(除非你指定一个范围,然后它只覆盖范围)。您可以从群集读取对象(和对象范围)。您也可以从群集中删除对象。例如:

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 5px 0px; background-color: transparent; color: rgb(170, 170, 170); line-height: 1.2em; border: 0px; font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">1 2 3 4 五 6 7 8</pre>

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">打印 “ \ n 将内容'Hello World'写入对象'hw'!汇集“数据”。“
ioctx 。write_full (“hw” , “Hello World!” )
print “ \ n \ n 对象'hw'的内容\ n ------------------------ \ n “
打印 ioctx 。读取(“hw” )
打印 “ \ n 删除对象'hw'”
ioctx 。remove_object (“hw” ) </pre>

|

写作和阅读XATTRS

一旦创建了对象,就可以将扩展属性(XATTR)写入对象并从对象中读取XATTR。例如:

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 5px 0px; background-color: transparent; color: rgb(170, 170, 170); line-height: 1.2em; border: 0px; font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">1 2 3 4 五</pre>

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">打印 “ \ n \ n 写入值为'en_US'的
XATTR'lang
'以反对' hw''ioctx 。set_xattr (“hw” ,“lang” ,“en_US” ) print “ \ n \ n 从对象'hw'获取XATTR'lang' \ n ”
print ioctx 。get_xattr (“hw” , “lang” ) </pre>

|

清单对象

如果要检查池中对象的列表,可以检索对象列表并使用对象迭代器对它们进行迭代。例如:

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 5px 0px; background-color: transparent; color: rgb(170, 170, 170); line-height: 1.2em; border: 0px; font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;"> 1 2 3 4 五 6 7 8 9 10</pre>

|

<pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; background-color: white; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(94, 106, 113); font-size: 1.1em; margin: 1.5em; box-shadow: rgb(230, 232, 232) 1px 1px 1px;">object_iterator = ioctx 。list_objects ()
while True :

    尝试 :

rados_object = object_iterator 。next ()打印“Object contents =” + rados_object 。read ()除了StopIteration :break

</pre>

|

Object类提供了一个类似文件的接口的对象,使您可以读取和写入的内容和扩展属性。使用I / O上下文的对象操作提供了额外的功能和异步功能。

集群处理

Rados类提供一个接口到Ceph的存储守护进程。

配置

Rados类提供用于获取和设置配置值,读取Ceph的配置文件,并解析参数的方法。您无需连接Ceph存储群集即可调用以下方法。有关设置的详情,请参阅存储群集配置

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.conf_get">Rados.``conf_get可选</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.conf_set">Rados.``conf_setoption,*val *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.conf_read_file">Rados.``conf_read_file(*path = None *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.conf_parse_argv">Rados.``conf_parse_argv(*args *)</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Rados.conf_parse_argv(self,args)

从参数中解析已知的参数并移除; 返回的参数只包含那些未知的ceph

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.version">Rados.``version()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Rados.version(个体经营)

获取libradosC库的版本号。

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 返回: | librados版本组件的元组(major, minor, extra) |

</dd>

</dl>

连接管理

一旦配置了集群句柄,就可以连接到集群,检查集群fsid,检索集群统计信息,并从集群断开连接(关闭)。您也可以断言群集句柄处于特定状态(例如,“配置”,“连接”等)。

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.connect">Rados.``connect(*timeout = 0 *)</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Rados.connect(self,timeout = 0)

连接到群集。使用shutdown()释放资源。

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.shutdown">Rados.``shutdown()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Rados.shutdown(个体经营)

断开与群集的连接。当不再使用Rados.connect()ed对象时,明确地调用它。

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.get_fsid">Rados.``get_fsid()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Rados.get_fsid(个体经营)

以十六进制字符串形式获取群集的fsid。

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 举: | Error |
| 返回: | str - cluster fsid |

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.get_cluster_stats">Rados.``get_cluster_stats()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Rados.get_cluster_stats(个体经营)

阅读有关群集的使用情况信息

这会告诉您总空间,使用空间,可用空间和对象数量。这些数据写入时不会立即更新,它们最终一致。

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 返回: | 字典 - 包含以下键:

  • kb (int) - 总空间
  • kb_used (int) - 使用的空间
  • kb_avail (int) - 可用空间
  • num_objects (int) - 对象的数量

|

</dd>

</dl>

<dl class="class" style="margin-bottom: 15px;">

<dt id="rados.Rados">rados.``Rados</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.require_state">require_state(** args *)</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

检查Rados对象是否处于特殊状态

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 参数: | 参数 - 可以检查为单独参数的任意数量的状态 |
| 举: | RadosStateError |

</dd>

</dl>

</dd>

</dl>

池操作

要使用池操作方法,您必须首先连接到Ceph存储群集。您可以列出可用的池,创建池,检查池是否存在以及删除池。

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.list_pools">Rados.``list_pools()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Rados.list_pools(个体经营)

获取池名称的列表。

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 返回: | 列表 - 池名称。 |

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.create_pool">Rados.``create_poolpool_nameauid = None,*crush_rule = None *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.pool_exists">Rados.``pool_exists()</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.delete_pool">Rados.``delete_pool(*pool_name *)</dt>

</dl>

输入/输出上下文

要将数据写入Ceph对象存储并从中读取数据,您必须创建一个输入/输出上下文(ioctx)。所述<cite>拉多什</cite>类提供<cite>open_ioctx()</cite> 和<cite>open_ioctx2()</cite>方法。其余的ioctx操作涉及调用<cite>Ioctx</cite>和其他类的方法。

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Rados.open_ioctx">Rados.``open_ioctx(*ioctx_name *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.require_ioctx_open">Ioctx.``require_ioctx_open()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Ioctx.require_ioctx_open(个体经营)

检查rados.Ioctx对象状态是否为'open'

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 举: | IoctxStateError |

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.get_stats">Ioctx.``get_stats()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Ioctx.get_stats(个体经营)

获取池使用统计信息

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 返回: | 字典 - 包含以下键:

  • num_bytes (int) - 池的大小(以字节为单位)

  • num_kb (int) - 以千字节为单位的池大小

  • num_objects (int) - 池中的对象数

  • num_object_clones (int) - 对象克隆的数量

  • num_object_copies (int) - 对象副本的数量

  • <dl class="first docutils" style="margin-bottom: 15px; margin-top: 0px !important;">

    <dt>num_objects_missing_on_primary (int) - objets的数量</dt>

    <dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">主要缺失</dd>

    </dl>

  • num_objects_unfound (int) - 未发现对象的数量

  • num_objects_degraded (int) - 降级对象的数量

  • num_rd (int) - 读取字节

  • num_rd_kb (int) - 千字节读取

  • num_wr (int) - 写入的字节

  • num_wr_kb (int) - 千字节写入

|

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.change_auid">Ioctx.``change_auid(*auid *)</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Ioctx.change_auid(self,auid)

尝试更改io上下文关联的智能“所有者”。

要求您对当前和新的交易都有写入权限。

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 举: | Error |

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.get_last_version">Ioctx.``get_last_version()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Ioctx.get_last_version(个体经营)

返回读取或写入的最后一个对象的版本。

这暴露了通过这个IO上下文读取或写入的最后一个对象的内部版本号

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 返回: | 使用的最后一个对象的版本 |

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.close">Ioctx.``close()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Ioctx.close(个体经营)

关闭一个rados.Ioctx对象。

这只是告诉librados你不再需要使用io上下文。如果有未处理的异步请求,它可能不会立即释放,但在调用此函数后不应再使用io上下文。

</dd>

</dl>

对象操作

Ceph存储集群将数据存储为对象。您可以同步或异步读写对象。您可以读取和写入偏移量。一个对象有一个名字(或关键字)和数据。

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.aio_write">Ioctx.``aio_writeobject_nameto_writeoffset = 0oncomplete = None,*onsafe = None *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.aio_write_full">Ioctx.``aio_write_fullobject_nameto_writeoncomplete = None,*onsafe = None *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.aio_append">Ioctx.``aio_appendobject_nameto_appendoncomplete = None,*onsafe = None *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.write">Ioctx.``write数据,*偏移量= 0 *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.write_full">Ioctx.``write_full数据</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.aio_flush">Ioctx.``aio_flush()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Ioctx.aio_flush(个体经营)

阻塞,直到io上下文中的所有挂起写入都是安全的

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 举: | Error |

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.set_locator_key">Ioctx.``set_locator_key(*loc_key *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.aio_read">Ioctx.``aio_readobject_namelengthoffset,*oncomplete *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.read">Ioctx.``readkeylength = 8192,*offset = 0 *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.stat">Ioctx.``stat重点</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.trunc">Ioctx.``trunckey,*size *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.remove_object">Ioctx.``remove_object重点</dt>

</dl>

对象扩展属性

您可以在对象上设置扩展属性(XATTR)。您可以检索对象或XATTR的列表并遍历它们。

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.set_xattr">Ioctx.``set_xattrkeyxattr_name,*xattr_value *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.get_xattrs">Ioctx.``get_xattrs(*oid *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.XattrIterator.next">XattrIterator.``__next__()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

获取对象上的下一个xattr

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 举: | 的StopIteration |
| 返回: | 配对 - 下一个Xattr的名称和值 |

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.get_xattr">Ioctx.``get_xattrkey,*xattr_name *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.rm_xattr">Ioctx.``rm_xattrkey,*xattr_name *)</dt>

</dl>

对象接口

从I / O上下文中,您可以从池中检索对象列表并遍历它们。提供的对象接口使每个对象看起来像一个文件,并且您可以对这些对象执行同步操作。对于异步操作,您应该使用I / O上下文方法。

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Ioctx.list_objects">Ioctx.``list_objects()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

Ioctx.list_objects(个体经营)

在rados.Ictctx对象上获取ObjectIterator。

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 返回: | ObjectIterator |

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.ObjectIterator.next">ObjectIterator.``__next__()</dt>

<dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; line-height: 1.5em;">

获取池中的下一个对象名称和位置

<colgroup><col class="field-name" style="hyphens: manual;"><col class="field-body"></colgroup>
| 举: | 的StopIteration |
| 返回: | 下一个rados.Ictctx对象 |

</dd>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Object.read">Object.``read(*长度= 1024 * 1024 *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Object.write">Object.``write(*string_to_write *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Object.get_xattrs">Object.``get_xattrs()</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Object.get_xattr">Object.``get_xattr(*xattr_name *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Object.set_xattr">Object.``set_xattrxattr_name,*xattr_value *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Object.rm_xattr">Object.``rm_xattr(*xattr_name *)</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Object.stat">Object.``stat()</dt>

</dl>

<dl class="method" style="margin-bottom: 15px;">

<dt id="rados.Object.remove">Object.``remove()</dt>

</dl>

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,204评论 6 506
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,091评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,548评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,657评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,689评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,554评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,302评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,216评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,661评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,851评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,977评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,697评论 5 347
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,306评论 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,898评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,019评论 1 270
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,138评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,927评论 2 355

推荐阅读更多精彩内容