fog-hyperv 0.0.2 → 0.0.3

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
2
  SHA1:
3
- metadata.gz: fe6d782233a6722d2154ac70cec0ae338bf5bac8
4
- data.tar.gz: 869248c4e4c8c92b65c1f74f22661cb501a2dbb0
3
+ metadata.gz: 800c08e48379e123d5b8803ea3bda44f4eddbaa8
4
+ data.tar.gz: df40fef67b97eeed7469c51710b12bec6b455f39
5
5
  SHA512:
6
- metadata.gz: 31abe8a044296350c114cea4e1bb7a7320b224e1e42537f8d4cf36f253020f3ca89394175369f955ad2ec978812c38ca2669de92adddfe3a997e2191eb27ee9d
7
- data.tar.gz: 015668191289501a9e0520f48e8e51972ef1f2fd4e4ef782e9d8b6534423e0e8f923fe7ad8753e7e618d6d13562dbcd4a4c548ac35bc4b1caa8c6e313c35336b
6
+ metadata.gz: 0401b571330dad19781f5c35bfbc0cce18de2fdb02266583ba4ca2255b9c4a16e3c38b93303cfde9fa655ed0e73c0abf217dea43495a243460f2328ba42cbdac
7
+ data.tar.gz: 718b6a478f911d0070427d486951125a2ddb8407475cbc2540c962bb90f64a45a7af4cb982c9bfd0f9bc09afab2238d71a52dd0f622a7541d27b9afc65ebf2dc
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ ## v0.0.3 2017-09-30
2
+
3
+ - Fix handling of BIOS/Firmware
4
+ - Skip unnecessary Hyper-V calls when checking dirty status
5
+ - Add some possible interface improvements when dealing with clusters
6
+
7
+ ## v0.0.2 2017-09-28
8
+
9
+ - Reduced `fog-core` dependency to 1.42
10
+ - Disabled `status` attribute for network adapters, due to Hyper-V 6.3 issues
11
+
12
+ ## v0.0.1 2017-09-25
13
+
14
+ - Initial release
@@ -7,10 +7,14 @@ module Fog
7
7
  @get_method ||= method
8
8
  end
9
9
 
10
- def self.requires?
10
+ def self.requires
11
11
  @requires ||= []
12
12
  end
13
13
 
14
+ def self.requires?(req)
15
+ requires.include? req
16
+ end
17
+
14
18
  def search_attributes
15
19
  attributes.dup.merge(
16
20
  _return_fields: model.attributes - model.lazy_attributes,
@@ -19,7 +23,7 @@ module Fog
19
23
  end
20
24
 
21
25
  def all(filters = {})
22
- requires(*self.class.requires?)
26
+ requires(*self.class.requires)
23
27
  data = service.send(method, search_attributes.merge(filters))
24
28
  data = [] unless data
25
29
 
@@ -27,7 +31,7 @@ module Fog
27
31
  end
28
32
 
29
33
  def get(filters = {})
30
- data = self.all(filters).first
34
+ data = all(filters).first
31
35
  data if data
32
36
  rescue Fog::Hyperv::Errors::PSError => err
33
37
  raise Fog::Errors::NotFound, err if err.message =~ /Hyper-V was unable to find|^No .* is found|/
@@ -35,7 +39,7 @@ module Fog
35
39
  end
36
40
 
37
41
  def new(options = {})
38
- requires(*self.class.requires?)
42
+ requires(*self.class.requires)
39
43
  super(search_attributes.merge(options))
40
44
  end
41
45
 
@@ -54,13 +58,17 @@ module Fog
54
58
 
55
59
  class ComputerCollection < Fog::Hyperv::Collection
56
60
  def self.requires_computer
57
- requires? << :computer
61
+ requires << :computer
58
62
  end
59
63
 
64
+ attr_accessor :cluster
60
65
  attr_accessor :computer
61
66
 
62
67
  def search_attributes
63
68
  attrs = super
69
+ attrs.delete :cluster
70
+ attrs.delete :computer
71
+ attrs[:computer_name] ||= cluster.hosts.map { |n| n.name } if cluster
64
72
  attrs[:computer_name] ||= computer.name if computer
65
73
  attrs
66
74
  end
@@ -72,13 +80,14 @@ module Fog
72
80
  end
73
81
 
74
82
  def self.requires_vm
75
- requires? << :vm
83
+ requires << :vm
76
84
  end
77
85
 
78
86
  attr_accessor :vm
79
87
 
80
88
  def search_attributes
81
89
  attrs = super
90
+ attrs.delete :vm
82
91
  if vm
83
92
  attrs[:computer_name] ||= vm.computer_name
84
93
  attrs[match] = vm.send(match)
@@ -30,6 +30,7 @@ module Fog
30
30
  )
31
31
 
32
32
  merge_attributes(data)
33
+ @old = dup
33
34
  self
34
35
  end
35
36
 
@@ -43,7 +44,7 @@ module Fog
43
44
  _return_fields: self.class.attributes,
44
45
  _json_depth: 1
45
46
  )
46
- merge_attributes(data.attributes)
47
+ merge_attributes(data)
47
48
  self
48
49
  end
49
50
  end
@@ -9,13 +9,15 @@ module Fog
9
9
  attribute :name, type: :string
10
10
 
11
11
  def nodes
12
- [service.get_cluster_node(cluster: name, _return_fields: [:description, :name, :node_name])].flatten
12
+ @nodes ||= [service.get_cluster_node(cluster: name, _return_fields: [:description, :name, :node_name])].flatten
13
+ end
14
+
15
+ def hosts
16
+ @hosts ||= service.hosts computer_name: nodes.map { |n| n[:name] }
13
17
  end
14
18
 
15
19
  def servers
16
- @servers ||= service.servers.class.new \
17
- cluster: self,
18
- service: service
20
+ @servers ||= service.servers cluster: self
19
21
  end
20
22
 
21
23
  def reload
@@ -3,6 +3,7 @@ module Fog
3
3
  class Hyperv
4
4
  class DvdDrives < Fog::Hyperv::VMCollection
5
5
  model Fog::Compute::Hyperv::DvdDrive
6
+ requires_vm
6
7
 
7
8
  get_method :get_vm_dvd_drive
8
9
  end
@@ -13,16 +13,16 @@ module Fog
13
13
  attribute :vm_name
14
14
 
15
15
  def save
16
- requires :computetr_name, :vm_name
16
+ requires :computer_name, :vm_name
17
17
 
18
18
  raise Fog::Hyperv::Errors::ServiceError, "Can't create Firmware instances" unless persisted?
19
19
 
20
- data = service.set_firmware(
20
+ data = service.set_vm_firmware(
21
21
  computer_name: computer_name,
22
22
  vm_name: vm_name,
23
23
  passthru: true,
24
24
 
25
- enable_secure_boot: changed?(:secure_boot) ? (secure_boot && 'On' || 'Off') : nil,
25
+ enable_secure_boot: changed!(:secure_boot),
26
26
  preferred_network_boot_protocol: changed!(:preferred_network_boot_protocol),
27
27
  console_mode: changed!(:console_mode),
28
28
 
@@ -37,13 +37,13 @@ module Fog
37
37
  def reload
38
38
  requires :computer_name, :vm_name
39
39
 
40
- data = service.get_firmware(
40
+ data = service.get_vm_firmware(
41
41
  computer_name: computer_name,
42
42
  vm_name: vm_name,
43
43
 
44
- _return_fields: self.class.attribute
44
+ _return_fields: self.class.attributes
45
45
  )
46
- merge_attributes(data.attributes)
46
+ merge_attributes(data)
47
47
  self
48
48
  end
49
49
  end
@@ -3,6 +3,7 @@ module Fog
3
3
  class Hyperv
4
4
  class FloppyDrives < Fog::Hyperv::VMCollection
5
5
  model Fog::Compute::Hyperv::FloppyDrive
6
+ requires_vm
6
7
 
7
8
  get_method :get_vm_floppy_disk_drive
8
9
  end
@@ -14,6 +14,28 @@ module Fog
14
14
  attribute :maximum_virtual_machine_migrations
15
15
  attribute :virtual_hard_disk_path
16
16
  attribute :virtual_machine_path
17
+
18
+ def initialize(attrs = {})
19
+ super
20
+
21
+ @collections = {}
22
+ self.class.ensure_collections!
23
+ end
24
+
25
+ def self.ensure_collections!
26
+ return if @collections
27
+ @collections = true
28
+
29
+ Fog::Compute::Hyperv.collections.each do |coll|
30
+ coll_name = coll.to_s.split('_').map(&:capitalize).join
31
+ klass = Fog::Compute::Hyperv.const_get(coll_name)
32
+ next if klass.requires? :vm
33
+
34
+ define_method coll do
35
+ @collections[coll] ||= service.send(coll, computer: self)
36
+ end
37
+ end
38
+ end
17
39
  end
18
40
  end
19
41
  end
@@ -129,7 +129,6 @@ module Fog
129
129
 
130
130
  def save(options = {})
131
131
  requires :name
132
- logger.debug "Saving server with; #{attributes}, #{options}"
133
132
 
134
133
  data = \
135
134
  if !persisted?
@@ -1,20 +1,11 @@
1
1
  module Fog
2
2
  module Compute
3
3
  class Hyperv
4
- class Servers < Fog::Hyperv::Collection
5
- attribute :cluster
6
-
4
+ class Servers < Fog::Hyperv::ComputerCollection
7
5
  model Fog::Compute::Hyperv::Server
8
6
 
9
7
  get_method :get_vm
10
8
 
11
- def search_attributes
12
- attrs = super
13
- attrs[:computer_name] = cluster.nodes.map { |n| n[:name] } if cluster
14
- attrs.delete :cluster
15
- attrs
16
- end
17
-
18
9
  def get(identity, filters = {})
19
10
  guid = identity =~ /\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/
20
11
 
@@ -1,7 +1,7 @@
1
1
  module Fog
2
2
  module Compute
3
3
  class Hyperv
4
- class Switches < Fog::Hyperv::Collection
4
+ class Switches < Fog::Hyperv::ComputerCollection
5
5
  model Fog::Compute::Hyperv::Switch
6
6
 
7
7
  get_method :get_vm_switch
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Hyperv
3
- VERSION = '0.0.2'.freeze
3
+ VERSION = '0.0.3'.freeze
4
4
  end
5
5
  end
data/lib/fog/model.rb CHANGED
@@ -59,6 +59,12 @@ module Fog
59
59
  class Model < Fog::Model
60
60
  extend Fog::Hyperv::ModelExtends
61
61
  include Fog::Hyperv::ModelIncludes
62
+
63
+ def initialize(attributes = {})
64
+ super
65
+
66
+ @old = dup if persisted?
67
+ end
62
68
  end
63
69
  end
64
70
  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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Olofsson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-28 00:00:00.000000000 Z
11
+ date: 2017-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -89,6 +89,7 @@ extra_rdoc_files: []
89
89
  files:
90
90
  - ".gitignore"
91
91
  - ".travis.yml"
92
+ - CHANGELOG.md
92
93
  - Gemfile
93
94
  - README.md
94
95
  - Rakefile