<commit_before>require 'puppet/util/network_device'
require 'puppet/provider/dell_ftos'

Puppet::Type.type(:force10_firmwareupdate).provide :dell_ftos, :parent => Puppet::Provider do
  mk_resource_methods

  def run(firmwarelocation, forceupdate)
     Puppet.debug("Puppet::Force10_firmwareUpdate*********************")
     Puppet.debug("firmware Image path is: #{firmwarelocation} and force update flag is: #{forceupdate}")
     dev = Puppet::Util::NetworkDevice.current     
     currentFirmwareVersion = dev.switch.facts['dell_force10_application_software_version'] 
     Puppet.debug(" currentfirmwareversion: #{currentFirmwareVersion}")
     newfirmwareversion = firmwarelocation.split("\/").last.split("-").last.split(".bin").first
     Puppet.debug("  newfirmwareversion  is: " + newfirmwareversion )
     txt = ''     
    if currentFirmwareVersion.eql? newfirmwareversion && forceupdate == :false
		Puppet.debug("Existing Firmware versions is same as new Firmware version, so not doing firmware update")
        txt = "Existing Firmware versions is same as new Firmware version, so not doing firmware update"
		return txt
    end
    dev.transport.command("upgrade system #{firmwarelocation} A:")  do |out|
		txt << out
    end
    item = txt.scan("successfully")
    if item.empty?
		txt="Firmware update is not successful"
		Puppet.debug(txt)
		raise txt 
    end<commit_msg>Code changes for Force10 Firmware update(Code to read the version from the file using switch)<commit_after>require 'puppet/util/network_device'

require 'puppet/provider/dell_ftos'

Puppet::Type.type(:force10_firmwareupdate).provide :dell_ftos, :parent => Puppet::Provider do
  mk_resource_methods

  def run(firmwarelocation, forceupdate)
     Puppet.debug("Puppet::Force10_firmwareUpdate*********************")
     Puppet.debug("firmware Image path is: #{firmwarelocation} and force update flag is: #{forceupdate}")
     dev = Puppet::Util::NetworkDevice.current     
     currentFirmwareVersion = dev.switch.facts['dell_force10_application_software_version'] 
     Puppet.debug(" currentfirmwareversion: #{currentFirmwareVersion}")
     newfirmwareversion = firmwarelocation.split("\/").last.split("-").last.split(".bin").first
     
     firmwareversiondata = ""
     dev.transport.command("show os-version #{firmwarelocation}") do |firmwareResponse|
      firmwareversiondata << firmwareResponse
     end
     firmwarewversionline = firmwareversiondata.match(/^\s*(.*:\s*\b([A-Za-z]{1}[A-Za-z0-9]*)\b\s*\b([0-9]{1}[0-9\-\.]*)\b.*)/)[1]
     Puppet.debug("The version of the firmware update file is  #{firmwarewversionline.split("\ ")[2]}")
     newfirmwareversion = firmwarewversionline.split("\ ")[2]
     Puppet.debug("  newfirmwareversion  is: " + newfirmwareversion )
     txt = ''     
    if currentFirmwareVersion.eql? newfirmwareversion && forceupdate == :false
		Puppet.debug("Existing Firmware versions is same as new Firmware version, so not doing firmware update")
        txt = "Existing Firmware versions is same as new Firmware version, so not doing firmware update"
		return txt
    end
    dev.transport.command("upgrade system #{firmwarelocation} A:")  do |out|
		txt << out
    end
    item = txt.scan("successfully")
    if item.empty?
		txt="Firmware update is not successful"
		Puppet.debug(txt)
		raise txt 
    end
{'fraction_non_alphanumeric': 0.1311918342839988, 'fraction_numerical': 0.007505253677574302, 'mean_word_length': 4.382875605815832, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6436138', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1010, 'n_words': 233}