1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
module Fog
module AWS
class Compute
class Real
require 'fog/aws/parsers/compute/restore_address_to_classic'
# Move address from VPC to Classic
#
# === Returns
# * response<~Excon::Response>:
# * body<~<Hash>:
# * 'publicIp'<~String> - IP address
# * 'requestId'<~String> - Id of the request
# * 'status'<~String> - The status of the move of the IP address (MoveInProgress | InVpc | InClassic)
def restore_address_to_classic(public_ip)
request(
'Action' => 'RestoreAddressToClassic',
'PublicIp' => public_ip,
:idempotent => true,
:parser => Fog::Parsers::AWS::Compute::RestoreAddressToClassic.new
)
end
end
class Mock
def restore_address_to_classic(public_ip)
response = Excon::Response.new
address = self.data[:addresses][public_ip]
if address
if address[:origin] == 'vpc'
raise Fog::AWS::Compute::Error.new("InvalidState => You cannot migrate an Elastic IP address that was originally allocated for use in EC2-VPC to EC2-Classic.")
end
address['domain'] = 'standard'
address.delete("allocationId")
response.status = 200
response.body = {
'requestId' => Fog::AWS::Mock.request_id,
'publicIp' => public_ip,
'status' => "InClassic"
}
response
else
raise Fog::AWS::Compute::NotFound.new("Address does not exist")
end
end
end
end
end
end
|