openstack learning - Image Management

Testing conducted by Openstack Dashboard and Openstack CLI in two ways mirrored download, create, and basic operation of registered image format conversion. Reference "HCIP-Cloud_Computing-OpenStack_V1.0_ Laboratory Manual"

Experimental procedures are as follows:
openstack learning - Image Management

openstack dashboard operation

Create a mirror

cirros mirror is a relatively small (about 12M) for Linux Mirror, mirror the format QCOW2, after downloading can register directly
Download http://donload.cirros-cloud.net/0.4.0/
select "cirros-0.4.0 -x86_64-disk.img "
openstack learning - Image Management

Using admin login Openstack Dashboard user interface, in the left navigation bar, select "Project - computing - Mirror", enter the mirror list, click Create "create a mirror"
openstack learning - Image Management

Create a mirror according to the following information
image name, Img_web
image format, select QCOW2-QEMU Emulator
minimum disk, select 1GB
minimum RAM, select 128MB
image share, select the disclosure indicates that the image can be shared with other projects, private representation item is only belongs to use, here select private
protected sex, the choice is a mirror image can not be deleted, select No indicates that the image can be deleted, is selected here
openstack learning - Image Management
, click "create image" to complete the creation of the mirror
return mirror list, waiting for the mirror status change to "run", said mirror successfully registered
openstack learning - Image Management

Modify Mirror

Select "Project - computing - image", select "Edit image" in the operation list
openstack learning - Image Management

You can complete the image information in a pop-up interface modified as follows

openstack learning - Image Management

openstack cli operation

Download image

Download Mirror (cirros), the host controller to the image file in the node upload

scp -P 2230 cirros-0.4.0-x86_64-disk.img [email protected]:/home/osbash

Log controller nodes view image file details

qemu-img info cirros-0.4.0-x86_64-disk.img

openstack learning - Image Management

Creating a Registration Mirror

导入admin用户环境变量
openstack镜像相关命令是openstack image

创建镜像“Img_cli",镜像格式为”QCOW2",镜像设置为“Private”和“Protected"

openstack image create --disk-format qcow2 --container-format bare --min-disk 1 --min-ram 128 --private --protected --file ./cirros-0.4.0-x86_64-disk.img Img_cli

openstack learning - Image Management
然后查看镜像列表

openstack image list

openstack learning - Image Management

修改镜像

将镜像设置为”public"

openstack image set --public --unprotected Img_cli

查看镜像详细信息

openstack image show Img_cli

openstack learning - Image Management

共享镜像

将镜像设置为"shared"

openstack image set --shared Img_cli

导入用户“User_cli_01"的环境变量,查看镜像列表中是否会显示镜像”Img_cli"

. User_cli_01-openrc.sh
openstack image list

openstack learning - Image Management
可以看到,改为共享后,镜像Img_cli会被用户User_cli_01-openrc.sh看到

导入admin的环境变量,并查看镜像列表和项目列表

. admin-openrc.sh
openstack image list
openstack project list

openstack learning - Image Management
记录镜像“Img_cli"和”Project_cli"的ID
将镜像“Img_cli"添加到项目”Project_cli"中

openstack image add project <IMAGE_ID> <PROJECT_ID>

openstack learning - Image Management
执行完成后,查看状态为“pending"

导入用户”User_cli_01"的环境变量,查看能否显示共享镜像

. User_cli_01-openrc.sh
openstack image list

openstack learning - Image Management

转换镜像格式

QCOW2格式支持镜像的压缩,所以通常会将其他格式的镜像转换成QCOW2格式在上传到openstack中。
本次将测试VMDK格式的Ubuntu镜像转换为QCOW2格式
首先下载ubuntu镜像

wget http://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.vmdk

然后将镜像文件复制到Controller节点的/home/osbash目录下

scp -P 2230 bionic-server-cloudimg-amd64.vmdk [email protected]:/home/osbash

然后进入controller节点,导入用户admin环境变量,并查看镜像文件

ssh -p 2230 [email protected]
. admin_openrc.sh
qemu-img info bionic-server-cloudimg-amd64.vmdk

openstack learning - Image Management
执行以下命令,将镜像从VMDK格式转换为QCOW2格式

qemu-img convert -f vmdk -O qcow2 -c -p bionic-server-cloudimg-amd64.vmdk bionic-server-cloudimg-amd64.qcow2

Where:
-f specifies the input disk image format
-O specifies the output format
-c goal can only be compressed into QCOW2 format
-p Displays progress of the conversion
to wait for image format conversion is completed
openstack learning - Image Management
the following command to view the image format conversion information

qemu-img info bionic-server-cloudimg-amd64.qcow2 

openstack learning - Image Management
Execute the following command to create a mirror Ubuntu_cli, format QCOW2, and mirror state Public Unprotected

openstack image create --disk-format qcow2 --container-format bare --min-disk 1 --min-ram 128 --public --unprotected --file ./bionic-server-cloudimg-amd64.qcow2 Ubuntu_cli

openstack learning - Image Management

Export Mirror

View mirror list

openstack image list

openstack learning - Image Management
Save Mirror "Ubuntu_cli" to local
openstack image save --file Ubuntu.qcow2 Ubuntu_cli

And then view the saved image file
openstack learning - Image Management

Guess you like

Origin blog.51cto.com/11555417/2437660