Method: Cisco::Upgrade.upgrade

Defined in:
lib/cisco_node_utils/upgrade.rb

.upgrade(image, uri = 'bootflash:', del_boot = false, force_all = false) ⇒ Object

Attempts to upgrade the device to ‘image’



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/cisco_node_utils/upgrade.rb', line 101

def self.upgrade(image, uri='bootflash:', del_boot=false,
                 force_all=false)
  delete_boot(uri) if del_boot
  force_all ? upgrade_str = 'upgrade_force' : upgrade_str = 'upgrade'
  begin
    Cisco::Logger.debug("Upgrading to version: #{image}")
    config_set('upgrade', upgrade_str, image: image, uri: uri)
  rescue Cisco::RequestFailed, Cisco::CliError => e1
    # raise if install command failed
    raise e1 if e1.class == Cisco::CliError
    # Catch 'Backend Processing Error'. Install continues inspite of the
    # error thrown. Resend install command and expect a CliError.
    begin
      config_set('upgrade', upgrade_str, image: image, uri: uri)
    rescue Cisco::CliError => e2
      raise e2 unless
        e2.message.include?('Another install procedure may be in progress')
    end
  end
end