CentOS 7
Sponsored Link

OpenStack Ocata : Add VM Images2017/02/27

 
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
* If you'd like to connect to Instances with SSH key-pair, install "cloud-init" package and enable "cloud-init" service.
[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         | 3d6ecc5c0f2b0cb35c60fb6957e903ce                     |
| container_format | bare                                                 |
| created_at       | 2017-02-28T06:48:22Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/c8f1484e-b877-4447-b6ce-f1baa6bef785/file |
| id               | c8f1484e-b877-4447-b6ce-f1baa6bef785                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | CentOS7                                              |
| owner            | c654e2e098b14356b97b6e613775cc54                     |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 1341784064                                           |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2017-02-28T06:48:28Z                                 |
| virtual_size     | None                                                 |
| visibility       | public                                               |
+------------------+------------------------------------------------------+

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

+--------------------------------------+---------+--------+
| ID                                   | Name    | Status |
+--------------------------------------+---------+--------+
| c8f1484e-b877-4447-b6ce-f1baa6bef785 | 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