Skip to content

Commit

Permalink
ASM-9277 Do not #read a closed file handle, File.read instead
Browse files Browse the repository at this point in the history
  • Loading branch information
ripienaar committed Mar 8, 2017
1 parent 1003b79 commit 822ebba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions lib/asm/firmware.rb
Expand Up @@ -211,14 +211,16 @@ def update_idrac_firmware(firmware_list, force_restart, wsman)
def gets_install_uri_job(firmware, wsman)
config_file = create_xml_config_file(firmware["instance_id"], firmware["uri_path"])
resp = wsman.install_from_uri(:input_file => config_file.path)

if resp[:return_value] == "4096"
job_id = resp[:job]
logger.debug("InstallFromURI started")
logger.debug("JOB_ID: #{job_id}")
else
logger.debug("Error installing From URI config: #{config_file.read}")
logger.debug("Error installing From URI config: %s" % File.read(config_file.path))
raise("Problem running InstallFromURI: #{resp[:message]}")
end

job_id
end

Expand Down Expand Up @@ -336,9 +338,9 @@ def setup_job_queue(config_file, wsman)
#
# this creates a temporary file to be used for the SetupJobQueue wsman call
#
# @param [Array<string>] job_ids job ids to be scheduled
# @param [String] reboot_id the reboot job
# @return [File] the xml file object
# @param job_ids [Array<String>] job ids to be scheduled
# @param reboot_id [String] the reboot job
# @return [Tempfile] the xml file object
def create_job_queue_config(job_ids, reboot_id=nil)
template = <<-EOF
<p:SetupJobQueue_INPUT xmlns:p="http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_JobService"><% job_ids.each do |job_id| %>
Expand All @@ -359,8 +361,8 @@ def create_job_queue_config(job_ids, reboot_id=nil)
# Used to create an XML file:
#
# @param instance_id [String] job_id
# @return [void]
# Path specifies moount path
# @param path [String] specifies moount path
# @return [Tempfile]
def create_xml_config_file(instance_id, path)
template = <<-EOF
<p:InstallFromURI_INPUT xmlns:p="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_SoftwareInstallationService">
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/asm/firmware_spec.rb
Expand Up @@ -222,7 +222,7 @@
it "should raise an error when install_from_uri job fails" do
data = {:name => "xyz", :description => "test file"}.to_json
data.stubs(:path).returns("/tmp")
data.stubs(:read).returns("tmp")
File.stubs(:read).with("/tmp").returns("tmp")
firmware_obj.stubs(:create_xml_config_file).returns(data)
wsman.stubs(:install_from_uri).returns(failed_return)
expect do
Expand Down

0 comments on commit 822ebba

Please sign in to comment.