官术网_书友最值得收藏!

Common OpenStack image tasks

This section outlines a number of steps, intended as a quick overview only, when operating against the OpenStack Image service (known as Glance). For more detailed information and explanation of each task, refer to Chapter 6, Glance – OpenStack Image Service.

Getting ready

Ensure that you have the OpenStack clients installed, as described in the first recipes in this chapter.

How to do it…

Carry out the following steps to create and modify images in OpenStack:

Uploading an image to Glance

Uploading an image to OpenStack is achieved with the following. To upload, a QCOW2 image such as one provided by CirrOS for testing, carry out the following command:

openstack image create
 --container-type bare
 --disk-format qcow2
 --public
 --file
 /path/to/cirros-0.3.5-x86_64-disk.img

Downloading an image or snapshot from Glance as a file

To download an image from Glance, perhaps for copying to another environment or to store as an offsite backup, carry out the following command:

openstack image save
 --file myImage.qcow2 myImage

Sharing images between projects

In most situations, an image is either public (available to all projects), or private (only available to the project that the image was uploaded onto). However, you are able to share a private image to isolated projects of your choosing. To do this, you will need the following:

  • The image UUID of the image you will be sharing
  • The UUID of the project that you will be sharing the image with

Carry out the following steps to share an image with another project. In the following example, we will share the cirros-image, currently only available in admin project with the anotherProject project:

  1. First, query the project list:
    openstack project list
    

    This will bring back output like the following:

    Sharing images between projects
  2. We will set the image to be shared:
    openstack image set cirros-image --shared
    
  3. We will then tell OpenStack which project we want this sharing using the following command:
    openstack image add project anotherProject
    

    This will bring back output like the following – we will use the image_id in the next step:

    Sharing images between projects
  4. Important: as a user in the receiving (anotherProject) project, execute the following:
    openstack image set --accept f6578a80-5f6f-4f2d-9a8a-9d84cec8a60d
    
  5. Now, as that same user, you can confirm that you can see this shared image by executing an image listing:
    openstack image list
    

    This will bring back output like the following, showing the available image:

    Sharing images between projects
主站蜘蛛池模板: 海原县| 镇赉县| 上林县| 遂昌县| 仁布县| 浙江省| 安岳县| 朝阳区| 朝阳区| 朝阳区| 龙江县| 襄樊市| 凯里市| 井研县| 富顺县| 札达县| 贺州市| 旌德县| 泰兴市| 蒙城县| 天祝| 无极县| 恭城| 志丹县| 阿拉善盟| 三门县| 万全县| 武胜县| 拜泉县| 乌恰县| 钟祥市| 车险| 安泽县| 东莞市| 友谊县| 璧山县| 石景山区| 宜川县| 平泉县| 余江县| 贵州省|