fog-hyperv 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f66bbfe9d046bb995a0ad3ae1ce65bdfd1576953
4
- data.tar.gz: e074ab919089ff977deb7acfc711bd5f5c38788b
2
+ SHA256:
3
+ metadata.gz: e0d0573b3cef41610d0b6fbc09d680a35273ad86aa2fa67344e3a576a77572ff
4
+ data.tar.gz: 01f53dafc9163356e4d6b6d1ffd820bc6b2566637b0943b2481fbf38a26531a2
5
5
  SHA512:
6
- metadata.gz: 0f7eacd330a94baa6438555a38ed8ad8ef2c887c8f57d9b1fa543a26b0b5340c1368f703e1e89205dfd8730df3372374eb2f9685ad8a092aa906fd5c0e2bc9e9
7
- data.tar.gz: 2058a3bcaa548732a4509b6af58653cafe1692f0ce1b10e12f869d5ca72a2983d24c331a44a88ca09dd3ce4c426eeea1c6acf1e354fa93eee9ce21c97dcf1369
6
+ metadata.gz: fdf47eb11f71bc887e3d2597c445ddb38ac40fc7b4628cd0d24a484efd8bfe0f2dbade04b5cb10bec3a1078d778676336d0e47059373c1c7f039262db9b947be
7
+ data.tar.gz: 6b8ba989fb728271572e79b645130159d17a5d2263d8f39b98ba3180ab6875c0121530d10537f1bdf79f948bc9034e653afcc2319eda1d606878f2ff277f8bcb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## v0.0.8 2018-04-06
2
+
3
+ - Fix issues due to a lost `to_s` call
4
+ - Fix enum handling
5
+ - Improve Ruby 2.4 support
6
+ - Add support for baking PS option maps in commands
7
+ - Default to using the cluster if one, and only one, is available
8
+ - Support adding legacy network adapters
9
+
1
10
  ## v0.0.7 2018-01-22
2
11
 
3
12
  - Add a temporary VM-wide VLAN assignment method
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Alexander Olofsson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Fog Hyper-V
2
2
 
3
- [![Build Status](https://travis-ci.org/ace13/fog-hyperv.svg?branch=master)](https://travis-ci.org/ace13/fog-hyperv) [![Gem Version](https://badge.fury.io/rb/fog-hyperv.svg)](https://badge.fury.io/rb/fog-hyperv)
3
+ [![Build Status](https://travis-ci.org/ananace/fog-hyperv.svg?branch=master)](https://travis-ci.org/ananace/fog-hyperv) [![Gem Version](https://badge.fury.io/rb/fog-hyperv.svg)](https://badge.fury.io/rb/fog-hyperv)
4
4
 
5
5
  Manage your Hyper-V instance with the help of the Fog cloud service abstractions.
6
6
 
@@ -49,5 +49,5 @@ After checking out the repo, run `bundle install` to install dependencies. Then,
49
49
 
50
50
  ## Contributing
51
51
 
52
- Bug reports and pull requests are welcome on GitHub at https://github.com/ace13/fog-hyperv.
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ananace/fog-hyperv.
53
53
 
data/lib/fog/hyperv.rb CHANGED
@@ -63,6 +63,7 @@ module Fog
63
63
  .gsub(/\n/, '`n')
64
64
  .gsub(/\r/, '`r')
65
65
  .inspect
66
+ .gsub(/\\"/, '`"')
66
67
  .gsub(/\\\\/, '\\')
67
68
  else
68
69
  data
@@ -2,26 +2,26 @@ module Fog
2
2
  module Compute
3
3
  class Hyperv < Fog::Service
4
4
  STATUS_ENUM_VALUES = [
5
- :Unknown, # 0
6
- :Other, # 1
7
- :Ok, # 2
8
- :Degraded, # 3
9
- :Stressed, # 4
10
- :PredictiveFailure, # 5
11
- :Error, # 6
12
- :NonRecoverableError, # 7
13
- :Starting, # 8
14
- :Stopping, # 9
15
- :Stopped, # 10
16
- :InService, # 11
17
- :NoContact, # 12
18
- :LostCommunication, # 13
19
- :Aborted, # 14
20
- :Dormant, # 15
21
- :SupportingEntity, # 16
22
- :Completed, # 17
23
- :PowerMode # 18
24
- # :ProtocolVersion # 32775
5
+ Unknown: 0,
6
+ Other: 1,
7
+ Ok: 2,
8
+ Degraded: 3,
9
+ Stressed: 4,
10
+ PredictiveFailure: 5,
11
+ Error: 6,
12
+ NonRecoverableError: 7,
13
+ Starting: 8,
14
+ Stopping: 9,
15
+ Stopped: 0,
16
+ InService: 1,
17
+ NoContact: 2,
18
+ LostCommunication: 3,
19
+ Aborted: 4,
20
+ Dormant: 5,
21
+ SupportingEntity: 6,
22
+ Completed: 7,
23
+ PowerMode: 8,
24
+ ProtocolVersion: 32775,
25
25
  ].freeze
26
26
 
27
27
  requires :hyperv_username
@@ -135,6 +135,8 @@ module Fog
135
135
  class Real < Shared
136
136
  attr_reader :logger
137
137
 
138
+ attr_accessor :bake_optmap, :bake_json
139
+
138
140
  def initialize(options = {})
139
141
  # require 'ostruct'
140
142
  require 'fog/json'
@@ -189,13 +191,31 @@ module Fog
189
191
  run_shell("$VMMS = if ([environment]::Is64BitProcess) { \"$($env:SystemRoot)\\System32\\vmms.exe\" } else { \"$($env:SystemRoot)\\Sysnative\\vmms.exe\" }\n(Get-Item $VMMS).VersionInfo.ProductVersion", _skip_json: true).stdout.strip
190
192
  end
191
193
 
194
+ def ps_version
195
+ @ps_version ||= run_shell('$PSVersionTable.PSVersion', _bake_optmap: false, _bake_json: false)
196
+ end
197
+
192
198
  private
193
199
 
194
200
  def hash_to_optmap(options = {})
195
- args = options.reject { |k, v| v.nil? || v.is_a?(FalseClass) || k.to_s.start_with?('_') }.map do |k, v|
196
- "'#{k}'=#{Fog::Hyperv.shell_quoted(v, true)}"
201
+ bake_json = options.delete :_bake_json
202
+ if bake_json
203
+ if ps_version[:major] >= 6
204
+ "$Args = ConvertFrom-Json -AsHashtable '#{Fog::JSON.encode options}'"
205
+ else
206
+ <<-EOS
207
+ $JsonObject = '#{Fog::JSON.encode options}'
208
+ $JsonParameters = ConvertFrom-Json -InputObject $JsonObject
209
+ $Args = $JsonParameters.psobject.properties | foreach -begin {$h=@{}} -process {$h."$($_.Name)" = $_.Value} -end {$h}
210
+ EOS
211
+ end
212
+ else
213
+ args = options.reject { |k, v| v.nil? || v.is_a?(FalseClass) || k.to_s.start_with?('_') }.map do |k, v|
214
+ "'#{k}'=#{Fog::Hyperv.shell_quoted(v, true)}"
215
+ end
216
+
217
+ "$Args = @{#{args.join ';'}}"
197
218
  end
198
- "@{#{args.join ';'}}"
199
219
  end
200
220
 
201
221
  def run_shell_with_vm(command, vm_options, options = {})
@@ -235,9 +255,14 @@ module Fog
235
255
  skip_json = options.delete :_skip_json
236
256
  skip_camelize = options.delete :_skip_camelize
237
257
  skip_uncamelize = options.delete :_skip_uncamelize
258
+ always_include = options.delete(:_always_include) {|_| []}
259
+ bake_optmap = options.delete(:_bake_optmap) {|_| @bake_optmap }
260
+ bake_json = options.delete(:_bake_json) {|_| @bake_json }
238
261
  computer = options.delete(:_target_computer) || '.'
239
262
  computers = [options.delete(:computer_name)].flatten.compact
240
- options.delete_if { |o| o.start_with? '_' }
263
+ options.delete_if { |o| o.to_s.start_with?('_') }
264
+
265
+ always_include = Fog::Hyperv.camelize(always_include) unless skip_camelize
241
266
  options = Fog::Hyperv.camelize(options) unless skip_camelize
242
267
 
243
268
  if supports_multihop?
@@ -258,19 +283,19 @@ module Fog
258
283
  return ret
259
284
  end
260
285
 
261
- # commandline = "$Args = #{hash_to_optmap options}\n$Ret = #{command} @Args#{"\n$Ret #{return_fields} | ConvertTo-Json -Compress #{"-Depth #{json_depth}" if json_depth}" unless skip_json}"
262
- # puts " > #{commandline.split("\n").join "\n > "}" if @hyperv_debug
263
- args = options.reject { |k, v| v.nil? || v.is_a?(FalseClass) || k.to_s.start_with?('_') || (v.is_a?(String) && v.empty?) }.map do |k, v|
264
- "-#{k} #{Fog::Hyperv.shell_quoted v unless v.is_a?(TrueClass)}"
286
+ args = options.reject { |k, v| !always_include.include?(k) && (v.nil? || v.is_a?(FalseClass) || k.to_s.start_with?('_') || (v.is_a?(String) && v.empty?)) }.map do |k, v|
287
+ "-#{k} #{Fog::Hyperv.shell_quoted v if !v.is_a?(TrueClass) || always_include.include?(k)}"
288
+ end
289
+
290
+ if bake_optmap
291
+ command_args = "#{hash_to_optmap options.merge(_bake_json: bake_json)}\n#{command} @Args"
292
+ else
293
+ command_args = "#{command} #{args.join ' ' unless args.empty?}"
265
294
  end
266
- command_args = "#{command} #{args.join ' ' unless args.empty?}"
267
295
  commandline = "#{command_args} #{suffix} #{return_fields} #{"| ConvertTo-Json -Compress #{"-Depth #{json_depth}" if json_depth}" unless skip_json}"
268
296
  logger.debug "PS; >>> #{commandline}"
269
297
 
270
- out = nil # OpenStruct.new stdout: '',
271
- # stderr: '',
272
- # exitcode: -1
273
-
298
+ out = nil
274
299
  if local?
275
300
  commanddata = [
276
301
  'powershell',
@@ -280,6 +305,9 @@ module Fog
280
305
  commandline
281
306
  ]
282
307
  begin
308
+ out = OpenStruct.new stdout: '',
309
+ stderr: '',
310
+ exitcode: -1
283
311
  out.stdout, out.stderr, out.exitcode = Open3.capture3(*commanddata)
284
312
  out.exitcode = out.exitcode.exitstatus
285
313
  rescue StandardError => ex
@@ -288,6 +316,8 @@ module Fog
288
316
  end
289
317
  else
290
318
  connection(computer).shell(:powershell) do |shell|
319
+ # TODO: Reuse shell?
320
+ # XXX Multiple commands in one invokation?
291
321
  out = shell.run(commandline)
292
322
  end
293
323
  end
@@ -339,6 +369,7 @@ module Fog
339
369
  return c[1] if c
340
370
 
341
371
  # TODO: Support non-standard endpoints for additional hosts
372
+ # TODO: Get Windows to provide FQDN for all other hosts
342
373
  unless host.include? '.'
343
374
  host = "#{host}.#{URI.parse(@hyperv_endpoint).host.split('.').drop(1).join('.')}"
344
375
  end
@@ -5,12 +5,18 @@ module Fog
5
5
 
6
6
  def initialize(model, name, options)
7
7
  @values = options.fetch(:values, [])
8
+
9
+ raise Fog::Hyperv::Errors::ServiceError, "#{values} is not a valid array or hash" \
10
+ unless values.class.to_s == 'Array' || values.class.to_s == 'Hash'
11
+
8
12
  super
9
13
  end
10
14
 
11
15
  def ensure_value_getter
12
- return if model.methods.include?("#{name}_values".to_sym)
16
+ return if model.private_methods.include?("#{name}_values".to_sym)
17
+
13
18
  model.class_eval <<-EOS, __FILE__, __LINE__
19
+ private
14
20
  def #{name}_values
15
21
  #{values}.freeze
16
22
  end
@@ -19,24 +25,31 @@ module Fog
19
25
 
20
26
  def create_setter
21
27
  ensure_value_getter
28
+
29
+ # Add a setter that always stores a symbol value
22
30
  model.class_eval <<-EOS, __FILE__, __LINE__
23
- def #{name}=(new_#{name})
31
+ def #{name}=(new_value)
24
32
  _values = #{name}_values
25
- # FIXME: Prepare a key comparison array in advance
26
- if new_#{name}.is_a?(Fixnum)
27
- if _values.class.to_s == 'Array' # TODO: Better way to do class comparison in generated code
28
- raise Fog::Hyperv::Errors::ServiceError, "\#{new_#{name}} is not in the range (0..\#{_values.length - 1})" unless new_#{name} >= 0 && new_#{name} < _values.length
29
- else
30
- raise Fog::Hyperv::Errors::ServiceError, "\#{new_#{name}} is not one of \#{_values.is_a?(Hash) ? _values.values : _values})" unless (_values.is_a?(Hash) ? _values.values : _values).include? new_#{name}
33
+ if new_value.is_a?(Numeric)
34
+ # TODO: Better way to do class comparison in generated code
35
+ if _values.class.to_s == 'Array'
36
+ raise Fog::Hyperv::Errors::ServiceError, "\#{new_value} is not in the range (0..\#{_values.length - 1})" \
37
+ unless new_value >= 0 && new_value < _values.length
38
+ attributes[:#{name}] = _values[new_value]
39
+ elsif _values.class.to_s == 'Hash'
40
+ raise Fog::Hyperv::Errors::ServiceError, "\#{new_value} is not one of \#{_values.values})" \
41
+ unless _values.values.include? new_value
42
+ attributes[:#{name}] = _values.key(new_value)
31
43
  end
32
-
33
- attributes[:#{name}] = _values[new_#{name}]
34
- elsif new_#{name}.nil?
44
+ elsif new_value.nil?
35
45
  attributes[:#{name}] = nil
36
46
  else
37
- new_#{name} = new_#{name}.to_s.to_sym unless new_#{name}.is_a? Symbol
38
- raise Fog::Hyperv::Errors::ServiceError, "\#{new_#{name}} is not one of \#{_values.is_a?(Hash) ? _values.keys : _values})" unless (_values.is_a?(Hash) ? _values.keys : _values).include? new_#{name}
39
- attributes[:#{name}] = new_#{name}
47
+ new_value = new_value.to_s.to_sym unless new_value.is_a? Symbol
48
+ # Ensure values is the array of enum symbols
49
+ _values = (_values.is_a?(Hash) ? _values.keys : _values)
50
+ raise Fog::Hyperv::Errors::ServiceError, "\#{new_value.inspect} is not one of \#{_values})" \
51
+ unless _values.include? new_value
52
+ attributes[:#{name}] = new_value
40
53
  end
41
54
  end
42
55
  EOS
@@ -44,21 +57,27 @@ module Fog
44
57
 
45
58
  def create_getter
46
59
  ensure_value_getter
60
+
61
+ # Add a getter for <enum>_num to get the numeric value
47
62
  model.class_eval <<-EOS, __FILE__, __LINE__
48
63
  def #{name}_num
49
64
  _values = #{name}_values
50
- return nil if self.#{name}.nil?
51
- if self.#{name}.is_a?(Fixnum)
52
- self.#{name}
65
+ _value = attributes[:#{name}]
66
+
67
+ return nil if _value.nil?
68
+ if _value.is_a?(Numeric)
69
+ _value
53
70
  else
54
71
  if _values.is_a?(Hash)
55
- _values.key(self.#{name})
72
+ _values.send(:[], _value)
56
73
  else
57
- _values.index(self.#{name})
74
+ _values.index(_value)
58
75
  end
59
76
  end
60
77
  end
61
78
  EOS
79
+
80
+ # Add the default getter for the symbol value
62
81
  super
63
82
  end
64
83
  end
@@ -33,6 +33,10 @@ module Fog
33
33
  _return_fields: self.class.attributes,
34
34
  _json_depth: 1
35
35
  )
36
+
37
+ @nodes = nil
38
+ @hosts = nil
39
+
36
40
  merge_attributes(data.attributes)
37
41
  self
38
42
  end
@@ -44,6 +48,7 @@ module Fog
44
48
  Fog::Compute::Hyperv.collections.each do |coll|
45
49
  # Don't recurse on hosts
46
50
  next if coll == :hosts
51
+
47
52
  coll_name = coll.to_s.split('_').map(&:capitalize).join
48
53
  klass = Fog::Compute::Hyperv.const_get(coll_name)
49
54
  next if klass.requires?(:vm)
@@ -6,10 +6,10 @@ module Fog
6
6
 
7
7
  attribute :boot_order
8
8
  attribute :computer_name
9
- attribute :console_mode, type: :enum, values: [ :Default, :COM1, :COM2, :None ]
9
+ attribute :console_mode, type: :enum, values: %i[Default COM1 COM2 None]
10
10
  # attribute :is_deleted
11
- attribute :preferred_network_boot_protocol, type: :enum, values: [ :IPv4, :IPv6 ]
12
- attribute :secure_boot, type: :enum, values: [ :On, :Off ]
11
+ attribute :preferred_network_boot_protocol, type: :enum, values: %i[IPv4 IPv6]
12
+ attribute :secure_boot, type: :enum, values: %i[On Off]
13
13
  attribute :vm_name
14
14
 
15
15
  def save
@@ -27,6 +27,9 @@ module Fog
27
27
  @collections = true
28
28
 
29
29
  Fog::Compute::Hyperv.collections.each do |coll|
30
+ # Hosts don't have host collections
31
+ next if coll == :hosts
32
+
30
33
  coll_name = coll.to_s.split('_').map(&:capitalize).join
31
34
  klass = Fog::Compute::Hyperv.const_get(coll_name)
32
35
  next if klass.requires?(:vm)
@@ -69,6 +69,7 @@ module Fog
69
69
  passthru: true,
70
70
 
71
71
  dynamic_mac_address: dynamic_mac_address_enabled,
72
+ is_legacy: !!is_legacy,
72
73
  static_mac_address: !dynamic_mac_address_enabled && mac_address,
73
74
  switch_name: switch_name,
74
75
 
@@ -131,7 +132,8 @@ module Fog
131
132
  data = collection.get(
132
133
  name,
133
134
  computer_name: computer_name,
134
- vm_name: vm_name
135
+ vm_name: vm_name,
136
+ _suffix: "| Where Id -Eq '#{id}'"
135
137
  )
136
138
  merge_attributes(data.attributes)
137
139
  @old = data
@@ -8,33 +8,33 @@ module Fog
8
8
  include Fog::Hyperv::ModelIncludes
9
9
 
10
10
  VM_STATUS_ENUM_VALUES = {
11
- :Unknown => 1,
12
- :Running => 2,
13
- :Off => 3,
14
- :Stopping => 4,
15
- :Saved => 6,
16
- :Paused => 9,
17
- :Starting => 10,
18
- :Reset => 11,
19
- :Saving => 32773,
20
- :Pausing => 32776,
21
- :Resuming => 32777,
22
- :FastSaved => 32779,
23
- :FastSaving => 32780,
24
- :ForceShutdown => 32781,
25
- :ForceReboot => 32782,
26
- :RunningCritical => 32783,
27
- :OffCritical => 32784,
28
- :StoppingCritical => 32785,
29
- :SavedCritical => 32786,
30
- :PausedCritical => 32787,
31
- :StartingCritical => 32788,
32
- :ResetCritical => 32789,
33
- :SavingCritical => 32790,
34
- :PausingCritical => 32791,
35
- :ResumingCritical => 32792,
36
- :FastSavedCritical => 32793,
37
- :FastSavingCritical => 32794,
11
+ Unknown: 1,
12
+ Running: 2,
13
+ Off: 3,
14
+ Stopping: 4,
15
+ Saved: 6,
16
+ Paused: 9,
17
+ Starting: 10,
18
+ Reset: 11,
19
+ Saving: 32773,
20
+ Pausing: 32776,
21
+ Resuming: 32777,
22
+ FastSaved: 32779,
23
+ FastSaving: 32780,
24
+ ForceShutdown: 32781,
25
+ ForceReboot: 32782,
26
+ RunningCritical: 32783,
27
+ OffCritical: 32784,
28
+ StoppingCritical: 32785,
29
+ SavedCritical: 32786,
30
+ PausedCritical: 32787,
31
+ StartingCritical: 32788,
32
+ ResetCritical: 32789,
33
+ SavingCritical: 32790,
34
+ PausingCritical: 32791,
35
+ ResumingCritical: 32792,
36
+ FastSavedCritical: 32793,
37
+ FastSavingCritical: 32794,
38
38
  }.freeze
39
39
 
40
40
  identity :id, type: :string
@@ -49,7 +49,7 @@ module Fog
49
49
  attribute :state, type: :enum, values: VM_STATUS_ENUM_VALUES
50
50
  attribute :status, type: :string
51
51
  attribute :memory_assigned, type: :integer
52
- attribute :memory_maximum, type: :integer, default: 171_798_691_84
52
+ attribute :memory_maximum, type: :integer, default: 17_179_869_184
53
53
  attribute :memory_minimum, type: :integer, default: 536_870_912
54
54
  attribute :memory_startup, type: :integer, default: 536_870_912
55
55
  attribute :notes, type: :string
@@ -163,25 +163,25 @@ module Fog
163
163
  attributes.select { |k, _v| usable.include? k }
164
164
  .merge(options)
165
165
  .merge(_return_fields: self.class.attributes, _json_depth: 1)
166
- else
167
- service.set_vm options.merge(
168
- computer_name: old.computer_name,
169
- name: old.name,
170
- passthru: true,
171
-
172
- processor_count: changed!(:processor_count),
173
- dynamic_memory: changed?(:dynamic_memory_enabled) && dynamic_memory_enabled,
174
- static_memory: changed?(:dynamic_memory_enabled) && !dynamic_memory_enabled,
175
- memory_minimum_bytes: changed?(:memory_minimum) && dynamic_memory_enabled && memory_minimum,
176
- memory_maximum_bytes: changed?(:memory_maximum) && dynamic_memory_enabled && memory_maximum,
177
- memory_startup_bytes: changed!(:memory_startup),
178
- notes: changed!(:notes),
179
- new_name: changed!(:name),
180
-
181
- _return_fields: self.class.attributes,
182
- _json_depth: 1
183
- )
184
- end
166
+ else
167
+ service.set_vm options.merge(
168
+ computer_name: old.computer_name,
169
+ name: old.name,
170
+ passthru: true,
171
+
172
+ processor_count: changed!(:processor_count),
173
+ dynamic_memory: changed?(:dynamic_memory_enabled) && dynamic_memory_enabled,
174
+ static_memory: changed?(:dynamic_memory_enabled) && !dynamic_memory_enabled,
175
+ memory_minimum_bytes: changed?(:memory_minimum) && dynamic_memory_enabled && memory_minimum,
176
+ memory_maximum_bytes: changed?(:memory_maximum) && dynamic_memory_enabled && memory_maximum,
177
+ memory_startup_bytes: changed!(:memory_startup),
178
+ notes: changed!(:notes),
179
+ new_name: changed!(:name),
180
+
181
+ _return_fields: self.class.attributes,
182
+ _json_depth: 1
183
+ )
184
+ end
185
185
 
186
186
  merge_attributes(data)
187
187
  @old = dup
@@ -4,7 +4,7 @@ module Fog
4
4
  class Real
5
5
  def add_vm_network_adapter(options = {})
6
6
  requires_one options, :vm_name, :management_os
7
- run_shell('Add-VMNetworkAdapter', options)
7
+ run_shell('Add-VMNetworkAdapter', options.merge(_always_include: [:is_legacy]))
8
8
  end
9
9
  end
10
10
  end
@@ -9,9 +9,7 @@ module Fog
9
9
  end
10
10
 
11
11
  class Mock
12
- def get_vm_firmware(options = {})
13
- requires options, :vm_name
14
-
12
+ def get_vm_firmware(args = {})
15
13
  handle_mock_response(args).find { |b| b[:vm_name].casecmp(args[:vm_name]).zero? }
16
14
  end
17
15
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Hyperv
3
- VERSION = '0.0.7'.freeze
3
+ VERSION = '0.0.8'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-hyperv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Olofsson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-22 00:00:00.000000000 Z
11
+ date: 2018-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -91,6 +91,7 @@ files:
91
91
  - ".travis.yml"
92
92
  - CHANGELOG.md
93
93
  - Gemfile
94
+ - LICENSE
94
95
  - README.md
95
96
  - Rakefile
96
97
  - fog-hyperv.gemspec
@@ -194,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
195
  version: '0'
195
196
  requirements: []
196
197
  rubyforge_project:
197
- rubygems_version: 2.6.14
198
+ rubygems_version: 2.7.6
198
199
  signing_key:
199
200
  specification_version: 4
200
201
  summary: Module for the `fog` gem to support Microsoft Hyper-V.