OpenStack Juno : Add Virtual Machine Images2015/06/05 |
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
# confirm 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 Fedora 22 for adding. |
# create a disk image [root@dlp ~]# qemu-img create -f qcow2 /var/kvm/images/fedora22.img 10G
# Install [root@dlp ~]# virt-install \
Starting install...
--name fedora22 \ --ram 2048 \ --disk path=/var/kvm/images/fedora22.img,format=qcow2 \ --vcpus 2 \ --os-type linux \ --os-variant fedora22 \ --graphics none \ --console pty,target_type=serial \ --location 'http://ftp.jaist.ac.jp/pub/Linux/Fedora/releases/22/Server/x86_64/os/' \ --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="Fedora22" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/fedora22.img +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | a2760c7b45a6e574a7f2914d1a6b6570 | | container_format | bare | | created_at | 2015-06-05T13:31:25 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | de47027d-2a2a-48e1-b403-0c0c185e78f9 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | Fedora22 | | owner | a521391a3fff4634ab11a18d06772ded | | protected | False | | size | 1714356224 | | status | active | | updated_at | 2015-06-05T13:31:34 | | virtual_size | None | +------------------+--------------------------------------+[root@dlp ~(keystone)]# glance image-list +-----------+----------+-------------+------------------+------------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +-----------+----------+-------------+------------------+------------+--------+ | de47027d- | Fedora22 | qcow2 | bare | 1714356224 | active | +-----------+----------+-------------+------------------+------------+--------+ |
[5] | By the way, if you got an image fron internet, it's OK to simplt add it like follows. |
root@dlp:~#
root@dlp:~# wget http://cloud-images.ubuntu.com/releases/15.04/release/ubuntu-15.04-server-cloudimg-amd64-disk1.img -P /var/kvm/images
glance image-create --name="Ubuntu1504" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/ubuntu-15.04-server-cloudimg-amd64-disk1.img +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 0ea22e8661eb533876eb903119cfa214 | | container_format | bare | | created_at | 2015-06-05T13:45:50 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | 872a3ac9-6e9d-4d7d-a7f1-56270c19047d | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | Ubuntu1504 | | owner | a521391a3fff4634ab11a18d06772ded | | protected | False | | size | 285213184 | | status | active | | updated_at | 2015-06-05T13:45:53 | | virtual_size | None | +------------------+--------------------------------------+ |
Sponsored Link |