Class: Cloudscale::Constants::AgentInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudscale/monitor/model/constants/agent_instance_store.rb

Constant Summary collapse

@@AGENT_INSTANCE_STORE_PATH =
"#{File.dirname(__FILE__)}/../../../store/agent/agent_instance.store"

Class Method Summary collapse

Class Method Details

.create(hash) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/cloudscale/monitor/model/constants/agent_instance_store.rb', line 14

def self.create(hash)
  settings = YAML::Store.new(@@AGENT_INSTANCE_STORE_PATH)

  settings.transaction {
    hash.each { | key, value |
      settings[key] = value
    }
  }
end

.loadObject



24
25
26
27
28
29
30
# File 'lib/cloudscale/monitor/model/constants/agent_instance_store.rb', line 24

def self.load
  begin
    YAML.load(File.read(@@AGENT_INSTANCE_STORE_PATH))
  rescue
    return nil
  end
end

.removeObject



32
33
34
35
36
37
# File 'lib/cloudscale/monitor/model/constants/agent_instance_store.rb', line 32

def self.remove
  file = File.read(@@AGENT_INSTANCE_STORE_PATH)
  if (file)
    File.delete(@@AGENT_INSTANCE_STORE_PATH)
  end
end