OpenStack | Images
command syntax1: openstack image <action/operation> <--flags values> <image-name/UUID>
command syntax2: openstack image add project <image-name/UUID> <project-name>
#to view the list of images
cumulus@server01:~$ openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 8a700aea-4f30-4798-b6f7-037b11dc9494 | cirros | active |
+--------------------------------------+--------+--------+
#to check more details about the image with name 'cirros'
cumulus@server01:~$ openstack image show cirros
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | 133eae9fb1c98f45894a4e60d8736619 |
| container_format | bare |
| created_at | 2018-07-05T07:42:54Z |
| disk_format | qcow2 |
| file | /v2/images/8a700aea-4f30-4798-b6f7-037b11dc9494/file |
| id | 8a700aea-4f30-4798-b6f7-037b11dc9494 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 9a4ce13914f0444789153f632722a42a |
| protected | False |
| schema | /v2/schemas/image |
| size | 13200896 |
| status | active |
| tags | |
| updated_at | 2018-07-05T07:42:55Z |
| virtual_size | None |
| visibility | public |
+------------------+------------------------------------------------------+
#the image that we checked above, is already there in the system, what if we want to install a new image, for that we need to first to download the image from it's URL, let's try to download the light weight cirros image, which is used for learning purposes
cumulus@server01:~$ wget https://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
--2018-07-08 08:23:33-- https://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
Resolving download.cirros-cloud.net (download.cirros-cloud.net)... 64.90.42.85, 2607:f298:6:a036::bd6:a
72a
Connecting to download.cirros-cloud.net (download.cirros-cloud.net)|64.90.42.85|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13267968 (13M) [text/plain]
Saving to: ‘cirros-0.3.5-x86_64-disk.img’
cirros-0.3.5-x86_64-disk. 100%[====================================>] 12.65M 19.8MB/s in 0.6s
2018-07-08 08:23:34 (19.8 MB/s) - ‘cirros-0.3.5-x86_64-disk.img’ saved [13267968/13267968]
#now, we can create an openstack image using this downloaded image file
cumulus@server01:~$ openstack image create --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --min-disk 1 --min-ram 512 --property description='Cirros_Cloud_Image' --property architecture='x64' firstImage
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
| container_format | bare |
| created_at | 2018-07-08T08:48:28Z |
| disk_format | qcow2 |
| file | /v2/images/faa6f7a0-f772-4fa1-bf07-6e0414488eac/file |
| id | faa6f7a0-f772-4fa1-bf07-6e0414488eac |
| min_disk | 1 |
| min_ram | 512 |
| name | firstImage |
| owner | 9a4ce13914f0444789153f632722a42a |
| properties | architecture='x64', description='Cirros_Cloud_Image' |
| protected | False |
| schema | /v2/schemas/image |
| size | 13267968 |
| status | active |
| tags | |
| updated_at | 2018-07-08T08:48:29Z |
| virtual_size | None |
| visibility | shared |
+------------------+------------------------------------------------------+cumulus@server01:~$
#the newly create Image should now appear in the Image list
cumulus@server01:~$ openstack image list
+--------------------------------------+------------+--------+
| ID | Name | Status |
+--------------------------------------+------------+--------+
| 8a700aea-4f30-4798-b6f7-037b11dc9494 | cirros | active |
| faa6f7a0-f772-4fa1-bf07-6e0414488eac | firstImage | active |
+--------------------------------------+------------+--------+
#we can also download the image in OpenStack to a local directory on the controller node
cumulus@server01:~$ openstack image save --file /tmp/downloaded_cirros_image.img firstImage
Note: when you have more than one image with the same name, we can use the image UUID instead of the name
cumulus@server01:~$ openstack image save --file /tmp/firstDownloadeImage.img faa6f7a0-f772-4fa1-bf07-6e0414488eac
#we can verify the directory to verify the file exists
cumulus@server01:~$ ls /tmp/ | grep first
firstDownloadeImage.img
cumulus@server01:~$
#to check more information about the file
cumulus@server01:~$ ls -l /tmp/ | grep cirros
-rw-rw-r-- 1 cumulus cumulus 13267968 Jul 8 08:36 downloaded_cirros_image.img
#Let's try modifying the values of certain fields of the image
cumulus@server01:~$ openstack image show faa6f7a0-f772-4fa1-bf07-6e0414488eac | grep min_disk
| min_disk | 1
let's change the min_disk capacity from 1GB to 2GB
cumulus@server01:~$ openstack image set --min-disk 2 faa6f7a0-f772-4fa1-bf07-6e0414488eac
cumulus@server01:~$
#let's set the os_distro property
cumulus@server01:~$ openstack image set --property os_distro='firstCirrosImage' faa6f7a0-f772-4fa1-bf07-6e0414488eac
#to verify
cumulus@server01:~$ openstack image show faa6f7a0-f772-4fa1-bf07-6e0414488eac
+------------------+-----------------------------------------------------------------------------------
-+
| Field | Value
|
+------------------+-----------------------------------------------------------------------------------
-+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290
|
| container_format | bare
|
| created_at | 2018-07-08T08:48:28Z
|
| disk_format | qcow2
|
| file | /v2/images/faa6f7a0-f772-4fa1-bf07-6e0414488eac/file
|
| id | faa6f7a0-f772-4fa1-bf07-6e0414488eac
|
| min_disk | 2
|
| min_ram | 512
|
| name | firstImage
|
| owner | 9a4ce13914f0444789153f632722a42a
|
| properties | architecture='x64', description='Cirros_Cloud_Image', os_distro='firstCirrosImage'
|
| protected | False
|
| schema | /v2/schemas/image
|
| size | 13267968
|
| status | active
|
| tags |
|
| updated_at | 2018-07-08T09:02:25Z
|
| virtual_size | None
|
| visibility | shared
|
+------------------+-----------------------------------------------------------------------------------
-+
#to add the image firstImage to the project firstProject
cumulus@server01:~$ openstack image add project faa6f7a0-f772-4fa1-bf07-6e0414488eac firstProject
+------------+--------------------------------------+
| Field | Value |
+------------+--------------------------------------+
| created_at | 2018-07-08T09:10:47Z |
| image_id | faa6f7a0-f772-4fa1-bf07-6e0414488eac |
| member_id | 23595ea6e5ed4201914e3831c12820ae |
| schema | /v2/schemas/member |
| status | pending |
| updated_at | 2018-07-08T09:10:47Z |
+------------+--------------------------------------+
--end-of-post--