Class: Fog::CurrentMachine
- Inherits:
-
Object
- Object
- Fog::CurrentMachine
- Defined in:
- lib/fog/core/current_machine.rb
Constant Summary collapse
- AMAZON_AWS_CHECK_IP =
'http://checkip.amazonaws.com'
- @@lock =
Mutex.new
Class Method Summary collapse
-
.ip_address ⇒ Object
Get the ip address of the machine from which this command is run.
- .ip_address=(ip_address) ⇒ Object
Class Method Details
.ip_address ⇒ Object
Get the ip address of the machine from which this command is run. It is recommended that you surround calls to this function with a timeout block to ensure optimum performance in the case where the amazonaws checkip service is unavailable.
30 31 32 33 34 35 36 |
# File 'lib/fog/core/current_machine.rb', line 30 def self.ip_address @@lock.synchronize do @@ip_address ||= Net::HTTP \ .get_response(URI.parse(AMAZON_AWS_CHECK_IP)) \ .body.chomp end end |
.ip_address=(ip_address) ⇒ Object
9 10 11 12 13 |
# File 'lib/fog/core/current_machine.rb', line 9 def self.ip_address= ip_address @@lock.synchronize do @@ip_address = ip_address end end |