Module: GClouder::Resources::Compute::Instances
Defined Under Namespace
Modules: Instance, Local, Remote
Class Method Summary
collapse
cli_args, #cli_args, included, load, valid_resources
Methods included from Logging
#add, #bad, #change, #debug, #error, #fatal, #good, included, #info, log, loggers, #remove, report, #resource_state, setup, #warn, #warning
Methods included from Helpers
#hash_to_args, included, #module_exists?, #to_arg, #to_deep_merge_hash, #valid_json?
Class Method Details
.clean ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/gclouder/resources/compute/instances.rb', line 51
def self.clean
return if undefined.empty?
:clean
undefined.each do |instance, zone|
info zone, heading: true, indent: 2
info
warning "#{instance['name']} (not defined locally)"
end
end
|
.ensure ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/gclouder/resources/compute/instances.rb', line 21
def self.ensure
return if Local.list.empty?
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
|
11
12
13
|
# File 'lib/gclouder/resources/compute/instances.rb', line 11
def self.(stage = :ensure)
info "[#{stage}] compute / instance", indent: 1, title: true
end
|
.undefined ⇒ Object
62
63
64
65
66
67
68
69
70
|
# 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 ⇒ Object
15
16
17
18
19
|
# File 'lib/gclouder/resources/compute/instances.rb', line 15
def self.validate
return if Local.list.empty?
:validate
Local.validate
end
|