Class: Netscaler::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/netscaler/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Connection

Returns a new instance of Connection.

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/netscaler/connection.rb', line 23

def initialize(options={})
  missing_options=[]
  options = Netscaler.hash_hack(options)
  [:username, :password, :hostname].each do |required_option|
    missing_options << required_option unless options[required_option] != nil
  end

  raise ArgumentError, "Required options are missing. #{missing_options.join(', ')}" if missing_options.length > 0

  @username   = options[:username]
  @password   = options[:password]
  @verify_ssl = options[:verify_ssl].nil? ? true : options[:verify_ssl]
  @adapter = HttpAdapter.new :hostname => "https://#{options[:hostname]}", :username => @username, :password => @password, :verify_ssl => @verify_ssl
  @load_balancing = LoadBalancing.new self
  @service = Service.new self
  @servicegroups = ServiceGroup.new self
  @servers = Server.new self
  @policy = Policy.new self
  @lb = Lb.new self
  @cs = Cs.new self
  @rewrite = Rewrite.new self
  @responder = Responder.new self
  @ssl =Ssl.new self
  @system = System.new self
  @ha = Ha.new self
end

Instance Method Details

#adapterObject



50
51
52
# File 'lib/netscaler/connection.rb', line 50

def adapter
  return @adapter
end

#adapter=(value) ⇒ Object



54
55
56
# File 'lib/netscaler/connection.rb', line 54

def adapter=(value)
  @adapter=value
end

#csObject



82
83
84
# File 'lib/netscaler/connection.rb', line 82

def cs
  @cs
end

#haObject



102
103
104
# File 'lib/netscaler/connection.rb', line 102

def ha
  @ha
end

#lbObject



78
79
80
# File 'lib/netscaler/connection.rb', line 78

def lb
  @lb
end

#load_balancingObject



70
71
72
# File 'lib/netscaler/connection.rb', line 70

def load_balancing
  return @load_balancing
end

#loginObject



122
123
124
125
126
127
128
129
130
131
# File 'lib/netscaler/connection.rb', line 122

def ()
  payload = {
    'username' => @username,
    'password' => @password
  }

  result = @adapter.post('config/login', { 'login' => payload})
  @adapter.session = result['sessionid']
  return @adapter.session
end

#logoutObject



133
134
135
# File 'lib/netscaler/connection.rb', line 133

def logout
  result = @adapter.post_no_body('config/logout', {'logout'=>{}})
end

#policyObject



74
75
76
# File 'lib/netscaler/connection.rb', line 74

def policy
  @policy
end

#responderObject



94
95
96
# File 'lib/netscaler/connection.rb', line 94

def responder
  @responder
end

#rewriteObject



90
91
92
# File 'lib/netscaler/connection.rb', line 90

def rewrite
  @rewrite
end

#serverObject



110
111
112
# File 'lib/netscaler/connection.rb', line 110

def server
  return @servers
end

#serversObject



106
107
108
# File 'lib/netscaler/connection.rb', line 106

def servers
  return @servers
end

#serviceObject



58
59
60
# File 'lib/netscaler/connection.rb', line 58

def service
  return @service
end

#servicegroupObject



66
67
68
# File 'lib/netscaler/connection.rb', line 66

def servicegroup
  return @servicegroups
end

#servicegroupsObject



62
63
64
# File 'lib/netscaler/connection.rb', line 62

def servicegroups
  return @servicegroups
end

#sessionObject



114
115
116
# File 'lib/netscaler/connection.rb', line 114

def session
  return @adapter.session
end

#sslObject



86
87
88
# File 'lib/netscaler/connection.rb', line 86

def ssl
  @ssl
end

#systemObject



98
99
100
# File 'lib/netscaler/connection.rb', line 98

def system
  @system
end

#verify_sslObject



118
119
120
# File 'lib/netscaler/connection.rb', line 118

def verify_ssl
  return @verify_ssl
end