CentOS 7
Sponsored Link

OpenStack Queens : Add VM Images2018/03/03

 
Add Virtual Machine images in Glance.
For example on here, add CentOS 7 virtual machine image.
[1]
Install KVM HyperVisor, refer to here.
It's unnecessarry to set Bridge networking on the section [2] of the link.
[2] 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         | 9be54c554f6f9b51400eda1abf56fdef                     |
| container_format | bare                                                 |
| created_at       | 2018-03-03T15:53:10Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/88551fbc-ce7e-4719-a67a-dd7cad478019/file |
| id               | 88551fbc-ce7e-4719-a67a-dd7cad478019                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | CentOS7                                              |
| owner            | 2551ca222ff54fac984a914e5beb40d1                     |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 1324154880                                           |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2018-03-03T15:53:17Z                                 |
| virtual_size     | None                                                 |
| visibility       | public                                               |
+------------------+------------------------------------------------------+

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

+--------------------------------------+---------+--------+
| ID                                   | Name    | Status |
+--------------------------------------+---------+--------+
| 88551fbc-ce7e-4719-a67a-dd7cad478019 | 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