Class: Makitzo::World::Host
Constant Summary
Constants included
from FileSystem
FileSystem::HISTORY_DIR, FileSystem::INSTALL_FILE
Instance Attribute Summary
Attributes inherited from NamedEntity
#name
Instance Method Summary
collapse
Methods included from FileSystem
install_file, #install_file, migration_history_dir, #migration_history_dir
Methods inherited from NamedEntity
#<=>, #eql?, #hash, #initialize, #read!, setting_accessor, #to_s
Methods included from Settings
#[], #[]=, #memo, #read, #set, #settings
#app, #config, #logger, #store
Instance Method Details
#address ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/makitzo/world/host.rb', line 14
def address
address = name
if username = read_merged(:ssh_username)
address = "#{username}@#{address}"
end
if port = read_merged(:ssh_port)
address << ":#{port}"
end
address
end
|
#applied_migrations ⇒ Object
72
73
74
|
# File 'lib/makitzo/world/host.rb', line 72
def applied_migrations
store.applied_migrations_for_host(self)
end
|
#mark_migration_as_applied(migration) ⇒ Object
76
77
78
|
# File 'lib/makitzo/world/host.rb', line 76
def mark_migration_as_applied(migration)
store.mark_migration_as_applied(self, migration)
end
|
#read_all_from_store(*keys) ⇒ Object
64
65
66
|
# File 'lib/makitzo/world/host.rb', line 64
def read_all_from_store(*keys)
store.read_all(self, *keys)
end
|
#read_from_store(key, default = nil) ⇒ Object
56
57
58
|
# File 'lib/makitzo/world/host.rb', line 56
def read_from_store(key, default = nil)
store.read(self, key) || default
end
|
#read_merged(key, default = nil) ⇒ Object
read a setting from this host, or from its roles if the setting is not present on this host, all roles supplying a non-nil value must be in consensus or else a ConflictingPropertyError will be raised.
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/makitzo/world/host.rb', line 35
def read_merged(key, default = nil)
config.synchronize do
val = read(key)
if val.nil?
role_values = roles.map { |r| r.read(key) }.compact.uniq
raise ConflictingPropertyError if role_values.length > 1
val = role_values.first
end
val.nil? ? default : val
end
end
|
#read_merged!(key) ⇒ Object
47
48
49
50
51
|
# File 'lib/makitzo/world/host.rb', line 47
def read_merged!(key)
val = read_merged(key)
raise MissingPropertyError, "missing property: #{key}" if val.nil?
val
end
|
#roles ⇒ Object
5
6
7
|
# File 'lib/makitzo/world/host.rb', line 5
def roles
@roles ||= []
end
|
#roles=(roles) ⇒ Object
9
10
11
12
|
# File 'lib/makitzo/world/host.rb', line 9
def roles=(roles)
resolved_roles = [roles].flatten.map { |r| config.resolve_role(r) }
@roles = resolved_roles
end
|
#root ⇒ Object
28
|
# File 'lib/makitzo/world/host.rb', line 28
def root; read_merged(:makitzo_root); end
|
#root! ⇒ Object
29
|
# File 'lib/makitzo/world/host.rb', line 29
def root!; read_merged!(:makitzo_root); end
|
#unmark_migration_as_applied(migration) ⇒ Object
80
81
82
|
# File 'lib/makitzo/world/host.rb', line 80
def unmark_migration_as_applied(migration)
store.unmark_migration_as_applied(self, migration)
end
|
#write_all_to_store(hash) ⇒ Object
68
69
70
|
# File 'lib/makitzo/world/host.rb', line 68
def write_all_to_store(hash)
store.write_all(self, hash)
end
|
#write_to_store(key, value) ⇒ Object
60
61
62
|
# File 'lib/makitzo/world/host.rb', line 60
def write_to_store(key, value)
store.write(self, key, value)
end
|