Module: GClouder::Resources::Compute::Disks

Includes:
Config::Arguments, Config::CLIArgs, Config::Project, Logging, GClouder::Resource::Cleaner
Defined in:
lib/gclouder/resources/compute/disks.rb

Defined Under Namespace

Modules: Disk, Local, Remote

Class Method Summary collapse

Methods included from GClouder::Resource::Cleaner

#clean, #cleaner, included, #undefined

Methods included from Config::Arguments

arguments, #arguments, included, load, permitted, required

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 Config::Project

load, #project, project

Methods included from Helpers

#hash_to_args, included, #module_exists?, #to_arg, #to_deep_merge_hash, #valid_json?

Methods included from Config::CLIArgs

cli_args, #cli_args, included, load, valid_resources

Class Method Details

.checkObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/gclouder/resources/compute/disks.rb', line 31

def self.check
  Remote.list.each do |region, disks|
    disks.each do |disk, config|
      local_config = Local.list[region][disk]
      next unless local_config
      next if local_config == config
      info "[compute disks] local resource definition differs from immutable remote resource: #{disk}"
      info "# local config"
      ap local_config
      info "# remote config"
      ap config
      fatal ""
    end
  end
end

.ensureObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gclouder/resources/compute/disks.rb', line 17

def self.ensure
  return if Local.list.empty?
  header

  Local.list.each do |region, disks|
    next if disks.empty?
    info region, indent: 2, heading: true
    info
    disks.each do |disk|
      Disk.ensure(disk["name"], disk["zone"], disk["size"], disk["type"])
    end
  end
end

.header(stage = :ensure) ⇒ Object



13
14
15
# File 'lib/gclouder/resources/compute/disks.rb', line 13

def self.header(stage = :ensure)
  info "[#{stage}] compute / disks", title: true, indent: 1
end

.validateObject



47
48
49
50
51
# File 'lib/gclouder/resources/compute/disks.rb', line 47

def self.validate
  return if Local.list.empty?
  header :validate
  Local.validate
end