fog-ovirt 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -0
  3. data/.rubocop_todo.yml +17 -5
  4. data/Gemfile +0 -1
  5. data/Gemfile.local.rb +0 -0
  6. data/README.md +2 -6
  7. data/Rakefile +2 -8
  8. data/fog-ovirt.gemspec +3 -2
  9. data/lib/fog/ovirt/compute.rb +5 -29
  10. data/lib/fog/ovirt/compute/v4.rb +42 -24
  11. data/lib/fog/ovirt/models/compute/instance_type.rb +1 -0
  12. data/lib/fog/ovirt/models/compute/interfaces.rb +0 -2
  13. data/lib/fog/ovirt/models/compute/server.rb +0 -2
  14. data/lib/fog/ovirt/models/compute/volume.rb +1 -0
  15. data/lib/fog/ovirt/models/compute/volumes.rb +0 -2
  16. data/lib/fog/ovirt/requests/compute/v4/add_interface.rb +0 -2
  17. data/lib/fog/ovirt/requests/compute/v4/add_volume.rb +2 -2
  18. data/lib/fog/ovirt/requests/compute/v4/create_vm.rb +4 -4
  19. data/lib/fog/ovirt/requests/compute/v4/get_volume.rb +19 -0
  20. data/lib/fog/ovirt/requests/compute/v4/list_template_volumes.rb +0 -2
  21. data/lib/fog/ovirt/requests/compute/v4/list_vm_volumes.rb +0 -2
  22. data/lib/fog/ovirt/requests/compute/v4/mock_files/disk.xml +28 -0
  23. data/lib/fog/ovirt/requests/compute/v4/mock_files/operating_systems.xml +4 -4
  24. data/lib/fog/ovirt/requests/compute/v4/mock_files/template.xml +48 -45
  25. data/lib/fog/ovirt/requests/compute/v4/mock_files/templates.xml +17 -2
  26. data/lib/fog/ovirt/requests/compute/v4/mock_files/vnic_profile.xml +10 -0
  27. data/lib/fog/ovirt/requests/compute/v4/storage_domains.rb +1 -0
  28. data/lib/fog/ovirt/requests/compute/v4/update_vm.rb +0 -2
  29. data/lib/fog/ovirt/version.rb +1 -1
  30. data/tests/ovirt/models/compute/instance_type_tests.rb +23 -0
  31. data/tests/ovirt/models/compute/instance_types_tests.rb +7 -0
  32. data/tests/ovirt/requests/compute/v4/client_tests.rb +1 -1
  33. data/tests/ovirt/requests/compute/v4/create_vm_tests.rb +1 -0
  34. metadata +28 -84
  35. data/lib/fog/ovirt/compute/v3.rb +0 -137
  36. data/lib/fog/ovirt/requests/compute/v3/activate_volume.rb +0 -23
  37. data/lib/fog/ovirt/requests/compute/v3/add_interface.rb +0 -22
  38. data/lib/fog/ovirt/requests/compute/v3/add_to_affinity_group.rb +0 -23
  39. data/lib/fog/ovirt/requests/compute/v3/add_volume.rb +0 -23
  40. data/lib/fog/ovirt/requests/compute/v3/attach_volume.rb +0 -24
  41. data/lib/fog/ovirt/requests/compute/v3/create_affinity_group.rb +0 -20
  42. data/lib/fog/ovirt/requests/compute/v3/create_vm.rb +0 -20
  43. data/lib/fog/ovirt/requests/compute/v3/datacenters.rb +0 -22
  44. data/lib/fog/ovirt/requests/compute/v3/deactivate_volume.rb +0 -24
  45. data/lib/fog/ovirt/requests/compute/v3/destroy_affinity_group.rb +0 -21
  46. data/lib/fog/ovirt/requests/compute/v3/destroy_interface.rb +0 -24
  47. data/lib/fog/ovirt/requests/compute/v3/destroy_vm.rb +0 -21
  48. data/lib/fog/ovirt/requests/compute/v3/destroy_volume.rb +0 -24
  49. data/lib/fog/ovirt/requests/compute/v3/detach_volume.rb +0 -24
  50. data/lib/fog/ovirt/requests/compute/v3/get_affinity_group.rb +0 -20
  51. data/lib/fog/ovirt/requests/compute/v3/get_api_version.rb +0 -18
  52. data/lib/fog/ovirt/requests/compute/v3/get_cluster.rb +0 -19
  53. data/lib/fog/ovirt/requests/compute/v3/get_instance_type.rb +0 -19
  54. data/lib/fog/ovirt/requests/compute/v3/get_quota.rb +0 -19
  55. data/lib/fog/ovirt/requests/compute/v3/get_template.rb +0 -19
  56. data/lib/fog/ovirt/requests/compute/v3/get_virtual_machine.rb +0 -19
  57. data/lib/fog/ovirt/requests/compute/v3/list_affinity_group_vms.rb +0 -24
  58. data/lib/fog/ovirt/requests/compute/v3/list_affinity_groups.rb +0 -22
  59. data/lib/fog/ovirt/requests/compute/v3/list_clusters.rb +0 -21
  60. data/lib/fog/ovirt/requests/compute/v3/list_instance_types.rb +0 -21
  61. data/lib/fog/ovirt/requests/compute/v3/list_networks.rb +0 -18
  62. data/lib/fog/ovirt/requests/compute/v3/list_operating_systems.rb +0 -21
  63. data/lib/fog/ovirt/requests/compute/v3/list_quotas.rb +0 -21
  64. data/lib/fog/ovirt/requests/compute/v3/list_template_interfaces.rb +0 -21
  65. data/lib/fog/ovirt/requests/compute/v3/list_template_volumes.rb +0 -21
  66. data/lib/fog/ovirt/requests/compute/v3/list_templates.rb +0 -21
  67. data/lib/fog/ovirt/requests/compute/v3/list_virtual_machines.rb +0 -21
  68. data/lib/fog/ovirt/requests/compute/v3/list_vm_interfaces.rb +0 -21
  69. data/lib/fog/ovirt/requests/compute/v3/list_vm_volumes.rb +0 -21
  70. data/lib/fog/ovirt/requests/compute/v3/list_volumes.rb +0 -21
  71. data/lib/fog/ovirt/requests/compute/v3/mock_files/affinitygroup.xml +0 -8
  72. data/lib/fog/ovirt/requests/compute/v3/mock_files/affinitygroup_vms.xml +0 -9
  73. data/lib/fog/ovirt/requests/compute/v3/mock_files/affinitygroups.xml +0 -17
  74. data/lib/fog/ovirt/requests/compute/v3/mock_files/cluster.xml +0 -20
  75. data/lib/fog/ovirt/requests/compute/v3/mock_files/clusters.xml +0 -39
  76. data/lib/fog/ovirt/requests/compute/v3/mock_files/data_centers.xml +0 -17
  77. data/lib/fog/ovirt/requests/compute/v3/mock_files/disks.xml +0 -58
  78. data/lib/fog/ovirt/requests/compute/v3/mock_files/instance_type.xml +0 -42
  79. data/lib/fog/ovirt/requests/compute/v3/mock_files/instance_types.xml +0 -197
  80. data/lib/fog/ovirt/requests/compute/v3/mock_files/nics.xml +0 -10
  81. data/lib/fog/ovirt/requests/compute/v3/mock_files/operating_systems.xml +0 -10
  82. data/lib/fog/ovirt/requests/compute/v3/mock_files/quotas.xml +0 -7
  83. data/lib/fog/ovirt/requests/compute/v3/mock_files/storage_domains.xml +0 -36
  84. data/lib/fog/ovirt/requests/compute/v3/mock_files/template.xml +0 -39
  85. data/lib/fog/ovirt/requests/compute/v3/mock_files/templates.xml +0 -110
  86. data/lib/fog/ovirt/requests/compute/v3/mock_files/vm.xml +0 -52
  87. data/lib/fog/ovirt/requests/compute/v3/mock_files/vms.xml +0 -152
  88. data/lib/fog/ovirt/requests/compute/v3/mock_files/volumes.xml +0 -40
  89. data/lib/fog/ovirt/requests/compute/v3/remove_from_affinity_group.rb +0 -23
  90. data/lib/fog/ovirt/requests/compute/v3/storage_domains.rb +0 -22
  91. data/lib/fog/ovirt/requests/compute/v3/update_interface.rb +0 -36
  92. data/lib/fog/ovirt/requests/compute/v3/update_vm.rb +0 -20
  93. data/lib/fog/ovirt/requests/compute/v3/update_volume.rb +0 -37
  94. data/lib/fog/ovirt/requests/compute/v3/vm_action.rb +0 -24
  95. data/lib/fog/ovirt/requests/compute/v3/vm_start_with_cloudinit.rb +0 -21
  96. data/lib/fog/ovirt/requests/compute/v3/vm_ticket.rb +0 -19
  97. data/tests/ovirt/requests/compute/v3/client_tests.rb +0 -31
  98. data/tests/ovirt/requests/compute/v3/create_vm_tests.rb +0 -17
  99. data/tests/ovirt/requests/compute/v3/destroy_vm_tests.rb +0 -14
  100. data/tests/ovirt/requests/compute/v3/list_datacenters_tests.rb +0 -11
  101. data/tests/ovirt/requests/compute/v3/list_quotas_tests.rb +0 -10
  102. data/tests/ovirt/requests/compute/v3/list_storage_domains_tests.rb +0 -11
  103. data/tests/ovirt/requests/compute/v3/update_vm_tests.rb +0 -14
  104. data/tests/ovirt/requests/compute/v3/update_volume_tests.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8782e80f74881843f3d5cfdf3537289c1f828190f9285905989d75f486252d13
4
- data.tar.gz: b9088bc35338d04d9b6408ad91ff11db4623a998ca84346e2bce9c726b449e28
3
+ metadata.gz: '0018dbcebca7b9c47941e86933df6d71f9106c80348689ab8ff3e355c5bb550a'
4
+ data.tar.gz: 312123f1ff82516363de62ed8cc2617117f3a8a9bd11cb655244332bbcf3b6dc
5
5
  SHA512:
6
- metadata.gz: b25cf3dc201edb0a1b53fadab1d10182d3a7de3ecd26fed18c1e3c19ccad9d2855465f6e8e4f551aa4fcb685058db544e9baf730a90934bb7968e2dda3b770ca
7
- data.tar.gz: e2423a8441309249034df7311e1884265fc5a1c747e3d3f20cb3a182747b8626d3137dd73b23bf02c589af499377a05f318fe8616a242db9f5a31a9f30a5a0a7
6
+ metadata.gz: b3218482b5f4b274c684c906688e59112ea1a67d78a437c89502840ab8a6edecdf5e311072cf8470f88c8752f31527e53e479924290b6f0323a73f3579d7ff27
7
+ data.tar.gz: e5aa103e4a011613b64a86d2150a4a936d13e0f331bb287c404a912bcce618431d32ecb8d6ddb3c57b2b8c456840d89dd83fba1735663552eecbb27ed49cf77f
@@ -21,3 +21,13 @@ Style/SignalException:
21
21
 
22
22
  Layout/EmptyLineAfterGuardClause:
23
23
  Enabled: false
24
+
25
+ Metrics/AbcSize:
26
+ Enabled: false
27
+
28
+ Gemspec/RequiredRubyVersion:
29
+ Enabled: false
30
+
31
+ AllCops:
32
+ Exclude:
33
+ - 'lib/fog/ovirt/compute.rb'
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-05-22 10:36:37 +0300 using RuboCop version 0.70.0.
3
+ # on 2020-10-15 17:29:26 +0300 using RuboCop version 0.81.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -11,11 +11,18 @@
11
11
  Metrics/ClassLength:
12
12
  Max: 150
13
13
 
14
- # Offense count: 10
14
+ # Offense count: 8
15
15
  # Configuration parameters: CountComments, ExcludedMethods.
16
16
  Metrics/MethodLength:
17
17
  Max: 26
18
18
 
19
+ # Offense count: 1
20
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
21
+ # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
22
+ Naming/FileName:
23
+ Exclude:
24
+ - 'Gemfile.local.rb'
25
+
19
26
  # Offense count: 1
20
27
  Style/ClassVars:
21
28
  Exclude:
@@ -26,7 +33,7 @@ Style/CommentedKeyword:
26
33
  Exclude:
27
34
  - 'lib/fog/ovirt/models/compute/server.rb'
28
35
 
29
- # Offense count: 188
36
+ # Offense count: 98
30
37
  Style/Documentation:
31
38
  Enabled: false
32
39
 
@@ -36,13 +43,18 @@ Style/DoubleNegation:
36
43
  - 'lib/fog/ovirt/models/compute/server.rb'
37
44
  - 'tests/helpers/succeeds_helper.rb'
38
45
 
39
- # Offense count: 133
46
+ # Offense count: 84
40
47
  # Cop supports --auto-correct.
41
48
  # Configuration parameters: EnforcedStyle.
42
- # SupportedStyles: always, never
49
+ # SupportedStyles: always, always_true, never
43
50
  Style/FrozenStringLiteralComment:
44
51
  Enabled: false
45
52
 
53
+ # Offense count: 3
54
+ Style/MissingRespondToMissing:
55
+ Exclude:
56
+ - 'lib/fog/ovirt/compute.rb'
57
+
46
58
  # Offense count: 4
47
59
  Style/MultilineTernaryOperator:
48
60
  Exclude:
data/Gemfile CHANGED
@@ -1,3 +1,2 @@
1
1
  source "https://rubygems.org"
2
-
3
2
  gemspec
File without changes
data/README.md CHANGED
@@ -40,9 +40,7 @@ compute = Fog::Compute.new(
40
40
 
41
41
  ## API Support
42
42
 
43
- This gem fully supports API v3 of oVirt.
44
-
45
- Version 1.0.2 adds support API V4 as well.
43
+ This gem fully supports API V4 of oVirt.
46
44
  The first version does not give full support.
47
45
  The supported requests for API V4 are:
48
46
 
@@ -72,9 +70,7 @@ This example shows the usage as a fog provider:
72
70
  :ovirt_url => url,
73
71
  :ovirt_datacenter => datacenter,
74
72
  :public_key => public_key,
75
- :api_version => 'v4'
76
73
  )
77
- The :api_version can be sent 'v3' or 'v4' to determine which API version to use.
78
74
 
79
75
 
80
76
  Feedback is welcome. Please feel free to open issues for the V4 support and contribute.
@@ -85,4 +81,4 @@ Please refer to [CONTRIBUTING.md](CONTRIBUTING.md).
85
81
 
86
82
  ## License
87
83
 
88
- Please refer to [LICENSE.md](LICENSE.md).
84
+ Please refer to [LICENSE.md](LICENSE.md).
data/Rakefile CHANGED
@@ -9,14 +9,8 @@ require "bundler/gem_tasks"
9
9
 
10
10
  mock = ENV["FOG_MOCK"] || "true"
11
11
 
12
- begin
13
- require "rubocop/rake_task"
14
- RuboCop::RakeTask.new do |t|
15
- t.patterns = Dir["{lib,spec,tests}/**/*"]
16
- end
17
- rescue StandardError
18
- puts "Rubocop not loaded"
19
- end
12
+ require "rubocop/rake_task"
13
+ RuboCop::RakeTask.new
20
14
 
21
15
  task :test do
22
16
  sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/ovirt")
@@ -17,13 +17,14 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0")
19
19
  spec.test_files = spec.files.grep(%r{^tests\/})
20
-
21
20
  spec.require_paths = ["lib"]
21
+ spec.required_ruby_version = ">= 2.0.0"
22
22
 
23
+ spec.add_dependency("activesupport")
23
24
  spec.add_dependency("fog-core")
24
25
  spec.add_dependency("fog-json")
25
26
  spec.add_dependency("fog-xml")
26
- spec.add_dependency("ovirt-engine-sdk", ">= 4.1.3")
27
+ spec.add_dependency("ovirt-engine-sdk", ">= 4.3.1")
27
28
  spec.add_dependency("rbovirt", "~> 0.1.5")
28
29
 
29
30
  spec.add_development_dependency "bundler"
@@ -50,22 +50,13 @@ module Fog
50
50
  end
51
51
  end
52
52
 
53
- require "fog/ovirt/compute/v3"
54
53
  require "fog/ovirt/compute/v4"
55
54
 
56
55
  def self.new(options = {})
57
56
  super(options)
58
-
59
- # rubocop:disable Style/ConditionalAssignment
60
- if options[:api_version] == "v4"
61
- @client = Fog::Ovirt::Compute::V4.new(options)
62
- else
63
- @client = Fog::Ovirt::Compute::V3.new(options)
64
- end
65
- # rubocop:enable Style/ConditionalAssignment
57
+ @client = Fog::Ovirt::Compute::V4.new(options)
66
58
  end
67
59
 
68
- # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
69
60
  def method_missing(symbol, *args)
70
61
  @client.__send__(symbol, *args)
71
62
  end
@@ -73,20 +64,13 @@ module Fog
73
64
  def respond_to?(symbol, include_all = false)
74
65
  @client.respond_to?(symbol, include_all)
75
66
  end
76
- # rubocop:enable Style/MethodMissingSuper, Style/MissingRespondToMissing
77
67
 
78
68
  class Mock
79
69
  def initialize(options = {})
80
- if options[:api_version] == "v4"
81
- Fog::Ovirt::Compute::V4::Mock.send(:include, Fog::Ovirt::Compute::Collections)
82
- @client = Fog::Ovirt::Compute::V4::Mock.new(options)
83
- else
84
- Fog::Ovirt::Compute::V3::Mock.send(:include, Fog::Ovirt::Compute::Collections)
85
- @client = Fog::Ovirt::Compute::V3::Mock.new(options)
86
- end
70
+ Fog::Ovirt::Compute::V4::Mock.include Fog::Ovirt::Compute::Collections
71
+ @client = Fog::Ovirt::Compute::V4::Mock.new(options)
87
72
  end
88
73
 
89
- # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
90
74
  def method_missing(symbol, *args)
91
75
  @client.__send__(symbol, *args)
92
76
  end
@@ -94,21 +78,14 @@ module Fog
94
78
  def respond_to?(symbol, include_all = false)
95
79
  @client.respond_to?(symbol, include_all)
96
80
  end
97
- # rubocop:enable Style/MethodMissingSuper, Style/MissingRespondToMissing
98
81
  end
99
82
 
100
83
  class Real
101
84
  def initialize(options = {})
102
- if options[:api_version] == "v4"
103
- Fog::Ovirt::Compute::V4::Real.send(:include, Fog::Ovirt::Compute::Collections)
104
- @client = Fog::Ovirt::Compute::V4::Real.new(options)
105
- else
106
- Fog::Ovirt::Compute::V3::Real.send(:include, Fog::Ovirt::Compute::Collections)
107
- @client = Fog::Ovirt::Compute::V3::Real.new(options)
108
- end
85
+ Fog::Ovirt::Compute::V4::Real.include Fog::Ovirt::Compute::Collections
86
+ @client = Fog::Ovirt::Compute::V4::Real.new(options)
109
87
  end
110
88
 
111
- # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
112
89
  def method_missing(symbol, *args)
113
90
  @client.send(symbol, *args)
114
91
  end
@@ -116,7 +93,6 @@ module Fog
116
93
  def respond_to?(symbol, include_all = false)
117
94
  @client.respond_to?(symbol, include_all)
118
95
  end
119
- # rubocop:enable Style/MethodMissingSuper, Style/MissingRespondToMissing
120
96
  end
121
97
  end
122
98
  end
@@ -1,3 +1,6 @@
1
+ require "active_support"
2
+ require "active_support/core_ext"
3
+
1
4
  module Fog
2
5
  module Ovirt
3
6
  class Compute
@@ -33,6 +36,7 @@ module Fog
33
36
  request :list_template_volumes
34
37
  request :list_volumes
35
38
  request :add_volume
39
+ request :get_volume
36
40
  request :destroy_volume
37
41
  request :update_volume
38
42
  request :get_api_version
@@ -41,9 +45,9 @@ module Fog
41
45
  request :list_operating_systems
42
46
 
43
47
  module Shared
44
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
48
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
45
49
  # converts an OVIRT object into an hash for fog to consume.
46
- def ovirt_attrs(obj)
50
+ def shared_ovirt_attrs(obj)
47
51
  opts = {}
48
52
  # TODO: stop using instance_variables, they will change
49
53
  obj.instance_variables.each do |v|
@@ -51,7 +55,7 @@ module Fog
51
55
  value = obj.instance_variable_get(v)
52
56
 
53
57
  if key == :network
54
- opts[key] = obj.vnic_profile.present? ? client.follow_link(obj.vnic_profile).network.id : value
58
+ opts[key] = obj.vnic_profile.present? ? yield(obj) : value
55
59
  next
56
60
  end
57
61
 
@@ -69,9 +73,10 @@ module Fog
69
73
  end
70
74
  opts
71
75
  end
72
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
73
76
 
74
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
77
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
78
+
79
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
75
80
  def get_attr_value(value, opts)
76
81
  case value
77
82
  when OvirtSDK4::List
@@ -102,29 +107,31 @@ module Fog
102
107
  when OvirtSDK4::Console
103
108
  { :enabled => value.enabled }
104
109
  else
105
- if value.class.respond_to?(:parent) && value.class.parent == OvirtSDK4
110
+ if value.class.respond_to?(:module_parent) && value.class.module_parent == OvirtSDK4
106
111
  value.id if value.respond_to?(:id)
107
112
  else
108
113
  value.to_s.strip
109
114
  end
110
115
  end
111
116
  end
112
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
113
-
114
- def convert_string_to_bool(opts)
115
- return opts unless opts.present?
116
- opts.each do |key, value|
117
- if value == "true"
118
- opts[key] = true
119
- elsif value == "false"
120
- opts[key] = false
121
- elsif value.is_a? Hash
122
- convert_string_to_bool(value)
123
- elsif value.is_a? Array
124
- value.map { |item| convert_string_to_bool(item) }
117
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
118
+
119
+ def convert_string_to_bool(value)
120
+ case value
121
+ when "true"
122
+ true
123
+ when "false"
124
+ false
125
+ when Array
126
+ value.map { |elem| convert_string_to_bool(elem) }
127
+ when Hash
128
+ value.each do |key, elem|
129
+ value[key] = convert_string_to_bool(elem)
125
130
  end
131
+ value
132
+ else
133
+ value
126
134
  end
127
- opts
128
135
  end
129
136
  end
130
137
 
@@ -135,6 +142,13 @@ module Fog
135
142
  require "ovirtsdk4"
136
143
  end
137
144
 
145
+ def ovirt_attrs(obj)
146
+ shared_ovirt_attrs(obj) do
147
+ xml = read_xml("vnic_profile.xml")
148
+ Nokogiri::XML(xml).xpath("/vnic_profile/network/@id").to_s
149
+ end
150
+ end
151
+
138
152
  private
139
153
 
140
154
  def client
@@ -151,7 +165,6 @@ module Fog
151
165
  class Real
152
166
  include Shared
153
167
 
154
- # rubocop:disable Metrics/AbcSize
155
168
  def initialize(options = {})
156
169
  require "ovirtsdk4"
157
170
  username = options[:ovirt_username]
@@ -172,7 +185,12 @@ module Fog
172
185
 
173
186
  @client = ExceptionWrapper.new(OvirtSDK4::Connection.new(connection_opts))
174
187
  end
175
- # rubocop:enable Metrics/AbcSize
188
+
189
+ def ovirt_attrs(obj)
190
+ shared_ovirt_attrs(obj) do
191
+ client.follow_link(obj.vnic_profile).network.id
192
+ end
193
+ end
176
194
 
177
195
  def api_version
178
196
  api = client.system_service.get
@@ -180,11 +198,11 @@ module Fog
180
198
  end
181
199
 
182
200
  def datacenter
183
- @datacenter ||= datacenter_hash[:id]
201
+ datacenter_hash[:id]
184
202
  end
185
203
 
186
204
  def datacenter_hash
187
- @datacenter_hash ||= datacenters.find { |x| x[:id] == @datacenter } if @datacenter
205
+ @datacenter_hash ||= datacenters.find { |x| x[:id] == @datacenter } || datacenters.find { |x| x[:name] == @datacenter } if @datacenter
188
206
  @datacenter_hash ||= datacenters.first
189
207
  end
190
208
 
@@ -10,6 +10,7 @@ module Fog
10
10
  attribute :description
11
11
  attribute :memory
12
12
  attribute :cores
13
+ attribute :sockets
13
14
  attribute :creation_time
14
15
  attribute :os
15
16
  attribute :ha
@@ -9,7 +9,6 @@ module Fog
9
9
 
10
10
  attr_accessor :vm
11
11
 
12
- # rubocop:disable Metrics/AbcSize
13
12
  def all(_filters = {})
14
13
  requires :vm
15
14
  if vm.is_a? Fog::Ovirt::Compute::Server
@@ -20,7 +19,6 @@ module Fog
20
19
  raise ::Fog::Ovirt::Errors::OvirtError, "interfaces should have vm or template"
21
20
  end
22
21
  end
23
- # rubocop:enable Metrics/AbcSize
24
22
 
25
23
  def get(id)
26
24
  new service.get_interface(id)
@@ -121,7 +121,6 @@ module Fog
121
121
  vm_power_action(:start)
122
122
  end
123
123
 
124
- # rubocop:disable Metrics/AbcSize
125
124
  def start_with_cloudinit(options = {})
126
125
  wait_for { !locked? } if options[:blocking]
127
126
  user_data = if options[:use_custom_script]
@@ -133,7 +132,6 @@ module Fog
133
132
  reload
134
133
  action_status
135
134
  end
136
- # rubocop:enable Metrics/AbcSize
137
135
 
138
136
  def stop(_options = {})
139
137
  vm_power_action(:stop)
@@ -17,6 +17,7 @@ module Fog
17
17
  attribute :quota
18
18
  attribute :alias
19
19
  attribute :wipe_after_delete
20
+ attribute :name
20
21
 
21
22
  def size_gb
22
23
  attributes[:size_gb] ||= attributes[:size].to_i / Fog::Ovirt::Compute::DISK_SIZE_TO_GB if attributes[:size]
@@ -9,7 +9,6 @@ module Fog
9
9
 
10
10
  attr_accessor :vm
11
11
 
12
- # rubocop:disable Metrics/AbcSize
13
12
  def all(_filters = {})
14
13
  if vm.is_a? Fog::Ovirt::Compute::Server
15
14
  load service.list_vm_volumes(vm.id)
@@ -19,7 +18,6 @@ module Fog
19
18
  load service.list_volumes
20
19
  end
21
20
  end
22
- # rubocop:enable Metrics/AbcSize
23
21
 
24
22
  def get(id)
25
23
  new service.get_volume(id)
@@ -3,7 +3,6 @@ module Fog
3
3
  class Compute
4
4
  class V4
5
5
  class Real
6
- # rubocop:disable Metrics/AbcSize
7
6
  def add_interface(id, options = {})
8
7
  raise ArgumentError, "instance id is a required parameter" unless id
9
8
  vm = client.system_service.vms_service.vm_service(id)
@@ -26,7 +25,6 @@ module Fog
26
25
  interface = OvirtSDK4::Nic.new(options)
27
26
  nics_service.add(interface)
28
27
  end
29
- # rubocop:enable Metrics/AbcSize
30
28
  end
31
29
 
32
30
  class Mock