Skip to content

Commit

Permalink
ssl vservers and a host of other things to support features i'm using
Browse files Browse the repository at this point in the history
  • Loading branch information
burnettk committed Apr 9, 2015
1 parent 229da57 commit cc46fb8
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/netscaler/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
require 'netscaler/policy'
require 'netscaler/lb'
require 'netscaler/cs'
require 'netscaler/ssl'
require 'netscaler/rewrite'
require 'netscaler/responder'

Expand Down
6 changes: 6 additions & 0 deletions lib/netscaler/cs/vserver/bind.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def responder_policy(payload)
return @netscaler.adapter.post_no_body("config/csvserver_responderpolicy_binding/#{payload['name']}", {'params' => {'action' => 'bind'}, 'csvserver_responderpolicy_binding' => payload})
end

def lbvserver(payload)
raise ArgumentError, 'payload cannot be null' if payload.nil?
validate_payload(payload, [:name, :lbvserver])
return @netscaler.adapter.post_no_body("config/csvserver_lbvserver_binding/#{payload['name']}", {'params' => {'action' => 'bind'}, 'csvserver_lbvserver_binding' => payload})
end

end
end
end
Expand Down
28 changes: 28 additions & 0 deletions lib/netscaler/lb/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,34 @@ def initialize(netscaler)
@netscaler = netscaler
end

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

# not working. always dies saying it wants a type no matter how i pass the type. :)
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

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

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

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])
Expand Down
5 changes: 4 additions & 1 deletion lib/netscaler/servicegroup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def unbind(payload) # :args: :serviceGroupName => 'foo', :port => '80', :server
def toggle(toggle_action, payload)
raise ArgumentError, 'payload cannot be null' if payload.nil?
validate_payload(payload, [:serviceGroupName])
return @netscaler.adapter.post('config/', {"params" => {"action" => toggle_action}, "servicegroup" => {"servicegroupname" => payload[:service_group]}})
service_group_options = {"servicegroupname" => payload[:serviceGroupName]}
service_group_options.merge!("serverName" => payload[:serverName]) if payload[:serverName]
service_group_options.merge!("port" => payload[:port]) if payload[:port]
return @netscaler.adapter.post('config/', {"params" => {"action" => toggle_action}, "servicegroup" => service_group_options})
end

end
Expand Down
17 changes: 17 additions & 0 deletions lib/netscaler/ssl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'netscaler/ssl/vserver'
require 'netscaler/ssl/vserver/bind'
require 'netscaler/ssl/vserver/unbind'

module Netscaler
class Ssl

def initialize(netscaler)
@netscaler = netscaler
end

def vserver
Vserver.new @netscaler
end

end
end
55 changes: 55 additions & 0 deletions lib/netscaler/ssl/vserver.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
require 'netscaler/netscaler_service'

module Netscaler
class Ssl
class Vserver < NetscalerService
def initialize(netscaler)
@netscaler=netscaler
end

def show(payload={})
if payload[:name] != nil then
validate_payload(payload, [:name])
return @netscaler.adapter.get("config/sslvserver/#{payload[:name]}")
elsif payload == {} then
return @netscaler.adapter.get('config/sslvserver/')
else
raise ArgumentError, 'payload supplied must have been missing :name'
end
end

def show_binding(payload)
raise ArgumentError, 'payload cannot be null' if payload.nil?
validate_payload(payload, [:name])
return @netscaler.adapter.get("config/sslvserver_binding/#{payload[:name]}")
end

def remove(payload) # :args: :name
raise ArgumentError, 'payload cannot be null' if payload.nil?
validate_payload(payload, [:name])
return @netscaler.adapter.delete("config/sslvserver/#{payload[:name]}")
end

def add(payload)
raise ArgumentError, 'payload cannot be null' if payload.nil?
validate_payload(payload, [:name, :serviceType, :ipv46, :port])
return @netscaler.adapter.post_no_body('config/sslvserver/', {'sslvserver' => payload})
end

def stat(payload)
raise ArgumentError, 'payload cannot be null' if payload.nil?
validate_payload(payload, [:name])
return @netscaler.adapter.get("stat/sslvserver/#{payload[:name]}")
end

def bind
Bind.new @netscaler
end

def unbind
Unbind.new @netscaler
end

end
end
end
22 changes: 22 additions & 0 deletions lib/netscaler/ssl/vserver/bind.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module Netscaler
class Ssl
class Vserver
class Bind < NetscalerService
def initialize(netscaler)
@netscaler=netscaler
end

def sslcertkey(payload)
raise ArgumentError, 'payload cannot be null' if payload.nil?
validate_payload(payload, [:vservername, :certkeyname])
puts "config/sslvserver_sslcertkey_binding/#{payload[:vservername]}"
return @netscaler.adapter.post_no_body("config/sslvserver_sslcertkey_binding/#{payload[:vservername]}", {'params' => {'action' => 'bind'}, 'sslvserver_sslcertkey_binding' => payload})
end

end
end
end
end



18 changes: 18 additions & 0 deletions lib/netscaler/ssl/vserver/unbind.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Netscaler
class Ssl
class Vserver
class Unbind < NetscalerService
def initialize(netscaler)
@netscaler=netscaler
end

def sslcertkey(payload)
raise ArgumentError, 'payload cannot be null' if payload.nil?
validate_payload(payload, [:vservername, :certkeyname])
return @netscaler.adapter.post_no_body("config/sslvserver_sslcertkey_binding/#{payload[:vservername]}?action=unbind/", {'params' => {'action' => 'unbind'}, 'sslvserver_sslcertkey_binding' => payload})
end

end
end
end
end

0 comments on commit cc46fb8

Please sign in to comment.