module Milc::Gcloud::Compute::Instances

Public Class Methods

first_external_ip(network_interfaces) click to toggle source
# 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) click to toggle source
# File lib/milc/gcloud/compute/instances.rb, line 21
def first_internal_ip(network_interfaces)
  network_interfaces.map{|i| i["networkIP"]}.compact.first
end

Public Instance Methods

build_attr_arg(attr_name, value) click to toggle source
Calls superclass method
# 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

Private Instance Methods

first_external_ip(network_interfaces) click to toggle source
# 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) click to toggle source
# File lib/milc/gcloud/compute/instances.rb, line 21
def first_internal_ip(network_interfaces)
  network_interfaces.map{|i| i["networkIP"]}.compact.first
end