Class: Nagira::ServicegroupController
- Inherits:
-
Object
- Object
- Nagira::ServicegroupController
- Defined in:
- app/controllers/servicegroups_controller.rb
Defined Under Namespace
Classes: Member
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #by_hostname ⇒ Object (also: #list)
-
#initialize(name) ⇒ ServicegroupController
constructor
A new instance of ServicegroupController.
- #members ⇒ Object
- #objects ⇒ Object
- #output(type) ⇒ Object
- #servicegroup ⇒ Object
-
#state ⇒ Object
Shortened status informaation.
- #status ⇒ Object (also: #normal)
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
#name ⇒ Object (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_hostname ⇒ Object 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 |
#members ⇒ Object
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 |
#objects ⇒ Object
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 |
#servicegroup ⇒ Object
39 40 41 |
# File 'app/controllers/servicegroups_controller.rb', line 39 def servicegroup objects[:servicegroup][name] end |
#state ⇒ Object
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 |
#status ⇒ Object Also known as: normal
67 68 69 |
# File 'app/controllers/servicegroups_controller.rb', line 67 def status output(:status) end |