Class: Cloudscale::Preops::Preop

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudscale/monitor/agent/preops/preop.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#logObject

Returns the value of attribute log.



13
14
15
# File 'lib/cloudscale/monitor/agent/preops/preop.rb', line 13

def log
  @log
end

#registryObject

Returns the value of attribute registry.



13
14
15
# File 'lib/cloudscale/monitor/agent/preops/preop.rb', line 13

def registry
  @registry
end

Instance Method Details

#clear_optionsObject



52
53
54
55
56
# File 'lib/cloudscale/monitor/agent/preops/preop.rb', line 52

def clear_options
  @plugin_settings_db.fetch.each do | element |
    @plugin_settings_db.delete(element)
  end
end

#get_option(key) ⇒ Object



26
27
28
# File 'lib/cloudscale/monitor/agent/preops/preop.rb', line 26

def get_option(key)
  options[key.to_sym]
end

#get_option_value(key) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/cloudscale/monitor/agent/preops/preop.rb', line 30

def get_option_value(key)
  if (options[key.to_sym] != nil)
    options[key.to_sym][:value] #|| @plugin_settings_db[key.to_s]
  else
    nil
  end
end

#initObject



15
16
17
18
19
20
# File 'lib/cloudscale/monitor/agent/preops/preop.rb', line 15

def init
  @log = Logger.new(STDOUT)
  @registry = Monitor::Registry.instance
  @plugin_settings_db = FSDB::Database.new("#{File.dirname(__FILE__)}/../../../store/plugin/")
  init_options()
end

#init_charts(path) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/cloudscale/monitor/agent/preops/preop.rb', line 58

def init_charts(path)
  log.info("Starting monitoring chart synchronization...")

  Monitor::InitCharts.new(@registry.agent_instance_id, path)

  log.info("Successfully synchronized charts...")
end

#init_menus(path) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/cloudscale/monitor/agent/preops/preop.rb', line 66

def init_menus(path)
  log.info("Starting monitoring menu synchronization...")

  Monitor::InitMenus.new(@registry.agent_instance_id, path)

  log.info("Successfully synchronized menus...")
end

#init_optionsObject



38
39
40
41
42
43
44
# File 'lib/cloudscale/monitor/agent/preops/preop.rb', line 38

def init_options
  @plugin_settings_db.fetch.each do | key |
    if (options[key.to_sym])
      options[key.to_sym][:value] = @plugin_settings_db[key]
    end
  end
end

#save_optionsObject



46
47
48
49
50
# File 'lib/cloudscale/monitor/agent/preops/preop.rb', line 46

def save_options
  options.each do | key, value |
    @plugin_settings_db[key.to_s] = value[:value].to_s
  end
end

#set_option_value(key, val) ⇒ Object



22
23
24
# File 'lib/cloudscale/monitor/agent/preops/preop.rb', line 22

def set_option_value(key, val)
  options[key.to_sym][:value] = val
end