Feature #1048

EC2 driver Tags, Security Groups, VPC and Region support

Added by Patrice Lachance 5 months ago. Updated 3 months ago.

Status:Closed Start date:01/01/2012
Priority:Normal Due date:
Assignee:Daniel Molina % Done:

100%

Category:EC2
Target version:Release 3.4 - S0
Resolution:fixed
Story points-
Velocity based estimate-

Description

Hello

Please find attached a patch improving the EC2 driver to add support for Amazon Tags, Security Groups and VPC.
Is also allow to manage regions using a custom EC2REGION attribute defined on the hosts.

Tested with current master branch.
See this post on my blog for more details: http://www.itisopen.net/2012/01/Enhancing_OpenNebula_EC2_Driver/

Thanks again for your good work and Happy New Year!

Patrice

0001-Added-EC2-Regions-Security-Groups-VPC-ID-and-Tags-ma.patch - patch file (6.7 kB) Patrice Lachance, 01/01/2012 03:13 pm

0001-Added-EC2-Regions-Security-Groups-VPC-ID-Tags-and-Co.patch - New patch, including all previous changes (11 kB) Patrice Lachance, 01/03/2012 03:58 pm

Associated revisions

Revision b70a4e33
Added by Daniel Molina 3 months ago

feature #1048: Refactor one_vmm_ec2 and add suspend/reboot/resume support

Revision a4275202
Added by Daniel Molina 9 days ago

feature #1048: Remove exec_and_log_ec2 default params

History

Updated by Patrice Lachance 4 months ago

Hello

Please find attached a new release of the patch, adding more features and tested more deeply.
The documentation has been updated on my blog as well.

Patrice

Updated by Ruben S. Montero 4 months ago

  • Assignee set to Daniel Molina
  • Target version changed from Release 3.2 to Release 3.4 - S0
  • Resolution deleted (worksforme)

Hi Patrice

This is a wonderful contribution indeed :)

I am planning to include this contribution in the first sprint of next release, as now we are to close to the release....

Again thanks for this!

Updated by Daniel Molina 3 months ago

Hi Patrice,

First of all thanks for your great work as Ruben said this is a wonderful contribution.

I would like to comment some changes that I have done:

EC2 cmds

I have included a hash where you can define the different commands and the available options for those commands. Therefore adding new options will be easier. The key of the hash is the xpath where you can find the value provided by ONE, :opt will be the option that will be added to the command and you can optionally provide a block to process the string provided by one (:proc) if needed. You can set default values for all these options in the ec2conf file.

EC2REGION

You added a new EC2REGION attribute to the hosts to manage different regions. This functionality was supported by OpenNebula using different drivers and specifying the -u option in the arguments section, instead of updating the host with the EC2REGION attribute you define the vmm on creation. Since the region is defined per host I think it is better to use a different driver for each region, therefore the requests will be distributed among different processes. Also using this approach you do not need to request the host information to ONE for each request.
If you want to keep the EC2REGION approach I recommend you to use the OCA ruby binding to query the host instead of the OpenNebula CLI (onehost). BTW the command, query_cmd = "#{ONE_LOCATION}/bin/onehost show #{host}", will work in self-contained installation but in system-wide installations the onehost command is in "/usr/bin/onehost"

TAGS

In the TAGS argument you allow to define values using $ which are resolved based on the template information. Since this syntax differs from the one used in the CONTEXT section I have changed it to only support static keys and values. If we want to include this functionality I think that it should be included in the core as we currently do with the CONTEXT section. However if you need this functionality you can define the TAGS in the CONTEXT section instead of inside EC2. If you define the tags there you only have to change the key ''TAGS'' to ''../CONTEXT/TAGS'' and it should work, the variable will be resolved by the OpenNebula core.

        :tags => {
            :cmd => "#{EC2_LOCATION}/bin/ec2-create-tags",
            :args => {
                "../CONTEXT/TAGS" => {
                    :opt  => '-t',
                    :proc => lambda {|str| str.split(',').join(' -t ')}
                }
            }
        }

USERDATA and USERDATFILE

I have moved these variables inside the EC2 section, to keep all the arguments in the same section. You can change this in the hash:

                "../CONTEXT/USERDATA" => {
                    :opt => '-d'
                },
                "../CONTEXT/USERDATAFILE" => {
                    :opt => '-f'
                },

wait4instances

I have been trying the ELASTICIP association and I have no errors if I delete the wait4instance method. I have not included this method in the code but some comments: if the associate/describe command fails a deploy FAILURE is sent to ONE but the instance is not deleted from EC2. In the code I have uploaded if the associate command fails a log will be sent to ONE but the deploy will SUCCESS, as lon as the VM is running

NEW ACTIONS

I have included support for the following actions: suspend, resume and reboot

-

If you have any suggestion or comments on this do not hesitate to tell me.

Have you heart about the ec2 official ruby gem? Maybe it would be interesting to use this library instead of the ec2tools in future updates.
http://docs.amazonwebservices.com/AWSRubySDK/latest/frames.html

Cheers and thanks again for this contribution

Updated by Daniel Molina 3 months ago

Updated by Ruben S. Montero 3 months ago

  • Status changed from New to Closed
  • Resolution set to fixed

Also available in: Atom PDF