Skip to content

Instantly share code, notes, and snippets.

@timbot
Forked from gcgists/cloud-init-clone.txt
Last active December 22, 2015 12:08
Show Gist options
  • Save timbot/6470011 to your computer and use it in GitHub Desktop.
Save timbot/6470011 to your computer and use it in GitHub Desktop.
# Create a VM snapshot
nova live-image-create vms-test-vm vms-test-snapshot
# Boot a VM, passing in the cloud-init-vms.txt file as user-data.
# Note: --flavor, --image, and --security_groups should
# be set according to your environment.
nova boot --flavor windows.medium --image win7-x64-vlk --security_groups windows --poll vms-test-vm
# Delete a VM
nova delete vms-test-clone
# Discard a live-image
nova live-image-delete vms-test-snapshot
$ nova list
+--------------------------------------+-------------------+--------+-----------------+
| ID | Name | Status | Networks |
+--------------------------------------+-------------------+--------+-----------------+
| a4867099-e979-444c-bafb-6c661eac2278 | vms-test-snapshot | BUILD | |
| fac5036a-e899-4251-8c63-979dc0303917 | vms-test-vm | ACTIVE | private=X.X.X.X |
+--------------------------------------+-------------------+--------+-----------------+
[...]
$ nova list
+--------------------------------------+-------------------+---------+-----------------+
| ID | Name | Status | Networks |
+--------------------------------------+-------------------+---------+-----------------+
| a4867099-e979-444c-bafb-6c661eac2278 | vms-test-snapshot | BLESSED | |
| fac5036a-e899-4251-8c63-979dc0303917 | vms-test-vm | ACTIVE | private=X.X.X.X |
+--------------------------------------+-------------------+---------+-----------------+
$ nova list
+--------------------------------------+-------------------+---------+-----------------+
| ID | Name | Status | Networks |
+--------------------------------------+-------------------+---------+-----------------+
| f42bed03-3baa-4bed-92c9-6a15bbb4bc47 | vms-test-clone | BUILD | private=X.X.X.X |
| a4867099-e979-444c-bafb-6c661eac2278 | vms-test-snapshot | BLESSED | |
| fac5036a-e899-4251-8c63-979dc0303917 | vms-test-vm | ACTIVE | private=X.X.X.X |
+--------------------------------------+-------------------+---------+-----------------+
[...]
$ nova list
+--------------------------------------+-------------------+---------+-----------------+
| ID | Name | Status | Networks |
+--------------------------------------+-------------------+---------+-----------------+
| f42bed03-3baa-4bed-92c9-6a15bbb4bc47 | vms-test-clone | ACTIVE | private=X.X.X.X |
| a4867099-e979-444c-bafb-6c661eac2278 | vms-test-snapshot | BLESSED | |
| fac5036a-e899-4251-8c63-979dc0303917 | vms-test-vm | ACTIVE | private=X.X.X.X |
+--------------------------------------+-------------------+---------+-----------------+
# Launch a VM from a live-image
# Note: all parameters are optional.
# --target is the memory target for the clone
# virtual machine, in megabytes, and defaults
# to 0 (no memory target)
# --user_data defaults to None (no user data)
# --security-groups defaults to the security groups
# specified in the original VM
# --availability_zone defaults to the availability
# zone specified in the original VM
# --num-instances defaults to 1
# --key-name defaults to the key name specified
# in the original VM
# --params defaults to None
nova live-image-start --live-image vms-test-snapshot vms-test-clone
# Launch a VM from a live-image, giving a machine name and Active Directory machine account password
nova live-image-start --live-image vms-test-snapshot --params name=vms-test-win-01 --params machinepassword=j3n432rjnkjafeeaf vms-test-clone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment