knife-vsphere 1.2.18 → 1.2.19
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_network_add.rb +68 -0
- data/lib/chef/knife/vsphere_vm_vnc_set.rb +54 -0
- data/lib/knife-vsphere/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c25fd6b8d92bd7e275f83b51cf56547e11c40bc
|
4
|
+
data.tar.gz: fa0e605b6779e90693077b4505648ea123e9365d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e82afdd76191d93c17ac79a3f349bf2fcf5225b50bc1bc97535ee7a1c017a50fe1528eb6bd83d5283f8cbe7912f458d346a7cafe482b4411c2bdf2f26ec02c24
|
7
|
+
data.tar.gz: 6ba7c5d6f7923ed5bbcb5d12b5de0855a8cfaa06656ed8b73d510bc1979c534037e6531eb294e6a2a2f9a182da62c8fe18ecd76b4deb78f94e74cdab73fa23ac
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Scott Williams (<scott@backups.net.au>)
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
require 'chef/knife'
|
6
|
+
require 'chef/knife/base_vsphere_command'
|
7
|
+
require 'rbvmomi'
|
8
|
+
require 'netaddr'
|
9
|
+
|
10
|
+
class Chef::Knife::VsphereVmNetworkAdd < Chef::Knife::BaseVsphereCommand
|
11
|
+
banner 'knife vsphere vm network add VMNAME NETWORKNAME'
|
12
|
+
|
13
|
+
common_options
|
14
|
+
|
15
|
+
def run
|
16
|
+
$stdout.sync = true
|
17
|
+
vmname = @name_args[0]
|
18
|
+
if vmname.nil?
|
19
|
+
show_usage
|
20
|
+
fatal_exit('You must specify a virtual machine name')
|
21
|
+
end
|
22
|
+
|
23
|
+
networkname = @name_args[1]
|
24
|
+
if networkname.nil?
|
25
|
+
show_usage
|
26
|
+
fatal_exit('You must specify the network name')
|
27
|
+
end
|
28
|
+
|
29
|
+
vim_connection
|
30
|
+
|
31
|
+
dc = datacenter
|
32
|
+
folder = find_folder(get_config(:folder)) || dc.vmFolder
|
33
|
+
vm = traverse_folders_for_vm(folder, vmname) || abort("VM #{vmname} not found")
|
34
|
+
|
35
|
+
network = find_network(networkname)
|
36
|
+
|
37
|
+
puts network.class
|
38
|
+
case network
|
39
|
+
when RbVmomi::VIM::DistributedVirtualPortgroup
|
40
|
+
switch, pg_key = network.collect 'config.distributedVirtualSwitch', 'key'
|
41
|
+
port = RbVmomi::VIM.DistributedVirtualSwitchPortConnection(
|
42
|
+
switchUuid: switch.uuid,
|
43
|
+
portgroupKey: pg_key
|
44
|
+
)
|
45
|
+
summary = network.name
|
46
|
+
backing = RbVmomi::VIM.VirtualEthernetCardDistributedVirtualPortBackingInfo(port: port)
|
47
|
+
when VIM::Network
|
48
|
+
summary = network.name
|
49
|
+
backing = RbVmomi::VIM.VirtualEthernetCardNetworkBackingInfo(deviceName: network.name)
|
50
|
+
else fail
|
51
|
+
end
|
52
|
+
|
53
|
+
vm.ReconfigVM_Task(
|
54
|
+
spec: {
|
55
|
+
deviceChange: [{
|
56
|
+
operation: :add,
|
57
|
+
fileOperation: nil,
|
58
|
+
device: RbVmomi::VIM::VirtualVmxnet3(
|
59
|
+
key: -1,
|
60
|
+
deviceInfo: { summary: summary, label: '' },
|
61
|
+
backing: backing,
|
62
|
+
addressType: 'generated'
|
63
|
+
)
|
64
|
+
}]
|
65
|
+
}
|
66
|
+
).wait_for_completion
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Scott Williams (<scott@backups.net.au>)
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
require 'chef/knife'
|
6
|
+
require 'chef/knife/base_vsphere_command'
|
7
|
+
require 'rbvmomi'
|
8
|
+
require 'netaddr'
|
9
|
+
|
10
|
+
class Chef::Knife::VsphereVmVncset < Chef::Knife::BaseVsphereCommand
|
11
|
+
banner 'knife vsphere vm vncset VMNAME COMMAND ARGS'
|
12
|
+
|
13
|
+
option :vnc_port,
|
14
|
+
long: '--vnc-port PORT',
|
15
|
+
description: 'Port to run VNC on',
|
16
|
+
required: true
|
17
|
+
|
18
|
+
option :vnc_password,
|
19
|
+
long: '--vnc-password PASSWORD',
|
20
|
+
description: 'Password for connecting to VNC',
|
21
|
+
required: true
|
22
|
+
|
23
|
+
common_options
|
24
|
+
|
25
|
+
def run
|
26
|
+
$stdout.sync = true
|
27
|
+
vmname = @name_args[0]
|
28
|
+
if vmname.nil?
|
29
|
+
show_usage
|
30
|
+
fatal_exit('You must specify a virtual machine name')
|
31
|
+
end
|
32
|
+
|
33
|
+
vim_connection
|
34
|
+
|
35
|
+
dc = datacenter
|
36
|
+
folder = find_folder(get_config(:folder)) || dc.vmFolder
|
37
|
+
|
38
|
+
vm = find_in_folder(folder, RbVmomi::VIM::VirtualMachine, vmname) || abort("VM #{vmname} not found")
|
39
|
+
|
40
|
+
extra_config, = vm.collect('config.extraConfig')
|
41
|
+
|
42
|
+
vm.ReconfigVM_Task(
|
43
|
+
spec: {
|
44
|
+
extraConfig: [
|
45
|
+
{ key: 'RemoteDisplay.vnc.enabled', value: 'true' },
|
46
|
+
{ key: 'RemoteDisplay.vnc.port', value: config[:vnc_port].to_s },
|
47
|
+
{ key: 'RemoteDisplay.vnc.password', value: config[:vnc_password].to_s }
|
48
|
+
]
|
49
|
+
}
|
50
|
+
).wait_for_completion
|
51
|
+
|
52
|
+
puts extra_config.detect { |x| 'RemoteDisplay.vnc.enabled'.casecmp(x.key) && 'true'.casecmp(x.value.downcase) }
|
53
|
+
end
|
54
|
+
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: 1.2.
|
4
|
+
version: 1.2.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ezra Pagel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filesize
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- lib/chef/knife/vsphere_vm_migrate.rb
|
160
160
|
- lib/chef/knife/vsphere_vm_move.rb
|
161
161
|
- lib/chef/knife/vsphere_vm_net.rb
|
162
|
+
- lib/chef/knife/vsphere_vm_network_add.rb
|
162
163
|
- lib/chef/knife/vsphere_vm_network_set.rb
|
163
164
|
- lib/chef/knife/vsphere_vm_property_get.rb
|
164
165
|
- lib/chef/knife/vsphere_vm_property_set.rb
|
@@ -168,6 +169,7 @@ files:
|
|
168
169
|
- lib/chef/knife/vsphere_vm_state.rb
|
169
170
|
- lib/chef/knife/vsphere_vm_toolsconfig.rb
|
170
171
|
- lib/chef/knife/vsphere_vm_vmdk_add.rb
|
172
|
+
- lib/chef/knife/vsphere_vm_vnc_set.rb
|
171
173
|
- lib/chef/knife/vsphere_vm_wait_sysprep.rb
|
172
174
|
- lib/knife-vsphere/version.rb
|
173
175
|
homepage: http://github.com/ezrapagel/knife-vsphere
|