Class: Houcho::OuterRole
- Includes:
- Attribute
- Defined in:
- lib/houcho/outerrole.rb,
lib/houcho/outerrole/save.rb,
lib/houcho/outerrole/yabitz.rb,
lib/houcho/outerrole/cloudforecast.rb
Defined Under Namespace
Modules: Save Classes: CloudForecast, Yabitz
Instance Method Summary collapse
- #details(outer_role) ⇒ Object
- #hostlist(outer_role) ⇒ Object
-
#initialize ⇒ OuterRole
constructor
A new instance of OuterRole.
Methods included from Attribute
#attr_id, #del_attr, #get_attr, #get_attr_json, #set_attr, #set_attr!
Methods inherited from Element
#attach, #detach, #detach_from_all, #id, #list
Constructor Details
#initialize ⇒ OuterRole
Returns a new instance of OuterRole.
10 11 12 13 |
# File 'lib/houcho/outerrole.rb', line 10 def initialize super("outerrole") @type_id = 1 end |
Instance Method Details
#details(outer_role) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/houcho/outerrole.rb', line 15 def details(outer_role) outer_role = outer_role.is_a?(Array) ? outer_role : [outer_role] result = {} outer_role.each do |role| hosts = hostlist(role) if !hosts.empty? result[role] = {} result[role]["host"] = hosts end end result end |
#hostlist(outer_role) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/houcho/outerrole.rb', line 29 def hostlist(outer_role) outer_role = outer_role.is_a?(Array) ? outer_role : [outer_role] hosts = [] outer_role.each do |role| id = id(role) hosts << @db.execute(" SELECT host.name FROM host JOIN outerrole_host ORHOST ON host.id = ORHOST.host_id WHERE ORHOST.outerrole_id = ? ", id) end hosts.flatten.uniq.sort end |