Class: Hubcap::Server

Inherits:
Group
  • Object
show all
Defined in:
lib/hubcap/server.rb

Constant Summary

Constants inherited from Group

Group::IP_PATTERN

Instance Attribute Summary collapse

Attributes inherited from Group

#children, #name, #parent

Instance Method Summary collapse

Methods inherited from Group

#absorb, #cap_attribute, #cap_attributes, #cap_role, #cap_roles, #cap_set, #collectable?, #extra, #extras, #history, #host, #hosts, #hub, #lookup, #param, #params, #processable?, #puppet_role, #puppet_roles, #resolv, #role

Constructor Details

#initialize(parent, name, options = {}, &blk) ⇒ Server

Returns a new instance of Server.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/hubcap/server.rb', line 6

def initialize(parent, name, options = {}, &blk)
  super(parent, name, &blk)
  hist = history.join('.')

  # only set the server_name if it's not already set
  param('server_name' => hist) if params['server_name'].nil?

  # If name is an IP, or is not in hosts hash, use name as address
  # Otherwise, dereference it from the hash and assign it
  unless @address = options[:address]
    @address = lookup(hist)
    @address = lookup(name)  if @address == hist
  end
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



3
4
5
# File 'lib/hubcap/server.rb', line 3

def address
  @address
end

Instance Method Details

#application(*args) ⇒ Object



22
23
24
# File 'lib/hubcap/server.rb', line 22

def application(*args)
  raise(Hubcap::ServerSubgroupDisallowed, 'application')
end

#application_parentObject



37
38
39
40
41
42
43
44
# File 'lib/hubcap/server.rb', line 37

def application_parent
  p = self
  while p && p != hub
    return p  if p.kind_of?(Hubcap::Application)
    p = p.instance_variable_get(:@parent)
  end
  nil
end

#group(*args) ⇒ Object



32
33
34
# File 'lib/hubcap/server.rb', line 32

def group(*args)
  raise(Hubcap::ServerSubgroupDisallowed, 'group')
end

#server(*args) ⇒ Object



27
28
29
# File 'lib/hubcap/server.rb', line 27

def server(*args)
  raise(Hubcap::ServerSubgroupDisallowed, 'server')
end

#yamlObject



47
48
49
# File 'lib/hubcap/server.rb', line 47

def yaml
  { 'classes' => puppet_roles, 'parameters' => params }.to_yaml
end