From 6d889d4a59d20abace63d40b30c22f120b7a0cf6 Mon Sep 17 00:00:00 2001 From: Albert Choi Date: Wed, 25 Apr 2012 19:58:51 -0700 Subject: [PATCH] [aws|address] fixes release_address for VPC EIPs * amazon requires allocation_id only for vpc eips, and public_ip otherwise --- lib/fog/aws/requests/compute/release_address.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/fog/aws/requests/compute/release_address.rb b/lib/fog/aws/requests/compute/release_address.rb index 756f52beb..44839f223 100644 --- a/lib/fog/aws/requests/compute/release_address.rb +++ b/lib/fog/aws/requests/compute/release_address.rb @@ -14,10 +14,18 @@ module Fog # * 'return'<~Boolean> - success? # # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ReleaseAddress.html] - def release_address(public_ip) + # + # non-VPC: requires public_ip only + # VPC: requires allocation_id only + def release_address(ip_or_allocation) + field = if ip_or_allocation.to_s =~ /^(\d|\.)+$/ + "PublicIp" + else + "AllocationId" + end request( 'Action' => 'ReleaseAddress', - 'PublicIp' => public_ip, + field => ip_or_allocation, :idempotent => true, :parser => Fog::Parsers::Compute::AWS::Basic.new )