Ubuntu 14.04
Sponsored Link

OpenStack Mitaka : Add VM-Images2016/04/20

 
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_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_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 error is 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         | ef60758ffb134097b999792134e56d22     |
| container_format | bare                                 |
| created_at       | 2016-04-20T13:07:30Z                 |
| disk_format      | qcow2                                |
| id               | ea8eff5d-07d1-49ba-a44a-875370b7ecb9 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Ubuntu1404                           |
| owner            | 7b165caeb26a40eb8b26063b013ad26a     |
| protected        | False                                |
| size             | 2437808128                           |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2016-04-20T13:08:05Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+

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

+--------------------------------------+------------+
| ID                                   | Name       |
+--------------------------------------+------------+
| ea8eff5d-07d1-49ba-a44a-875370b7ecb9 | 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