The assignment was to create Elastix 3.0.0 AMI on Amazon AWS. There are two possibilities to complete this task. One is to create a normal Centos-based in­stance and install FreePBX, A2billing and other Elastix related code on it. And the second way to install Elastix on vmware virtual machine from Elastix ISO image available on Elastix website and then transform it to Amazon compatible AMI.

1 Introduction

The assignment was to create Elastix 3.0.0 AMI on Amazon AWS. There are two possibilities to complete this task. One is to create a normal Centos-based in­stance and install FreePBX, A2billing and other Elastix related code on it. And the second way to install Elastix on vmware virtual machine from Elastix ISO image available on Elastix website and then transform it to Amazon compatible AMI.

I have tried to setup Elastix via source code, that is, the .rst way of installing it. However I didn’t .nd any information on the web that motivated me to go that way. So I have started work on the second way, i.e, to convert vmware image to Amazon compatible AMI. In the following section, I will stepwise elaborate the tasks that I performed to make Elastix AMI available on Amazon EC2.

2 EC2 API Tool setup

To communicate with Amazon AWS services, Amazon provides a java-based API called EC2 API. In this regard, I have created a small instance, it can be CentOS or Ubuntu. I have created a micro ubuntu lucid 10.04 Instance. This instance is created just to install EC2 API Tool on it and once the virtual machine is ready (on our local desktop) we will upload it .rst to this instance and after using some speci.c API commands we can upload it to S3 and .nally we will have Amazon AMI.

2.1 Instance creation

Following are the steps to setup a vanilla instance on Amazon EC2.

After login to AWS, the user will see the dashboard of the Amazon AWS, mentioned in Figure 1. Click on the services circled in red (cf. Figure 1)

Click on Community AMIs to get the list of community created AMIs (cf. Figure 4).

Select checkbox on Ubuntu to show only ubuntu-based AMIs and select ubuntu 32 bit circled in red. Both steps are mentioned in Figure 5.

The last step is to review and launch button. Everything will be selected as default provided by EC2. This last step to launch the instance is depicted in Figure 6

After it, user will have an option either to use the existing key to access this system or to create a new one. So generate a new one and download its private key (in pem format) to login to the system after launch.

2.2 JRE Setup

After creating the instance, its time to login to the system and install Java Runtime Environment (JRE). JRE is the prerequisite for using EC2 API Tool.

Following are the steps to setup the JRE environment in Linux.

Execute the command to get the JRE from sun java website.[code language=”text”]
wget http://javadl.sun.com/webapps/download/AutoDL?BundleId=49015
[/code]

It gives download JRE in long text so rename it to its standard naming convention.[code language=”text”]
mv long-name jre-6u26-linux-i586.bin
[/code]

Now make this file executable[code language=”text”]
chmod 755 jre-6u26-linux-i586.bin
[/code]

Extract the files from the package by executing it.[code language=”text”]
./jre-6u26-linux-i586.bin
[/code]

Create a directory with amazonapi in /root or whatever is convenient to you and put all extracted JRE files in it.[code language=”text”]
mkdir amazonapi
mv jre1.6.0 26 /root/amazonapi
[/code]

Now create a soft link of the bin and Java executables to the standard path so all the commands can be executed without providing absolute path.[code language=”text”]
ln s /root/amazonapi/jre1.6.0 26/bin /bin
ln -s /root/amazonapi/jre1.6.0 26/bin/java /bin/java
[/code]

Java is now installed and setup so EC2 AMI Tool can use it. Next part is to setup EC2 AMI Tool itself that will help to make all the commands related to creating an AMI, becomes available.

2.3 EC2 API Tool Setup

The EC2 API tool can be downloaded by clicking Here. When reach to the site there is a download link with text ”Download the Amazon EC2 API Tools” in the middle of the page. Click on that and downloading will start. One tricky thing is that the link cannot be downloaded directly to the Amazon Intance via wget (as we did before) so first it should be downloaded to the workstation (windows) whatever OS you are using and then upload it to EC2 instance via Winscp. Provide the IP of amazon Instance and the private key to connect then drag the downloaded EC2 Tool to instance (cf. Figure 7 )

Now login to the Amazon Instance via putty or other ssh client and follow the steps below.

With the above commands the EC2 API tool are setup and all the API commands are available.

One more thing that is X-509 certificate and its private key is required by the API to communicate with the specific Amazon account. Following is the procedure to download the X-509 certificate, its private key and place into the EC2 API.

Upload these downloaded certificates and private key to the EC2 instance from the windows system as we did in Figure 7 via Winscp. Create a directory x-509 under /home/ubuntu/ move the certificate and private key there.

Now open bashrc file and setup the environment for these certificates and java setup earlier so that API can use it to communicate with Amazon AWS services;[code language=”text”]
vi /root/.bashrc
[/code][code language=”text”]
export EC2_HOME=~/.ec2
export PATH=$PATH:$EC2_HOME/bin
export EC2_PRIVATE_KEY=$EC2_HOME/pk-xxx.pem
export EC2_CERT=$EC2_HOME/cert-xxx.pem
#Put the path where you extracted JRE (Mentioned in previous steps):
export JAVA_HOME=/root/jre1.6.0_26
#add ec2 tools to default path
export PATH=~/.ec2/bin:$PATH
[/code]

Now update the environment by getting login with another shell or execute this command;[code language=”text”]
source /root/.bashrc
[/code]

Now execute one of the API tool commands to verify that the environment is setup correctly. ec2-describe-instance command will show all instances related to your account.[code language=”text”]
ec2-describe-instances[/code]Resulting output

Once we have EC2 API tool setup correctly. Its time to download, install CentOS Instance on VMWare and upload the VMDK to the instance where we setup our AMI tool. After it with the help of ec2-import-instance EC2 API command we will create the AMI on Amazon EC2.

3 Elastix 3.0 Installation on VMWare

Here we will discuss the VMware installation, after it Elastix setup on it and conversion of VMDK to OCF(Open Standard Format).

3.1 VMware Download and setup

Download the VMware workstation from here. You might need to sign-up before getting the download link or if you have already just logged in and downloaded it. After downloading, install the VMware with its default options.

3.2 Elastix Download and its Installation on VMware Player

Next step is to download the Elastix 3.0 from here. It will take some time depending on the speed of the Internet. After the download completes, launch VMware player.

Main screen of the VMware player gives the option to ”Create a new virtual machine” select that as mentioned in Figure 10.

Next option is to select the installation medium, so select ”Installer disc image file” and browse the ISO to directory where the Elastix 3.0 ISO is downloaded.

Next select Linux radio button and version should be ”CentOS” because RedHat 6 is not availble in the option. Note: Elastix 3.0 is based on CentOS 6.

On the next screen give the name to the virtual machine and the location.

Specify the Virtual harddisk file size and select ”store virtual disk as a single file”.

Click finish and Installation screen will come.

Now write ”linux text” at main installation screen so that the installation starts in text mode. Note: graphical mode the installation interrupted for some unknown reason.

Select the ”Networking options as default”.

On next screen you will get warning about the drive so select the option of ”Re-initialize all”

For the rest of the installation, select all the default options. In the middle you will get a prompt to provide password for the system user, mysql and web interface of Elastix so provide that. After it, Elastix will be ready for use in few minutes.

4 VMDK file Conversion to OVF

I will provide a bit of background of OVF(Open Virtualization Format) that how I get to know about it. Initially I did install Elastix on oracle virtual box and uploaded the final vmdk file to the Linux box where we have the EC2 API. However, I realized that virtual box created VMDK(Virtual machine disk) file is not supported by Amazon. So the Amazon API cannot convert it to Amazon AMI via ec2-import-instance command . Then I installed VMware as mentioned in the above section and uploaded its VMDK file to EC2 API instance. I got again an error message that the file format of VMDK is not in OVF and is not supported by Amazon API Tool.

So by default, when the virtual machine is installed on VMware it stores the VMDK in .VMX format. Its configuration file is also generated in .VMX. To transform VMX format to OVF, VMware provided a tool called OVF Tool.

You can use OVF Tool to distribute and import virtual machines and vApps. For example, you can create a virtual machine within VMware vSphere, and use OVF Tool to export it into an OVF package for installation.

Next part shows the OVF Tool installation and conversion procedure.

4.1 Installation of OVF Tool and conversion from VMX to OVF

OVF tool is available for Linux and Windows both. As we have installed Elastix on windows-based VMware so we need to have OVF Tool for Windows. Down-load the OVF Tool from here. Installation is straight forward. Just click on .MSI file and click next on all the default options. If you want to change the installation path you can change that at the installation screen.

4.1.1 Setup Environment for OVF Tool

After the installation has been completed. put the OVF Tool installation path in the environment variable so OVF commands can be executed from anywhere in the command line.

Right Click on ”Computer” in Windows 7 -¿ Click Properties –¿ ”Advance System Setting” –¿ click on the PATH variable mentioned in Figure 11 and add the installation path. In my case the path is ”C:/Program Files/VMware/VMware OVF Tool/”.

4.1.2 Conversion of VMX-based VMDK to OVF-based VMDK

Now we have the environment variable setup and we can run the ovftool command in MS-Dos. To get command prompt write cmd in the search of windows or write run and then write cmd you will get the black command prompt.

I have stored Elastix 3.0 files on path ”C:/Users/ims4/Documents/Virtual Machines/elastix-vmx” while installing it on VMware. I have the VMX configuration file on path ”C:/Users/ims4/Documents/Virtual Machines/elastix-vmx/elastix-vmx.vmx”. Now I will create new directory at location C:/Users/ims4/Documents/Virtual Machines/elastix-ovf/. This path we will give us destination to the OVF Tool to convert VMX VMDK to OVF VMDK. See the final and the most important step that actually performs the conversion.

The highlighted part is the command that converts the VMX VMDK to OVF format. See Figure 12 for the complete output including the command.

Finally we have a VMDK in OVF Format. We can upload this new VMDK to our Amazon Instance where we have the EC2 API setup. Uploading can be done either via winscp as mentioned in first section. However, this is a slow process because the VMDK file after compression is about 400M to 500M so I have uploaded it to a temporary file upload web site and then downloaded it via links which is a command line Linux browser. Note: wget does not work on these websites because the websites do not provide the direct link. The temporary file upload site is this. I selected specifically this fileconvoy website because at the time of download via links it does not require any captcha. The problem with captcha is that it is in the form of image which cannot be visible in links command line browser.

5 Creating a bucket to AMI temporarily while importing the VMDK

Before importing the image the final step is to create a bucket on S3. It is temporarily required and once the import complete you can delete that bucket. Bucket creation process is straight forward. Just go the S3 in Amazon AWS and click on the create bucket option, give name and thats all. You will have to provide that bucket name while importing the image.

6 Final Step to Import OVF VMDK to Amazon AMI

After uploading VMDK to Amazon EC2 API Instance. We can execute the following command to import our uploaded VMDK to Amazon AMI.

Now, we have successfully uploaded the imported VMDK to the Amazon AMI. you can login to Amazon AWS control panel, you can see the Amazon instance will be running in the specified Zone at the time of importing. To store this running instance in the form of AMI so more Instances can be created from this. The next step will be to stop the instance be right clicking on it. Secondly right click again on the stopped instance and select ”create AMI”. It will be created and you can go into the Amazon AMI image section on the Amazon EC2 section. You can see the AMI is there with the name you provided to it.