ijin-right_aws 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +239 -0
- data/Manifest.txt +46 -0
- data/README.txt +167 -0
- data/Rakefile +125 -0
- data/VERSION +1 -0
- data/lib/acf/right_acf_interface.rb +413 -0
- data/lib/acw/right_acw_interface.rb +249 -0
- data/lib/as/right_as_interface.rb +690 -0
- data/lib/awsbase/benchmark_fix.rb +39 -0
- data/lib/awsbase/right_awsbase.rb +931 -0
- data/lib/awsbase/support.rb +115 -0
- data/lib/ec2/right_ec2.rb +617 -0
- data/lib/ec2/right_ec2_ebs.rb +451 -0
- data/lib/ec2/right_ec2_images.rb +373 -0
- data/lib/ec2/right_ec2_instances.rb +760 -0
- data/lib/ec2/right_ec2_monitoring.rb +70 -0
- data/lib/ec2/right_ec2_reserved_instances.rb +167 -0
- data/lib/ec2/right_ec2_vpc.rb +571 -0
- data/lib/elb/right_elb_interface.rb +407 -0
- data/lib/rds/right_rds_interface.rb +998 -0
- data/lib/right_aws.rb +79 -0
- data/lib/s3/right_s3.rb +1102 -0
- data/lib/s3/right_s3_interface.rb +1195 -0
- data/lib/sdb/active_sdb.rb +930 -0
- data/lib/sdb/right_sdb_interface.rb +672 -0
- data/lib/sqs/right_sqs.rb +388 -0
- data/lib/sqs/right_sqs_gen2.rb +343 -0
- data/lib/sqs/right_sqs_gen2_interface.rb +523 -0
- data/lib/sqs/right_sqs_interface.rb +594 -0
- data/test/acf/test_helper.rb +2 -0
- data/test/acf/test_right_acf.rb +146 -0
- data/test/awsbase/test_helper.rb +2 -0
- data/test/awsbase/test_right_awsbase.rb +12 -0
- data/test/ec2/test_helper.rb +2 -0
- data/test/ec2/test_right_ec2.rb +108 -0
- data/test/http_connection.rb +87 -0
- data/test/rds/test_helper.rb +2 -0
- data/test/rds/test_right_rds.rb +120 -0
- data/test/s3/test_helper.rb +2 -0
- data/test/s3/test_right_s3.rb +419 -0
- data/test/s3/test_right_s3_stubbed.rb +95 -0
- data/test/sdb/test_active_sdb.rb +299 -0
- data/test/sdb/test_helper.rb +3 -0
- data/test/sdb/test_right_sdb.rb +247 -0
- data/test/sqs/test_helper.rb +2 -0
- data/test/sqs/test_right_sqs.rb +291 -0
- data/test/sqs/test_right_sqs_gen2.rb +276 -0
- data/test/test_credentials.rb +37 -0
- data/test/ts_right_aws.rb +14 -0
- metadata +122 -0
| @@ -0,0 +1,70 @@ | |
| 1 | 
            +
            #
         | 
| 2 | 
            +
            # Copyright (c) 2009 RightScale Inc
         | 
| 3 | 
            +
            #
         | 
| 4 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining
         | 
| 5 | 
            +
            # a copy of this software and associated documentation files (the
         | 
| 6 | 
            +
            # "Software"), to deal in the Software without restriction, including
         | 
| 7 | 
            +
            # without limitation the rights to use, copy, modify, merge, publish,
         | 
| 8 | 
            +
            # distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 9 | 
            +
            # permit persons to whom the Software is furnished to do so, subject to
         | 
| 10 | 
            +
            # the following conditions:
         | 
| 11 | 
            +
            #
         | 
| 12 | 
            +
            # The above copyright notice and this permission notice shall be
         | 
| 13 | 
            +
            # included in all copies or substantial portions of the Software.
         | 
| 14 | 
            +
            #
         | 
| 15 | 
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 16 | 
            +
            # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 17 | 
            +
            # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 18 | 
            +
            # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 19 | 
            +
            # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 20 | 
            +
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 21 | 
            +
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 22 | 
            +
            #
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            module RightAws
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              class Ec2
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                # Enables monitoring for a running instances. For more information, refer to the Amazon CloudWatch Developer Guide.
         | 
| 29 | 
            +
                # 
         | 
| 30 | 
            +
                #  ec2.monitor_instances('i-8437ddec') #=>
         | 
| 31 | 
            +
                #    {:instance_id=>"i-8437ddec", :monitoring_state=>"pending"}
         | 
| 32 | 
            +
                #
         | 
| 33 | 
            +
                def monitor_instances(*list)
         | 
| 34 | 
            +
                  link = generate_request("MonitorInstances", amazonize_list('InstanceId', list.flatten) )
         | 
| 35 | 
            +
                  request_info(link, QEc2MonitorInstancesParser.new(:logger => @logger)).first
         | 
| 36 | 
            +
                rescue Exception
         | 
| 37 | 
            +
                  on_exception
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                # Disables monitoring for a running instances. For more information, refer to the Amazon CloudWatch Developer Guide.
         | 
| 41 | 
            +
                #
         | 
| 42 | 
            +
                #  ec2.unmonitor_instances('i-8437ddec') #=>
         | 
| 43 | 
            +
                #    {:instance_id=>"i-8437ddec", :monitoring_state=>"disabling"}
         | 
| 44 | 
            +
                #
         | 
| 45 | 
            +
                def unmonitor_instances(*list)
         | 
| 46 | 
            +
                  link = generate_request("UnmonitorInstances", amazonize_list('InstanceId', list.flatten) )
         | 
| 47 | 
            +
                  request_info(link, QEc2MonitorInstancesParser.new(:logger => @logger)).first
         | 
| 48 | 
            +
                rescue Exception
         | 
| 49 | 
            +
                  on_exception
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                class QEc2MonitorInstancesParser < RightAWSParser #:nodoc:
         | 
| 53 | 
            +
                  def tagstart(name, attributes)
         | 
| 54 | 
            +
                    @item = {} if name == 'item'
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                  def tagend(name)
         | 
| 57 | 
            +
                    case name
         | 
| 58 | 
            +
                    when 'instanceId'   then @item[:instance_id] = @text
         | 
| 59 | 
            +
                    when 'state'        then @item[:monitoring_state] = @text
         | 
| 60 | 
            +
                    when 'item'         then @result << @item
         | 
| 61 | 
            +
                    end
         | 
| 62 | 
            +
                  end
         | 
| 63 | 
            +
                  def reset
         | 
| 64 | 
            +
                    @result = []
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            end
         | 
| @@ -0,0 +1,167 @@ | |
| 1 | 
            +
            #
         | 
| 2 | 
            +
            # Copyright (c) 2009 RightScale Inc
         | 
| 3 | 
            +
            #
         | 
| 4 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining
         | 
| 5 | 
            +
            # a copy of this software and associated documentation files (the
         | 
| 6 | 
            +
            # "Software"), to deal in the Software without restriction, including
         | 
| 7 | 
            +
            # without limitation the rights to use, copy, modify, merge, publish,
         | 
| 8 | 
            +
            # distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 9 | 
            +
            # permit persons to whom the Software is furnished to do so, subject to
         | 
| 10 | 
            +
            # the following conditions:
         | 
| 11 | 
            +
            #
         | 
| 12 | 
            +
            # The above copyright notice and this permission notice shall be
         | 
| 13 | 
            +
            # included in all copies or substantial portions of the Software.
         | 
| 14 | 
            +
            #
         | 
| 15 | 
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 16 | 
            +
            # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 17 | 
            +
            # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 18 | 
            +
            # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 19 | 
            +
            # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 20 | 
            +
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 21 | 
            +
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 22 | 
            +
            #
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            module RightAws
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              class Ec2
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              #-----------------------------------------------------------------
         | 
| 29 | 
            +
              #      Reserved instances
         | 
| 30 | 
            +
              #-----------------------------------------------------------------
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                # Retrieve reserved instances list.
         | 
| 33 | 
            +
                # Returns a list of Reserved Instances.
         | 
| 34 | 
            +
                #
         | 
| 35 | 
            +
                # ec2.describe_reserved_instances #=>
         | 
| 36 | 
            +
                #    [{:aws_id=>"1ba8e2e3-1c40-434c-a741-5ff16a4c542e",
         | 
| 37 | 
            +
                #      :aws_duration=>31536000,
         | 
| 38 | 
            +
                #      :aws_instance_type=>"m1.small",
         | 
| 39 | 
            +
                #      :aws_usage_price=>0.03,
         | 
| 40 | 
            +
                #      :aws_availability_zone=>"us-east-1b",
         | 
| 41 | 
            +
                #      :aws_state=>"payment-pending",
         | 
| 42 | 
            +
                #      :aws_product_description=>"Test",
         | 
| 43 | 
            +
                #      :aws_fixed_price=>325.0,
         | 
| 44 | 
            +
                #      :aws_instance_count=>1}]
         | 
| 45 | 
            +
                #
         | 
| 46 | 
            +
                def describe_reserved_instances(list=[])
         | 
| 47 | 
            +
                  link = generate_request("DescribeReservedInstances", amazonize_list('ReservedInstancesId',list.to_a))
         | 
| 48 | 
            +
                  request_cache_or_info(:describe_reserved_instances, link,  QEc2DescribeReservedInstancesParser, @@bench, list.blank?)
         | 
| 49 | 
            +
                rescue Exception
         | 
| 50 | 
            +
                  on_exception
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                # Retrieve reserved instances offerings.
         | 
| 54 | 
            +
                # Returns a set of available offerings.
         | 
| 55 | 
            +
                #
         | 
| 56 | 
            +
                # Optional params:
         | 
| 57 | 
            +
                #  :aws_instance_type       => String
         | 
| 58 | 
            +
                #  :aws_availability_zone   => String
         | 
| 59 | 
            +
                #  :aws_product_description => String
         | 
| 60 | 
            +
                #
         | 
| 61 | 
            +
                #  ec2.describe_reserved_instances_offerings #=>
         | 
| 62 | 
            +
                #    [{:aws_instance_type=>"c1.medium",
         | 
| 63 | 
            +
                #      :aws_availability_zone=>"us-east-1c",
         | 
| 64 | 
            +
                #      :aws_duration=>94608000,
         | 
| 65 | 
            +
                #      :aws_product_description=>"Linux/UNIX",
         | 
| 66 | 
            +
                #      :aws_id=>"e5a2ff3b-f6eb-4b4e-83f8-b879d7060257",
         | 
| 67 | 
            +
                #      :aws_usage_price=>0.06,
         | 
| 68 | 
            +
                #      :aws_fixed_price=>1000.0},
         | 
| 69 | 
            +
                #      ...
         | 
| 70 | 
            +
                #     {:aws_instance_type=>"m1.xlarge",
         | 
| 71 | 
            +
                #      :aws_availability_zone=>"us-east-1a",
         | 
| 72 | 
            +
                #      :aws_duration=>31536000,
         | 
| 73 | 
            +
                #      :aws_product_description=>"Linux/UNIX",
         | 
| 74 | 
            +
                #      :aws_id=>"c48ab04c-63ab-4cd6-b8f5-978a29eb9bcc",
         | 
| 75 | 
            +
                #      :aws_usage_price=>0.24,
         | 
| 76 | 
            +
                #      :aws_fixed_price=>2600.0}]
         | 
| 77 | 
            +
                #
         | 
| 78 | 
            +
                def describe_reserved_instances_offerings(*list_and_params)
         | 
| 79 | 
            +
                  list, params = AwsUtils::split_items_and_params(list_and_params)
         | 
| 80 | 
            +
                  # backward compartibility with the old way
         | 
| 81 | 
            +
                  list ||= params[:aws_ids].to_a
         | 
| 82 | 
            +
                  rparams = {}
         | 
| 83 | 
            +
                  rparams.update(amazonize_list('ReservedInstancesOfferingId', list)) unless list.blank?
         | 
| 84 | 
            +
                  rparams['InstanceType']       = params[:aws_instance_type]       if params[:aws_instance_type]
         | 
| 85 | 
            +
                  rparams['AvailabilityZone']   = params[:aws_availability_zone]   if params[:aws_availability_zone]
         | 
| 86 | 
            +
                  rparams['ProductDescription'] = params[:aws_product_description] if params[:aws_product_description]
         | 
| 87 | 
            +
                  link = generate_request("DescribeReservedInstancesOfferings", rparams)
         | 
| 88 | 
            +
                  request_cache_or_info(:describe_reserved_instances_offerings, link,  QEc2DescribeReservedInstancesOfferingsParser, @@bench, list.blank?)
         | 
| 89 | 
            +
                rescue Exception
         | 
| 90 | 
            +
                  on_exception
         | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                # Purchase a Reserved Instance.
         | 
| 94 | 
            +
                # Returns ReservedInstancesId value.
         | 
| 95 | 
            +
                #
         | 
| 96 | 
            +
                #  ec2.purchase_reserved_instances_offering('e5a2ff3b-f6eb-4b4e-83f8-b879d7060257', 3) # => '4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8'
         | 
| 97 | 
            +
                #
         | 
| 98 | 
            +
                def purchase_reserved_instances_offering(reserved_instances_offering_id, instance_count=1)
         | 
| 99 | 
            +
                  link = generate_request("PurchaseReservedInstancesOffering", { 'ReservedInstancesOfferingId' => reserved_instances_offering_id,
         | 
| 100 | 
            +
                                                                                 'InstanceCount'               => instance_count  })
         | 
| 101 | 
            +
                  request_info(link, QEc2PurchaseReservedInstancesOfferingParser.new)
         | 
| 102 | 
            +
                rescue Exception
         | 
| 103 | 
            +
                  on_exception
         | 
| 104 | 
            +
                end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
              #-----------------------------------------------------------------
         | 
| 107 | 
            +
              #      PARSERS: ReservedInstances
         | 
| 108 | 
            +
              #-----------------------------------------------------------------
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                class QEc2DescribeReservedInstancesParser < RightAWSParser #:nodoc:
         | 
| 111 | 
            +
                  def tagstart(name, attributes)
         | 
| 112 | 
            +
                    @item = {} if name == 'item'
         | 
| 113 | 
            +
                  end
         | 
| 114 | 
            +
                  def tagend(name)
         | 
| 115 | 
            +
                    case name
         | 
| 116 | 
            +
                      when 'reservedInstancesId' then @item[:aws_id]                  = @text
         | 
| 117 | 
            +
                      when 'instanceType'        then @item[:aws_instance_type]       = @text
         | 
| 118 | 
            +
                      when 'availabilityZone'    then @item[:aws_availability_zone]   = @text
         | 
| 119 | 
            +
                      when 'duration'            then @item[:aws_duration]            = @text.to_i
         | 
| 120 | 
            +
                      when 'usagePrice'          then @item[:aws_usage_price]         = @text.to_f
         | 
| 121 | 
            +
                      when 'fixedPrice'          then @item[:aws_fixed_price]         = @text.to_f
         | 
| 122 | 
            +
                      when 'instanceCount'       then @item[:aws_instance_count]      = @text.to_i
         | 
| 123 | 
            +
                      when 'productDescription'  then @item[:aws_product_description] = @text
         | 
| 124 | 
            +
                      when 'state'               then @item[:aws_state]               = @text
         | 
| 125 | 
            +
                      when 'item'                then @result << @item
         | 
| 126 | 
            +
                    end
         | 
| 127 | 
            +
                  end
         | 
| 128 | 
            +
                  def reset
         | 
| 129 | 
            +
                    @result = []
         | 
| 130 | 
            +
                  end
         | 
| 131 | 
            +
                end
         | 
| 132 | 
            +
             | 
| 133 | 
            +
                class QEc2DescribeReservedInstancesOfferingsParser < RightAWSParser #:nodoc:
         | 
| 134 | 
            +
                  def tagstart(name, attributes)
         | 
| 135 | 
            +
                    @item = {} if name == 'item'
         | 
| 136 | 
            +
                  end
         | 
| 137 | 
            +
                  def tagend(name)
         | 
| 138 | 
            +
                    case name
         | 
| 139 | 
            +
                      when 'reservedInstancesOfferingId' then @item[:aws_id]                  = @text
         | 
| 140 | 
            +
                      when 'instanceType'                then @item[:aws_instance_type]       = @text
         | 
| 141 | 
            +
                      when 'availabilityZone'            then @item[:aws_availability_zone]   = @text
         | 
| 142 | 
            +
                      when 'duration'                    then @item[:aws_duration]            = @text.to_i
         | 
| 143 | 
            +
                      when 'usagePrice'                  then @item[:aws_usage_price]         = @text.to_f
         | 
| 144 | 
            +
                      when 'fixedPrice'                  then @item[:aws_fixed_price]         = @text.to_f
         | 
| 145 | 
            +
                      when 'productDescription'          then @item[:aws_product_description] = @text
         | 
| 146 | 
            +
                      when 'item'                        then @result << @item
         | 
| 147 | 
            +
                    end
         | 
| 148 | 
            +
                  end
         | 
| 149 | 
            +
                  def reset
         | 
| 150 | 
            +
                    @result = []
         | 
| 151 | 
            +
                  end
         | 
| 152 | 
            +
                end
         | 
| 153 | 
            +
             | 
| 154 | 
            +
                class QEc2PurchaseReservedInstancesOfferingParser < RightAWSParser #:nodoc:
         | 
| 155 | 
            +
                  def tagend(name)
         | 
| 156 | 
            +
                    if name == 'reservedInstancesId'
         | 
| 157 | 
            +
                      @result = @text
         | 
| 158 | 
            +
                    end
         | 
| 159 | 
            +
                  end
         | 
| 160 | 
            +
                  def reset
         | 
| 161 | 
            +
                    @result = ''
         | 
| 162 | 
            +
                  end
         | 
| 163 | 
            +
                end
         | 
| 164 | 
            +
             | 
| 165 | 
            +
              end
         | 
| 166 | 
            +
             | 
| 167 | 
            +
            end
         | 
| @@ -0,0 +1,571 @@ | |
| 1 | 
            +
            #
         | 
| 2 | 
            +
            # Copyright (c) 2009 RightScale Inc
         | 
| 3 | 
            +
            #
         | 
| 4 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining
         | 
| 5 | 
            +
            # a copy of this software and associated documentation files (the
         | 
| 6 | 
            +
            # "Software"), to deal in the Software without restriction, including
         | 
| 7 | 
            +
            # without limitation the rights to use, copy, modify, merge, publish,
         | 
| 8 | 
            +
            # distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 9 | 
            +
            # permit persons to whom the Software is furnished to do so, subject to
         | 
| 10 | 
            +
            # the following conditions:
         | 
| 11 | 
            +
            #
         | 
| 12 | 
            +
            # The above copyright notice and this permission notice shall be
         | 
| 13 | 
            +
            # included in all copies or substantial portions of the Software.
         | 
| 14 | 
            +
            #
         | 
| 15 | 
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 16 | 
            +
            # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 17 | 
            +
            # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 18 | 
            +
            # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 19 | 
            +
            # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 20 | 
            +
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 21 | 
            +
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 22 | 
            +
            #
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            module RightAws
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              class Ec2
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              private
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                def vpc__split_list_and_filters(params) # :nodoc:
         | 
| 31 | 
            +
                  params = params.to_a
         | 
| 32 | 
            +
                  filters = params.last.is_a?(Hash) ? params.pop : {}
         | 
| 33 | 
            +
                  # Make values to be arrays.
         | 
| 34 | 
            +
                  filters.each{|key, values| filters[key] = values.to_a }
         | 
| 35 | 
            +
                  [params, filters]
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              public
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                #-----------------
         | 
| 41 | 
            +
                # VPC
         | 
| 42 | 
            +
                #-----------------
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                # Describe VPCs
         | 
| 45 | 
            +
                #
         | 
| 46 | 
            +
                #  ec2.describe_vpcs #=>
         | 
| 47 | 
            +
                #    [{:vpc_id=>"vpc-890ce2e0",
         | 
| 48 | 
            +
                #      :dhcp_options_id=>"default",
         | 
| 49 | 
            +
                #      :cidr_block=>"10.0.0.0/23",
         | 
| 50 | 
            +
                #      :state=>"available"}]
         | 
| 51 | 
            +
                #
         | 
| 52 | 
            +
                #  ec2.describe_vpcs("vpc-890ce2e0")
         | 
| 53 | 
            +
                #
         | 
| 54 | 
            +
                def describe_vpcs(*list_and_filters)
         | 
| 55 | 
            +
                  list, filters = vpc__split_list_and_filters(list_and_filters)
         | 
| 56 | 
            +
                  cache_for = (list.empty? && filters.empty?) ? :describe_vpcs : nil
         | 
| 57 | 
            +
                  request_hash = {}
         | 
| 58 | 
            +
                  request_hash.merge!(amazonize_list('VpcId', list))
         | 
| 59 | 
            +
                  request_hash.merge!(amazonize_list(['Filter.?.Key','Filter.?.Value.?'], filters))
         | 
| 60 | 
            +
                  link = generate_request("DescribeVpcs", request_hash)
         | 
| 61 | 
            +
                  request_cache_or_info cache_for, link,  QEc2DescribeVpcsParser, @@bench, cache_for
         | 
| 62 | 
            +
                rescue Exception
         | 
| 63 | 
            +
                  on_exception
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                # Create VPC.
         | 
| 67 | 
            +
                #
         | 
| 68 | 
            +
                #  ec2.create_vpc('10.0.0.0/23') #=>
         | 
| 69 | 
            +
                #    {:vpc_id=>"vpc-890ce2e0",
         | 
| 70 | 
            +
                #     :dhcp_options_id=>"default",
         | 
| 71 | 
            +
                #     :cidr_block=>"10.0.0.0/23",
         | 
| 72 | 
            +
                #     :state=>"pending"}
         | 
| 73 | 
            +
                #
         | 
| 74 | 
            +
                def create_vpc(cidr_block)
         | 
| 75 | 
            +
                  link = generate_request("CreateVpc",'CidrBlock' => cidr_block )
         | 
| 76 | 
            +
                  request_info(link, QEc2DescribeVpcsParser.new(:logger => @logger)).first
         | 
| 77 | 
            +
                rescue Exception
         | 
| 78 | 
            +
                  on_exception
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                # Delete VPC.
         | 
| 82 | 
            +
                #
         | 
| 83 | 
            +
                #  ec2.delete_vpc("vpc-890ce2e0") #=> true
         | 
| 84 | 
            +
                #
         | 
| 85 | 
            +
                def delete_vpc(vpc_id)
         | 
| 86 | 
            +
                  link = generate_request("DeleteVpc", 'VpcId' => vpc_id )
         | 
| 87 | 
            +
                  request_info(link, RightHttp2xxParser.new(:logger => @logger))
         | 
| 88 | 
            +
                rescue Exception
         | 
| 89 | 
            +
                  on_exception
         | 
| 90 | 
            +
                end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                #-----------------
         | 
| 93 | 
            +
                # Subnets
         | 
| 94 | 
            +
                #-----------------
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                # Describe Subnet.
         | 
| 97 | 
            +
                #
         | 
| 98 | 
            +
                #  ec2.describe_subnets #=>
         | 
| 99 | 
            +
                #    [{:available_ip_address_count=>"251",
         | 
| 100 | 
            +
                #      :vpc_id=>"vpc-890ce2e0",
         | 
| 101 | 
            +
                #      :availability_zone=>"us-east-1a",
         | 
| 102 | 
            +
                #      :subnet_id=>"subnet-770de31e",
         | 
| 103 | 
            +
                #      :cidr_block=>"10.0.1.0/24",
         | 
| 104 | 
            +
                #      :state=>"available"}]
         | 
| 105 | 
            +
                #
         | 
| 106 | 
            +
                def describe_subnets(*list_and_filters)
         | 
| 107 | 
            +
                  list, filters = vpc__split_list_and_filters(list_and_filters)
         | 
| 108 | 
            +
                  cache_for = (list.empty? && filters.empty?) ? :describe_subnets : nil
         | 
| 109 | 
            +
                  request_hash = {}
         | 
| 110 | 
            +
                  request_hash.merge!(amazonize_list('SubnetId', list))
         | 
| 111 | 
            +
                  request_hash.merge!(amazonize_list(['Filter.?.Key','Filter.?.Value.?'], filters))
         | 
| 112 | 
            +
                  link = generate_request("DescribeSubnets", request_hash)
         | 
| 113 | 
            +
                  request_cache_or_info cache_for, link,  QEc2DescribeSubnetsParser, @@bench, cache_for
         | 
| 114 | 
            +
                rescue Exception
         | 
| 115 | 
            +
                  on_exception
         | 
| 116 | 
            +
                end
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                # Create Subnet.
         | 
| 119 | 
            +
                #
         | 
| 120 | 
            +
                #  ec2.create_subnet("vpc-890ce2e0",'10.0.1.0/24') #=>
         | 
| 121 | 
            +
                #    {:available_ip_address_count=>"251",
         | 
| 122 | 
            +
                #     :vpc_id=>"vpc-890ce2e0",
         | 
| 123 | 
            +
                #     :availability_zone=>"us-east-1a",
         | 
| 124 | 
            +
                #     :subnet_id=>"subnet-770de31e",
         | 
| 125 | 
            +
                #     :cidr_block=>"10.0.1.0/24",
         | 
| 126 | 
            +
                #     :state=>"pending"}
         | 
| 127 | 
            +
                #
         | 
| 128 | 
            +
                def create_subnet(vpc_id, cidr_block, availability_zone = nil)
         | 
| 129 | 
            +
                  request_hash = { 'VpcId'     => vpc_id,
         | 
| 130 | 
            +
                                   'CidrBlock' => cidr_block }
         | 
| 131 | 
            +
                  request_hash['AvailabilityZone'] = availability_zone unless availability_zone.blank?
         | 
| 132 | 
            +
                  link = generate_request("CreateSubnet", request_hash)
         | 
| 133 | 
            +
                  request_info(link, QEc2DescribeSubnetsParser.new(:logger => @logger)).first
         | 
| 134 | 
            +
                rescue Exception
         | 
| 135 | 
            +
                  on_exception
         | 
| 136 | 
            +
                end
         | 
| 137 | 
            +
             | 
| 138 | 
            +
                # Delete Subnet.
         | 
| 139 | 
            +
                #
         | 
| 140 | 
            +
                #  ec2.delete_subnet("subnet-770de31e") #=> true
         | 
| 141 | 
            +
                #
         | 
| 142 | 
            +
                def delete_subnet(subnet_id)
         | 
| 143 | 
            +
                  link = generate_request("DeleteSubnet", 'SubnetId' => subnet_id )
         | 
| 144 | 
            +
                  request_info(link, RightHttp2xxParser.new(:logger => @logger))
         | 
| 145 | 
            +
                rescue Exception
         | 
| 146 | 
            +
                  on_exception
         | 
| 147 | 
            +
                end
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                #-----------------
         | 
| 150 | 
            +
                # DHCP Options
         | 
| 151 | 
            +
                #-----------------
         | 
| 152 | 
            +
             | 
| 153 | 
            +
                # Describe DHCP options.
         | 
| 154 | 
            +
                # 
         | 
| 155 | 
            +
                # ec2.describe_dhcp_options #=>
         | 
| 156 | 
            +
                #    [{:dhcp_options_id=>"dopt-cb0de3a2",
         | 
| 157 | 
            +
                #    :dhcp_configuration_set=>
         | 
| 158 | 
            +
                #     {"netbios-node-type"=>["1"], "domain-name"=>["my.awesomesite.ru"]}}]
         | 
| 159 | 
            +
                #
         | 
| 160 | 
            +
                def describe_dhcp_options(*list)
         | 
| 161 | 
            +
                  list = list.flatten
         | 
| 162 | 
            +
                  cache_for = list.empty? ? :describe_dhcp_options : nil
         | 
| 163 | 
            +
                  request_hash = amazonize_list('DhcpOptionsId', list)
         | 
| 164 | 
            +
                  link = generate_request("DescribeDhcpOptions", request_hash)
         | 
| 165 | 
            +
                  request_cache_or_info cache_for, link,  QEc2DescribeDhcpOptionsParser, @@bench, cache_for
         | 
| 166 | 
            +
                rescue Exception
         | 
| 167 | 
            +
                  on_exception
         | 
| 168 | 
            +
                end
         | 
| 169 | 
            +
             | 
| 170 | 
            +
                # Create DHCP options.
         | 
| 171 | 
            +
                #
         | 
| 172 | 
            +
                #  ec2.create_dhcp_options('domain-name' => 'my.awesomesite.ru',
         | 
| 173 | 
            +
                #                          'netbios-node-type' => 1) #=>
         | 
| 174 | 
            +
                #    {:dhcp_options_id=>"dopt-cb0de3a2",
         | 
| 175 | 
            +
                #     :dhcp_configuration_set=>
         | 
| 176 | 
            +
                #      {"netbios-node-type"=>["1"], "domain-name"=>["my.awesomesite.ru"]}}
         | 
| 177 | 
            +
                #
         | 
| 178 | 
            +
                def create_dhcp_options(dhcp_configuration)
         | 
| 179 | 
            +
                  dhcp_configuration.each{ |key, values| dhcp_configuration[key] = values.to_a }
         | 
| 180 | 
            +
                  request_hash = amazonize_list(['DhcpConfiguration.?.Key','DhcpConfiguration.?.Value.?'], dhcp_configuration)
         | 
| 181 | 
            +
                  link = generate_request("CreateDhcpOptions", request_hash)
         | 
| 182 | 
            +
                  request_info(link, QEc2DescribeDhcpOptionsParser.new(:logger => @logger)).first
         | 
| 183 | 
            +
                rescue Exception
         | 
| 184 | 
            +
                  on_exception
         | 
| 185 | 
            +
                end
         | 
| 186 | 
            +
             | 
| 187 | 
            +
                # Associate DHCP options
         | 
| 188 | 
            +
                #
         | 
| 189 | 
            +
                # ec2.associate_dhcp_options("dopt-cb0de3a2", "vpc-890ce2e0" ) #=> true
         | 
| 190 | 
            +
                # ec2.describe_vpcs #=>
         | 
| 191 | 
            +
                #    [{:vpc_id=>"vpc-890ce2e0",
         | 
| 192 | 
            +
                #      :dhcp_options_id=>"dopt-cb0de3a2",
         | 
| 193 | 
            +
                #      :cidr_block=>"10.0.0.0/23",
         | 
| 194 | 
            +
                #      :state=>"available"}]
         | 
| 195 | 
            +
                #
         | 
| 196 | 
            +
                def associate_dhcp_options(dhcp_options_id, vpc_id)
         | 
| 197 | 
            +
                  link = generate_request("AssociateDhcpOptions", 'DhcpOptionsId' => dhcp_options_id,
         | 
| 198 | 
            +
                                                                  'VpcId'         => vpc_id)
         | 
| 199 | 
            +
                  request_info(link, RightHttp2xxParser.new(:logger => @logger))
         | 
| 200 | 
            +
                rescue Exception
         | 
| 201 | 
            +
                  on_exception
         | 
| 202 | 
            +
                end
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                # Delete DHCP Options.
         | 
| 205 | 
            +
                #
         | 
| 206 | 
            +
                #  ec2.delete_dhcp_options("dopt-cb0de3a2") #=> true
         | 
| 207 | 
            +
                #
         | 
| 208 | 
            +
                def delete_dhcp_options(dhcp_options_id)
         | 
| 209 | 
            +
                  link = generate_request("DeleteDhcpOptions", 'DhcpOptionsId' => dhcp_options_id )
         | 
| 210 | 
            +
                  request_info(link, RightHttp2xxParser.new(:logger => @logger))
         | 
| 211 | 
            +
                rescue Exception
         | 
| 212 | 
            +
                  on_exception
         | 
| 213 | 
            +
                end
         | 
| 214 | 
            +
             | 
| 215 | 
            +
                #-----------------
         | 
| 216 | 
            +
                # Customer Gateways
         | 
| 217 | 
            +
                #-----------------
         | 
| 218 | 
            +
             | 
| 219 | 
            +
                # Describe customer gateways.
         | 
| 220 | 
            +
                #
         | 
| 221 | 
            +
                #  ec2.describe_customer_gateways
         | 
| 222 | 
            +
                #
         | 
| 223 | 
            +
                #    [{:type=>"ipsec.1",
         | 
| 224 | 
            +
                #      :ip_address=>"12.1.2.3",
         | 
| 225 | 
            +
                #      :bgp_asn=>"65534",
         | 
| 226 | 
            +
                #      :state=>"available",
         | 
| 227 | 
            +
                #      :customer_gateway_id=>"cgw-d5a643bc"}]
         | 
| 228 | 
            +
                #
         | 
| 229 | 
            +
                def describe_customer_gateways(*list_and_filters)
         | 
| 230 | 
            +
                  list, filters = vpc__split_list_and_filters(list_and_filters)
         | 
| 231 | 
            +
                  cache_for = (list.empty? && filters.empty?) ? :describe_customer_gateways : nil
         | 
| 232 | 
            +
                  request_hash = {}
         | 
| 233 | 
            +
                  request_hash.merge!(amazonize_list('CustomerGatewayId', list))
         | 
| 234 | 
            +
                  request_hash.merge!(amazonize_list(['Filter.?.Key','Filter.?.Value.?'], filters))
         | 
| 235 | 
            +
                  link = generate_request("DescribeCustomerGateways", request_hash)
         | 
| 236 | 
            +
                  request_cache_or_info cache_for, link,  QEc2DescribeCustomerGatewaysParser, @@bench, cache_for
         | 
| 237 | 
            +
                rescue Exception
         | 
| 238 | 
            +
                  on_exception
         | 
| 239 | 
            +
                end
         | 
| 240 | 
            +
             | 
| 241 | 
            +
                # Create customer gateway.
         | 
| 242 | 
            +
                # 
         | 
| 243 | 
            +
                #  ec2.create_customer_gateway('ipsec.1', '12.1.2.3', 65534) #=>
         | 
| 244 | 
            +
                #    {:type=>"ipsec.1",
         | 
| 245 | 
            +
                #     :bgp_asn=>"65534",
         | 
| 246 | 
            +
                #     :ip_address=>"12.1.2.3",
         | 
| 247 | 
            +
                #     :state=>"pending",
         | 
| 248 | 
            +
                #     :customer_gateway_id=>"cgw-d5a643bc"}
         | 
| 249 | 
            +
                #
         | 
| 250 | 
            +
                def create_customer_gateway(type, ip_address, bgp_asn)
         | 
| 251 | 
            +
                  link = generate_request("CreateCustomerGateway", 'Type'      => type,
         | 
| 252 | 
            +
                                                                   'IpAddress' => ip_address,
         | 
| 253 | 
            +
                                                                   'BgpAsn'    => bgp_asn )
         | 
| 254 | 
            +
                  request_info(link, QEc2DescribeCustomerGatewaysParser.new(:logger => @logger)).first
         | 
| 255 | 
            +
                rescue Exception
         | 
| 256 | 
            +
                  on_exception
         | 
| 257 | 
            +
                end
         | 
| 258 | 
            +
             | 
| 259 | 
            +
                # Delete customer gateway.
         | 
| 260 | 
            +
                #
         | 
| 261 | 
            +
                #  ec2.delete_customer_gateway("cgw-d5a643bc") #=> true
         | 
| 262 | 
            +
                #
         | 
| 263 | 
            +
                def delete_customer_gateway(customer_gateway_id)
         | 
| 264 | 
            +
                  link = generate_request("DeleteCustomerGateway", 'CustomerGatewayId' => customer_gateway_id )
         | 
| 265 | 
            +
                  request_info(link, RightHttp2xxParser.new(:logger => @logger))
         | 
| 266 | 
            +
                rescue Exception
         | 
| 267 | 
            +
                  on_exception
         | 
| 268 | 
            +
                end
         | 
| 269 | 
            +
             | 
| 270 | 
            +
                #-----------------
         | 
| 271 | 
            +
                # VPN Gateways
         | 
| 272 | 
            +
                #-----------------
         | 
| 273 | 
            +
             | 
| 274 | 
            +
                # Describe VPN gateways.
         | 
| 275 | 
            +
                #
         | 
| 276 | 
            +
                #  ec2.describe_vpn_gateways #=>
         | 
| 277 | 
            +
                #    [{:type=>"ipsec.1",
         | 
| 278 | 
            +
                #      :availability_zone=>"us-east-1a",
         | 
| 279 | 
            +
                #      :attachments=>[{:vpc_id=>"vpc-890ce2e0", :state=>"attached"}],
         | 
| 280 | 
            +
                #      :vpn_gateway_id=>"vgw-dfa144b6"}]
         | 
| 281 | 
            +
                #
         | 
| 282 | 
            +
                def describe_vpn_gateways(*list_and_filters)
         | 
| 283 | 
            +
                  list, filters = vpc__split_list_and_filters(list_and_filters)
         | 
| 284 | 
            +
                  cache_for = (list.empty? && filters.empty?) ? :describe_vpn_gateways : nil
         | 
| 285 | 
            +
                  request_hash = {}
         | 
| 286 | 
            +
                  request_hash.merge!(amazonize_list('VpnGatewayId', list))
         | 
| 287 | 
            +
                  request_hash.merge!(amazonize_list(['Filter.?.Key','Filter.?.Value.?'], filters))
         | 
| 288 | 
            +
                  link = generate_request("DescribeVpnGateways", request_hash)
         | 
| 289 | 
            +
                  request_cache_or_info cache_for, link,  QEc2DescribeVpnGatewaysParser, @@bench, cache_for
         | 
| 290 | 
            +
                rescue Exception
         | 
| 291 | 
            +
                  on_exception
         | 
| 292 | 
            +
                end
         | 
| 293 | 
            +
             | 
| 294 | 
            +
                # Create VPN gateway.
         | 
| 295 | 
            +
                #
         | 
| 296 | 
            +
                #  ec2.create_vpn_gateway('ipsec.1') #=>
         | 
| 297 | 
            +
                #    {:type=>"ipsec.1",
         | 
| 298 | 
            +
                #     :availability_zone=>"us-east-1a",
         | 
| 299 | 
            +
                #     :attachments=>[nil],
         | 
| 300 | 
            +
                #     :vpn_gateway_id=>"vgw-dfa144b6"}
         | 
| 301 | 
            +
                #
         | 
| 302 | 
            +
                def create_vpn_gateway(type, availability_zone=nil)
         | 
| 303 | 
            +
                  request_hash = { 'Type' => type }
         | 
| 304 | 
            +
                  request_hash['AvailabilityZone'] = availability_zone unless availability_zone.blank?
         | 
| 305 | 
            +
                  link = generate_request("CreateVpnGateway", request_hash )
         | 
| 306 | 
            +
                  request_info(link, QEc2DescribeVpnGatewaysParser.new(:logger => @logger)).first
         | 
| 307 | 
            +
                rescue Exception
         | 
| 308 | 
            +
                  on_exception
         | 
| 309 | 
            +
                end
         | 
| 310 | 
            +
             | 
| 311 | 
            +
                # Attach VPN gateway.
         | 
| 312 | 
            +
                #
         | 
| 313 | 
            +
                #  ec2.attach_vpn_gateway('vgw-dfa144b6','vpc-890ce2e0') #=>
         | 
| 314 | 
            +
                #     {:vpc_id=>"vpc-890ce2e0", :state=>"attaching"}
         | 
| 315 | 
            +
                #
         | 
| 316 | 
            +
                def attach_vpn_gateway(vpn_gateway_id, vpc_id)
         | 
| 317 | 
            +
                  link = generate_request("AttachVpnGateway", 'VpnGatewayId' => vpn_gateway_id,
         | 
| 318 | 
            +
                                                              'VpcId'        => vpc_id )
         | 
| 319 | 
            +
                  request_info(link, QEc2AttachVpnGatewayParser.new(:logger => @logger))
         | 
| 320 | 
            +
                rescue Exception
         | 
| 321 | 
            +
                  on_exception
         | 
| 322 | 
            +
                end
         | 
| 323 | 
            +
             | 
| 324 | 
            +
                # Detach VPN gateway.
         | 
| 325 | 
            +
                #
         | 
| 326 | 
            +
                #  ec2.detach_vpn_gateway('vgw-dfa144b6','vpc-890ce2e0') #=> true
         | 
| 327 | 
            +
                #
         | 
| 328 | 
            +
                def detach_vpn_gateway(vpn_gateway_id, vpc_id)
         | 
| 329 | 
            +
                  link = generate_request("DetachVpnGateway", 'VpnGatewayId' => vpn_gateway_id,
         | 
| 330 | 
            +
                                                              'VpcId'        => vpc_id )
         | 
| 331 | 
            +
                  request_info(link, RightHttp2xxParser.new(:logger => @logger))
         | 
| 332 | 
            +
                rescue Exception
         | 
| 333 | 
            +
                  on_exception
         | 
| 334 | 
            +
                end
         | 
| 335 | 
            +
             | 
| 336 | 
            +
                # Delete vpn gateway.
         | 
| 337 | 
            +
                #
         | 
| 338 | 
            +
                #  ec2.delete_vpn_gateway("vgw-dfa144b6") #=> true
         | 
| 339 | 
            +
                #
         | 
| 340 | 
            +
                def delete_vpn_gateway(vpn_gateway_id)
         | 
| 341 | 
            +
                  link = generate_request("DeleteVpnGateway", 'VpnGatewayId' => vpn_gateway_id )
         | 
| 342 | 
            +
                  request_info(link, RightHttp2xxParser.new(:logger => @logger))
         | 
| 343 | 
            +
                rescue Exception
         | 
| 344 | 
            +
                  on_exception
         | 
| 345 | 
            +
                end
         | 
| 346 | 
            +
             | 
| 347 | 
            +
                #-----------------
         | 
| 348 | 
            +
                # VPN Connections
         | 
| 349 | 
            +
                #-----------------
         | 
| 350 | 
            +
             | 
| 351 | 
            +
                # Describe VPN connections.
         | 
| 352 | 
            +
                #
         | 
| 353 | 
            +
                #  ec2.describe_vpn_connections #=>
         | 
| 354 | 
            +
                #    [{:type=>"ipsec.1",
         | 
| 355 | 
            +
                #      :vpn_connection_id=>"vpn-a9a643c0",
         | 
| 356 | 
            +
                #      :customer_gateway_configuration=>
         | 
| 357 | 
            +
                #       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vpn_connection id=\"vpn-a9a643c0\">\n...</vpn_connection>\n",
         | 
| 358 | 
            +
                #      :state=>"available",
         | 
| 359 | 
            +
                #      :vpn_gateway_id=>"vgw-dfa144b6",
         | 
| 360 | 
            +
                #      :customer_gateway_id=>"cgw-81a643e8"}]
         | 
| 361 | 
            +
                #
         | 
| 362 | 
            +
                def describe_vpn_connections(*list_and_filters)
         | 
| 363 | 
            +
                  list, filters = vpc__split_list_and_filters(list_and_filters)
         | 
| 364 | 
            +
                  cache_for = (list.empty? && filters.empty?) ? :describe_vpn_connections : nil
         | 
| 365 | 
            +
                  request_hash = {}
         | 
| 366 | 
            +
                  request_hash.merge!(amazonize_list('VpnConnectionId', list))
         | 
| 367 | 
            +
                  request_hash.merge!(amazonize_list(['Filter.?.Key','Filter.?.Value.?'], filters))
         | 
| 368 | 
            +
                  link = generate_request("DescribeVpnConnections", request_hash)
         | 
| 369 | 
            +
                  request_cache_or_info cache_for, link,  QEc2DescribeVpnConnectionsParser, @@bench, cache_for
         | 
| 370 | 
            +
                rescue Exception
         | 
| 371 | 
            +
                  on_exception
         | 
| 372 | 
            +
                end
         | 
| 373 | 
            +
             | 
| 374 | 
            +
                # Create VPN connection.
         | 
| 375 | 
            +
                #
         | 
| 376 | 
            +
                #  ec2.create_vpn_connection('ipsec.1', 'cgw-81a643e8' ,'vgw-dfa144b6')
         | 
| 377 | 
            +
                #    {:customer_gateway_id=>"cgw-81a643e8",
         | 
| 378 | 
            +
                #     :vpn_connection_id=>"vpn-a9a643c0",
         | 
| 379 | 
            +
                #     :customer_gateway_configuration=>
         | 
| 380 | 
            +
                #      "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vpn_connection id=\"vpn-a9a643c0\">\n...</vpn_connection>\n",
         | 
| 381 | 
            +
                #     :state=>"pending",
         | 
| 382 | 
            +
                #     :vpn_gateway_id=>"vgw-dfa144b6"}
         | 
| 383 | 
            +
                #
         | 
| 384 | 
            +
                def create_vpn_connection(type, customer_gateway_id, vpn_gateway_id)
         | 
| 385 | 
            +
                  link = generate_request("CreateVpnConnection", 'Type'              => type,
         | 
| 386 | 
            +
                                                                 'CustomerGatewayId' => customer_gateway_id,
         | 
| 387 | 
            +
                                                                 'VpnGatewayId'      => vpn_gateway_id )
         | 
| 388 | 
            +
                  request_info(link, QEc2DescribeVpnConnectionsParser.new(:logger => @logger)).first
         | 
| 389 | 
            +
                rescue Exception
         | 
| 390 | 
            +
                  on_exception
         | 
| 391 | 
            +
                end
         | 
| 392 | 
            +
             | 
| 393 | 
            +
                # Delete VPN connection.
         | 
| 394 | 
            +
                #
         | 
| 395 | 
            +
                #  ec2.delete_vpn_connection("vpn-a9a643c0") #=> true
         | 
| 396 | 
            +
                #
         | 
| 397 | 
            +
                def delete_vpn_connection(vpn_connection_id)
         | 
| 398 | 
            +
                  link = generate_request("DeleteVpnConnection", 'VpnConnectionId' => vpn_connection_id )
         | 
| 399 | 
            +
                  request_info(link, RightHttp2xxParser.new(:logger => @logger))
         | 
| 400 | 
            +
                rescue Exception
         | 
| 401 | 
            +
                  on_exception
         | 
| 402 | 
            +
                end
         | 
| 403 | 
            +
             | 
| 404 | 
            +
                #-----------------
         | 
| 405 | 
            +
                # Parsers
         | 
| 406 | 
            +
                #-----------------
         | 
| 407 | 
            +
             | 
| 408 | 
            +
                class QEc2DescribeVpcsParser < RightAWSParser #:nodoc:
         | 
| 409 | 
            +
                  def tagstart(name, attributes)
         | 
| 410 | 
            +
                    case name
         | 
| 411 | 
            +
                    when 'item', 'vpc' then @item = {}
         | 
| 412 | 
            +
                    end
         | 
| 413 | 
            +
                  end
         | 
| 414 | 
            +
                  def tagend(name)
         | 
| 415 | 
            +
                    case name
         | 
| 416 | 
            +
                      when 'vpcId'         then @item[:vpc_id] = @text
         | 
| 417 | 
            +
                      when 'state'         then @item[:state] = @text
         | 
| 418 | 
            +
                      when 'dhcpOptionsId' then @item[:dhcp_options_id] = @text
         | 
| 419 | 
            +
                      when 'cidrBlock'     then @item[:cidr_block] = @text
         | 
| 420 | 
            +
                      when 'item', 'vpc'   then @result << @item
         | 
| 421 | 
            +
                    end
         | 
| 422 | 
            +
                  end
         | 
| 423 | 
            +
                  def reset
         | 
| 424 | 
            +
                    @result = []
         | 
| 425 | 
            +
                  end
         | 
| 426 | 
            +
                end
         | 
| 427 | 
            +
             | 
| 428 | 
            +
                class QEc2DescribeSubnetsParser < RightAWSParser #:nodoc:
         | 
| 429 | 
            +
                  def tagstart(name, attributes)
         | 
| 430 | 
            +
                    case name
         | 
| 431 | 
            +
                    when 'item', 'subnet' then @item = {}
         | 
| 432 | 
            +
                    end
         | 
| 433 | 
            +
                  end
         | 
| 434 | 
            +
                  def tagend(name)
         | 
| 435 | 
            +
                    case name
         | 
| 436 | 
            +
                      when 'subnetId'                then @item[:subnet_id] = @text
         | 
| 437 | 
            +
                      when 'state'                   then @item[:state] = @text
         | 
| 438 | 
            +
                      when 'vpcId'                   then @item[:vpc_id] = @text
         | 
| 439 | 
            +
                      when 'cidrBlock'               then @item[:cidr_block] = @text
         | 
| 440 | 
            +
                      when 'availabilityZone'        then @item[:availability_zone] = @text
         | 
| 441 | 
            +
                      when 'availableIpAddressCount' then @item[:available_ip_address_count] = @text
         | 
| 442 | 
            +
                      when 'item', 'subnet'          then @result << @item
         | 
| 443 | 
            +
                    end
         | 
| 444 | 
            +
                  end
         | 
| 445 | 
            +
                  def reset
         | 
| 446 | 
            +
                    @result = []
         | 
| 447 | 
            +
                  end
         | 
| 448 | 
            +
                end
         | 
| 449 | 
            +
             | 
| 450 | 
            +
                class QEc2DescribeDhcpOptionsParser < RightAWSParser #:nodoc:
         | 
| 451 | 
            +
                  def tagstart(name, attributes)
         | 
| 452 | 
            +
                    case full_tag_name
         | 
| 453 | 
            +
                    when @p1, @p2
         | 
| 454 | 
            +
                      @item = { :dhcp_configuration_set => {} }
         | 
| 455 | 
            +
                    end
         | 
| 456 | 
            +
                  end
         | 
| 457 | 
            +
                  def tagend(name)
         | 
| 458 | 
            +
                    case name
         | 
| 459 | 
            +
                    when 'dhcpOptionsId' then @item[:dhcp_options_id] = @text
         | 
| 460 | 
            +
                    when 'key'           then @conf_item_key = @text
         | 
| 461 | 
            +
                    when 'value'         then (@item[:dhcp_configuration_set][@conf_item_key] ||= []) << @text
         | 
| 462 | 
            +
                    end
         | 
| 463 | 
            +
                    case full_tag_name
         | 
| 464 | 
            +
                    when @p1, @p2
         | 
| 465 | 
            +
                      @result << @item
         | 
| 466 | 
            +
                    end
         | 
| 467 | 
            +
                  end
         | 
| 468 | 
            +
                  def reset
         | 
| 469 | 
            +
                    @p1 = 'DescribeDhcpOptionsResponse/dhcpOptionsSet/item'
         | 
| 470 | 
            +
                    @p2 = 'CreateDhcpOptionsResponse/dhcpOptions'
         | 
| 471 | 
            +
                    @result = []
         | 
| 472 | 
            +
                  end
         | 
| 473 | 
            +
                end
         | 
| 474 | 
            +
             | 
| 475 | 
            +
                class QEc2DescribeCustomerGatewaysParser < RightAWSParser #:nodoc:
         | 
| 476 | 
            +
                  def tagstart(name, attributes)
         | 
| 477 | 
            +
                    case name
         | 
| 478 | 
            +
                    when 'item', 'customerGateway'
         | 
| 479 | 
            +
                      @item = {}
         | 
| 480 | 
            +
                    end
         | 
| 481 | 
            +
                  end
         | 
| 482 | 
            +
                  def tagend(name)
         | 
| 483 | 
            +
                    case name
         | 
| 484 | 
            +
                    when 'customerGatewayId' then @item[:customer_gateway_id] = @text
         | 
| 485 | 
            +
                    when 'state'             then @item[:state] = @text
         | 
| 486 | 
            +
                    when 'type'              then @item[:type] = @text
         | 
| 487 | 
            +
                    when 'ipAddress'         then @item[:ip_address] = @text
         | 
| 488 | 
            +
                    when 'bgpAsn'            then @item[:bgp_asn] = @text
         | 
| 489 | 
            +
                    when 'item', 'customerGateway' then @result << @item
         | 
| 490 | 
            +
                    end
         | 
| 491 | 
            +
                  end
         | 
| 492 | 
            +
                  def reset
         | 
| 493 | 
            +
                    @result = []
         | 
| 494 | 
            +
                  end
         | 
| 495 | 
            +
                end
         | 
| 496 | 
            +
             | 
| 497 | 
            +
                class QEc2DescribeVpnGatewaysParser < RightAWSParser #:nodoc:
         | 
| 498 | 
            +
                  def tagstart(name, attributes)
         | 
| 499 | 
            +
                    case full_tag_name
         | 
| 500 | 
            +
                    when @p1, @p2
         | 
| 501 | 
            +
                      @item = { :attachments => [] }
         | 
| 502 | 
            +
                    when "#{@p1}/attachments/item",
         | 
| 503 | 
            +
                         "#{@p2}/attachments/item"
         | 
| 504 | 
            +
                      @attachment = {}
         | 
| 505 | 
            +
                    end
         | 
| 506 | 
            +
                  end
         | 
| 507 | 
            +
                  def tagend(name)
         | 
| 508 | 
            +
                    case name
         | 
| 509 | 
            +
                    when 'vpnGatewayId'     then @item[:vpn_gateway_id] = @text
         | 
| 510 | 
            +
                    when 'availabilityZone' then @item[:availability_zone] = @text
         | 
| 511 | 
            +
                    when 'type'             then @item[:type] = @text
         | 
| 512 | 
            +
                    when 'vpcId'            then @attachment[:vpc_id] = @text
         | 
| 513 | 
            +
                    end
         | 
| 514 | 
            +
                    case full_tag_name
         | 
| 515 | 
            +
                    when "#{@p1}/state",
         | 
| 516 | 
            +
                         "#{@p2}/state"
         | 
| 517 | 
            +
                      @item[:state] = @text
         | 
| 518 | 
            +
                    when "#{@p1}/attachments/item/state",
         | 
| 519 | 
            +
                         "#{@p2}/attachments/item/state"
         | 
| 520 | 
            +
                      @attachment[:state] = @text
         | 
| 521 | 
            +
                    when "#{@p1}/attachments/item",
         | 
| 522 | 
            +
                         "#{@p2}/attachments/item"
         | 
| 523 | 
            +
                      @item[:attachments] << @attachment unless @attachment.blank?
         | 
| 524 | 
            +
                    when @p1, @p2
         | 
| 525 | 
            +
                      @result << @item
         | 
| 526 | 
            +
                    end
         | 
| 527 | 
            +
                  end
         | 
| 528 | 
            +
                  def reset
         | 
| 529 | 
            +
                    @p1 = 'DescribeVpnGatewaysResponse/vpnGatewaySet/item'
         | 
| 530 | 
            +
                    @p2 = 'CreateVpnGatewayResponse/vpnGateway'
         | 
| 531 | 
            +
                    @result = []
         | 
| 532 | 
            +
                  end
         | 
| 533 | 
            +
                end
         | 
| 534 | 
            +
             | 
| 535 | 
            +
                class QEc2AttachVpnGatewayParser < RightAWSParser #:nodoc:
         | 
| 536 | 
            +
                  def tagend(name)
         | 
| 537 | 
            +
                    case name
         | 
| 538 | 
            +
                    when 'vpcId' then @result[:vpc_id] = @text
         | 
| 539 | 
            +
                    when 'state' then @result[:state]  = @text
         | 
| 540 | 
            +
                    end
         | 
| 541 | 
            +
                  end
         | 
| 542 | 
            +
                  def reset
         | 
| 543 | 
            +
                    @result = {}
         | 
| 544 | 
            +
                  end
         | 
| 545 | 
            +
                end
         | 
| 546 | 
            +
             | 
| 547 | 
            +
             | 
| 548 | 
            +
                class QEc2DescribeVpnConnectionsParser < RightAWSParser #:nodoc:
         | 
| 549 | 
            +
                  def tagstart(name, attributes)
         | 
| 550 | 
            +
                    case name
         | 
| 551 | 
            +
                    when 'item', 'vpnConnection' then @item = {}
         | 
| 552 | 
            +
                    end
         | 
| 553 | 
            +
                  end
         | 
| 554 | 
            +
                  def tagend(name)
         | 
| 555 | 
            +
                    case name
         | 
| 556 | 
            +
                    when 'vpnConnectionId'   then @item[:vpn_connection_id] = @text
         | 
| 557 | 
            +
                    when 'state'             then @item[:state] = @text
         | 
| 558 | 
            +
                    when 'type'              then @item[:type] = @text
         | 
| 559 | 
            +
                    when 'vpnGatewayId'      then @item[:vpn_gateway_id] = @text
         | 
| 560 | 
            +
                    when 'customerGatewayId' then @item[:customer_gateway_id] = @text
         | 
| 561 | 
            +
                    when 'customerGatewayConfiguration' then @item[:customer_gateway_configuration] = @text
         | 
| 562 | 
            +
                    when 'item','vpnConnection'         then @result << @item
         | 
| 563 | 
            +
                    end
         | 
| 564 | 
            +
                  end
         | 
| 565 | 
            +
                  def reset
         | 
| 566 | 
            +
                    @result = []
         | 
| 567 | 
            +
                  end
         | 
| 568 | 
            +
                end
         | 
| 569 | 
            +
             | 
| 570 | 
            +
              end
         | 
| 571 | 
            +
            end
         |