Class: EquitracUtilities::Connection
- Inherits:
-
Object
- Object
- EquitracUtilities::Connection
- Includes:
- UserActions
- Defined in:
- lib/equitrac_utilities/connection.rb
Overview
Note:
You should use environment variables to initialize your server.
The EquitracUtilities, makes it east to work with Equitac EQCmd.exe commands
Instance Attribute Summary collapse
- #eqcmd_path ⇒ Object readonly
- #hostname ⇒ Object readonly
- #servicename ⇒ Object readonly
- #ssh_options ⇒ Object readonly
- #username ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Connection
constructor
Make connection to the Equitrac server.
-
#run(command:, attributes:) ⇒ String
The restult from the ssh command.
Methods included from UserActions
#check_atrribs, #process_user_exists?, #user_add, #user_adjust_set, #user_delete, #user_exists?, #user_lock, #user_modify, #user_query, #user_unlock
Constructor Details
#initialize(params = {}) ⇒ Connection
Note:
Hostname, Username and Servicename are required
Make connection to the Equitrac server
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/equitrac_utilities/connection.rb', line 20 def initialize(params={}) config = defaults.merge(params) @hostname = config[:hostname] @username = config[:username] @servicename = config[:servicename] @eqcmd_path = config[:eqcmd_path] @ssh_options = config[:ssh_options] raise ArgumentError, 'hostname missing' if hostname.nil? or hostname.empty? raise ArgumentError, 'username missing' if username.nil? or username.empty? raise ArgumentError, 'servicename missing' if servicename.nil? or servicename.empty? end |
Instance Attribute Details
#eqcmd_path ⇒ Object (readonly)
13 14 15 |
# File 'lib/equitrac_utilities/connection.rb', line 13 def eqcmd_path @eqcmd_path end |
#hostname ⇒ Object (readonly)
13 14 15 |
# File 'lib/equitrac_utilities/connection.rb', line 13 def hostname @hostname end |
#servicename ⇒ Object (readonly)
13 14 15 |
# File 'lib/equitrac_utilities/connection.rb', line 13 def servicename @servicename end |
#ssh_options ⇒ Object (readonly)
13 14 15 |
# File 'lib/equitrac_utilities/connection.rb', line 13 def @ssh_options end |
#username ⇒ Object (readonly)
13 14 15 |
# File 'lib/equitrac_utilities/connection.rb', line 13 def username @username end |
Instance Method Details
#run(command:, attributes:) ⇒ String
Note:
Run a command against the Equitrac server
Returns the restult from the ssh command.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/equitrac_utilities/connection.rb', line 38 def run(command:, attributes:) result = '' begin action = send(command, attributes) # action = send(:check_user_id, command, attributes) ssh_cmd = build_full_command(action) response = send_eqcmd(ssh_cmd) result = post_processing(command, response) rescue ArgumentError, NoMethodError => error result = "#{error.} -- :#{command} using #{attributes}" end return result end |