Attaching a CD device to an instance in Openstack

Solution In Progress - Updated -

Environment

  • Red Hat Enterprise Linux OpenStack Platform 5.0

Issue

  • What I need is to boot from a regular cinder image, but I also need that CRDOM image to be present at the boot time. The OS expects to have it to be able to read from it information for initial configuration.

Resolution

  • Starting an instance with a volume attached as a cdrom is possible by using the --block-device option in the nova boot command.
--block-device key1=value1[,key2=value2...]
                        Block device mapping with the keys: id=image_id,
                        snapshot_id or volume_id, source=source type (image,
                        snapshot, volume or blank), dest=destination type of
                        the block device (volume or local), bus=device's bus,
                        device=name of the device (e.g. vda, xda, ...),
                        size=size of the block device in GB, format=device
                        will be formatted (e.g. swap, ext3, ntfs, ...),
                        bootindex=integer used for ordering the boot disks,
                        type=device type (e.g. disk, cdrom, ...) and
                        shutdown=shutdown behaviour (either preserve or
                        remove).

  • Start with 2 cinder volumes that have images already loaded into them.
# cinder list
+--------------------------------------+-----------+---------------+------+-------------+----------+--------------------------------------+
|                  ID                  |   Status  |  Display Name | Size | Volume Type | Bootable |             Attached to              |
+--------------------------------------+-----------+---------------+------+-------------+----------+--------------------------------------+
| bda9af3a-c2f5-4b3a-828e-7f3dedcab3a8 | available | 01177474-test |  20  |     None    |   true   |                                      |
| c41bfd82-4705-4f93-8d09-9907901aa83d | available |               |  5   |     None    |   true   |                                      |
+--------------------------------------+-----------+---------------+------+-------------+----------+--------------------------------------+
  • Then launch a new instance with both volumes attached. Besure to specifiy the type=cdrom for the volume that contains the cdrom iso.
# nova boot --flavor m1.small --nic net-id=e23a3b20-604d-44af-a3eb-8f71fb72e2cc --block-device id=c41bfd82-4705-4f93-8d09-9907901aa83d,source=volume,dest=volume,bus=ide,device=/dev/vdb,size=5,type=cdrom,bootindex=1 --block-device source=volume,id=c4a48716-ee22-4939-898b-03e0ff3a2c65,dest=volume,device=/dev/vda,size=17,bootindex=0  test2 --user-data rhel65
+--------------------------------------+--------------------------------------------------------------------------------------------------+
| Property                             | Value                                                                                            |
+--------------------------------------+--------------------------------------------------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                                                           |
| OS-EXT-AZ:availability_zone          | nova                                                                                             |
| OS-EXT-SRV-ATTR:host                 | -                                                                                                |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | -                                                                                                |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000018                                                                                |
| OS-EXT-STS:power_state               | 0                                                                                                |
| OS-EXT-STS:task_state                | scheduling                                                                                       |
| OS-EXT-STS:vm_state                  | building                                                                                         |
| OS-SRV-USG:launched_at               | -                                                                                                |
| OS-SRV-USG:terminated_at             | -                                                                                                |
| accessIPv4                           |                                                                                                  |
| accessIPv6                           |                                                                                                  |
| adminPass                            | kbRDtmuyw38Z                                                                                     |
| config_drive                         |                                                                                                  |
| created                              | 2014-10-09T21:20:31Z                                                                             |
| flavor                               | m1.small (2)                                                                                     |
| hostId                               |                                                                                                  |
| id                                   | fec129f3-64a2-4bc4-ad37-17a31696765c                                                             |
| image                                | Attempt to boot from volume - no image supplied                                                  |
| key_name                             | -                                                                                                |
| metadata                             | {}                                                                                               |
| name                                 | test2                                                                                            |
| os-extended-volumes:volumes_attached | [{"id": "c41bfd82-4705-4f93-8d09-9907901aa83d"}, {"id": "c4a48716-ee22-4939-898b-03e0ff3a2c65"}] |
| progress                             | 0                                                                                                |
| security_groups                      | default                                                                                          |
| status                               | BUILD                                                                                            |
| tenant_id                            | 2382fa1ffc364cbc803b650aa7c39ed9                                                                 |
| updated                              | 2014-10-09T21:20:31Z                                                                             |
| user_id                              | 22c672053b264aecb5ceb1c982eaa271                                                                 |
+--------------------------------------+--------------------------------------------------------------------------------------------------+
  • The iso, will be attached as a cd in the instance
-bash-4.1# lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0     11:0    1   5G  0 rom  
vda    252:0    0  17G  0 disk 
└─vda1 252:1    0  15G  0 part /

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

1 Comments

Currently it's only possible to specify type cd-rom at vm boot time. Opened an RFE to add ability to specify type cdrom for iso volumes at attach time.

RFE: Ability to attach iso to existing VM https://bugzilla.redhat.com/show_bug.cgi?id=1492226