Module: Milc::Gcloud::Compute::Instances

Defined in:
lib/milc/gcloud/compute/instances.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.first_external_ip(network_interfaces) ⇒ Object



26
27
28
29
30
31
# File 'lib/milc/gcloud/compute/instances.rb', line 26

def first_external_ip(network_interfaces)
  network_interfaces.map{|i|
    configs = i["accessConfigs"] || []
    configs.map{|c| c["natIP"] }.compact.first
  }.flatten.first
end

.first_internal_ip(network_interfaces) ⇒ Object



21
22
23
# File 'lib/milc/gcloud/compute/instances.rb', line 21

def first_internal_ip(network_interfaces)
  network_interfaces.map{|i| i["networkIP"]}.compact.first
end

Instance Method Details

#build_attr_arg(attr_name, value) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/milc/gcloud/compute/instances.rb', line 11

def build_attr_arg(attr_name, value)
  case attr_name
  when :disk, :disks then
    disks = Array.wrap(value).map{|d| d.is_a?(Hash) ? build_sub_attr_args(d) : d.to_s }
    disks.map{|d| "--disk #{d}"}.join(" ")
  else
    super(attr_name, value)
  end
end