Thursday, February 18, 2016

OpenStack - How to Create/Access Ubuntu VM with SSH Keys and Preserve DevStack Environment



I will use the DevStack environment that I created recently for this post (see my earlier post on how to built this particular environment).  The first step that we need to do will be to download a working Ubuntu image. I usually go to this link to get the latest image.  You should see a section for the official Ubuntu images.  Note that we will want to use the qcow2 format in this case.  

Click on the link to download the Ubuntu 14.04 image (highlighted in yellow below).  It might take a while to download, depending on the speed of your internet connection.



After the image is downloaded to your local machine, go to the "Images" tab under "Project".  We will see the Cirros images that come with the DevStack installation.




Click on the "Create Image" button and we will see a "Create An Image" form.  You will need to give your image a name.  You will also have to set "Image Source" to be "Image File" and select the Ubuntu qcow2 file that was downloaded earlier from your local laptop.  Select the Format as "QCOW2 - QEMU Emulator" and leave the rest as default for now.  Next, click on the "Create Image" button at bottom right of the form to upload the image.




You will see the Ubuntu image upon successful upload.  One thing that you will notice is that this image is only visible to the demo project as we did not select the "Public" check-box (as seen in the above screen shot) when we created that image.  You can make it visible to all tenants if you make it a public image, i.e. if you select the "Public" check-box. 




Next, we will need to create SSH key pairs in order to access the Ubuntu VM that we will be creating.  Go to the "Access & Security" tab and click on "Import Key Pair". 



As you might have noticed, there are instructions on how to generate key pairs if you do not have one.  We can do the following (just hit enter for the prompts, i.e. do not set passphrase):




You will get the private and public key after that.  Copy the content of id_rsa.pub and paste it in the "Public Key" box. Click "Import Key Pair" after that.




We will see the newly imported key after that




Once that is done, go back to the "Instances" tab




Click on the "Launch Instance" and you will see a "Launch Instance" form.  Fill in the Instance Name, select "m1.small" as the Flavor and select the Ubuntu image that was uploaded earlier.




On the "Access & Security" tab, select "Key1" as the Key Pair



On the "Networking" tab, select the "Management Network".  Click on the "Launch" button after that to create the Ubuntu VM.



The Ubuntu VM will take a while to become "Active" if you are building it for the first time.  Check the console of the Ubuntu VM to make sure that it reaches the login prompt (refer to earlier post on how to access VM console if you need guidance).  Note that the Ubuntu VM will take a while to reach the login prompt. 




Next, we will use the SSH key to log into the VM as ubuntu user via the Management Network



Preserving Current State of DevStack Environment (VirtualBox)


In many cases we would like to keep our environment intact and preserve our work.  I have tried several methods and the one that seems to work best is to create a snapshot of the DevStack VM.  

As you can see below, I saved a snapshot of my DevStack VM after initial installation and named it as "DevStack-Working-State".  Now that I have successfully uploaded Ubuntu Image and created an Ubuntu VM, I would like to be able to resume my work at a later stage.  I want to be able to continue my work even if I shut down Virtualbox or my laptop.


The way to achieve that will be to create a new snapshot of the current DevStack VM state



We will click on the "Take Snapshot" button and give a name to the snapshot




You will see the new snapshot if everything is goes well


To make sure that things are working as expected, we will send a signal to shut down the current DevStack VM (right click on the VM and select ACPI Shutdown). Wait for DevStack VM to fully shut down.




Next, we will restore the DevStack image with the running Ubuntu VM. Remember to unselect the checkbox for "Create a snapshot of the current machine state" as we do not want the shutdown state of the DevStack machine to be saved.





Click the "Start" button to start the DevStack VM




Check that the DevStack VM has been successfully restored and log back into the Horizon Dashboard.  You will see that the Ubuntu VM remains active and pingable from the DevStack VM.







I hope that this post helped those (like me) who were thinking of ways to save their work in DevStack =)





1 comment:

illanipipackwood said...

MEGA88 Casino $500 no deposit bonus + 300 Free Spins
MEGA88 Casino. Casino No Deposit Bonus + 포항 출장마사지 300 Free Spins. No code required. 군포 출장안마 Welcome Bonus 군포 출장안마 up 충청북도 출장샵 to $500! Play your favorite Mega Drive games 진주 출장마사지