knife-vsphere 1.2.20 → 1.2.21
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 +31 -3
- data/lib/knife-vsphere/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75be37e04c524b55d4e49cf27e95b5d689f4588f
|
4
|
+
data.tar.gz: d68bd0bb8b73ce62437191cf74efec809e1412af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa48a83dc562b4af0798e3faa1bb9cba61b01343bf215f1937950b8e5b13f0f8b3e8a58d6d9065271a3cd9e1ec6fb2e350170b8b5e6fd2d2a6189a53dab13151
|
7
|
+
data.tar.gz: 84a0f2525640c43902a15ad7685ae91e9949f10dd26887d397ba20791713188387642aa8066862567f10b014bd3131be11113373c98530305711f070dd937d3a
|
@@ -10,8 +10,19 @@ require 'netaddr'
|
|
10
10
|
class Chef::Knife::VsphereVmNetworkAdd < Chef::Knife::BaseVsphereCommand
|
11
11
|
banner 'knife vsphere vm network add VMNAME NETWORKNAME'
|
12
12
|
|
13
|
+
option :adapter_type,
|
14
|
+
long: '--adapter-type STRING',
|
15
|
+
description: 'Adapter type eg e1000,vmxnet3',
|
16
|
+
required: true
|
17
|
+
|
18
|
+
option :mac_address,
|
19
|
+
long: '--mac-address STRING',
|
20
|
+
description: 'Adapter MAC address eg. AA:BB:CC:DD:EE:FF',
|
21
|
+
required: false
|
22
|
+
|
13
23
|
common_options
|
14
24
|
|
25
|
+
|
15
26
|
def run
|
16
27
|
$stdout.sync = true
|
17
28
|
vmname = @name_args[0]
|
@@ -34,7 +45,6 @@ class Chef::Knife::VsphereVmNetworkAdd < Chef::Knife::BaseVsphereCommand
|
|
34
45
|
|
35
46
|
network = find_network(networkname)
|
36
47
|
|
37
|
-
puts network.class
|
38
48
|
case network
|
39
49
|
when RbVmomi::VIM::DistributedVirtualPortgroup
|
40
50
|
switch, pg_key = network.collect 'config.distributedVirtualSwitch', 'key'
|
@@ -50,16 +60,34 @@ class Chef::Knife::VsphereVmNetworkAdd < Chef::Knife::BaseVsphereCommand
|
|
50
60
|
else fail
|
51
61
|
end
|
52
62
|
|
63
|
+
device_type = case get_config(:adapter_type)
|
64
|
+
when 'e1000'
|
65
|
+
:VirtualE1000
|
66
|
+
when 'vmxnet3'
|
67
|
+
:VirtualVmxnet3
|
68
|
+
when *
|
69
|
+
fatal_exit('The adapter must be either e1000 or vmxnet3')
|
70
|
+
end
|
71
|
+
|
72
|
+
if get_config(:mac_address).nil?
|
73
|
+
address_type = 'generated'
|
74
|
+
mac_address = ''
|
75
|
+
else
|
76
|
+
address_type = 'manual'
|
77
|
+
mac_address = get_config(:mac_address)
|
78
|
+
end
|
79
|
+
|
53
80
|
vm.ReconfigVM_Task(
|
54
81
|
spec: {
|
55
82
|
deviceChange: [{
|
56
83
|
operation: :add,
|
57
84
|
fileOperation: nil,
|
58
|
-
device: RbVmomi::VIM
|
85
|
+
device: RbVmomi::VIM.send(device_type,
|
59
86
|
key: -1,
|
60
87
|
deviceInfo: { summary: summary, label: '' },
|
61
88
|
backing: backing,
|
62
|
-
addressType:
|
89
|
+
addressType: address_type,
|
90
|
+
macAddress: mac_address
|
63
91
|
)
|
64
92
|
}]
|
65
93
|
}
|
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.21
|
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-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filesize
|