knife-vsphere 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06e3ee523488e2e14df1e267f2c980880a427e19
4
- data.tar.gz: 7050570b79976dc09f12b4370176645a857e3894
3
+ metadata.gz: 8385a5227a8b7ca2a3df24c33ad157042949080a
4
+ data.tar.gz: a1389be7c172d6d83cd2212a3c783f0787e3814b
5
5
  SHA512:
6
- metadata.gz: 6df9b92b2fe8a8ece228ca68104968c49943e6440ddbf239a590fd4de221836533cc665d5c5447e8188c1298c542966072570f44b05066a0afe7df28b0d96bc6
7
- data.tar.gz: 733ec8e53a9930bb05632f5d8864d19bfa51c5eb44ef8ac068a532127bfe6141ee7147c05751954c5cb9db4b865100f0f45a700fb36d98d2aacad1b587c78614
6
+ metadata.gz: 5a109cb170ebcd0708e395efcc4258aca961fd1f32454559533501de58a37401c0165da0964a74a79556ed4fcdd40c2563bc913155047cb4c0233e074484529d
7
+ data.tar.gz: 9cdb024fe3a930c80eefa15d122c2ab7f696723da86f436544873b0611620b9fd6f41629d78e68454f8983a5635f697e052e334ce897ae635f5d96ef6f70e8cc
@@ -7,6 +7,7 @@
7
7
  require 'chef/knife'
8
8
  require 'rbvmomi'
9
9
  require 'base64'
10
+ require 'filesize'
10
11
 
11
12
  # Base class for vsphere knife commands
12
13
  class Chef
@@ -344,10 +344,6 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
344
344
  config[:distro] = 'windows-chef-client-msi' if config[:distro].nil? || config[:distro] == 'chef-full'
345
345
  unless config[:disable_customization]
346
346
  # Wait for customization to complete
347
- # TODO: Figure out how to find the customization complete event from the vsphere logs. The
348
- # customization can take up to 10 minutes to complete from what I have seen perhaps
349
- # even longer. For now I am simply sleeping, but if anyone knows how to do this
350
- # better fix it.
351
347
  puts 'Waiting for customization to complete...'
352
348
  CustomizationHelper.wait_for_sysprep(vm, vim, get_config(:sysprep_timeout), 10)
353
349
  puts 'Customization Complete'
@@ -0,0 +1,66 @@
1
+ #
2
+ # Author:: Malte Heidenreich (https://github.com/mheidenr)
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+
6
+ require 'chef/knife'
7
+ require 'chef/knife/base_vsphere_command'
8
+ require 'rbvmomi'
9
+
10
+ class Chef::Knife::VsphereVmDiskExtend < Chef::Knife::BaseVsphereCommand
11
+ banner 'knife vsphere vm disk extend VMNAME SIZE. Extends the disk of vm VMNAME to SIZE kilobytes.'
12
+
13
+ common_options
14
+
15
+ option :diskname,
16
+ long: '--diskname DISKNAME',
17
+ description: 'The name of the disk that will be extended'
18
+
19
+ def run
20
+ $stdout.sync = true
21
+ vmname = @name_args[0]
22
+ if vmname.nil?
23
+ show_usage
24
+ fatal_exit('You must specify a virtual machine name')
25
+ end
26
+
27
+ size = @name_args[1]
28
+ if size.nil? || !size.match(/^\d+$/)
29
+ show_usage
30
+ fatal_exit('You must specify the new disk size')
31
+ end
32
+
33
+ disk_name = get_config(:diskname) unless get_config(:diskname).nil?
34
+
35
+ vim_connection
36
+
37
+ dc = datacenter
38
+
39
+ folder = find_folder(get_config(:folder)) || dc.vmFolder
40
+
41
+ vm = find_in_folder(folder, RbVmomi::VIM::VirtualMachine, vmname) || abort("VM #{vmname} not found")
42
+
43
+ disks = vm.config.hardware.device.select do |device|
44
+ device.is_a?(RbVmomi::VIM::VirtualDisk) && (disk_name.nil? || device.deviceInfo.label == disk_name)
45
+ end
46
+
47
+ if disks.length > 1
48
+ names = disks.map { |disk| disk.deviceInfo.label }
49
+ abort("More than 1 disk found: #{names}, please use --diskname DISKNAME")
50
+ elsif disks.length == 0
51
+ abort('No disk found')
52
+ end
53
+
54
+ disk = disks[0]
55
+ disk.capacityInKB = size
56
+
57
+ vm.ReconfigVM_Task(spec:
58
+ RbVmomi::VIM::VirtualMachineConfigSpec(
59
+ deviceChange: [RbVmomi::VIM::VirtualDeviceConfigSpec(
60
+ device: disk,
61
+ operation: RbVmomi::VIM::VirtualDeviceConfigSpecOperation('edit'))]
62
+ )).wait_for_completion
63
+
64
+ puts 'Disk resized successfully'
65
+ end
66
+ end
@@ -0,0 +1,32 @@
1
+ require 'chef/knife'
2
+ require 'chef/knife/base_vsphere_command'
3
+
4
+ # List the disks attached to a VM
5
+ class Chef::Knife::VsphereVmDiskList < Chef::Knife::BaseVsphereCommand
6
+ banner 'knife vsphere vm disk list VMNAME'
7
+
8
+ common_options
9
+
10
+ def run
11
+ $stdout.sync = true
12
+
13
+ unless vmname = @name_args[0]
14
+ show_usage
15
+ fatal_exit 'You must specify a virtual machine name'
16
+ end
17
+
18
+ vim_connection
19
+ vm = get_vm(vmname)
20
+ fatal_exit "Could not find #{vmname}" unless vm
21
+
22
+ disks = vm.config.hardware.device.select do |device|
23
+ device.is_a? RbVmomi::VIM::VirtualDisk
24
+ end
25
+
26
+ disks.each do |disk|
27
+ puts '%3d %20s %s' % [disk.unitNumber,
28
+ disk.deviceInfo.label,
29
+ Filesize.from("#{disk.capacityInKB} KB").pretty]
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module KnifeVsphere
2
- VERSION = '1.2.5'
2
+ VERSION = '1.2.6'
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezra Pagel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2015-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: filesize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: netaddr
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,8 @@ files:
94
108
  - lib/chef/knife/vsphere_vm_clone.rb
95
109
  - lib/chef/knife/vsphere_vm_config.rb
96
110
  - lib/chef/knife/vsphere_vm_delete.rb
111
+ - lib/chef/knife/vsphere_vm_disk_extend.rb
112
+ - lib/chef/knife/vsphere_vm_disk_list.rb
97
113
  - lib/chef/knife/vsphere_vm_execute.rb
98
114
  - lib/chef/knife/vsphere_vm_find.rb
99
115
  - lib/chef/knife/vsphere_vm_list.rb