Preamble

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.

Limitations:

  • 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.

The procedure involves using the Nova command line client.  A summary of the Nova tool is here and here.

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:

  1. Backup all important data and configuration information from the existing instance.
  2. Try out the procedure on a test virtual before you attempt to use it to change MAC addresses on a virtual / image that matters.
  3. 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.

The Procedure.

  1. Install the Nova client on your workstation:
    $ sudo apt-get install python-novaclient          # Ubuntu
    or
    $ sudo yum install python-novaclient              # Fedora 18 or later
  2.  Obtain the OpenStack credentials for your project, following the procedure described here.  Summary (current 20/12/2013):

    1. From the NeCTAR Dashboard, select your project.
    2. 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.
    3. 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.
    4. 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.
  3. Run the following to get the ID for the instance you want to "rebuild".
    $ nova list
  4. Find the ID of the Image you want to use:
    1. Go your project's NeCTAR dashboard.
    2. Select the Images & Snapshots page and identify the Image you want to use.
    3. Click on the image link, and select / copy the ID from the Image Overview.
  5. You did take backups ... didn't you?

  6.  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.

Notes:

  1. 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.
  2. With the latest version of the NeCTAR dashboard, you can "rebuild" an instance from the Instance "Action" menu.