CentOS 7
Sponsored Link

OpenStack Pike : Add VM Images2017/09/03

 
Add Virtual Machine images in Glance.
For example on here, add CentOS 7 virtual machine image.
[1] Create CentOS 7 image on Glance Host.
# 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/centos7.img 10G
# install

[root@dlp ~(keystone)]#
virt-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'
Starting install...    
# installation starts
[2]
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]
* install [cloud-init] package and enable [cloud-init] service, and also add a user whose name is [centos].
[3] Add the virtual image to Glance.
[root@dlp ~(keystone)]#
openstack image create "CentOS7" --file /var/kvm/images/centos7.img --disk-format qcow2 --container-format bare --public

+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | bac19d4ee3533cb79fcd6d9905a5ef02                     |
| container_format | bare                                                 |
| created_at       | 2017-09-04T05:38:19Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/68132026-60aa-4afe-8976-398b0482cfd6/file |
| id               | 68132026-60aa-4afe-8976-398b0482cfd6                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | CentOS7                                              |
| owner            | 09158bee8c6441519bf3a3743d936566                     |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 1378942976                                           |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2017-09-04T05:38:25Z                                 |
| virtual_size     | None                                                 |
| visibility       | public                                               |
+------------------+------------------------------------------------------+

[root@dlp ~(keystone)]#
openstack image list

+--------------------------------------+---------+--------+
| ID                                   | Name    | Status |
+--------------------------------------+---------+--------+
| 68132026-60aa-4afe-8976-398b0482cfd6 | CentOS7 | active |
+--------------------------------------+---------+--------+
[4] 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/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img -P /var/kvm/images
[root@dlp ~(keystone)]#
openstack image create "Ubuntu1604" --file /var/kvm/images/ubuntu-16.04-server-cloudimg-amd64-disk1.img --disk-format qcow2 --container-format bare --public

+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | fc5ad26274fcc42cfa32d97308613432                     |
| container_format | bare                                                 |
| created_at       | 2017-02-24T01:44:21Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/3113fc28-fa1f-4221-909e-a4fc5bdb8d6a/file |
| id               | 3113fc28-fa1f-4221-909e-a4fc5bdb8d6a                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | Ubuntu1604                                           |
| owner            | 3424019a88f34894b22058d6e15a8d35                     |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 324141056                                            |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2017-02-24T01:44:23Z                                 |
| virtual_size     | None                                                 |
| visibility       | public                                               |
+------------------+------------------------------------------------------+
Matched Content