Skip to content

Commit

Permalink
Add snapshot id to snapshot listing and cpu and memory hot add enable…
Browse files Browse the repository at this point in the history
…d option to vm find (#424)

* Test

* Revert Change

* Add snapshot creation timestamp to snapshot listing to allow users to not only see the current tree of snapshots but to also view the snapshots creation timestamp. Also added option --snapshot-descr DESCR to allow users to add a description when creating a snapshot.  Currently, the descripton field is hardcode to an empty string.

* fixed 11 violations identified by Hound

* fixed 2 violations identified by Hound

* Fixed CHANGELOG to use GitHub account name and replaced double quotes around newline character with single quotes.

* Refactored display_node method to output snapshot tree hierarchy in json and various other formats. Also added snapshot description to the snapshot info that is outputted.

* fix issues identified by hound

* fix more changes identified by hound

* Fix code to use map when listing snapshots. Removed the shift statement in display_node method as it is no longer required as we are now storing the list of snapshots in a data structure.

* fix issues identified by Hound

* fix issues identified by Hound

* add snapshot id to snapshot listing and cpu and memory hot add enabled to vm find command

* Added the flags --cpu-hot-add-enabled and --memory-hot-add-enabled to the readme file
  • Loading branch information
nammiesgal authored and swalberg committed Mar 19, 2018
1 parent 42e8de9 commit de4ef52
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ knife-vsphere changelog
2.0.4 nammiesgal - Refactored display_node method in vsphere_vm_snapshot.rb to output
list of snapshots in a tree hierarchy that can be output in various
formats using ui.output.
- Add additional snapshot information to the tree hierarchy
- Add additional snapshot information to the tree hierarchy
- Add cpu and memory hot add enabled flags to vsphere_vm_find.rb
2.0.3 swalberg - If the node exists prior to clone, move to bootstrap

2.0.2 nammiesgal - Add snapshot creation timestamp to snapshot listing.
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ currently supports the following:
* datastore
* resource pool

Note: For Windows guests we can run sysprep
Note: For Windows guests we can run FIELDS

## Basic Examples:

Expand Down Expand Up @@ -211,6 +211,7 @@ FIELDS:
```bash
--alarms show alarm status
--cpu Show cpu
--cpu-hot-add-enabled Show cpu hot add enabled flag
--esx-disk Show esx disks
--full-path Show full path
--hostname show hostname
Expand All @@ -220,6 +221,7 @@ FIELDS:
--os Show os details
--os-disks Show os disks
--ram Show ram
--memory-hot-add-enabled Show memory hot add enabled flag
--snapshots Show snapshots
--tools show tools status
```
Expand Down
16 changes: 16 additions & 0 deletions lib/chef/knife/vsphere_vm_find.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ class Chef::Knife::VsphereVmFind < Chef::Knife::BaseVsphereCommand
long: '--cpu',
description: 'Show cpu'

option :cpu_hot_add_enabled,
long: '--cpu_hot_add_enabled',
description: 'Show cpu hot add enabled'

option :memory_hot_add_enabled,
long: '--memory_hot_add_enabled',
description: 'Show memory hot add enabled'

option :ram,
long: '--ram',
description: 'Show ram'
Expand Down Expand Up @@ -235,6 +243,14 @@ def run
thisvm['ram'] = vm.summary.config.memorySizeMB
end

if get_config(:cpu_hot_add_enabled)
thisvm['cpu_hot_add_enabled'] = vm.config.cpuHotAddEnabled
end

if get_config(:memory_hot_add_enabled)
thisvm['memory_hot_add_enabled'] = vm.config.memoryHotAddEnabled
end

if get_config(:cpu)
thisvm['cpu'] = vm.summary.config.numCpu
end
Expand Down
1 change: 1 addition & 0 deletions lib/chef/knife/vsphere_vm_snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def find_node(tree, name)
def display_node(node, current)
children = node.childSnapshotList.map { |item| display_node(item, current) }
snapshot_tree = { 'SnapshotName' => node.name,
'SnapshotId' => node.id,
'SnapshotDescription' => node.description,
'SnapshotCreationDate' => node.createTime.iso8601,
'Children' => children }
Expand Down

0 comments on commit de4ef52

Please sign in to comment.