Module: XClarityClient::Mixins::ManageRequestMixin
- Included in:
- Client
- Defined in:
- lib/xclarity_client/mixins/manage_request_mixin.rb
Overview
Exposes ManageRequestManagement features
Instance Method Summary collapse
- #fetch_manage_request(job_id) ⇒ Object
- #get_discovery_result(discovery_job_id) ⇒ Object
- #get_job_progress(dji, discovery_job_progress) ⇒ Object
- #manage_discovered_devices(manage_request, force) ⇒ Object
- #update_manage_request(manage_request, force, discovery_result) ⇒ Object
Instance Method Details
#fetch_manage_request(job_id) ⇒ Object
6 7 8 |
# File 'lib/xclarity_client/mixins/manage_request_mixin.rb', line 6 def fetch_manage_request(job_id) ManageRequestManagement.new(@config).fetch_manage_request(job_id) end |
#get_discovery_result(discovery_job_id) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/xclarity_client/mixins/manage_request_mixin.rb', line 23 def get_discovery_result(discovery_job_id) discovery_job_id = discovery_job_id[:location].split('/')[3] discovery_job_progress = 0 return false if discovery_job_id.nil? while discovery_job_progress < 100 sleep 30 opts = get_job_progress(discovery_job_id, discovery_job_progress) discovery_job_progress = opts[:discovery_job_progress] end opts[:discovery_result] end |
#get_job_progress(dji, discovery_job_progress) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/xclarity_client/mixins/manage_request_mixin.rb', line 10 def get_job_progress(dji, discovery_job_progress) discovery_result = DiscoverRequestManagement.new(@config)\ .monitor_discover_request(dji) discovery_result.map do |req| req.instance_variables.each do |attr| value = req.instance_variable_get(attr) discovery_job_progress = value if attr.id2name.eql?('@progress') end end { :discovery_job_progress => discovery_job_progress, :discovery_result => discovery_result } end |
#manage_discovered_devices(manage_request, force) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/xclarity_client/mixins/manage_request_mixin.rb', line 42 def manage_discovered_devices(manage_request, force) discovery_job_id = DiscoverRequestManagement.new(@config)\ .discover_manageable_devices( manage_request[:ip_address] ) d_res = get_discovery_result(discovery_job_id) raise 'manageable device Discovery failed' unless d_res update_manage_request(manage_request, force, d_res) ManageRequestManagement.new(@config)\ .manage_discovered_devices(manage_request) end |
#update_manage_request(manage_request, force, discovery_result) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/xclarity_client/mixins/manage_request_mixin.rb', line 35 def update_manage_request(manage_request, force, discovery_result) ManageRequestManagement.new(@config)\ .update_manage_request(manage_request, force, discovery_result) end |