This documents how to convert an existing VM instance into an OpenStack image which can be used to boot new instances. In particular it documents doing so when you are using volume backed instances.
Check the status of the source VM and stop it if it's not already:
$ nova list
+--------------------------------------+-----------+--------+------------+-
------------+---------------------------------------------+
| ID | Name | Status | Task State |
Power State | Networks |
+--------------------------------------+-----------+--------+------------+-
------------+---------------------------------------------+
| 4fef1b97-901e-4ab1-8e1f-191cb2f75969 | Tutorial1 | ACTIVE | - |
Running | Tutorial=192.168.0.107 |
+--------------------------------------+-----------+--------+------------+-
------------+---------------------------------------------+
$ nova stop Tutorial1
$ nova list
+--------------------------------------+-----------+--------+------------+-
------------+---------------------------------------------+
| ID | Name | Status | Task State |
Power State | Networks |
+--------------------------------------+-----------+---------+-----------+-
------------+---------------------------------------------+
| 4fef1b97-901e-4ab1-8e1f-191cb2f75969 | Tutorial1 | SHUTOFF | - |
Running | Tutorial=192.168.0.107 |
+--------------------------------------+-----------+---------+------------+-
------------+---------------------------------------------+
Take a snapshot and check the result:
$ nova image-create --poll Tutorial1 Tutorial1Snapshot
Server snapshotting... 100% complete
Finished
$ nova image-list
+--------------------------------------+-------------------+--------+--------+
| ID | Name | Status | Server |
+--------------------------------------+-------------------+--------+--------+
| 47e192f8-32b2-4839-8392-a18e3be1b9a6 | Tutorial1Snapshot | ACTIVE | |
+--------------------------------------+-------------------+--------+--------+
Obtain the snapshot ID from cinder:
$ cinder snapshot-list
+--------------------------------------+------------------------------------
--+----------+-------------------------+------+
| ID | Volume ID
| Status | Display Name | Size |
+--------------------------------------+------------------------------------
--+----------+-------------------------+------+
| 6a09198d-3b14-438d-a8e2-0473331fa0b7 | 616dbaa6-f5a5-4f06-9855-fdf222847f3
e | deleting | snapshot for Tutorial1 | 10 |
+--------------------------------------+------------------------------------
--+----------+-------------------------+------+
Create a volume from that snapshot:
$ cinder create --snapshot-id 6a09198d-3b14-438d-a8e2-0473331fa0b7 2
+---------------------+--------------------------------------+
| Property | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | MyZone |
| bootable | false |
| created_at | 2014-09-23T02:19:48.414823 |
| display_description | None |
| display_name | None |
| encrypted | False |
| id | 8fc9e82d-bb57-4e74-a48a-93e20c94fe2f |
| metadata | {} |
| size | 2 |
| snapshot_id | 6a09198d-3b14-438d-a8e2-0473331fa0b7 |
| source_volid | None |
| status | creating |
| volume_type | block |
+---------------------+--------------------------------------+
Create and upload an image from that volume:
$ cinder upload-to-image 8fc9e82d-bb57-4e74-a48a-93e20c94fe2f TutorialInstance
+---------------------+------------------------------------------------------
-----------------------------------------------------------------------------
--------------------------------------------------------------------+
| Property |
Value
|
+---------------------+------------------------------------------------------
-----------------------------------------------------------------------------
--------------------------------------------------------------------+
| container_format |
bare
|
| disk_format |
raw
|
| display_description |
None
|
| id |
8fc9e82d-bb57-4e74-a48a-93e20c94fe2f
|
| image_id |
83ec0ea1-e41e-475e-b925-96e5f702fba5
|
| image_name |
TutorialInstance
|
| size |
2
|
| status |
uploading
|
| updated_at |
2014-09-23T02:19:52.000000
|
| volume_type | {u'name': u'block', u'qos_specs_id': None, u'deleted'
: False, u'created_at': u'2014-08-08T04:04:49.000000', u'updated_at': None, u
'deleted_at': None, u'id': u'7a522201-7c27-4eaa-9d95-d70cfaaeb16a'} |
+---------------------+------------------------------------------------------
-----------------------------------------------------------------------------
--------------------------------------------------------------------+
Export your network UUID and image UUID:
$ export OS_IMAGE=83ec0ea1-e41e-475e-b925-96e5f702fba5
$ export OS_NET=c4beeb1d-c04d-43f4-b8fb-b485bcfcf005
Boot an instance from your new image to ensure it works:
$ nova boot --key-name $OS_USERNAME --flavor m1.tiny --block-device source=image,id=$OS_IMAGE,dest=volume,size=2,shutdown=remove,bootindex=0 --nic net-id=$OS_NET --poll Tutorial0
+--------------------------------------+-------------------------------------------------+
| Property | Value |
+--------------------------------------+-------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | MyZone |
| 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 | Riuvai8PvHu3 |
| config_drive | |
| created | 2014-09-23T02:25:14Z |
| flavor | m1.tiny (1) |
| hostId | |
| id | ec354ce2-fed9-4196-829e-483ab7759203 |
| image | Attempt to boot from volume - no image supplied |
| key_name | DemoTutorial |
| metadata | {} |
| name | Tutorial0 |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | default |
| status | BUILD |
| tenant_id | djfj4574fn478fh69gk489fn239fn9rn |
| updated | 2014-09-23T02:25:14Z |
| user_id | hy95g85nmf72bd0esdfj94582jd82j4f8 |
+--------------------------------------+-------------------------------------------------+
Server building... 100% complete
Finished
Your new image should now be waiting for you to log in.