Class: Netscaler::Lb::Monitor

Inherits:
NetscalerService show all
Defined in:
lib/netscaler/lb/monitor.rb

Instance Method Summary collapse

Methods inherited from NetscalerService

#validate_payload

Constructor Details

#initialize(netscaler) ⇒ Monitor

Returns a new instance of Monitor.



7
8
9
# File 'lib/netscaler/lb/monitor.rb', line 7

def initialize(netscaler)
  @netscaler = netscaler
end

Instance Method Details

#add(payload) ⇒ Object

:args: :monitorName => ‘HTTP-updates.dev.rs.com’, :serviceType => ‘HTTP’

Raises:

  • (ArgumentError)


11
12
13
14
15
# File 'lib/netscaler/lb/monitor.rb', line 11

def add(payload)  # :args: :monitorName => 'HTTP-updates.dev.rs.com', :serviceType => 'HTTP'
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:monitorName, :type])
  return @netscaler.adapter.post_no_body("config/lbmonitor/", "lbmonitor" => payload)
end

#bind(payload) ⇒ Object

:args: :monitorName => ‘http’, :entityName => ‘foo’ :entityType => ‘[service|servicegroup]’

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
46
47
48
49
# File 'lib/netscaler/lb/monitor.rb', line 39

def bind(payload) # :args: :monitorName => 'http', :entityName => 'foo' :entityType => '[service|servicegroup]'
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:monitorName, :entityName, :entityType])
  valid_entityTypes = %w(service servicegroup)
  raise ArgumentError, ":entityType does not equal one of the following: #{valid_entityTypes.flatten}" unless valid_entityTypes.include?(payload[:entityType])
  new_payload = {:monitorName => payload[:monitorName],
                 :"#{payload[:entityType]}Name" => payload[:entityName]}

  return @netscaler.adapter.post_no_body("config/lbmonitor_#{payload[:entityType]}_binding/#{payload[:monitorName]}?action=bind",
                                          {'params' => {'action' => 'bind'}, "lbmonitor_#{payload[:entityType]}_binding" => new_payload})
end

#remove(payload) ⇒ Object

not working. always dies saying it wants a type no matter how i pass the type. :)

Raises:

  • (ArgumentError)


18
19
20
21
22
# File 'lib/netscaler/lb/monitor.rb', line 18

def remove(payload)  # :args: :monitorName => 'HTTP-updates.dev.rs.com'
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:monitorName, :type])
  return @netscaler.adapter.delete("config/lbmonitor/#{payload[:monitorName]}", "lbmonitor" => payload)
end

#show(payload) ⇒ Object

:args: :monitorName => ‘http’, :entityName => ‘foo’ :entityType => ‘[service|servicegroup]’

Raises:

  • (ArgumentError)


24
25
26
27
28
# File 'lib/netscaler/lb/monitor.rb', line 24

def show(payload) # :args: :monitorName => 'http', :entityName => 'foo' :entityType => '[service|servicegroup]'
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:monitorName])
  return @netscaler.adapter.get("config/lbmonitor/#{payload[:monitorName]}")
end

#show_binding(payload) ⇒ Object

:args: :monitorName => ‘http’, :entityName => ‘foo’ :entityType => ‘[service|servicegroup]’

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
37
# File 'lib/netscaler/lb/monitor.rb', line 30

def show_binding(payload) # :args: :monitorName => 'http', :entityName => 'foo' :entityType => '[service|servicegroup]'
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:monitorName, :entityType])
  valid_entityTypes = %w(service servicegroup)
  raise ArgumentError, ":entityType does not equal one of the following: #{valid_entityTypes.flatten}" unless valid_entityTypes.include?(payload[:entityType])

  return @netscaler.adapter.get("config/lbmonbindings_#{payload[:entityType]}_binding/#{payload[:monitorName]}")
end

#unbind(payload) ⇒ Object

:args: :monitorName => ‘http’, :entityName => ‘foo’ :entityType => ‘[service|servicegroup]’

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
58
59
60
61
# File 'lib/netscaler/lb/monitor.rb', line 51

def unbind(payload) # :args: :monitorName => 'http', :entityName => 'foo' :entityType => '[service|servicegroup]'
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:monitorName, :entityName, :entityType])
  valid_entityTypes = %w(service servicegroup)
  raise ArgumentError, ":entityType does not equal one of the following: #{valid_entityTypes.flatten}" unless valid_entityTypes.include?(payload[:entityType])
  new_payload = {:monitorName => payload[:monitorName],
                 :"#{payload[:entityType]}Name" => payload[:entityName]}

  return @netscaler.adapter.post_no_body("config/lbmonitor_servicegroup_binding/#{payload[:monitorName]}?action=unbind",
                                         {'params' => {'action' => 'unbind'}, 'lbmonitor_servicegroup_binding' => new_payload})
end