Class: OpenDirectoryUtils::Connection
- Inherits:
-
Object
- Object
- OpenDirectoryUtils::Connection
- Defined in:
- lib/open_directory_utils/connection.rb
Constant Summary
Constants included from Version
Instance Attribute Summary collapse
-
#dir_info ⇒ Object
readonly
Returns the value of attribute dir_info.
-
#srv_info ⇒ Object
readonly
Returns the value of attribute srv_info.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Connection
constructor
configure connection with ENV_VARS (or parameters).
-
#run(command:, params:, output: nil) ⇒ Object
after configuring a connection with .new - send commands via ssh to open directory response [Hash] - { response: results, status: status, command: command, attributes: params, dscl_cmds: ssh_clean }.
- #version ⇒ Object
Methods included from CommandsUserCreateRemove
#user_create, #user_create_min, #user_delete, #user_update
Methods included from CommandsUserAttribs
#user_add_to_group, #user_append_chat, #user_append_email, #user_append_keyword, #user_create_chat, #user_create_keyword, #user_disable_login, #user_enable_login, #user_exists?, #user_get_info, #user_get_policy, #user_password_verified?, #user_remove_from_group, #user_set_chat, #user_set_city, #user_set_comment, #user_set_company, #user_set_country, #user_set_department, #user_set_first_email, #user_set_first_name, #user_set_home_phone, #user_set_job_title, #user_set_keywords, #user_set_last_name, #user_set_mobile_phone, #user_set_name_suffix, #user_set_nfs_home_directory, #user_set_organization_info, #user_set_password, #user_set_postal_code, #user_set_primary_group_id, #user_set_real_name, #user_set_relationships, #user_set_shell, #user_set_state, #user_set_street, #user_set_unique_id, #user_set_weblog, #user_set_work_phone
Methods included from CommandsBase
#build_dscl_command, #build_dseditgroup_command, #build_pwpolicy_command, #dscl, #dseditgroup, #pwpolicy
Methods included from CleanCheck
#assert, #check_critical_attribute, #group_record_name_alternatives, #tidy_attribs, #user_record_name_alternatives
Methods included from CommandsGroups
#group_create_full, #group_create_min, #group_delete, #group_exists?, #group_get_info, #group_set_primary_group_id, #group_set_real_name, #user_in_group?
Constructor Details
#initialize(params = {}) ⇒ Connection
-
mostly likely needed for better security is – dir_username:, dir_password:
configure connection with ENV_VARS (or parameters)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/open_directory_utils/connection.rb', line 22 def initialize(params={}) config = defaults.merge(params) @srv_info = { hostname: config[:srv_hostname], username: config[:srv_username], ssh_options: config[:ssh_options]} @dir_info = { username: config[:dir_username], password: config[:dir_password], data_path: config[:dir_datapath], dscl: config[:dscl_path], pwpol: config[:pwpol_path], dsedit: config[:dsedit_path], } raise ArgumentError, 'server hostname missing' if srv_info[:hostname].nil? or srv_info[:hostname].empty? raise ArgumentError, 'server username missing' if srv_info[:username].nil? or srv_info[:username].empty? end |
Instance Attribute Details
#dir_info ⇒ Object (readonly)
Returns the value of attribute dir_info.
11 12 13 |
# File 'lib/open_directory_utils/connection.rb', line 11 def dir_info @dir_info end |
#srv_info ⇒ Object (readonly)
Returns the value of attribute srv_info.
11 12 13 |
# File 'lib/open_directory_utils/connection.rb', line 11 def srv_info @srv_info end |
Instance Method Details
#run(command:, params:, output: nil) ⇒ Object
after configuring a connection with .new - send commands via ssh to open directory response [Hash] - { response: results, status: status, command: command, attributes: params, dscl_cmds: ssh_clean }
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/open_directory_utils/connection.rb', line 50 def run(command:, params:, output: nil) answer = {} params[:format] = output # just in case clear record_name and calculate later params[:record_name] = nil ssh_cmds = send(command, params, dir_info) # pp ssh_cmds results = send_cmds_to_od_server(ssh_cmds) # pp results answer = process_results(results, command, params, ssh_cmds ) params[:value] = nil return answer rescue ArgumentError, NoMethodError => error format_results(error., command, params, ssh_cmds, 'error') end |
#version ⇒ Object
41 42 43 |
# File 'lib/open_directory_utils/connection.rb', line 41 def version VERSION end |