@
Glance镜像服务介绍
创建镜像
[root@controller ~]# ls
cirros-0.3.4-x86_64-disk.img
[root@controller ~]# file cirros-0.3.4-x86_64-disk.img
cirros-0.3.4-x86_64-disk.img: QEMU QCOW Image (v2), 41126400 bytes
[root@controller images]# glance help image-create
usage: glance image-create [--architecture <ARCHITECTURE>]
[--protected [True|False]] [--name <NAME>]
[--instance-uuid <INSTANCE_UUID>]
[--min-disk <MIN_DISK>] [--visibility <VISIBILITY>]
[--kernel-id <KERNEL_ID>]
[--tags <TAGS> [<TAGS> ...]]
[--os-version <OS_VERSION>]
[--disk-format <DISK_FORMAT>]
[--os-distro <OS_DISTRO>] [--id <ID>]
[--owner <OWNER>] [--ramdisk-id <RAMDISK_ID>]
[--min-ram <MIN_RAM>]
[--container-format <CONTAINER_FORMAT>]
[--property <key=value>] [--file <FILE>]
[--progress]
#参数说明
--disk-format:镜像格式
--container-format: 镜像在其他项目中可见性
--progress: 显示上传镜像的进度
--file:选择本地镜像文件
--name:上传后镜像的名称
[root@controller ~]# glance image-create --name cirros-0.3.4 --disk-format qcow2 --container-format bare --progress < cirros-0.3.4-x86_64-disk.img
[=============================>] 100%
+------------------+--------------------------------------------------------------------+
| Property | Value |
+------------------+--------------------------------------------------------------------+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
| container_format | bare |
| created_at | 2022-02-10T03:15:29Z |
| disk_format | qcow2 |
| id | 32a2513c-e5ba-438b-a5ee-63c35c03b284 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros-0.3.4 |
| os_hash_algo | sha512 |
| os_hash_value | f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed2d6f9
19ca35d9046d437c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232 |
| os_hidden | False |
| owner | 1776912d52a7444d8b2d09eb86e8d1d9 |
| protected | False |
| size | 13267968 |
| status | active |
| tags | [] |
| updated_at | 2022-02-10T03:15:29Z |
| virtual_size | Not available |
| visibility | shared |
+------------------+--------------------------------------------------------------------+
查看镜像
[root@controller ~]# glance image-list
+--------------------------------------+--------------+
| ID | Name |
+--------------------------------------+--------------+
| 32a2513c-e5ba-438b-a5ee-63c35c03b284 | cirros-0.3.4 |
+--------------------------------------+--------------+
[root@controller ~]# glance image-show 32a2513c-e5ba-438b-a5ee-63c35c03b284
+------------------+--------------------------------------------------------------------+
| Property | Value |
+------------------+------------------------------------------------------------------ -+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
| container_format | bare |
| created_at | 2022-02-10T03:15:29Z |
| disk_format | qcow2 |
| id | 32a2513c-e5ba-438b-a5ee-63c35c03b284 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros-0.3.4 |
| os_hash_algo | sha512 |
| os_hash_value | f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed2d6f9
19ca35d9046d437c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232 |
| os_hidden | False |
| owner | 1776912d52a7444d8b2d09eb86e8d1d9 |
| protected | False |
| size | 13267968 |
| status | active |
| tags | [] |
| updated_at | 2022-02-10T03:15:29Z |
| virtual_size | Not available |
| visibility | shared |
+------------------+--------------------------------------------------------------------+
修改镜像
[root@controller images]# glance help image-update
usage: glance image-update [--architecture <ARCHITECTURE>]
[--protected [True|False]] [--name <NAME>]
[--instance-uuid <INSTANCE_UUID>]
[--min-disk <MIN_DISK>] [--visibility <VISIBILITY>]
[--kernel-id <KERNEL_ID>]
[--os-version <OS_VERSION>]
[--disk-format <DISK_FORMAT>]
[--os-distro <OS_DISTRO>] [--owner <OWNER>]
[--ramdisk-id <RAMDISK_ID>] [--min-ram <MIN_RAM>]
[--container-format <CONTAINER_FORMAT>]
[--property <key=value>] [--remove-property key]
<IMAGE_ID>
#参数说明
--min-disk:镜像启动最小硬盘大小
--name:镜像名称
--disk-format:镜像格式
--min-ram:镜像启动最小内存大小
--container-format:镜像在项目中可见性
[root@controller ~]# glance image-update --min-disk=1 32a2513c-e5ba-438b-a5ee-63c35c03b284
+------------------+--------------------------------------------------------------------+
| Property | Value |
+------------------+--------------------------------------------------------------------+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
| container_format | bare |
| created_at | 2022-02-10T03:15:29Z |
| disk_format | qcow2 |
| id | 32a2513c-e5ba-438b-a5ee-63c35c03b284 |
| min_disk | 1 |
| min_ram | 0 |
| name | cirros-0.3.4 |
| os_hash_algo | sha512 |
| os_hash_value | f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed2d6f9
19ca35d9046d437c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232 |
| os_hidden | False |
| owner | 1776912d52a7444d8b2d09eb86e8d1d9 |
| protected | False |
| size | 13267968 |
| status | active |
| tags | [] |
| updated_at | 2022-02-10T03:16:59Z |
| virtual_size | Not available |
| visibility | shared |
+------------------+--------------------------------------------------------------------+
[root@controller ~]# glance image-update --min-ram=1024 32a2513c-e5ba-438b-a5ee-63c35c03b284
+------------------+--------------------------------------------------------------------+
| Property | Value |
+------------------+--------------------------------------------------------------------+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
| container_format | bare |
| created_at | 2022-02-10T03:15:29Z |
| disk_format | qcow2 |
| id | 32a2513c-e5ba-438b-a5ee-63c35c03b284 |
| min_disk | 1 |
| min_ram | 1024 |
| name | cirros-0.3.4 |
| os_hash_algo | sha512 |
| os_hash_value | f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed2d6f9
19ca35d9046d437c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232 |
| os_hidden | False |
| owner | 1776912d52a7444d8b2d09eb86e8d1d9 |
| protected | False |
| size | 13267968 |
| status | active |
| tags | [] |
| updated_at | 2022-02-10T03:17:21Z |
| virtual_size | Not available |
| visibility | shared |
+------------------+--------------------------------------------------------------------+
删除镜像
[root@controller images]# glance image-delete 32a2513c-e5ba-438b-a5ee-63c35c03b284
[root@controller images]# glance image-list
+--------------------------------------+------------------------------+
| ID | Name |
+--------------------------------------+------------------------------+
+--------------------------------------+------------------------------+