Ubuntu 14.04
Sponsored Link

OpenStack Liberty : Add VM-Images2015/12/23

 
Add Virtual Machine images in Glance.
[1] Load environment variables first.
root@dlp:~#
unset OS_TOKEN OS_URL

root@dlp:~#
vi ~/keystonerc
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=adminpassword
export OS_AUTH_URL=http://10.0.0.30:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
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 |
+----+------+
+----+------+
[2] For example, Create a Virtual Machine image of ubuntu 14.04.
# create a directory for disk image

root@dlp ~(keystone)#
mkdir -p /var/kvm/images
# create a disk image

root@dlp ~(keystone)#
qemu-img create -f qcow2 /var/kvm/images/ubuntu1404.img 10G
# install

root@dlp ~(keystone)#
virt-install \
--name ubuntu1404 \
--ram 2048 \
--disk path=/var/kvm/images/ubuntu1404.img,format=qcow2 \
--vcpus 2 \
--os-type linux \
--os-variant ubuntutrusty \
--network network=default \
--graphics none \
--console pty,target_type=serial \
--location 'http://jp.archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/' \
--extra-args 'console=ttyS0,115200n8 serial'
Starting install...    
# installation starts
[3]
After installation, change settings in virtual machine like follows and shutdown it.
* Install openssh-server.
* Remove /etc/udev/rules.d/70-persistent-net.rules if it exists
[4] Add the virtual image to Glance.
root@dlp ~(keystone)#
glance image-create --name "Ubuntu1404" --file /var/kvm/images/ubuntu1404.img --disk-format qcow2 --container-format bare --visibility public

+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 29fb7399fc568dc925a2c6338bd6312c     |
| container_format | bare                                 |
| created_at       | 2015-12-24T15:03:00Z                 |
| disk_format      | qcow2                                |
| id               | d5b3b32b-e90c-4253-80e1-ce30ba29d06a |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Ubuntu1404                           |
| owner            | fa7d34414b8c45c4a2fdc29403fb5cd2     |
| protected        | False                                |
| size             | 2292056064                           |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2015-12-24T15:03:12Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+

root@dlp ~(keystone)#
glance image-list

+--------------------------------------+------------+
| ID                                   | Name       |
+--------------------------------------+------------+
| d5b3b32b-e90c-4253-80e1-ce30ba29d06a | Ubuntu1404 |
+--------------------------------------+------------+
[5] By the way, if you got an image from internet, it's OK to simply add it like follows.
root@dlp ~(keystone)#
wget http://cloud-images.ubuntu.com/releases/14.04.3/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img -P /var/kvm/images
root@dlp ~(keystone)#
glance image-create --name "Ubuntu1404" --file /var/kvm/images/ubuntu-14.04-server-cloudimg-amd64-disk1.img --disk-format qcow2 --container-format bare --visibility public

+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 4263306b9755eade84578f8ca27f8164     |
| container_format | bare                                 |
| created_at       | 2015-11-14T12:16:12Z                 |
| disk_format      | qcow2                                |
| id               | d3c09925-4eb1-40c7-ba18-d27d496eb64a |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Ubuntu1404                           |
| owner            | d625e02b3d394afbad250def2f88fefa     |
| protected        | False                                |
| size             | 258671104                            |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2015-11-14T12:16:13Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+
Matched Content