Class: OpsviewRest::MonitoringServer

Inherits:
Object
  • Object
show all
Includes:
Mixin
Defined in:
lib/opsview_rest/monitoringserver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin

#resource_path, #save, #to_json

Constructor Details

#initialize(opsview, options = {}) ⇒ MonitoringServer



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/opsview_rest/monitoringserver.rb', line 10

def initialize(opsview, options = {})
  @options = {
    :name => "Slave",
    :roles => [],
    :activated => true,
    :monitors => [],
    :nodes => [],
    :save    => true,
    :replace => false
  }.update options

  @opsview = opsview
  @resource_type = @options[:type]

  @option[:roles] = @option[:roles].map { |x| { "name" => x } }
  @option[:monitors] = @option[:monitors].map { |x| { "name" => x } }
  @option[:nodes] = @option[:nodes].map { |x| { "host" => { "name" => x } } }
  @options[:activated] = if @options[:activated] then 1 else 0 end

  save(@options[:replace]) if @options[:save]
end

Instance Attribute Details

#opsviewObject

Returns the value of attribute opsview.



8
9
10
# File 'lib/opsview_rest/monitoringserver.rb', line 8

def opsview
  @opsview
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/opsview_rest/monitoringserver.rb', line 8

def options
  @options
end

#resource_typeObject

Returns the value of attribute resource_type.



8
9
10
# File 'lib/opsview_rest/monitoringserver.rb', line 8

def resource_type
  @resource_type
end