fog-ovirt 1.2.2 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +10 -0
  4. data/.rubocop_todo.yml +17 -5
  5. data/Gemfile +0 -1
  6. data/README.md +2 -6
  7. data/Rakefile +2 -8
  8. data/fog-ovirt.gemspec +3 -3
  9. data/lib/fog/ovirt/compute.rb +5 -29
  10. data/lib/fog/ovirt/compute/v4.rb +27 -11
  11. data/lib/fog/ovirt/models/compute/interface.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 +4 -10
  17. data/lib/fog/ovirt/requests/compute/v4/add_volume.rb +2 -2
  18. data/lib/fog/ovirt/requests/compute/v4/create_vm.rb +2 -4
  19. data/lib/fog/ovirt/requests/compute/v4/list_template_volumes.rb +0 -2
  20. data/lib/fog/ovirt/requests/compute/v4/list_vm_volumes.rb +0 -2
  21. data/lib/fog/ovirt/requests/compute/v4/list_vnic_profiles.rb +25 -0
  22. data/lib/fog/ovirt/requests/compute/v4/mock_files/operating_systems.xml +4 -4
  23. data/lib/fog/ovirt/requests/compute/v4/mock_files/template.xml +48 -45
  24. data/lib/fog/ovirt/requests/compute/v4/mock_files/templates.xml +17 -2
  25. data/lib/fog/ovirt/requests/compute/v4/mock_files/vnic_profile.xml +10 -0
  26. data/lib/fog/ovirt/requests/compute/v4/mock_files/vnic_profiles.xml +42 -0
  27. data/lib/fog/ovirt/requests/compute/v4/storage_domains.rb +2 -1
  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/requests/compute/v4/client_tests.rb +1 -1
  31. metadata +18 -95
  32. data/lib/fog/ovirt/compute/v3.rb +0 -138
  33. data/lib/fog/ovirt/requests/compute/v3/activate_volume.rb +0 -23
  34. data/lib/fog/ovirt/requests/compute/v3/add_interface.rb +0 -22
  35. data/lib/fog/ovirt/requests/compute/v3/add_to_affinity_group.rb +0 -23
  36. data/lib/fog/ovirt/requests/compute/v3/add_volume.rb +0 -23
  37. data/lib/fog/ovirt/requests/compute/v3/attach_volume.rb +0 -24
  38. data/lib/fog/ovirt/requests/compute/v3/create_affinity_group.rb +0 -20
  39. data/lib/fog/ovirt/requests/compute/v3/create_vm.rb +0 -20
  40. data/lib/fog/ovirt/requests/compute/v3/datacenters.rb +0 -22
  41. data/lib/fog/ovirt/requests/compute/v3/deactivate_volume.rb +0 -24
  42. data/lib/fog/ovirt/requests/compute/v3/destroy_affinity_group.rb +0 -21
  43. data/lib/fog/ovirt/requests/compute/v3/destroy_interface.rb +0 -24
  44. data/lib/fog/ovirt/requests/compute/v3/destroy_vm.rb +0 -21
  45. data/lib/fog/ovirt/requests/compute/v3/destroy_volume.rb +0 -24
  46. data/lib/fog/ovirt/requests/compute/v3/detach_volume.rb +0 -24
  47. data/lib/fog/ovirt/requests/compute/v3/get_affinity_group.rb +0 -20
  48. data/lib/fog/ovirt/requests/compute/v3/get_api_version.rb +0 -18
  49. data/lib/fog/ovirt/requests/compute/v3/get_cluster.rb +0 -19
  50. data/lib/fog/ovirt/requests/compute/v3/get_instance_type.rb +0 -19
  51. data/lib/fog/ovirt/requests/compute/v3/get_quota.rb +0 -19
  52. data/lib/fog/ovirt/requests/compute/v3/get_template.rb +0 -19
  53. data/lib/fog/ovirt/requests/compute/v3/get_virtual_machine.rb +0 -19
  54. data/lib/fog/ovirt/requests/compute/v3/get_volume.rb +0 -19
  55. data/lib/fog/ovirt/requests/compute/v3/list_affinity_group_vms.rb +0 -24
  56. data/lib/fog/ovirt/requests/compute/v3/list_affinity_groups.rb +0 -22
  57. data/lib/fog/ovirt/requests/compute/v3/list_clusters.rb +0 -21
  58. data/lib/fog/ovirt/requests/compute/v3/list_instance_types.rb +0 -21
  59. data/lib/fog/ovirt/requests/compute/v3/list_networks.rb +0 -18
  60. data/lib/fog/ovirt/requests/compute/v3/list_operating_systems.rb +0 -21
  61. data/lib/fog/ovirt/requests/compute/v3/list_quotas.rb +0 -21
  62. data/lib/fog/ovirt/requests/compute/v3/list_template_interfaces.rb +0 -21
  63. data/lib/fog/ovirt/requests/compute/v3/list_template_volumes.rb +0 -21
  64. data/lib/fog/ovirt/requests/compute/v3/list_templates.rb +0 -21
  65. data/lib/fog/ovirt/requests/compute/v3/list_virtual_machines.rb +0 -21
  66. data/lib/fog/ovirt/requests/compute/v3/list_vm_interfaces.rb +0 -21
  67. data/lib/fog/ovirt/requests/compute/v3/list_vm_volumes.rb +0 -21
  68. data/lib/fog/ovirt/requests/compute/v3/list_volumes.rb +0 -21
  69. data/lib/fog/ovirt/requests/compute/v3/mock_files/affinitygroup.xml +0 -8
  70. data/lib/fog/ovirt/requests/compute/v3/mock_files/affinitygroup_vms.xml +0 -9
  71. data/lib/fog/ovirt/requests/compute/v3/mock_files/affinitygroups.xml +0 -17
  72. data/lib/fog/ovirt/requests/compute/v3/mock_files/cluster.xml +0 -20
  73. data/lib/fog/ovirt/requests/compute/v3/mock_files/clusters.xml +0 -39
  74. data/lib/fog/ovirt/requests/compute/v3/mock_files/data_centers.xml +0 -17
  75. data/lib/fog/ovirt/requests/compute/v3/mock_files/disks.xml +0 -58
  76. data/lib/fog/ovirt/requests/compute/v3/mock_files/instance_type.xml +0 -42
  77. data/lib/fog/ovirt/requests/compute/v3/mock_files/instance_types.xml +0 -197
  78. data/lib/fog/ovirt/requests/compute/v3/mock_files/nics.xml +0 -10
  79. data/lib/fog/ovirt/requests/compute/v3/mock_files/operating_systems.xml +0 -10
  80. data/lib/fog/ovirt/requests/compute/v3/mock_files/quotas.xml +0 -7
  81. data/lib/fog/ovirt/requests/compute/v3/mock_files/storage_domains.xml +0 -36
  82. data/lib/fog/ovirt/requests/compute/v3/mock_files/template.xml +0 -39
  83. data/lib/fog/ovirt/requests/compute/v3/mock_files/templates.xml +0 -110
  84. data/lib/fog/ovirt/requests/compute/v3/mock_files/vm.xml +0 -52
  85. data/lib/fog/ovirt/requests/compute/v3/mock_files/vms.xml +0 -152
  86. data/lib/fog/ovirt/requests/compute/v3/mock_files/volume.xml +0 -21
  87. data/lib/fog/ovirt/requests/compute/v3/mock_files/volumes.xml +0 -40
  88. data/lib/fog/ovirt/requests/compute/v3/remove_from_affinity_group.rb +0 -23
  89. data/lib/fog/ovirt/requests/compute/v3/storage_domains.rb +0 -22
  90. data/lib/fog/ovirt/requests/compute/v3/update_interface.rb +0 -36
  91. data/lib/fog/ovirt/requests/compute/v3/update_vm.rb +0 -20
  92. data/lib/fog/ovirt/requests/compute/v3/update_volume.rb +0 -37
  93. data/lib/fog/ovirt/requests/compute/v3/vm_action.rb +0 -24
  94. data/lib/fog/ovirt/requests/compute/v3/vm_start_with_cloudinit.rb +0 -21
  95. data/lib/fog/ovirt/requests/compute/v3/vm_ticket.rb +0 -19
  96. data/tests/ovirt/requests/compute/v3/client_tests.rb +0 -31
  97. data/tests/ovirt/requests/compute/v3/create_vm_tests.rb +0 -17
  98. data/tests/ovirt/requests/compute/v3/destroy_vm_tests.rb +0 -14
  99. data/tests/ovirt/requests/compute/v3/list_datacenters_tests.rb +0 -11
  100. data/tests/ovirt/requests/compute/v3/list_quotas_tests.rb +0 -10
  101. data/tests/ovirt/requests/compute/v3/list_storage_domains_tests.rb +0 -11
  102. data/tests/ovirt/requests/compute/v3/update_vm_tests.rb +0 -14
  103. 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: 62f57ba56922d0b42dcb1630ca68d8eeaddadb546af155531f067cb69a827f6c
4
- data.tar.gz: 8cd2223ae09ba6b051766f3c2adf16f16108aa62054809a2a67bc8d9a701b1f0
3
+ metadata.gz: 4cbc3f253a473c063a6f22507ecab2acb156f3be60d256184c7b2d024f4345f7
4
+ data.tar.gz: e7bccecc60f21d95f398fb99c8818c92c118d448b5d35da5ffb626eb7b67c14b
5
5
  SHA512:
6
- metadata.gz: 01da7011f032c165a82bd81fee927aa1692c5e5f47f6d3a4ff9520d6e2dce4eb05c5b63ce03fe31104da8cf50ab9f1c6416411daf74421e454b5dd4906271e74
7
- data.tar.gz: 627e9e59398bd1a035d9e9d93fee254830dd57308d41652a2ad61a6f8c4027e9a0950a3ccd0eef14314e4384a3e6e1bea26720b2aadf13a89cb504eb72075b6a
6
+ metadata.gz: 994e7f0826dde7c4fff25941e25065b098e3877493d5457a92edee03b7c951c993c4e4237a567b8e3c7c9091ededb0246c1b93ef363964b64e82dcf7ae22beb2
7
+ data.tar.gz: 0a8f71fd767765a45aff2524f2a4ea5467b84e6e66b7e7d8bf7efafa7a26ef87e05b9387d32823456efff68defba06203db36f58419705e23eb9581cc291566d
data/.gitignore CHANGED
@@ -19,6 +19,7 @@ doc/*
19
19
  docs/_site/*
20
20
  docs/about/supported_services.markdown
21
21
  Gemfile.lock
22
+ Gemfile.local.rb
22
23
  gemfiles/*.lock
23
24
  yardoc
24
25
  pkg
@@ -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
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,14 +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("rbovirt", "~> 0.1.5")
27
+ spec.add_dependency("ovirt-engine-sdk", ">= 4.3.1")
28
28
 
29
29
  spec.add_development_dependency "bundler"
30
30
  spec.add_development_dependency "pry"
@@ -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.include Fog::Ovirt::Compute::Collections
82
- @client = Fog::Ovirt::Compute::V4::Mock.new(options)
83
- else
84
- Fog::Ovirt::Compute::V3::Mock.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.include Fog::Ovirt::Compute::Collections
104
- @client = Fog::Ovirt::Compute::V4::Real.new(options)
105
- else
106
- Fog::Ovirt::Compute::V3::Real.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
@@ -40,11 +43,12 @@ module Fog
40
43
  request :list_quotas
41
44
  request :get_quota
42
45
  request :list_operating_systems
46
+ request :list_vnic_profiles
43
47
 
44
48
  module Shared
45
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
49
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
46
50
  # converts an OVIRT object into an hash for fog to consume.
47
- def ovirt_attrs(obj)
51
+ def shared_ovirt_attrs(obj)
48
52
  opts = {}
49
53
  # TODO: stop using instance_variables, they will change
50
54
  obj.instance_variables.each do |v|
@@ -52,7 +56,7 @@ module Fog
52
56
  value = obj.instance_variable_get(v)
53
57
 
54
58
  if key == :network
55
- opts[key] = obj.vnic_profile.present? ? client.follow_link(obj.vnic_profile).network.id : value
59
+ opts[key] = obj.vnic_profile.present? ? yield(obj) : value
56
60
  next
57
61
  end
58
62
 
@@ -70,9 +74,10 @@ module Fog
70
74
  end
71
75
  opts
72
76
  end
73
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
74
77
 
75
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
78
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
79
+
80
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
76
81
  def get_attr_value(value, opts)
77
82
  case value
78
83
  when OvirtSDK4::List
@@ -103,14 +108,14 @@ module Fog
103
108
  when OvirtSDK4::Console
104
109
  { :enabled => value.enabled }
105
110
  else
106
- if value.class.respond_to?(:parent) && value.class.parent == OvirtSDK4
111
+ if value.class.respond_to?(:module_parent) && value.class.module_parent == OvirtSDK4
107
112
  value.id if value.respond_to?(:id)
108
113
  else
109
114
  value.to_s.strip
110
115
  end
111
116
  end
112
117
  end
113
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
118
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
114
119
 
115
120
  def convert_string_to_bool(value)
116
121
  case value
@@ -138,6 +143,13 @@ module Fog
138
143
  require "ovirtsdk4"
139
144
  end
140
145
 
146
+ def ovirt_attrs(obj)
147
+ shared_ovirt_attrs(obj) do
148
+ xml = read_xml("vnic_profile.xml")
149
+ Nokogiri::XML(xml).xpath("/vnic_profile/network/@id").to_s
150
+ end
151
+ end
152
+
141
153
  private
142
154
 
143
155
  def client
@@ -154,7 +166,6 @@ module Fog
154
166
  class Real
155
167
  include Shared
156
168
 
157
- # rubocop:disable Metrics/AbcSize
158
169
  def initialize(options = {})
159
170
  require "ovirtsdk4"
160
171
  username = options[:ovirt_username]
@@ -175,7 +186,12 @@ module Fog
175
186
 
176
187
  @client = ExceptionWrapper.new(OvirtSDK4::Connection.new(connection_opts))
177
188
  end
178
- # rubocop:enable Metrics/AbcSize
189
+
190
+ def ovirt_attrs(obj)
191
+ shared_ovirt_attrs(obj) do
192
+ client.follow_link(obj.vnic_profile).network.id
193
+ end
194
+ end
179
195
 
180
196
  def api_version
181
197
  api = client.system_service.get
@@ -183,11 +199,11 @@ module Fog
183
199
  end
184
200
 
185
201
  def datacenter
186
- @datacenter ||= datacenter_hash[:id]
202
+ datacenter_hash[:id]
187
203
  end
188
204
 
189
205
  def datacenter_hash
190
- @datacenter_hash ||= datacenters.find { |x| x[:id] == @datacenter } if @datacenter
206
+ @datacenter_hash ||= datacenters.find { |x| x[:id] == @datacenter } || datacenters.find { |x| x[:name] == @datacenter } if @datacenter
191
207
  @datacenter_hash ||= datacenters.first
192
208
  end
193
209
 
@@ -9,6 +9,7 @@ module Fog
9
9
  attribute :network
10
10
  attribute :interface
11
11
  attribute :mac
12
+ attribute :vnic_profile
12
13
 
13
14
  def to_s
14
15
  name
@@ -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,30 +3,24 @@ 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)
10
9
  nics_service = vm.nics_service
11
10
  options = options.dup
12
11
  options = convert_string_to_bool(options)
13
- if options[:network].present?
12
+ if options[:network].present? && options[:vnic_profile].nil?
14
13
  network = client.system_service.networks_service.network_service(options[:network]).get
15
-
16
14
  profiles = client.follow_link(network.vnic_profiles)
17
-
18
15
  profile = profiles.detect { |x| x.name == network.name }
19
-
20
16
  profile ||= profiles.min_by(&:name)
21
-
22
- options.delete(:network)
23
- options[:vnic_profile] = { :id => profile.id }
17
+ options[:vnic_profile] = profile.id
24
18
  end
25
-
19
+ options[:vnic_profile] = { :id => options[:vnic_profile] }
20
+ options.delete(:network)
26
21
  interface = OvirtSDK4::Nic.new(options)
27
22
  nics_service.add(interface)
28
23
  end
29
- # rubocop:enable Metrics/AbcSize
30
24
  end
31
25
 
32
26
  class Mock