赞
踩
本文主要介绍如何使用glance命令上传镜像
Optional arguments: --architecture <ARCHITECTURE> Operating system architecture as specified in http://docs.openstack.org/trunk/openstack- compute/admin/content/adding-images.html --protected [True|False] If true, image will not be deletable. --name <NAME> Descriptive name for the image --instance-uuid <INSTANCE_UUID> Metadata which can be used to record which instance this image is associated with. (Informational only, does not create an instance snapshot.) --min-disk <MIN_DISK> Amount of disk space (in GB) required to boot image. --visibility <VISIBILITY> Scope of image accessibility Valid values: public, private --kernel-id <KERNEL_ID> ID of image stored in Glance that should be used as the kernel when booting an AMI-style image. --tags <TAGS> [<TAGS> ...] List of strings related to the image Operating system version as specified by the distributor --disk-format <DISK_FORMAT> Format of the disk Valid values: ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, iso Common name of operating system distribution as specified in http://docs.openstack.org/trunk /openstack-compute/admin/content/adding-images.html --id <ID> An identifier for the image --owner <OWNER> Owner of the image --ramdisk-id <RAMDISK_ID> ID of image stored in Glance that should be used as the ramdisk when booting an AMI-style image. --min-ram <MIN_RAM> Amount of ram (in MB) required to boot image. --container-format <CONTAINER_FORMAT> Format of the container Valid values: ami, ari, aki, bare, ovf, ova, docker --property <key=value> Arbitrary property to associate with image. May be used multiple times. --file <FILE> Local file that contains disk image to be uploaded during creation. Alternatively, the image data can be passed to the client via stdin. --progress Show upload progress bar.
[root@controller ~]# glance image-create --name centos7.2 --disk-format qcow2 --container bare --file /opt/iaas/images/CentOS_7.2_x86_64_XD.qcow2 +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | ea197f4c679b8e1ce34c0aa70ae2a94a | | container_format | bare | | created_at | 2019-10-08T19:51:27Z | | disk_format | qcow2 | | id | d1bf479f-d82a-4be3-8af4-6c0586f12f5e | | min_disk | 0 | | min_ram | 0 | | name | centos7.2 | | owner | 76a36b75f7124d26871eaf6977f4a3ba | | protected | False | | size | 400752640 | | status | active | | tags | [] | | updated_at | 2019-10-08T19:51:33Z | | virtual_size | None | | visibility | private | +------------------+--------------------------------------+
[root@controller ~]# glance image-list
You must provide a username via either --os-username or env[OS_USERNAME]
需要加载用户身份变量,执行以下代码
export OS_PROJECT_DOMAIN_NAME=demo
export OS_USER_DOMAIN_NAME=demo
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=000000 #此处以实际密码为准
export OS_AUTH_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
或者将以上代码保存到一个以 .sh (这里我保存在/etc/keystone/admin-openrc.sh 这个文件中)结尾的文件中然后执行下方操作
[root@controller ~]# source /etc/keystone/admin-openrc.sh
[root@controller ~]# glance image-list
+--------------------------------------+-----------+
| ID | Name |
+--------------------------------------+-----------+
| d1bf479f-d82a-4be3-8af4-6c0586f12f5e | centos7.2 |
+--------------------------------------+-----------+
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。