fog-vsphere 1.5.0 → 1.5.1

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: 8c29e38fdaa62dc93aec72fd59b93c8faf6f8625
4
- data.tar.gz: 76557efdce999f2226c60ca56752661831d04890
3
+ metadata.gz: edb0cd00d29fa95192e3d5a70f3f08d72c9a1221
4
+ data.tar.gz: f296c0b6fad69fb59c581c225af17398087a377d
5
5
  SHA512:
6
- metadata.gz: 6b7b39dd5c28e51ba0445ee47fa93608c3610daf67e30ec7ff129738ce1b3897c7e03da2c4ce8760fcd74b46653f83f969dc216bb1a291f0815d6e068102418f
7
- data.tar.gz: 34e87ecb4ac85e87d1862365f7d33b4d1b9c27c1865f24cc569ba9ceb6b8ceb46cb66d01dd1d68d5335194237ebf81686fdb51a078fa693d7594f317609cb771
6
+ metadata.gz: 0954d0617378088536af6d5099f39ff26097ed09069e8abf9eec1386c12aea659bf72847e05679064a9938a487f8e69c21bb8f1ec0164f62e7b526c26d471bde
7
+ data.tar.gz: 02cfbb0004d8e8cfec927052b0615eac8aefe2a24e4142495e2e3a256cfd05af05d6be642a67e606be213213321a4a03151da4d5b79a40b61b01ad21fa7fd774
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v1.5.1
2
+
3
+ * Move volume key generation to volume model
4
+ * Set defaults more reliably for SCSI
5
+
1
6
  ## v1.5.0
2
7
 
3
8
  * Rename the get_spec method in create_rule to get_group_spec
@@ -5,9 +5,14 @@ module Fog
5
5
  attribute :shared_bus
6
6
  attribute :type
7
7
  attribute :unit_number
8
- attribute :key
8
+ attribute :key, :type => :integer
9
9
  attribute :server_id
10
10
 
11
+ def initialize(attributes = {})
12
+ super
13
+ self.key ||= 1000
14
+ end
15
+
11
16
  def to_s
12
17
  "#{type} ##{key}: shared: #{shared_bus}, unit_number: #{unit_number}"
13
18
  end
@@ -17,7 +17,7 @@ module Fog
17
17
  attribute :size_gb
18
18
  attribute :key
19
19
  attribute :unit_number
20
- attribute :controller_key, :type => :integer, :default => 1000
20
+ attribute :controller_key, :type => :integer
21
21
 
22
22
  def initialize(attributes={})
23
23
  super defaults.merge(attributes)
@@ -87,13 +87,25 @@ module Fog
87
87
  end
88
88
  end
89
89
 
90
+ def set_key
91
+ requires :controller_key, :unit_number
92
+
93
+ return unless key.nil?
94
+
95
+ # controller key is based on 1000 + controller bus
96
+ # disk key is based on 2000 + the SCSI ID + the controller bus * 16
97
+ controller_bus = controller_key - 1000
98
+ self.key = 2000 + (controller_bus * 16) + unit_number
99
+ end
100
+
90
101
  private
91
102
 
92
103
  def defaults
93
104
  {
94
105
  :thin => true,
95
106
  :name => "Hard disk",
96
- :mode => "persistent"
107
+ :mode => "persistent",
108
+ :controller_key => 1000
97
109
  }
98
110
  end
99
111
 
@@ -149,7 +149,7 @@ module Fog
149
149
  disks.each do |disk|
150
150
  # we allow booting from all harddisks, the first disk has the highest priority
151
151
  boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableDiskDevice.new(
152
- :deviceKey => get_disk_device_key(disk.controllerKey, disk.unitNumber)
152
+ :deviceKey => disk.key
153
153
  )
154
154
  end
155
155
  when 'cdrom'
@@ -163,13 +163,6 @@ module Fog
163
163
  boot_order
164
164
  end
165
165
 
166
- def get_disk_device_key(controller_key, unit_number)
167
- # controller key is based on 1000 + controller bus
168
- # disk key is based on 2000 + the SCSI ID + the controller bus * 16
169
- controller_bus = controller_key - 1000
170
- 2000 + (controller_bus * 16) + unit_number
171
- end
172
-
173
166
  def create_nic_backing nic, attributes
174
167
  raw_network = get_raw_network(nic.network, attributes[:datacenter], if nic.virtualswitch then nic.virtualswitch end)
175
168
 
@@ -246,12 +239,13 @@ module Fog
246
239
  end
247
240
 
248
241
  disk.set_unit_number
242
+ disk.set_key
249
243
 
250
244
  payload = {
251
245
  :operation => operation,
252
246
  :fileOperation => operation == :add ? :create : :destroy,
253
247
  :device => RbVmomi::VIM.VirtualDisk(
254
- :key => -1,
248
+ :key => disk.key,
255
249
  :backing => RbVmomi::VIM.VirtualDiskFlatVer2BackingInfo(
256
250
  :fileName => datastore,
257
251
  :diskMode => disk.mode.to_sym,
@@ -3,17 +3,17 @@ module Fog
3
3
  class Vsphere
4
4
  class Real
5
5
  def add_vm_volume(volume)
6
- vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_disk(volume, volume.unit_number, :add)]})
6
+ vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_disk(volume, :add)]})
7
7
  end
8
8
 
9
9
  def destroy_vm_volume(volume)
10
- vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_disk(volume, volume.unit_number, :remove)]})
10
+ vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_disk(volume, :remove)]})
11
11
  end
12
12
  end
13
13
 
14
14
  class Mock
15
15
  def add_vm_volume(volume)
16
- vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_cdrom(volume, volume.unit_number, :add)]})
16
+ vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_cdrom(volume, :add)]})
17
17
  end
18
18
 
19
19
  def destroy_vm_volume(volume)
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '1.5.0'
3
+ VERSION = '1.5.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.R. Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-25 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core