class Makitzo::World::Host

Public Instance Methods

address() click to toggle source
# 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() click to toggle source
# File lib/makitzo/world/host.rb, line 72
def applied_migrations
  store.applied_migrations_for_host(self)
end
mark_migration_as_applied(migration) click to toggle source
# 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) click to toggle source
# 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) click to toggle source

Store delegators

# 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) click to toggle source

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.

# 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) click to toggle source
# 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() click to toggle source
# File lib/makitzo/world/host.rb, line 5
def roles
  @roles ||= []
end
roles=(roles) click to toggle source
# 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() click to toggle source
# File lib/makitzo/world/host.rb, line 28
def root;   read_merged(:makitzo_root);   end
root!() click to toggle source
# File lib/makitzo/world/host.rb, line 29
def root!;  read_merged!(:makitzo_root);  end
unmark_migration_as_applied(migration) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/makitzo/world/host.rb, line 60
def write_to_store(key, value)
  store.write(self, key, value)
end