赞
踩
glance image-create
命令--id <IMAGE_ID>
#镜像的ID--name <NAME>
#镜像的名称--store <STORE>
#储存的镜像上传到--disk-format <DISK_FORMAT>
#镜像的格式。可以接受的格式包含: ami,ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso.--container-format <CONTAINER_FORMAT>
#镜像容器的格式。可以接受的格式包含:ami,ari, aki, bare, and ovf.--owner <TENANT_ID>
# 拥有该镜像的租户--size <SIZE>
#镜像的大小(以bytes表示). 一般只与’–location’和’–copy_from’一起使用。--min-disk <DISK_GB>
#启动镜像所需的最小硬盘空间(用gigabytes表示).--min-ram <DISK_RAM>
#启动镜像所需的最小内存数量(用megabytes表示).--location <IMAGE_URL>
#镜像所在位置的URL。例如,如果镜像储存在swift中,--file <FILE>
#在创建过程中将要被上传的本地文件(包括硬盘镜像)。另外,镜像也可以通过stdin传递给客户端。--checksum <CHECKSUM>
#被Glance使用的可用于认证的镜像数据的哈希值,在此请提供一个md5校验值。--copy-from <IMAGE_URL>
#用法和’–location’参数相似,但表明Glance服务器应该能立即从镜像所储存的地方拷贝数据并储存。--is-public [True|False]
#表示镜像是否能被公众访问。--is-protected [True|False]
#用于避免镜像被删除。--property <key=value>
#与镜像有关的任意的属性。可以使用很多次。--human-readable
#用对人友好的格式打印镜像的尺寸。--progress
#显示上传的进度条[root@node-1 ~]# ls | grep qcow
centos-6.5-minimal.qcow2.tgz
centos7.2-x86_64.qcow2
Kylin-Desktop-V10-Release-Build1-20200704-x86_64-cloudinit.qcow2
rhel6.7-x86_64.qcow2
Windows-2008-Enterprise-R2-x64-sysprep.qcow2.tar.gz
[root@node-1 ~]#
glance image-create --name glance中看到的名字 --file 镜像路径 --disk-format 镜像格式 --container-format bare --visibility public --progress
[root@controller01 ~]# vi uplod.sh
#!/bin/bash
glance image-create --name $1 --file $2 --disk-format qcow2 --container-format bare --visibility public --progress
#脚本参数说明,$1是在glance中看到的名字(自定义的名字),$2是上传的镜像路径,最好加上绝对路径
[root@controller01 ~]# chmod +x uplod.sh
bash upload.sh 在glance中看到镜像名字(自定义名字) 镜像真是的名字(最好用绝对路径)
[root@controller01 ~]# bash upload.sh win2008r2 /home/raw/20180112-win2008r2.raw
openstack-glance-api.service
服务是否正常。[root@controller01 ~]# source admin-openrc.sh
[root@controller01 ~]# glance image-create --name "Kelin-Desktop" --file Kylin-Desktop-V10-Release-Build1-20200704-x86_64.qcow2 --disk-format qcow2 --container-format bare --visibility public --progress
usage: glance [--version] [-d] [-v] [--get-schema] [--no-ssl-compression] [-f]
[--os-image-url OS_IMAGE_URL]
[--os-image-api-version OS_IMAGE_API_VERSION]
[--profile HMAC_KEY] [--insecure] [--os-cacert <ca-certificate>]
[--os-cert <certificate>] [--os-key <key>] [--timeout <seconds>]
[--os-auth-url OS_AUTH_URL] [--os-domain-id OS_DOMAIN_ID]
[--os-domain-name OS_DOMAIN_NAME]
[--os-project-id OS_PROJECT_ID]
[--os-project-name OS_PROJECT_NAME]
[--os-project-domain-id OS_PROJECT_DOMAIN_ID]
[--os-project-domain-name OS_PROJECT_DOMAIN_NAME]
[--os-trust-id OS_TRUST_ID] [--os-user-id OS_USER_ID]
[--os-username OS_USERNAME]
[--os-user-domain-id OS_USER_DOMAIN_ID]
[--os-user-domain-name OS_USER_DOMAIN_NAME]
[--os-password OS_PASSWORD] [--key-file OS_KEY]
[--ca-file OS_CACERT] [--cert-file OS_CERT]
[--os-tenant-id OS_TENANT_ID] [--os-tenant-name OS_TENANT_NAME]
[--os-region-name OS_REGION_NAME]
[--os-auth-token OS_AUTH_TOKEN]
[--os-service-type OS_SERVICE_TYPE]
[--os-endpoint-type OS_ENDPOINT_TYPE]
<subcommand> ...
glance: error: unrecognized arguments: --file Kylin-Desktop-V10-Release-Build1-20200704-x86_64.qcow2
[root@controller01 ~]#
[root@controller01 ~]# glance --version
2.0.0
[root@controller01 ~]#
[root@controller01 ~]# sh /root/admin-openrc.sh
[root@controller01 ~]# glance image-list
[root@controller01 ~]# ls | grep qcow2
CentOS-7.4-heat-zabbix-lvm10-20180202.qcow2
CentOS-7.4-heat-zabbix-lvm10-20180202.qcow2.raw
Kylin-Desktop-V10-Release-Build1-20200704-x86_64.qcow2
win2k8r2-3.qcow2
win7.qcow2
win7.qcow2.raw
Windows-2008-Enterprise-R2-x64-sysprep.qcow2
Windows-2008-Enterprise-R2-x64-sysprep.qcow2.tar.gz
[root@controller01 ~]#
openstack image create 'xxxxName' --disk-format qcow2 --container-format bare --file /tmp/xxxx.img --public
# xxxxName——显示名称
#/tmp/xxxx.img —— 镜像
[root@controller01 ~]# source admin-openrc.sh
[root@controller01 ~]# openstack image create 'KeLindesk' --disk-format qcow2 --container-format bare --file /root/Kylin-Desktop-V10-Release-Build1-20200704-x86_64.qcow2 --public
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | e2c0eec7df61ed34aa930a49d7bd360d |
| container_format | bare |
| created_at | 2022-06-23T03:01:29Z |
| disk_format | qcow2 |
| file | /v2/images/61f9b025-19c2-41ff-bb92-c416e4c6ce5d/file |
| id | 61f9b025-19c2-41ff-bb92-c416e4c6ce5d |
| min_disk | 0 |
| min_ram | 0 |
| name | KeLindesk |
| owner | ed270068500d4f22b3ccac210fac8c80 |
| properties | direct_url='rbd://f5bf95c8-94ee-4a95-8e18-1e7f4a1db07a/images/61f9b025-19c2-41ff-bb92-c416e4c6ce5d/snap', locations='[{u'url': u'rbd://f5bf95c8-94ee-4a95-8e18-1e7f4a1db07a/images/61f9b025-19c2-41ff- |
| | bb92-c416e4c6ce5d/snap', u'metadata': {}}]' |
| protected | False |
| schema | /v2/schemas/image |
| size | 8851030016 |
| status | active |
| tags | |
| updated_at | 2022-06-23T03:05:15Z |
| virtual_size | None |
| visibility | public |
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@controller01 ~]#
# 现实可能各有差异,但有内容就行了
[root@controller01 ~]# glance image-list | grep KeLin
| 61f9b025-19c2-41ff-bb92-c416e4c6ce5d | KeLindesk |
[root@controller01 ~]#
# 其他版本
[root@node-1 ~]# glance image-list
+--------------------------------------+--------------------------+-------------+------------------+-------------+--------+
| ID | Name | Disk Format | Container Format | Size | Status |
+--------------------------------------+--------------------------+-------------+------------------+-------------+--------+
...
| 3edb9730-8dd5-4805-968b-8ed59b0c62ae | KeLindesk | qcow2 | bare | 8851030016 | active |
...
+--------------------------------------+--------------------------+-------------+------------------+-------------+--------+
[root@node-1 ~]#
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。