How to launch an instance on DreamCompute using an ISO image file

Creating an OpenStack image from an ISO image file

DreamCompute allows the ISO image files to be used in the creation of instances. The first step is to import the .iso file into the Glance image service. This can be done using the openstack image create command with the following parameters.

$ openstack image create \
    --private \
    --container-format bare \
    --disk-format iso \
    --file ubuntu-17.04-server-amd64.iso \
    ubuntu-17.04-server-amd64-iso
+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | 4672ce371fb3c1170a9e71bc4b2810b9                     |
| container_format | bare                                                 |
| created_at       | 2017-05-27T13:22:49Z                                 |
| disk_format      | iso                                                  |
| file             | /v2/images/b840f7f6-7fd8-47f9-848a-...               |
| id               | b840f7f6-7fd8-47f9-848a-9e9422925cb2                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | ubuntu-17.04-server-amd64-iso                        |
| owner            | USER_ID                                              |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 718274560                                            |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2017-05-27T13:23:17Z                                 |
| virtual_size     | None                                                 |
| visibility       | private                                              |
+------------------+------------------------------------------------------+

In this command, ubuntu-17.04-server-amd64.iso is the ISO image file, and ubuntu-17.04-server-amd64-iso is the name of the new image.

Boot an instance from the ISO-based, OpenStack image

The next step is to launch a temporary instance that will be used to install/configure the operating system. Do this with the openstack server create command and the following parameters.

$ openstack server create \
    --image ubuntu-17.04-server-amd64-iso \
    --nic net-id = NETWORK_UUID \
    --flavor 100 ubuntu-17.04-server-amd64-installer
+--------------------------------------+----------------------------------+
| Field                                | Value                            |
+--------------------------------------+----------------------------------+
| OS-DCF:diskConfig                    | MANUAL                           |
| OS-EXT-AZ:availability_zone          | iad-2                            |
| OS-EXT-STS:power_state               | 0                                |
| OS-EXT-STS:task_state                | scheduling                       |
| OS-EXT-STS:vm_state                  | building                         |
| OS-SRV-USG:launched_at               | None                             |
| OS-SRV-USG:terminated_at             | None                             |
| accessIPv4                           |                                  |
| accessIPv6                           |                                  |
| addresses                            |                                  |
| adminPass                            | SLZV7QgA7ick                     |
| config_drive                         |                                  |
| created                              | 2017-05-27T13:27:42Z             |
| flavor                               | gp1.semisonic (50)               |
| hostId                               |                                  |
| id                                   | INSTANCE_ID                      |
| image                                | ubuntu-17.04-server-amd64-iso    |
| key_name                             |                                  |
| name                                 | INSTANCE_NAME                    |
| os-extended-volumes:volumes_attached | []                               |
| progress                             | 0                                |
| project_id                           | PROJECT_ID                       |
| properties                           |                                  |
| security_groups                      | [{u'name': u'default'}]          |
| status                               | BUILD                            |
| updated                              | 2017-05-27T13:27:42Z             |
| user_id                              | USER_ID                          |
+--------------------------------------+----------------------------------+

ubuntu-17.04-server-amd64-iso is the OpenStack image created from the ISO file in the previous step and NETWORK_UUID is a valid network id.

After the instance is successfully launched, create a blank volume to temporarily store the configured operating system.

$ openstack volume create --size 20 VOLUME_NAME
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| attachments         | []                                   |
| availability_zone   | iad-2                                |
| bootable            | false                                |
| consistencygroup_id | None                                 |
| created_at          | 2017-05-27T13:48:05.568204           |
| description         | None                                 |
| encrypted           | False                                |
| id                  | VOLUME_ID                            |
| multiattach         | False                                |
| name                | VOLUME_NAME                          |
| properties          |                                      |
| replication_status  | disabled                             |
| size                | 20                                   |
| snapshot_id         | None                                 |
| source_volid        | None                                 |
| status              | creating                             |
| type                | None                                 |
| updated_at          | None                                 |
| user_id             | USER_ID                              |
+---------------------+--------------------------------------+

Connect the volume to the instance as the root device using the openstack server add volume INSTANCE_ID VOLUME_ID --device /dev/vda command.

Now connect to the instance using the console and install the operating system (as one would when using ISO images on a regular computer). When the installation is finished and the system is rebooted, the instance will try to install the operating system again. Remember: this is expected as that's what the instance was instructed to do (it's just used to prepare the image).

If problems with image creation are encountered, please check the Virtual Machine Image Guide for reference.

The next step is to isolate the volume attached to the temporary instance so that it can be uploaded to the Glance image service. To do this, delete the server with the openstack server delete INSTANCE_ID command.

With the volume isolated, its contents can now be uploaded to the Glance image service using the openstack image create --volume VOLUME_ID ubuntu-17.04-server-amd64 command.

ubuntu-17.04-server-amd64 can now be used to launch functional instances based on the operating system that was just installed/configured! Example:

$ openstack server create \
    --image ubuntu-17.04-server-amd64 \
    --nic net-id=e098d02f-bb35-4085-ae12-664aad3d9c52 \
    --flavor 50 ubuntu17test
+--------------------------------------+--------------------------------------+
| Field                                | Value                                |
+--------------------------------------+--------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                               |
| OS-EXT-AZ:availability_zone          | iad-2                                |
| OS-EXT-STS:power_state               | 0                                    |
| OS-EXT-STS:task_state                | scheduling                           |
| OS-EXT-STS:vm_state                  | building                             |
| OS-SRV-USG:launched_at               | None                                 |
| OS-SRV-USG:terminated_at             | None                                 |
| accessIPv4                           |                                      |
| accessIPv6                           |                                      |
| addresses                            |                                      |
| adminPass                            | DALBYZhdk8f4                         |
| config_drive                         |                                      |
| created                              | 2017-05-27T14:26:09Z                 |
| flavor                               | gp1.semisonic (50)                   |
| hostId                               |                                      |
| id                                   | INSTANCE_ID                          |
| image                                | ubuntu-17.04-server-amd64 (...)      |
| key_name                             |                                      |
| name                                 | ubuntu17test                         |
| os-extended-volumes:volumes_attached | []                                   |
| progress                             | 0                                    |
| project_id                           | ab4e40e91c9641c38828bc916b681f46     |
| properties                           |                                      |
| security_groups                      | [{u'name': u'default'}]              |
| status                               | BUILD                                |
| updated                              | 2017-05-27T14:26:10Z                 |
| user_id                              | 779d60c8f19d47a9aebe376b702eeaad     |
+--------------------------------------+--------------------------------------+

Alternatively the volume can simply be used as the boot source for a new instance. The "upload to Glance" concept is in case the desire is to use the same operating system/configuration on multiple instances.

 

Did this article answer your questions?

Article last updated .