knife-vsphere 2.1.0 → 2.1.1
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 +4 -4
- data/lib/chef/knife/vsphere_vm_config.rb +6 -18
- data/lib/chef/knife/vsphere_vm_execute.rb +10 -14
- data/lib/chef/knife/vsphere_vm_show.rb +14 -14
- data/lib/knife-vsphere/version.rb +1 -1
- metadata +2 -3
- data/lib/chef/knife/vsphere_vm_query.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a38302a790751f683b4e650f7bf7bb8425409b2
|
4
|
+
data.tar.gz: 2c4f53befb4b733af86250addfcd844f417df1be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fc957ac456c865811d93ea7b6e9ce6006b85e26ab710a21e8cd0ac31e6e39e5665c55a1b6ac1f1e78076cff52ea79c8863460e4f04d6df7c7bdb68f07a8ebd4
|
7
|
+
data.tar.gz: a51ce26b8a3e093dae4a11e82627fccfffa906b8c2fbef53aa935e29fbdb2cdb8dadd8830d1336e3e14b59f2d0dbe3d2b4c64bcc248452bd88eb468b9a14ac74
|
@@ -8,8 +8,8 @@ require 'chef/knife/search_helper'
|
|
8
8
|
# VsphereVMconfig extends the BaseVspherecommand
|
9
9
|
class Chef::Knife::VsphereVmConfig < Chef::Knife::BaseVsphereCommand
|
10
10
|
include SearchHelper
|
11
|
-
banner "knife vsphere vm config VMNAME PROPERTY VALUE
|
12
|
-
See \"
|
11
|
+
banner "knife vsphere vm config VMNAME PROPERTY VALUE (PROPERTY VALUE)...
|
12
|
+
See \"https://www.vmware.com/support/developer/converter-sdk/conv60_apireference/vim.vm.ConfigSpec.html\"
|
13
13
|
for allowed ATTRIBUTE values (any property of type xs:string is supported)."
|
14
14
|
|
15
15
|
common_options
|
@@ -18,31 +18,19 @@ class Chef::Knife::VsphereVmConfig < Chef::Knife::BaseVsphereCommand
|
|
18
18
|
#
|
19
19
|
def run
|
20
20
|
$stdout.sync = true
|
21
|
-
vmname = @name_args
|
21
|
+
vmname = @name_args.shift
|
22
22
|
if vmname.nil?
|
23
23
|
show_usage
|
24
24
|
fatal_exit('You must specify a virtual machine name')
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
show_usage
|
30
|
-
fatal_exit('You must specify a PROPERTY name (e.g. annotation)')
|
27
|
+
unless @name_args.length > 0 && @name_args.length % 2 == 0
|
28
|
+
fatal_exit('You must specify a series of PROPERTY name (e.g. annotation) followed by a value')
|
31
29
|
end
|
32
|
-
property_name = property_name.to_sym
|
33
|
-
|
34
|
-
property_value = @name_args[2]
|
35
|
-
if property_value.nil?
|
36
|
-
show_usage
|
37
|
-
fatal_exit('You must specify a PROPERTY value')
|
38
|
-
end
|
39
|
-
|
40
|
-
vim_connection
|
41
30
|
|
42
31
|
vm = get_vm_by_name(vmname, get_config(:folder)) || fatal_exit("Could not find #{vmname}")
|
43
32
|
|
44
|
-
properties = {}
|
45
|
-
properties[property_name] = property_value
|
33
|
+
properties = @name_args.each_slice(2).map { |prop, val| [prop.to_sym, val] }.to_h
|
46
34
|
vm.ReconfigVM_Task(spec: RbVmomi::VIM.VirtualMachineConfigSpec(properties)).wait_for_completion
|
47
35
|
end
|
48
36
|
end
|
@@ -3,11 +3,12 @@
|
|
3
3
|
|
4
4
|
require 'chef/knife'
|
5
5
|
require 'chef/knife/base_vsphere_command'
|
6
|
-
require '
|
7
|
-
require 'netaddr'
|
6
|
+
require 'chef/knife/search_helper'
|
8
7
|
|
9
8
|
# VsphereVMexecute extends the Basevspherecommand
|
10
9
|
class Chef::Knife::VsphereVmExecute < Chef::Knife::BaseVsphereCommand
|
10
|
+
include SearchHelper
|
11
|
+
|
11
12
|
banner 'knife vsphere vm execute VMNAME COMMAND ARGS'
|
12
13
|
|
13
14
|
option :exec_user,
|
@@ -30,34 +31,29 @@ class Chef::Knife::VsphereVmExecute < Chef::Knife::BaseVsphereCommand
|
|
30
31
|
#
|
31
32
|
def run
|
32
33
|
$stdout.sync = true
|
33
|
-
vmname = @name_args
|
34
|
+
vmname = @name_args.shift
|
34
35
|
if vmname.nil?
|
35
36
|
show_usage
|
36
37
|
fatal_exit('You must specify a virtual machine name')
|
37
38
|
end
|
38
|
-
command = @name_args
|
39
|
+
command = @name_args.shift
|
39
40
|
if command.nil?
|
40
41
|
show_usage
|
41
42
|
fatal_exit('You must specify a command to execute')
|
42
43
|
end
|
43
44
|
|
44
|
-
args = @name_args
|
45
|
-
args = '' if args.nil?
|
46
|
-
|
47
|
-
vim = vim_connection
|
48
|
-
|
49
|
-
dc = datacenter
|
50
|
-
folder = find_folder(get_config(:folder)) || dc.vmFolder
|
45
|
+
args = @name_args
|
46
|
+
args = '' if args.nil? || args.empty?
|
51
47
|
|
52
|
-
vm =
|
48
|
+
vm = get_vm_by_name(vmname, get_config(:folder)) || fatal_exit("Could not find #{vmname}")
|
53
49
|
|
54
|
-
gom =
|
50
|
+
gom = vim_connection.serviceContent.guestOperationsManager
|
55
51
|
|
56
52
|
guest_auth = RbVmomi::VIM::NamePasswordAuthentication(interactiveSession: false,
|
57
53
|
username: config[:exec_user],
|
58
54
|
password: config[:exec_passwd])
|
59
55
|
prog_spec = RbVmomi::VIM::GuestProgramSpec(programPath: command,
|
60
|
-
arguments: args,
|
56
|
+
arguments: args.join(' '),
|
61
57
|
workingDirectory: get_config(:exec_dir))
|
62
58
|
|
63
59
|
gom.processManager.StartProgramInGuest(vm: vm, auth: guest_auth, spec: prog_spec)
|
@@ -16,33 +16,33 @@ class Chef::Knife::VsphereVmShow < Chef::Knife::BaseVsphereCommand
|
|
16
16
|
#
|
17
17
|
def run
|
18
18
|
$stdout.sync = true
|
19
|
-
vmname = @name_args
|
19
|
+
vmname = @name_args.shift
|
20
20
|
if vmname.nil?
|
21
21
|
show_usage
|
22
22
|
fatal_exit('You must specify a virtual machine name')
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
if query_string.nil?
|
25
|
+
if @name_args.empty?
|
27
26
|
show_usage
|
28
27
|
fatal_exit('You must specify a QUERY value (e.g. guest.ipAddress or network[0].name)')
|
29
28
|
end
|
30
29
|
|
31
|
-
vim_connection
|
32
|
-
|
33
30
|
vm = get_vm_by_name(vmname, get_config(:folder)) || fatal_exit("Could not find #{vmname}")
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
32
|
+
out = @name_args.map do |query_string|
|
33
|
+
# split QUERY by dots, and walk the object model
|
34
|
+
query = query_string.split '.'
|
35
|
+
result = vm
|
36
|
+
query.each do |part|
|
37
|
+
message, index = part.split(/[\[\]]/)
|
38
|
+
unless result.respond_to? message.to_sym
|
39
|
+
fatal_exit("\"#{query_string}\" not recognized.")
|
40
|
+
end
|
41
|
+
result = index ? result.send(message)[index.to_i] : result.send(message)
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
{ query_string => result }
|
45
45
|
end
|
46
|
-
|
46
|
+
ui.output out
|
47
47
|
end
|
48
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-vsphere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ezra Pagel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03
|
11
|
+
date: 2018-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: knife-windows
|
@@ -208,7 +208,6 @@ files:
|
|
208
208
|
- lib/chef/knife/vsphere_vm_network_set.rb
|
209
209
|
- lib/chef/knife/vsphere_vm_property_get.rb
|
210
210
|
- lib/chef/knife/vsphere_vm_property_set.rb
|
211
|
-
- lib/chef/knife/vsphere_vm_query.rb
|
212
211
|
- lib/chef/knife/vsphere_vm_show.rb
|
213
212
|
- lib/chef/knife/vsphere_vm_snapshot.rb
|
214
213
|
- lib/chef/knife/vsphere_vm_state.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'chef/knife'
|
2
|
-
require 'chef/knife/base_vsphere_command'
|
3
|
-
|
4
|
-
# VsphereVmQuery extends the BaseVspherecommand
|
5
|
-
class Chef::Knife::VsphereVmQuery < Chef::Knife::BaseVsphereCommand
|
6
|
-
banner "knife vsphere vm query VMNAME QUERY. See \"http://pubs.vmware.com/vi3/sdk/ReferenceGuide/vim.VirtualMachine.html\" for allowed QUERY values."
|
7
|
-
|
8
|
-
common_options
|
9
|
-
|
10
|
-
# The main run method for vm_query
|
11
|
-
#
|
12
|
-
def run
|
13
|
-
args = ARGV
|
14
|
-
args[2] = 'show'
|
15
|
-
ui.warn 'vsphere vm query is moving to vsphere vm show. Next time, please run'
|
16
|
-
ui.warn args.join " "
|
17
|
-
Chef::Knife.run(args)
|
18
|
-
end
|
19
|
-
end
|