module GClouder::Resources::Compute::Instances

Public Class Methods

check() click to toggle source
# File lib/gclouder/resources/compute/instances.rb, line 35
def self.check
  return if Remote.list.empty?
  return if Local.list.empty?
  header :check

  Resources::Validate::Remote.instances(
    Local.manipulated,
    Remote.list,
    skip_keys: [
      "image",
      "zone",
      "network_interfaces"
    ]
  )
end
clean() click to toggle source
# File lib/gclouder/resources/compute/instances.rb, line 51
def self.clean
  return if undefined.empty?
  header :clean
  undefined.each do |instance, zone|
    info zone, heading: true, indent: 2
    info
    warning "#{instance['name']} (not defined locally)"
    #Instance.purge(instance["name"], "--zone=#{zone}")
  end
end
ensure() click to toggle source
# File lib/gclouder/resources/compute/instances.rb, line 21
def self.ensure
  return if Local.list.empty?
  header

  Local.list.each do |region, instances|
    next if instances.empty?
    info region, indent: 2, heading: true
    info
    instances.each do |instance|
      Instance.ensure(instance["name"], hash_to_args(instance))
    end
  end
end
header(stage = :ensure) click to toggle source
# File lib/gclouder/resources/compute/instances.rb, line 11
def self.header(stage = :ensure)
  info "[#{stage}] compute / instance", indent: 1, title: true
end
undefined() click to toggle source
# File lib/gclouder/resources/compute/instances.rb, line 62
def self.undefined
  Remote.list.map do |region, instances|
    return instances.map do |instance|
      next if Local.list.fetch(region, []).select {|i| i["name"] == instance["name"] }.length > 0
      zone = Resource::Find.zone(:"compute instances", instance["name"], region)
      [instance, zone]
    end.clean
  end
end
validate() click to toggle source
# File lib/gclouder/resources/compute/instances.rb, line 15
def self.validate
  return if Local.list.empty?
  header :validate
  Local.validate
end