openstacksdk - doc 翻譯(/doc/users/Image.rst)

Using OpenStack Image

Before working with the Image service, you'll need to create a connection
to your OpenStack cloud by following the :doc:connect user guide. This will
provide you with the conn variable used in the examples below.

The primary resource of the Image service is the image.

List Images

An image is a collection of files for a specific operating system
that you use to create or rebuild a server. OpenStack provides
pre-built images <http://docs.openstack.org/image-guide/obtain-images.html>_.
You can also create custom images, or snapshots, from servers that you have
launched. Images come in different formats and are sometimes called virtual
machine images.
(鏡像image是根據(jù)操作系統(tǒng)不同的一系列的文件集合,你可以使用它去創(chuàng)建和重建一個server。
openstack提供了預(yù)建的images苛预,你也可以創(chuàng)建自定義的images匙铡,或者從運(yùn)行的server創(chuàng)建快照风响。
images有不同的格式清钥,有時候也叫虛擬機(jī)鏡像艺谆。)
.. literalinclude:: ../examples/image/list.py
:pyobject: list_images

Full example: image resource list_

Create Image

Create an image by uploading its data and setting its attributes.
(上傳數(shù)據(jù)和設(shè)置屬性可以創(chuàng)建一個鏡像)
.. literalinclude:: ../examples/image/create.py
:pyobject: upload_image

Full example: image resource create_

.. _download_image-stream-true:

Downloading an Image with stream=True (下載鏡像)

As images are often very large pieces of data, storing their entire contents
in the memory of your application can be less than desirable. A more
efficient method may be to iterate over a stream of the response data.
(由于image是擁有很大的數(shù)據(jù)弊决,存儲它到你應(yīng)用的內(nèi)存是不可能的窑邦。一個更加有效率的的方式是循環(huán)迭代一個數(shù)據(jù)流)
By choosing to stream the response content, you determine the chunk_size
that is appropriate for your needs, meaning only that many bytes of data are
read for each iteration of the loop until all data has been consumed.
See :meth:requests.Response.iter_content for more information, as well
as Requests' :ref:body-content-workflow.
(在選擇去下載鏡像內(nèi)容的時候擅威,你決定chunk_size,由你的需求決定冈钦。xxx)

When you choose to stream an image download, openstacksdk is no longer
able to compute the checksum of the response data for you. This example
shows how you might do that yourself, in a very similar manner to how
the library calculates checksums for non-streamed responses.
(當(dāng)你選擇去下載一個鏡像的數(shù)據(jù)流郊丛,openstacksdk不再有能力去計算下載的數(shù)據(jù)比例。下面的例子顯示如果你你想,你應(yīng)該怎么做厉熟,
使用一個很類似的方式庫怎么計算沒有下載的數(shù)據(jù)的校驗和)
.. literalinclude:: ../examples/image/download.py
:pyobject: download_image_stream

Downloading an Image with stream=False

If you wish to download an image's contents all at once and to memory,
simply set stream=False, which is the default.
(如果你想去一次性下載一個鏡像的內(nèi)容导盅,保存到內(nèi)存,那么你設(shè)置stream=False)
.. literalinclude:: ../examples/image/download.py
:pyobject: download_image

Full example: image resource download_

Delete Image

Delete an image.
(刪除一個鏡像)
.. literalinclude:: ../examples/image/delete.py
:pyobject: delete_image

Full example: image resource delete_
(一套例子)
.. _image resource create: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/image/create.py
.. _image resource delete: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/image/delete.py
.. _image resource list: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/image/list.py
.. _image resource download: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/image/download.py

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末揍瑟,一起剝皮案震驚了整個濱河市白翻,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌绢片,老刑警劉巖滤馍,帶你破解...
    沈念sama閱讀 212,816評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異底循,居然都是意外死亡巢株,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,729評論 3 385
  • 文/潘曉璐 我一進(jìn)店門熙涤,熙熙樓的掌柜王于貴愁眉苦臉地迎上來纯续,“玉大人,你說我怎么就攤上這事灭袁。” “怎么了窗看?”我有些...
    開封第一講書人閱讀 158,300評論 0 348
  • 文/不壞的土叔 我叫張陵茸歧,是天一觀的道長。 經(jīng)常有香客問我显沈,道長软瞎,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,780評論 1 285
  • 正文 為了忘掉前任拉讯,我火速辦了婚禮涤浇,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘魔慷。我一直安慰自己只锭,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 65,890評論 6 385
  • 文/花漫 我一把揭開白布院尔。 她就那樣靜靜地躺著蜻展,像睡著了一般。 火紅的嫁衣襯著肌膚如雪邀摆。 梳的紋絲不亂的頭發(fā)上纵顾,一...
    開封第一講書人閱讀 50,084評論 1 291
  • 那天,我揣著相機(jī)與錄音栋盹,去河邊找鬼施逾。 笑死,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的汉额。 我是一名探鬼主播曹仗,決...
    沈念sama閱讀 39,151評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼闷愤!你這毒婦竟也來了整葡?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,912評論 0 268
  • 序言:老撾萬榮一對情侶失蹤讥脐,失蹤者是張志新(化名)和其女友劉穎遭居,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體旬渠,經(jīng)...
    沈念sama閱讀 44,355評論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡俱萍,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,666評論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了告丢。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片枪蘑。...
    茶點故事閱讀 38,809評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖岖免,靈堂內(nèi)的尸體忽然破棺而出岳颇,到底是詐尸還是另有隱情,我是刑警寧澤颅湘,帶...
    沈念sama閱讀 34,504評論 4 334
  • 正文 年R本政府宣布话侧,位于F島的核電站,受9級特大地震影響闯参,放射性物質(zhì)發(fā)生泄漏瞻鹏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 40,150評論 3 317
  • 文/蒙蒙 一鹿寨、第九天 我趴在偏房一處隱蔽的房頂上張望新博。 院中可真熱鬧,春花似錦脚草、人聲如沸赫悄。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,882評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽涩蜘。三九已至,卻和暖如春熏纯,著一層夾襖步出監(jiān)牢的瞬間同诫,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,121評論 1 267
  • 我被黑心中介騙來泰國打工樟澜, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留误窖,地道東北人叮盘。 一個月前我還...
    沈念sama閱讀 46,628評論 2 362
  • 正文 我出身青樓,卻偏偏與公主長得像霹俺,于是被迫代替她去往敵國和親柔吼。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 43,724評論 2 351

推薦閱讀更多精彩內(nèi)容