Openstack VM Rebuild with Same IP Address
Introduction
Oops! You accidentally created an ephemeral virtual machine (VM) instead of a volume-backed one! On top of that, it's already in production and you don't want to start fresh or have to deal with updating host inventories.
Relax!
There's a way out! It’s a somewhat painful, but recoverable, way out. Check it out below:
Prerequisites
Of course, you will need to have Openstack, and have already created an accidental ephemeral VM that’s in production to do the following:
Step 1
Create a snapshot of your chosen instance - this is what we will use to create our volume-backed instance.
- Click the dropdown menu to the right of the instance.
- Click “Create Snapshot”.
Name the snapshot. - Click “Create Snapshot” at the bottom of the window.
Step 2
Create a volume from the snapshot created in step 1.
- Click “Create Volume” from the dropdown on the right side of the snapshot.
- Name the volume and change the size if required.
- Click “Create Volume” at the bottom of the window.
Step 3
Record the interface information from the ephemeral VM. Include:
- Network the interface is attached to
- MAC address
- IP address
- FIPs attached (if any)
- Security groups
Step 4
Detach the interface from the ephemeral VM.
- From the dropdown on the right side of the instance, click “Detach Interface."
- On the new window that pops up, select which port to detach from the drop-down.
- Click “Detach Interface” at the bottom right.
Step 5
Create a port on the desired network using the information from step 3.
- Click the name of the desired network in the “Networks” section.
- Click the “Ports” tab near the top.
- Click “+Create Port” near the top right.
- Give the port a name (usually similar to the VM name), select “Fixed IP Address” from the dropdown, input the IP address from step 3, input the MAC address from step 3, and then click “Security Groups” at the top of the window.
- Attach any security groups needed from step 3.
- Click “Create” at the bottom of the window.
Step 6
Create a VM from the volume created in step 2. During the VM creation process, ensure to attach the port(s) created in step 5.
- Locate the volume under the “Volumes” section.
- From the dropdown on the right of the volume, click “Launch as Instance."
- Give the instance a name and then click “Source” or “Next."
- Ensure that the “Select Boot Source” dropdown is set to “Volume” and click the up arrow to the right of the volume name. Click “Flavor” or “Next."
- Select which flavor to use then click “Network Ports."
- Click the up arrow(s) next to the port(s) you created in step 5.
- Click “Launch Instance."
If there were no hiccups, you should now have a volume-backed VM with the same IP address!
Conclusion
There you go! Now you know how to turn an ephemeral VM into a volume-backed one, without losing any data! Once you can confirm all your data is intact, and the new VM is running, you can just remove the ephemeral VM. If you run into any issues with the above steps, just contact us at Awnix, and we’ll get you back on track!