Class: MCollective::Util::Playbook::DataStores::EtcdDataStore
- Inherits:
-
Base
- Object
- Base
- MCollective::Util::Playbook::DataStores::EtcdDataStore
show all
- Defined in:
- lib/mcollective/util/playbook/data_stores/etcd_data_store.rb
Instance Method Summary
collapse
Methods inherited from Base
#from_hash, #initialize, #lock, #members, #prepare, #release, #validate_configuration!
Instance Method Details
#conn ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/mcollective/util/playbook/data_stores/etcd_data_store.rb', line 12
def conn
return @_conn if @_conn
opts = {}
opts[:url] = @properties.fetch("url", "http://127.0.0.1:2379")
opts[:user] = @properties["user"] if @properties["user"]
opts[:password] = @properties["password"] if @properties["password"]
@_conn = Etcdv3.new(opts)
end
|
#delete(key) ⇒ Object
35
36
37
|
# File 'lib/mcollective/util/playbook/data_stores/etcd_data_store.rb', line 35
def delete(key)
conn.del(key)
end
|
#read(key) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/mcollective/util/playbook/data_stores/etcd_data_store.rb', line 23
def read(key)
result = conn.get(key)
raise("Could not find key %s" % key) if !result || result.kvs.empty?
result.kvs[0].value
end
|
#startup_hook ⇒ Object
6
7
8
9
10
|
# File 'lib/mcollective/util/playbook/data_stores/etcd_data_store.rb', line 6
def startup_hook
require "etcdv3"
rescue LoadError
raise("Etcd Data Store is not functional. Please install the etcdv3 Gem.")
end
|
#write(key, value) ⇒ Object
31
32
33
|
# File 'lib/mcollective/util/playbook/data_stores/etcd_data_store.rb', line 31
def write(key, value)
conn.put(key, value)
end
|