Class: Nagira::ServicegroupController

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/servicegroups_controller.rb

Defined Under Namespace

Classes: Member

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ServicegroupController

Returns a new instance of ServicegroupController.



30
31
32
# File 'app/controllers/servicegroups_controller.rb', line 30

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



33
34
35
# File 'app/controllers/servicegroups_controller.rb', line 33

def name
  @name
end

Instance Method Details

#by_hostnameObject Also known as: list



49
50
51
52
53
54
55
# File 'app/controllers/servicegroups_controller.rb', line 49

def by_hostname
  members.inject({ }) do |memo,item|
    memo[item.hostname] ||= []
    memo[item.hostname] << item.servicename
    memo
  end
end

#membersObject



43
44
45
46
47
# File 'app/controllers/servicegroups_controller.rb', line 43

def members
  servicegroup[:members].split(/\s+/).map do |mem|
    Member.new(mem)
  end
end

#objectsObject



35
36
37
# File 'app/controllers/servicegroups_controller.rb', line 35

def objects
  @objects ||= Parser.objects
end

#output(type) ⇒ Object



58
59
60
61
62
63
64
65
# File 'app/controllers/servicegroups_controller.rb', line 58

def output(type)
  members.reduce({  }) do |memo,member|
    h,s = member.hostname, member.servicename
    memo[h] ||= {  }
    memo[h][s] = member.send(type)
    memo
  end
end

#servicegroupObject



39
40
41
# File 'app/controllers/servicegroups_controller.rb', line 39

def servicegroup
  objects[:servicegroup][name]
end

#stateObject

Shortened status informaation. Only :host_name, :service_description, :current_state



75
76
77
# File 'app/controllers/servicegroups_controller.rb', line 75

def state
  output(:state)
end

#statusObject Also known as: normal



67
68
69
# File 'app/controllers/servicegroups_controller.rb', line 67

def status
  output(:status)
end