Skip to content

Commit

Permalink
Upgrade services (#520)
Browse files Browse the repository at this point in the history
* Initial upgrade services

* Remove white space

* Allows tokens to be passed to get_command

* Add tests and procs for install all nxos

* Update DOC to highlight that get_command can be tokenized

* Add YAML to specify params for upgrade

* Adding error handling and cleaning up code

* Reworked some TCs + Add new TCs

* Handle case when upgrade is run with booted image

* Add test_upgrade_boot_image

* Add Service to CHANGELOG.md

* Add TODO to upgrade scenario

* Update CHANGELOG.md

* Add command for upgrade_force

* Update upgrade to handle delete_boot and force upgrade
  • Loading branch information
rahushen authored and mikewiebe committed Feb 27, 2017
1 parent 1e93afc commit 98201d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/cisco_node_utils/cmd_ref/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ upgrade:
set_context: ['terminal dont-ask']
set_value: "install all nxos <media><image>"

upgrade_force:
set_context: ['terminal dont-ask']
set_value: "install force-all nxos <media><image>"

upgraded:
kind: boolean
get_command: 'show install all status'
Expand Down
14 changes: 12 additions & 2 deletions lib/cisco_node_utils/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def self.image_version(image=nil, media=nil)
end
end

# Return the image booted on the device
def self.image
config_get('show_version', 'system_image')
end

def self.save_config
config_set('service', 'save_config')
rescue Cisco::CliError => e
Expand All @@ -73,8 +78,13 @@ def self.upgraded?
end

# Attempts to upgrade the device to 'image'
def self.upgrade(image, media='bootflash:')
config_set('service', 'upgrade', image: image, media: media)
def self.upgrade(image, media='bootflash:', del_boot=false, force_all=false)
delete_boot(media) if del_boot
if force_all
config_set('service', 'upgrade_force', image: image, media: media)
else
config_set('service', 'upgrade', image: image, media: media)
end
end
end
end

0 comments on commit 98201d8

Please sign in to comment.