Reimaging a NeCTAR virtual
Life can be awkward if you are running proprietary software that requires a license key that is tied to a MAC address. In particular, if you need to "start again" for some reason and reinstall everything from a "bare" virtual image, then the obvious procedure of "terminating" the VM and creating a new instance will give you a system with a new MAC address. Furthermore, the OpenStack tools currently don't allow you to specify the MAC address to be used when creating a new instance, and (AFAIK) there is no way to change the MAC address for an OpenStack virtual.
However, there is a workaround. If you have an existing instance whose MAC address you want to reuse, you can use the Nova command line client to "rebuild" it. Actually "rebuild" is a bit misleading. What this procedure does is to replace your virtual instance's current state (including the volatile disc contents!) with a copy of a different image.
- The VM remains the same flavour; i.e. you cannot change the number of VCPUs, the amount of memory, or the volatile storage size.
- The VM remains in the same availability zone.
- The VM retains the same IP.
BIG SCARY WARNING!!
What you are about to do will trash your existing virtual image. Permanently! For ever! (Probably ...)
Common sense dictates that you should do the following BEFORE you try the procedure:
- Backup all important data and configuration information from the existing instance.
- Try out the procedure on a test virtual before you attempt to use it to change MAC addresses on a virtual / image that matters.
- Check with the supplier of your software that they will provide you with a fresh license key (for a different MAC address) if the procedure goes wrong.
- Install the Nova client on your workstation:
$ sudo apt-get install python-novaclient # Ubuntuor
$ sudo yum install python-novaclient # Fedora 18 or later
Obtain the OpenStack credentials for your project, following the procedure described here. Summary (current 20/12/2013):
- From the NeCTAR Dashboard, select your project.
- In the "Access & Security > API Access" panel, click "Download Openstack RC File" and save the resulting script in (for example) your "~/bin" directory. This file has details of your project embedded in it; e.g. a "tennant" id and name.
- You will need an OpenStack password for your project. If you don't have one (or can't remember it) click the Settings link (top right of the page), switch to the "Reset Password" panel and click "Reset Password". Put the password somewhere safe ... or treat it as a one-time password.
- On your workstation, "source" the project-specific "open-rc.sh" script, and copy and paste in the password when prompted. This will populate some environment variables that will allow the Nova command line tool to authenticate.
- Run the following to get the ID for the instance you want to "rebuild".
$ nova list
- Find the ID of the Image you want to use:
- Go your project's NeCTAR dashboard.
- Select the Images & Snapshots page and identify the Image you want to use.
- Click on the image link, and select / copy the ID from the Image Overview.
You did take backups ... didn't you?
Use the nova command to "rebuild" your instance with the chosen image:
$ nova rebuild <instance-id> <image-id> --poll
... replacing "<instance-id>" and "<image-id>" with the appropriate IDs. This could take a couple of minutes to complete.
- When I followed the above procedure, I found that the instance seemed to get "jammed". I unjammed it by connecting to the Console (via the instance's "Actions" menu in the NeCTAR Dashboard) and sending it a "CTRL-ALT-DEL". That caused the instance reboot to happen / proceed. However, this might just have been impatience on my part.
- With the latest version of the NeCTAR dashboard, you can "rebuild" an instance from the Instance "Action" menu.