Class: Rubix::HostGroup
Instance Attribute Summary
Attributes inherited from Model
#id, #properties
Class Method Summary
collapse
Instance Method Summary
collapse
#host_ids, #host_ids=, #hosts, #hosts=
Methods inherited from Model
#after_create, all, all_params, all_request, #before_destroy, #before_update, #create, #create_request, #destroy, #destroy_request, each, find, find_or_create, find_request, #id_field, list, #new_record?, properties, request, #request, #resource_name, resource_name, #save, #to_hash, #update, #update_params, #update_request, #validate, web_request, zabbix_attr, zabbix_define, zabbix_name
Methods included from Logs
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(properties = {}) ⇒ HostGroup
9
10
11
12
13
|
# File 'lib/rubix/models/host_group.rb', line 9
def initialize properties={}
super(properties)
self.host_ids = properties[:host_ids]
self.hosts = properties[:hosts]
end
|
Class Method Details
.build(host_group) ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/rubix/models/host_group.rb', line 47
def self.build host_group
new({
:id => host_group[id_field].to_i,
:name => host_group['name'],
:host_ids => host_group['hosts'].map { |host_info| host_info['hostid'].to_i }
})
end
|
.find_params(options = {}) ⇒ Object
43
44
45
|
# File 'lib/rubix/models/host_group.rb', line 43
def self.find_params options={}
get_params.merge(:filter => {id_field => options[:id], :name => options[:name]})
end
|
.get_params ⇒ Object
39
40
41
|
# File 'lib/rubix/models/host_group.rb', line 39
def self.get_params
super().merge(:select_hosts => :refer)
end
|
.id_field ⇒ Object
17
18
19
|
# File 'lib/rubix/models/host_group.rb', line 17
def self.id_field
'groupid'
end
|
Instance Method Details
#create_params ⇒ Object
31
32
33
|
# File 'lib/rubix/models/host_group.rb', line 31
def create_params
{:name => name}
end
|
#destroy_params ⇒ Object
35
36
37
|
# File 'lib/rubix/models/host_group.rb', line 35
def destroy_params
[{id_field => id}]
end
|