Class: BsaSoapBase
- Inherits:
-
Object
show all
- Defined in:
- lib/bl_soap/bsa_soap_base.rb
Direct Known Subclasses
BlPackage, BsaSoapClient, ComplianceJob, ComponentGroup, DeployJob, DepotGroup, Group, Job, JobGroup, JobManagement, JobResult, JobRun, Login, NSHScriptJob, PatchCatalog, PatchRemediationJob, PatchingJob, Server, ServerGroup, Template, Utility
Constant Summary
collapse
- HTTP_READ_TIMEOUT =
300
- DEFAULT_AUTH_TYPE =
"SRP"
- LOGIN_WSDL =
"/services/BSALoginService.wsdl"
- ROLE_WSDL =
"/services/BSAAssumeRoleService.wsdl"
- CLI_WSDL =
"/services/BSACLITunnelService.wsdl"
- LOGIN_SERVICE =
"/services/LoginService"
- ROLE_SERVICE =
"/services/AssumeRoleService"
- CLI_SERVICE =
"/services/CLITunnelService"
Instance Method Summary
collapse
Constructor Details
#initialize(url, session_id) ⇒ BsaSoapBase
Returns a new instance of BsaSoapBase.
21
22
23
24
|
# File 'lib/bl_soap/bsa_soap_base.rb', line 21
def initialize(url, session_id)
@url = url
@session_id = session_id
end
|
Instance Method Details
#execute_cli_with_attachments(namespace, command, args, payload) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/bl_soap/bsa_soap_base.rb', line 77
def execute_cli_with_attachments(namespace, command, args, payload)
BrpmAuto.log("blcli #{namespace} #{command} #{args.join(" ")}")
client = Savon.client("#{@url}#{CLI_WSDL}") do |wsdl, http|
http.auth.ssl.verify_mode = :none
end
client.http.read_timeout = HTTP_READ_TIMEOUT
response = client.request(:execute_command_using_attachments) do |soap|
soap.endpoint = "#{@url}#{CLI_SERVICE}"
soap. = {"ins1:sessionId" => @session_id}
body_details = { :nameSpace => namespace, :commandName => command, :commandArguments => args }
body_details.merge!({:payload => payload}) if payload
soap.body = body_details
end
result = response.body[:execute_command_using_attachments_response][:return]
return validate_cli_result(result)
rescue Savon::Error => error
raise "Error while executing CLI command over SOAP protocol: #{error.to_s}"
rescue => exception
raise "Error processing CLI(#{namespace}:#{command}) result: #{exception.to_s}"
end
|
#execute_cli_with_param_list(namespace, command, args = []) ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/bl_soap/bsa_soap_base.rb', line 99
def execute_cli_with_param_list(namespace, command, args = [])
BrpmAuto.log("blcli #{namespace} #{command} #{args.join(" ")}")
client = Savon.client("#{@url}#{CLI_WSDL}") do |wsdl, http|
http.auth.ssl.verify_mode = :none
end
client.http.read_timeout = HTTP_READ_TIMEOUT
response = client.request(:execute_command_by_param_list) do |soap|
soap.endpoint = "#{@url}#{CLI_SERVICE}"
soap. = {"ins1:sessionId" => @session_id}
soap.body = { :nameSpace => namespace, :commandName => command, :commandArguments => args }
end
result = response.body[:execute_command_by_param_list_response][:return]
return validate_cli_result(result)
rescue Savon::Error => error
raise "Error while executing CLI command over SOAP protocol: #{error.to_s}"
rescue Exception => exception
raise "Error processing CLI(#{namespace}:#{command}) results: #{exception.to_s}"
end
|
#get_all_servers(server_group) ⇒ Object
36
37
38
39
40
41
|
# File 'lib/bl_soap/bsa_soap_base.rb', line 36
def get_all_servers(server_group)
result = execute_cli_with_param_list("Server", "listServersInGroup", [server_group])
servers = get_cli_return_value(result)
rescue => exception
raise "Failed to get all servers for #{server_group}: #{exception.to_s}"
end
|
#get_cli_return_value(result) ⇒ Object
70
71
72
73
74
75
|
# File 'lib/bl_soap/bsa_soap_base.rb', line 70
def get_cli_return_value(result)
if result && result.is_a?(Hash) && result.has_key?(:success) && result[:success]
return result[:return_value]
end
nil
end
|
#validate_cli_option_hash_string_values(supported_values, options_key) ⇒ Object
30
31
32
33
34
|
# File 'lib/bl_soap/bsa_soap_base.rb', line 30
def validate_cli_option_hash_string_values(supported_values, options_key)
supported_values.any? {
|value| raise "options key value(#{options_value}) not supported" unless options_key.eql?(value)
}
end
|
#validate_cli_options_hash(required_keys, options) ⇒ Object
26
27
28
|
# File 'lib/bl_soap/bsa_soap_base.rb', line 26
def validate_cli_options_hash(required_keys, options)
required_keys.each { |key| raise "Invalid options hash(missing #{key}) for command, cannot continue" unless options.has_key?(key) }
end
|
#validate_cli_result(result) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/bl_soap/bsa_soap_base.rb', line 58
def validate_cli_result(result)
if result && (result.is_a? Hash)
if result[:success] == false
raise "Command execution failed: #{result[:error]}, #{result[:comments]}"
end
return result
else
raise "Command execution did not return a valid response: #{result.inspect}"
end
nil
end
|
#validate_servers(servers = []) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/bl_soap/bsa_soap_base.rb', line 43
def validate_servers(servers = [])
error = {}
servers.each do |server|
result = execute_cli_with_param_list("Server", "printPropertyValue", [server, "AGENT_STATUS"])
if result[:success] == false || result[:return_value] != "agent is alive"
error[:"#{server}"] = "cannot validate server status"
end
end
if error.length > 0
raise "Problem validating server: #{error}"
end
rescue => exception
raise "Failed to validate server: #{exception.to_s}"
end
|