knife-vsphere 1.2.20 → 1.2.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e13ce28b3bdc4b2b9bb0dbcc5d4d3d8bda496eed
4
- data.tar.gz: 6f02adc6815fee8cb34417e860b6d4afce3ea17a
3
+ metadata.gz: 75be37e04c524b55d4e49cf27e95b5d689f4588f
4
+ data.tar.gz: d68bd0bb8b73ce62437191cf74efec809e1412af
5
5
  SHA512:
6
- metadata.gz: eda8d5d50c86e096e4654cb33e7b42372f46192a42eea351ee722ecc3e29538b0ffa27fdbdbe9c2a86f99c89d28bb14c3f00a7f477d4c7357bf945588a151dd6
7
- data.tar.gz: afe13ef5403727e774eab7a94901c99a76f0db13c8f999b4cac2228958a2111e87bf4cb6a3bf53443ff5254b261f4a9b5ad5278d5ab53f6558076045960be4fc
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::VirtualVmxnet3(
85
+ device: RbVmomi::VIM.send(device_type,
59
86
  key: -1,
60
87
  deviceInfo: { summary: summary, label: '' },
61
88
  backing: backing,
62
- addressType: 'generated'
89
+ addressType: address_type,
90
+ macAddress: mac_address
63
91
  )
64
92
  }]
65
93
  }
@@ -1,3 +1,3 @@
1
1
  module KnifeVsphere
2
- VERSION = '1.2.20'
2
+ VERSION = '1.2.21'
3
3
  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.20
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-30 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: filesize