~~NOTOC~~
EC2 Driver Guide 1.4
# Max number of instances that can be launched into EC2
SMALL_INSTANCES=5
LARGE_INSTANCES=
EXTRALARGE_INSTANCES=
* ''$ONE_LOCATION/etc/vmm_ec2/vmm_ec2.conf'' : In this file we define default configurations for the VM placed in EC2, for example the "instancetype" attribute.
m1.small
* ''$ONE_LOCATION/etc/vmm_ec2/vmm_ec2rc'' : In this file we configure the account that will be used to launch instances on EC2, these are the environment variables needed by the EC2 API.
**Note:** If OpenNebula was installed in **system wide** mode these directories become ''/usr/lib/one/mads'' and ''/etc/one/'', respectively. The rest of this guide refers to the ''$ONE_LOCATION'' paths (corresponding to **self contained** mode) and omits the equivalent **system wide** locations. More information on installation modes can be found [[.:ignc#installation|here]].
====== Configuration ======
===== OpenNebula Configuration =====
Two lines must be added to the ''$ONE_LOCATION/etc/oned.conf'' file in order to use the driver.
IM_MAD = [
name = "im_ec2",
executable = "one_im_ec2",
arguments = "im_ec2/im_ec2.conf",
default = "im_ec2/im_ec2.conf" ]
VM_MAD = [
name = "vmm_ec2",
executable = "one_vmm_ec2",
arguments = " vmm_ec2/vmm_ec2.conf",
type = "xml" ]
where //
arguments = "-c /home/user/.ec2/ec2-cert.pem vmm_ec2/vmm_ec2.conf",
Make sure that the default configuration file (''vmm_ec2.conf'') is passed as the **last** argument.
After configuring everything when you start ONE, you need to add the ec2 host to the host list to be able to submit virtual machines, like the following:
EC2_HOME=""
EC2_PRIVATE_KEY=""
EC2_CERT=""
Also you must configure the maximum capacity that you want OpenNebula to deploy on the EC2, for this edit the file **$ONE_LOCATION/etc/im_ec2/im_ec2.conf** , in this example we say that we want at much 4 small and 1 large instances launched into EC2:
# Max number of instances that can be launched into EC2
SMALL_INSTANCES=4
LARGE_INSTANCES=1
EXTRALARGE_INSTANCES=
====== EC2 Specific Template Attributes ======
===== Mandatory Attributes =====
* **AMI**:the AMI name that will be launched
* **KEYPAIR**: This attribute indicates the rsa key-pair used to initiate the machines, the private keypair later will be used to execute commands like //ssh -i id_keypair// or //scp -i id_keypair//
===== Optional Attributes =====
* **ELASTICIP**: This is the elastic IP address you want to assign to the instance launched.
* **AUTHORIZED_PORTS**: this parameter is passed to the command //ec2-authorize default -p port//, and must be in the form of a number "22" or a range "22-90",
* **INSTANCETYPE**: this atribute indicates the type of instace to be launched in EC2, by default all instances will be "m1.small". Remember valid values for this are m1.small, m1.large, m1.xlarge, c1.medium, c1.xlarge.
====== Multi EC2 Site Support ======
From OpenNebula 1.4 onwards it is possible to define various EC2 sites to allow opennebula the managing of EC2 availability zones or even the use of various private clouds offering EC2 interfaces.
To properly configure multiple EC2 sites, you need to follow these steps:
* define one VMM driver for each EC2 site, like:
VM_MAD = [
name = "vmm_amazon_eu_west",
executable = "one_vmm_ec2",
arguments = "-u https://eu-west-1.ec2.amazonaws.com vmm_ec2/vmm_ec2.conf",
type = "xml" ]
* create a host that uses the MAD defined above. The EC2 site will be incarnated in this host for OpenNebula. We will use the EC2 IM driver, the ad-hoc defined VM mad and a dummy TM (all images for EC2 must have been uploaded previously on S3):
EC2 = [ CLOUD="ec2_eu_west",
AMI="ami-0022c769",
AUTHORIZED_PORTS="22" ]
EC2 = [ CLOUD="ec2_eu_east",
AMI="ami-03324cc9",
AUTHORIZED_PORTS="22" ]
If you create another EC2 host called //ec2_eu_east// then you will have //ami-0022c769// launched when this VM template is sent to host //ec2_eu_west// and //ami-03324cc9// whenever the VM template is sent to host //ec2_eu_east//.
CPU = 0.5
MEMORY = 128
#Xen or KVM template machine, this will be use when submitting this VM to local resources
OS = [kernel="/vmlinuz",initrd= "/initrd.img",root="sda1" ]
DISK = [source="/imges/apache.img",target="sda",readonly="no"]
NIC = [bridge="eth0"]
#EC2 template machine, this will be use wen submitting this VM to EC2
EC2 = [ AMI="ami-00bafcb5",
KEYPAIR="gsg-keypair",
ELASTICIP="75.101.155.97",
AUTHORIZED_PORTS="22",
INSTANCETYPE=m1.small]
#Add this if you want to use only EC2 cloud
#REQUIREMENTS = "HOSTNAME = ec2"
You only can submit and control the template using the OpenNebula interface: