Module: GClouder::Resources::Compute::Instances::Local
- Includes:
- GClouder::Resources
- Defined in:
- lib/gclouder/resources/compute/instances.rb
Class Method Summary collapse
- .create_from_mapping(mappings, value) ⇒ Object
- .instance_names ⇒ Object
- .list ⇒ Object
-
.manipulated ⇒ Object
manipulate local resources so they’re comparable with remote..
- .mappings ⇒ Object
- .section ⇒ Object
- .validate ⇒ Object
Class Method Details
.create_from_mapping(mappings, value) ⇒ Object
99 100 101 |
# File 'lib/gclouder/resources/compute/instances.rb', line 99 def self.create_from_mapping(mappings, value) mappings.reverse.inject(value) { |obj, key| key.is_a?(Integer) ? [obj] : { key => obj } } end |
.instance_names ⇒ Object
83 84 85 |
# File 'lib/gclouder/resources/compute/instances.rb', line 83 def self.instance_names list.map { |region, instances| instances.each.map { |instance| instance["name"] } }.flatten end |
.list ⇒ Object
79 80 81 |
# File 'lib/gclouder/resources/compute/instances.rb', line 79 def self.list Resources::Region.instances(path: section) end |
.manipulated ⇒ Object
manipulate local resources so they’re comparable with remote..
FIXME this could be automated:
-
iterate over compute::instaces
-
create key for each value
-
assign config to newly made key
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/gclouder/resources/compute/instances.rb', line 110 def self.manipulated list.each do |_region, resources| resources.each do |resource| data_structure = create_from_mapping(mappings, resource["subnet"]) resource.merge! data_structure["compute"]["instances"] resource.delete("subnet") resource end end end |
.mappings ⇒ Object
95 96 97 |
# File 'lib/gclouder/resources/compute/instances.rb', line 95 def self.mappings Mappings::Property.section(["compute::instances", "subnet"]) end |
.section ⇒ Object
75 76 77 |
# File 'lib/gclouder/resources/compute/instances.rb', line 75 def self.section %w(compute instances) end |