OpenStack Juno : Add Images2015/01/08 |
Add Virtual Machine images in Glance.
|
|
[1] | Load environment variables first. |
[root@dlp ~]# unset SERVICE_TOKEN [root@dlp ~]# unset SERVICE_ENDPOINT
[root@dlp ~]#
vi ~/keystonerc
export OS_USERNAME=admin
export OS_PASSWORD=adminpassword export OS_TENANT_NAME=admin export OS_AUTH_URL=http://10.0.0.30:35357/v2.0/ export PS1='[\u@\h \W(keystone)]\$ '
[root@dlp ~]#
chmod 600 ~/keystonerc [root@dlp ~]# source ~/keystonerc [root@dlp ~(keystone)]# echo "source ~/keystonerc " >> ~/.bash_profile
# display status (it's OK if no errors are shown) [root@dlp ~(keystone)]# glance image-list
+----+------+-------------+------------------+------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +----+------+-------------+------------------+------+--------+ +----+------+-------------+------------------+------+--------+ |
[2] | For example, Create a Virtual Machine image of CentOS 7 for adding. |
# create a disk image [root@dlp ~(keystone)]# qemu-img create -f qcow2 /var/kvm/images/centos7.img 10G
# install [root@dlp ~(keystone)]# virt-install \
Starting install...
--name centos7 \ --ram 2048 \ --disk path=/var/kvm/images/centos7.img,format=qcow2 \ --vcpus 2 \ --os-type linux \ --os-variant rhel7 \ --graphics none \ --console pty,target_type=serial \ --location 'http://ftp.iij.ad.jp/pub/linux/centos/7/os/x86_64/' \ --extra-args 'console=ttyS0,115200n8 serial' # installation starts
|
[3] |
After installation, change settings in virtual machine like follows and shutdown it.
* delete or comment out the line "HWADDR" and "UUID" in /etc/sysconfig/network-scripts/ifcfg-eth0 * set "dhcp" for "BOOTPROTO" in /etc/sysconfig/network-scripts/ifcfg-eth0 |
[4] | Add the virtual image to Glance. |
[root@dlp ~(keystone)]# glance image-create --name="CentOS7" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/centos7.img +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 53ef100c4653a55c3bc7f6627f75a5c2 | | container_format | bare | | created_at | 2015-01-08T13:40:54 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | 4a663fce-97eb-42d3-93d6-415e477bc0a4 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | CentOS7 | | owner | e8f6ac69de5f46afa189fcefd99c8a1a | | protected | False | | size | 974454784 | | status | active | | updated_at | 2015-01-08T13:40:59 | | virtual_size | None | +------------------+--------------------------------------+[root@dlp ~(keystone)]# glance image-list +-----------+---------+-------------+------------------+-----------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +-----------+---------+-------------+------------------+-----------+--------+ | 4a663fce- | CentOS7 | qcow2 | bare | 974454784 | active | +-----------+---------+-------------+------------------+-----------+--------+ |
[5] | By the way, if you got an image fron internet, it's OK to simply add it like follows. |
root@dlp:~#
root@dlp:~# wget http://cloud-images.ubuntu.com/releases/14.10/release/ubuntu-14.10-server-cloudimg-amd64-disk1.img -P /var/kvm/images
glance image-create --name="Ubuntu1410" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/ubuntu-14.10-server-cloudimg-amd64-disk1.img +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 1fde1b5712b25dd1710acca5779e7cca | | container_format | bare | | created_at | 2015-01-06T11:14:06 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | 32f8999d-4242-43b4-ad3c-9b0b705dedd3 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | Ubuntu1410 | | owner | ba9a9493fcd34512bf09108e455dc17e | | protected | False | | size | 266535424 | | status | active | | updated_at | 2015-01-06T11:14:09 | | virtual_size | None | +------------------+--------------------------------------+ |
Sponsored Link |