Ramblings of Linux openstack & ceph

Using VirtualBox Images in Openstack

| Comments

In this post we look at how to take a VirtualBox image (ova) file and use it in openstack backed by ceph. In this example I will use an image provided by kali.org.

To start you will need a Linux instance with around 4 CPU’s and 4GB or RAM, less will work but I was on a time limit.

Next we download the image using wget

1
2
3
4
5
6
7
8
9
10
11
# wget http://images.kali.org/Kali-Linux-2.0.0-vbox-amd64.7z
--2015-10-23 16:04:17--  http://images.kali.org/Kali-Linux-2.0.0-vbox-amd64.7z
Resolving images.kali.org (images.kali.org)... 199.189.86.7, 188.138.17.16
Connecting to images.kali.org (images.kali.org)|199.189.86.7|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3513198801 (3.3G) [application/x-7z-compressed]
Saving to: ‘Kali-Linux-2.0.0-vbox-amd64.7z’

100%[=================================================================================================================>] 3,513,198,801 24.7MB/s   in 2m 5s

2015-10-23 16:06:22 (26.9 MB/s) - ‘Kali-Linux-2.0.0-vbox-amd64.7z’ saved [3513198801/3513198801]

Then we extract the image

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# apt-get install p7zip-full
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  p7zip-rar
The following NEW packages will be installed:
  p7zip-full
0 upgraded, 1 newly installed, 0 to remove and 59 not upgraded.
Need to get 903 kB of archives.
After this operation, 3,922 kB of additional disk space will be used.
Get:1 http://nova.clouds.archive.ubuntu.com/ubuntu/ trusty-updates/universe p7zip-full amd64 9.20.1~dfsg.1-4+deb7u1build0.14.04.1 [903 kB]
Fetched 903 kB in 0s (933 kB/s)
Selecting previously unselected package p7zip-full.
(Reading database ... 60793 files and directories currently installed.)
Preparing to unpack .../p7zip-full_9.20.1~dfsg.1-4+deb7u1build0.14.04.1_amd64.deb ...
Unpacking p7zip-full (9.20.1~dfsg.1-4+deb7u1build0.14.04.1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up p7zip-full (9.20.1~dfsg.1-4+deb7u1build0.14.04.1) ...
root@glance:~# 7za e Kali-Linux-2.0.0-vbox-amd64.7z

7-Zip (A) [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)

Processing archive: Kali-Linux-2.0.0-vbox-amd64.7z

Extracting  Kali-Linux-2.0.0-vbox-amd64.ova

Everything is Ok

Size:       3713021952
Compressed: 3513198801

Now we can extract the ova file to review the VMDK files inside:

1
2
3
4
5
6
7
8
9
10
11
# file Kali-Linux-2.0.0-vbox-amd64.ova
Kali-Linux-2.0.0-vbox-amd64.ova: POSIX tar archive (GNU)
root@glance:~# tar -tf Kali-Linux-2.0.0-vbox-amd64.ova
Kali-Linux-2.0.0-vbox-amd64.ovf
Kali-Linux-2.0.0-vbox-amd64-disk1.vmdk
Kali-Linux-2.0.0-vbox-amd64.mf
root@glance:~# tar -xvf Kali-Linux-2.0.0-vbox-amd64.ova
Kali-Linux-2.0.0-vbox-amd64.ovf
Kali-Linux-2.0.0-vbox-amd64-disk1.vmdk
Kali-Linux-2.0.0-vbox-amd64.mf
root@glance:~#

Now we convert the VMDK to a raw file - a qcow2 would also work here but as my openstack install is backed by ceph I am using RAW

1
root@glance:~# qemu-img convert -O raw Kali-Linux-2.0.0-vbox-amd64-disk1.vmdk Kali-Linux-2.0.0-vbox-amd64-disk1.raw

Finally we upload the converted image to glance using the glance phyton-client

1
root@glance:~# glance image-create --name "Kali2_64" --disk-format raw --container-format bare --is-protected True < Kali-Linux-2.0.0-vbox-amd64-disk1.raw

Now are image is ready to be used and we can boot an instance from it

Comments