Class: Skewer::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/util.rb

Overview

A utility class to handle common cloud operations that we’ll encounter amongst different providers.

Instance Method Summary collapse

Instance Method Details

#get_location(server = nil) ⇒ Object

Get the location (dns name, or IP) for a given Fog server. Cloud provider agnostic.



7
8
9
10
11
12
13
14
15
# File 'lib/util.rb', line 7

def get_location(server = nil)
  # Negative case.
  return nil if server.nil?
  return nil if not server.respond_to?(:dns_name) and not server.respond_to?(:public_ip_address)

  # Positive case.
  return server.dns_name if server.respond_to? :dns_name
  server.public_ip_address if server.respond_to? :public_ip_address
end