fog-ovirt 0.1.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +20 -0
  3. data/.rubocop_todo.yml +43 -0
  4. data/.travis.yml +3 -1
  5. data/Gemfile +1 -1
  6. data/Rakefile +15 -5
  7. data/fog-ovirt.gemspec +15 -14
  8. data/lib/fog/bin/ovirt.rb +1 -1
  9. data/lib/fog/ovirt.rb +1 -1
  10. data/lib/fog/ovirt/compute.rb +56 -112
  11. data/lib/fog/ovirt/compute/v3.rb +137 -0
  12. data/lib/fog/ovirt/core.rb +13 -4
  13. data/lib/fog/ovirt/models/compute/affinity_group.rb +2 -2
  14. data/lib/fog/ovirt/models/compute/affinity_groups.rb +2 -2
  15. data/lib/fog/ovirt/models/compute/clusters.rb +2 -2
  16. data/lib/fog/ovirt/models/compute/instance_types.rb +2 -2
  17. data/lib/fog/ovirt/models/compute/interfaces.rb +7 -5
  18. data/lib/fog/ovirt/models/compute/operating_systems.rb +3 -3
  19. data/lib/fog/ovirt/models/compute/quotas.rb +3 -3
  20. data/lib/fog/ovirt/models/compute/server.rb +37 -31
  21. data/lib/fog/ovirt/models/compute/servers.rb +2 -2
  22. data/lib/fog/ovirt/models/compute/template.rb +9 -9
  23. data/lib/fog/ovirt/models/compute/templates.rb +2 -2
  24. data/lib/fog/ovirt/models/compute/volume.rb +3 -3
  25. data/lib/fog/ovirt/models/compute/volumes.rb +6 -4
  26. data/lib/fog/ovirt/requests/compute/v3/activate_volume.rb +23 -0
  27. data/lib/fog/ovirt/requests/compute/v3/add_interface.rb +22 -0
  28. data/lib/fog/ovirt/requests/compute/v3/add_to_affinity_group.rb +23 -0
  29. data/lib/fog/ovirt/requests/compute/v3/add_volume.rb +23 -0
  30. data/lib/fog/ovirt/requests/compute/v3/attach_volume.rb +24 -0
  31. data/lib/fog/ovirt/requests/compute/v3/create_affinity_group.rb +20 -0
  32. data/lib/fog/ovirt/requests/compute/v3/create_vm.rb +20 -0
  33. data/lib/fog/ovirt/requests/compute/v3/datacenters.rb +22 -0
  34. data/lib/fog/ovirt/requests/compute/v3/deactivate_volume.rb +24 -0
  35. data/lib/fog/ovirt/requests/compute/v3/destroy_affinity_group.rb +21 -0
  36. data/lib/fog/ovirt/requests/compute/v3/destroy_interface.rb +24 -0
  37. data/lib/fog/ovirt/requests/compute/v3/destroy_vm.rb +21 -0
  38. data/lib/fog/ovirt/requests/compute/v3/destroy_volume.rb +24 -0
  39. data/lib/fog/ovirt/requests/compute/v3/detach_volume.rb +24 -0
  40. data/lib/fog/ovirt/requests/compute/v3/get_affinity_group.rb +20 -0
  41. data/lib/fog/ovirt/requests/compute/v3/get_api_version.rb +18 -0
  42. data/lib/fog/ovirt/requests/compute/v3/get_cluster.rb +19 -0
  43. data/lib/fog/ovirt/requests/compute/v3/get_instance_type.rb +19 -0
  44. data/lib/fog/ovirt/requests/compute/v3/get_quota.rb +19 -0
  45. data/lib/fog/ovirt/requests/compute/v3/get_template.rb +19 -0
  46. data/lib/fog/ovirt/requests/compute/v3/get_virtual_machine.rb +19 -0
  47. data/lib/fog/ovirt/requests/compute/v3/list_affinity_group_vms.rb +24 -0
  48. data/lib/fog/ovirt/requests/compute/v3/list_affinity_groups.rb +22 -0
  49. data/lib/fog/ovirt/requests/compute/v3/list_clusters.rb +21 -0
  50. data/lib/fog/ovirt/requests/compute/v3/list_instance_types.rb +21 -0
  51. data/lib/fog/ovirt/requests/compute/v3/list_networks.rb +18 -0
  52. data/lib/fog/ovirt/requests/compute/v3/list_operating_systems.rb +21 -0
  53. data/lib/fog/ovirt/requests/compute/v3/list_quotas.rb +21 -0
  54. data/lib/fog/ovirt/requests/compute/v3/list_template_interfaces.rb +21 -0
  55. data/lib/fog/ovirt/requests/compute/v3/list_template_volumes.rb +21 -0
  56. data/lib/fog/ovirt/requests/compute/v3/list_templates.rb +21 -0
  57. data/lib/fog/ovirt/requests/compute/v3/list_virtual_machines.rb +21 -0
  58. data/lib/fog/ovirt/requests/compute/v3/list_vm_interfaces.rb +21 -0
  59. data/lib/fog/ovirt/requests/compute/v3/list_vm_volumes.rb +21 -0
  60. data/lib/fog/ovirt/requests/compute/v3/list_volumes.rb +21 -0
  61. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/affinitygroup.xml +0 -0
  62. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/affinitygroup_vms.xml +0 -0
  63. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/affinitygroups.xml +0 -0
  64. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/cluster.xml +0 -0
  65. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/clusters.xml +0 -0
  66. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/data_centers.xml +0 -0
  67. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/disks.xml +0 -0
  68. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/instance_type.xml +0 -0
  69. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/instance_types.xml +0 -0
  70. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/nics.xml +0 -0
  71. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/operating_systems.xml +0 -0
  72. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/quotas.xml +0 -0
  73. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/storage_domains.xml +0 -0
  74. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/template.xml +0 -0
  75. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/templates.xml +0 -0
  76. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/vm.xml +0 -0
  77. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/vms.xml +0 -0
  78. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/volumes.xml +0 -0
  79. data/lib/fog/ovirt/requests/compute/v3/remove_from_affinity_group.rb +23 -0
  80. data/lib/fog/ovirt/requests/compute/v3/storage_domains.rb +22 -0
  81. data/lib/fog/ovirt/requests/compute/v3/update_interface.rb +36 -0
  82. data/lib/fog/ovirt/requests/compute/v3/update_vm.rb +20 -0
  83. data/lib/fog/ovirt/requests/compute/v3/update_volume.rb +37 -0
  84. data/lib/fog/ovirt/requests/compute/v3/vm_action.rb +24 -0
  85. data/lib/fog/ovirt/requests/compute/v3/vm_start_with_cloudinit.rb +21 -0
  86. data/lib/fog/ovirt/requests/compute/v3/vm_ticket.rb +19 -0
  87. data/lib/fog/ovirt/version.rb +1 -1
  88. data/tests/helper.rb +1 -1
  89. data/tests/helpers/mock_helper.rb +4 -6
  90. data/tests/helpers/succeeds_helper.rb +1 -1
  91. data/tests/ovirt/compute_tests.rb +5 -6
  92. data/tests/ovirt/models/compute/cluster_tests.rb +10 -13
  93. data/tests/ovirt/models/compute/clusters_tests.rb +3 -5
  94. data/tests/ovirt/models/compute/interface_tests.rb +9 -11
  95. data/tests/ovirt/models/compute/interfaces_tests.rb +3 -5
  96. data/tests/ovirt/models/compute/operating_system_tests.rb +7 -13
  97. data/tests/ovirt/models/compute/operating_systems_tests.rb +4 -6
  98. data/tests/ovirt/models/compute/server_tests.rb +29 -32
  99. data/tests/ovirt/models/compute/servers_tests.rb +7 -9
  100. data/tests/ovirt/models/compute/template_tests.rb +10 -12
  101. data/tests/ovirt/models/compute/templates_tests.rb +3 -5
  102. data/tests/ovirt/requests/compute/client_tests.rb +31 -0
  103. data/tests/ovirt/requests/compute/create_vm_tests.rb +7 -16
  104. data/tests/ovirt/requests/compute/destroy_vm_tests.rb +8 -10
  105. data/tests/ovirt/requests/compute/list_datacenters_tests.rb +3 -5
  106. data/tests/ovirt/requests/compute/list_quotas_tests.rb +2 -4
  107. data/tests/ovirt/requests/compute/list_storage_domains_tests.rb +3 -5
  108. data/tests/ovirt/requests/compute/update_vm_tests.rb +9 -11
  109. data/tests/ovirt/requests/compute/update_volume_tests.rb +9 -12
  110. metadata +70 -65
  111. data/lib/fog/ovirt/requests/compute/activate_volume.rb +0 -22
  112. data/lib/fog/ovirt/requests/compute/add_interface.rb +0 -20
  113. data/lib/fog/ovirt/requests/compute/add_to_affinity_group.rb +0 -21
  114. data/lib/fog/ovirt/requests/compute/add_volume.rb +0 -21
  115. data/lib/fog/ovirt/requests/compute/attach_volume.rb +0 -22
  116. data/lib/fog/ovirt/requests/compute/create_affinity_group.rb +0 -18
  117. data/lib/fog/ovirt/requests/compute/create_vm.rb +0 -18
  118. data/lib/fog/ovirt/requests/compute/datacenters.rb +0 -20
  119. data/lib/fog/ovirt/requests/compute/deactivate_volume.rb +0 -22
  120. data/lib/fog/ovirt/requests/compute/destroy_affinity_group.rb +0 -19
  121. data/lib/fog/ovirt/requests/compute/destroy_interface.rb +0 -22
  122. data/lib/fog/ovirt/requests/compute/destroy_vm.rb +0 -19
  123. data/lib/fog/ovirt/requests/compute/destroy_volume.rb +0 -22
  124. data/lib/fog/ovirt/requests/compute/detach_volume.rb +0 -22
  125. data/lib/fog/ovirt/requests/compute/get_affinity_group.rb +0 -18
  126. data/lib/fog/ovirt/requests/compute/get_api_version.rb +0 -16
  127. data/lib/fog/ovirt/requests/compute/get_cluster.rb +0 -17
  128. data/lib/fog/ovirt/requests/compute/get_instance_type.rb +0 -17
  129. data/lib/fog/ovirt/requests/compute/get_quota.rb +0 -17
  130. data/lib/fog/ovirt/requests/compute/get_template.rb +0 -17
  131. data/lib/fog/ovirt/requests/compute/get_virtual_machine.rb +0 -17
  132. data/lib/fog/ovirt/requests/compute/list_affinity_group_vms.rb +0 -22
  133. data/lib/fog/ovirt/requests/compute/list_affinity_groups.rb +0 -20
  134. data/lib/fog/ovirt/requests/compute/list_clusters.rb +0 -19
  135. data/lib/fog/ovirt/requests/compute/list_instance_types.rb +0 -19
  136. data/lib/fog/ovirt/requests/compute/list_networks.rb +0 -16
  137. data/lib/fog/ovirt/requests/compute/list_operating_systems.rb +0 -19
  138. data/lib/fog/ovirt/requests/compute/list_quotas.rb +0 -19
  139. data/lib/fog/ovirt/requests/compute/list_template_interfaces.rb +0 -19
  140. data/lib/fog/ovirt/requests/compute/list_template_volumes.rb +0 -19
  141. data/lib/fog/ovirt/requests/compute/list_templates.rb +0 -19
  142. data/lib/fog/ovirt/requests/compute/list_virtual_machines.rb +0 -19
  143. data/lib/fog/ovirt/requests/compute/list_vm_interfaces.rb +0 -19
  144. data/lib/fog/ovirt/requests/compute/list_vm_volumes.rb +0 -19
  145. data/lib/fog/ovirt/requests/compute/list_volumes.rb +0 -19
  146. data/lib/fog/ovirt/requests/compute/remove_from_affinity_group.rb +0 -21
  147. data/lib/fog/ovirt/requests/compute/storage_domains.rb +0 -20
  148. data/lib/fog/ovirt/requests/compute/update_interface.rb +0 -35
  149. data/lib/fog/ovirt/requests/compute/update_vm.rb +0 -18
  150. data/lib/fog/ovirt/requests/compute/update_volume.rb +0 -39
  151. data/lib/fog/ovirt/requests/compute/vm_action.rb +0 -22
  152. data/lib/fog/ovirt/requests/compute/vm_start_with_cloudinit.rb +0 -19
  153. data/lib/fog/ovirt/requests/compute/vm_ticket.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71684d4a4643676f4814809219a4058a4fac0e27
4
- data.tar.gz: c955613117d9b60ce9146b603af5ee7414525986
3
+ metadata.gz: 6146d4fb921308e0f84cd983e1c0388cb81a8be5
4
+ data.tar.gz: 3b59c220c23dadfb77f63aaee4a6106ef169d064
5
5
  SHA512:
6
- metadata.gz: c5e5490f49c148e247b3ef5da98c0dd20e8655932ab1a5c02262f27460590ac5762bd8349dff44f9771d5d36d1be314c30964699eb43caa7b5842ea36089bc56
7
- data.tar.gz: 8878fcf57d1419ed852bb1f3a04cbe54107c646858b1683a1a5808e3974410ead1104329d064f5bf133aa213de2929f6a30b7f579b9e223b5bd37bcf8db9ecde
6
+ metadata.gz: 75bbc67488aac1503eae3ece69b447d8d09fdffa5af68bdb7ac9c5b5a4dba491e42ec1f8012c883b30964c5b50ac471adadcee280584786b7dcf44ebc2e72075
7
+ data.tar.gz: 38f7d09671007b163e23fd6ccf5e0d7dead675723ed1e24ada44193eb8e56427e7a68a919400544a5a9ef2e40e9cd8466baa5d36ad9979061684e1cca869494b
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Style/HashSyntax:
4
+ EnforcedStyle: hash_rockets
5
+
6
+ Metrics/LineLength:
7
+ Max: 100
8
+ Enabled: false
9
+
10
+ Style/StringLiterals:
11
+ EnforcedStyle: double_quotes
12
+
13
+ Style/Encoding:
14
+ Description: 'Use UTF-8 as the source file encoding.'
15
+ Enabled: false
16
+
17
+ Style/SignalException:
18
+ Description: 'Do not enforce use of fail when raising exceptions.'
19
+ # Valid values are: semantic, only_raise and only_fail
20
+ EnforcedStyle: only_raise
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,43 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-12-14 14:56:02 +0100 using RuboCop version 0.52.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: CountComments.
11
+ Metrics/ClassLength:
12
+ Max: 146
13
+
14
+ # Offense count: 2
15
+ # Configuration parameters: CountComments.
16
+ Metrics/MethodLength:
17
+ Max: 19
18
+
19
+ # Offense count: 1
20
+ Style/ClassVars:
21
+ Exclude:
22
+ - 'lib/fog/bin/ovirt.rb'
23
+
24
+ # Offense count: 1
25
+ Style/CommentedKeyword:
26
+ Exclude:
27
+ - 'lib/fog/ovirt/models/compute/server.rb'
28
+
29
+ # Offense count: 113
30
+ Style/Documentation:
31
+ Enabled: false
32
+
33
+ # Offense count: 3
34
+ Style/DoubleNegation:
35
+ Exclude:
36
+ - 'lib/fog/ovirt/models/compute/server.rb'
37
+ - 'tests/helpers/succeeds_helper.rb'
38
+
39
+ # Offense count: 4
40
+ Style/MultilineTernaryOperator:
41
+ Exclude:
42
+ - 'lib/fog/ovirt/models/compute/server.rb'
43
+ - 'lib/fog/ovirt/models/compute/template.rb'
data/.travis.yml CHANGED
@@ -3,7 +3,9 @@ language: ruby
3
3
  sudo: false
4
4
  dist: trusty
5
5
 
6
- script: bundle exec rake test
6
+ script:
7
+ - bundle exec rake rubocop
8
+ - bundle exec rake test
7
9
 
8
10
  rvm:
9
11
  - 2.1
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require 'bundler/gem_tasks'
1
+ require "bundler/gem_tasks"
2
2
  # require 'rake/testtask'
3
3
 
4
4
  # Rake::TestTask.new do |t|
@@ -7,9 +7,19 @@ require 'bundler/gem_tasks'
7
7
  # t.verbose = true
8
8
  # end
9
9
 
10
- mock = ENV['FOG_MOCK'] || 'true'
11
- task :test do
12
- sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/ovirt")
10
+ mock = ENV["FOG_MOCK"] || "true"
11
+
12
+ begin
13
+ require "rubocop/rake_task"
14
+ RuboCop::RakeTask.new do |t|
15
+ t.patterns = Dir["{lib,spec,tests}/**/*"]
13
16
  end
17
+ rescue StandardError
18
+ puts "Rubocop not loaded"
19
+ end
20
+
21
+ task :test do
22
+ sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/ovirt")
23
+ end
14
24
 
15
- task(:default => [:test])
25
+ task(:default => [:test])
data/fog-ovirt.gemspec CHANGED
@@ -1,32 +1,33 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+
3
+ lib = File.expand_path("lib", __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'fog/ovirt/version'
5
+ require "fog/ovirt/version"
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = 'fog-ovirt'
8
+ spec.name = "fog-ovirt"
8
9
  spec.version = Fog::Ovirt::VERSION
9
- spec.authors = ['Ori Rabin']
10
- spec.email = ['orabin@redhat.com']
10
+ spec.authors = ["Ori Rabin"]
11
+ spec.email = ["orabin@redhat.com"]
11
12
 
12
13
  spec.summary = "Module for the 'fog' gem to support Ovirt."
13
- spec.description = 'This library can be used as a module for `fog`.'
14
- spec.homepage = 'https://github.com/fog/fog-ovirt'
15
- spec.license = 'MIT'
14
+ spec.description = "This library can be used as a module for `fog`."
15
+ spec.homepage = "https://github.com/fog/fog-ovirt"
16
+ spec.license = "MIT"
16
17
 
17
18
  spec.files = `git ls-files -z`.split("\x0")
18
19
  spec.test_files = spec.files.grep(%r{^tests\/})
19
20
 
20
- spec.require_paths = ['lib']
21
+ spec.require_paths = ["lib"]
21
22
 
22
23
  spec.add_dependency("fog-core", "~> 1.45")
23
24
  spec.add_dependency("fog-json")
24
25
  spec.add_dependency("fog-xml", "~> 0.1.1")
25
26
  spec.add_dependency("rbovirt", "~> 0.1.5")
26
27
 
27
- spec.add_development_dependency 'bundler', '~> 1.10'
28
- spec.add_development_dependency 'pry', '~> 0.10'
29
- spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'rubocop', '~> 0.34'
31
- spec.add_development_dependency 'shindo', '~> 0.3'
28
+ spec.add_development_dependency "bundler", "~> 1.10"
29
+ spec.add_development_dependency "pry", "~> 0.10"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rubocop", "~> 0.52"
32
+ spec.add_development_dependency "shindo", "~> 0.3"
32
33
  end
data/lib/fog/bin/ovirt.rb CHANGED
@@ -13,7 +13,7 @@ class Ovirt < Fog::Bin
13
13
  @@connections ||= Hash.new do |hash, key|
14
14
  hash[key] = case key
15
15
  when :compute
16
- Fog::Compute.new(:provider => 'Ovirt')
16
+ Fog::Compute.new(:provider => "Ovirt")
17
17
  else
18
18
  raise ArgumentError, "Unrecognized service: #{key.inspect}"
19
19
  end
data/lib/fog/ovirt.rb CHANGED
@@ -1 +1 @@
1
- require 'fog/ovirt/compute'
1
+ require "fog/ovirt/compute"
@@ -1,14 +1,9 @@
1
- require 'fog/ovirt/core'
1
+ require "fog/ovirt/core"
2
2
 
3
3
  module Fog
4
4
  module Compute
5
5
  class Ovirt < Fog::Service
6
- requires :ovirt_username, :ovirt_password
7
- recognizes :ovirt_url, :ovirt_server, :ovirt_port, :ovirt_api_path, :ovirt_datacenter,
8
- :ovirt_filtered_api,
9
- :ovirt_ca_cert_store, :ovirt_ca_cert_file, :ovirt_ca_no_verify
10
-
11
- model_path 'fog/ovirt/models/compute'
6
+ model_path "fog/ovirt/models/compute"
12
7
  model :server
13
8
  collection :servers
14
9
  model :template
@@ -28,130 +23,79 @@ module Fog
28
23
  model :affinity_group
29
24
  collection :affinity_groups
30
25
 
31
- request_path 'fog/ovirt/requests/compute'
32
-
33
- request :vm_action
34
- request :vm_start_with_cloudinit
35
- request :destroy_vm
36
- request :create_vm
37
- request :update_vm
38
- request :datacenters
39
- request :storage_domains
40
- request :list_virtual_machines
41
- request :get_virtual_machine
42
- request :list_templates
43
- request :get_template
44
- request :list_instance_types
45
- request :get_instance_type
46
- request :list_clusters
47
- request :get_cluster
48
- request :add_interface
49
- request :destroy_interface
50
- request :update_interface
51
- request :list_vm_interfaces
52
- request :list_template_interfaces
53
- request :list_networks
54
- request :vm_ticket
55
- request :list_vm_volumes
56
- request :list_template_volumes
57
- request :list_volumes
58
- request :add_volume
59
- request :destroy_volume
60
- request :update_volume
61
- request :attach_volume
62
- request :detach_volume
63
- request :activate_volume
64
- request :deactivate_volume
65
- request :get_api_version
66
- request :list_quotas
67
- request :get_quota
68
- request :list_affinity_groups
69
- request :get_affinity_group
70
- request :list_affinity_group_vms
71
- request :create_affinity_group
72
- request :destroy_affinity_group
73
- request :add_to_affinity_group
74
- request :remove_from_affinity_group
75
- request :list_operating_systems
76
-
77
- module Shared
78
- # converts an OVIRT object into an hash for fog to consume.
79
- def ovirt_attrs obj
80
- opts = {:raw => obj}
81
- obj.instance_variables.each do |v|
82
- key = v.to_s.gsub("@","").to_sym
83
- value = obj.instance_variable_get(v)
84
- #ignore nil values
85
- next if value.nil?
26
+ class ExceptionWrapper
27
+ def initialize(client)
28
+ @client = client
29
+ end
86
30
 
87
- opts[key] = case value
88
- when OVIRT::Link
89
- value.id
90
- when OVIRT::TemplateVersion
91
- value
92
- when Array
93
- value
94
- when Hash
95
- value
96
- else
97
- value.to_s.strip
98
- end
31
+ # rubocop:disable Style/MethodMissing
32
+ def method_missing(symbol, *args)
33
+ if block_given?
34
+ @client.send(symbol, *args) do |*block_args|
35
+ yield(*block_args)
36
+ end
37
+ else
38
+ @client.send(symbol, *args)
99
39
  end
100
- opts
40
+ rescue ::OVIRT::OvirtException => e
41
+ raise ::Fog::Ovirt::Errors::OvirtEngineError, e
101
42
  end
102
- end
103
43
 
104
- class Mock
105
- include Shared
106
-
107
- def initialize(options={})
108
- require 'rbovirt'
44
+ def respond_to?(symbol, include_all = false)
45
+ @client.respond_to?(symbol, include_all)
109
46
  end
47
+ # rubocop:enable Style/MethodMissing
48
+ end
110
49
 
111
- private
50
+ require "fog/ovirt/compute/v3"
112
51
 
113
- def client
114
- return @client if defined?(@client)
115
- end
52
+ def self.new(options = {})
53
+ super()
54
+ @client = Fog::Compute::Ovirt::V3.new(options)
55
+ end
116
56
 
117
- #read mocks xml
118
- def read_xml(file_name)
119
- file_path = File.join(File.dirname(__FILE__),"requests","compute","mock_files",file_name)
120
- File.read(file_path)
121
- end
57
+ # rubocop:disable Style/MethodMissing
58
+ def method_missing(symbol, *args)
59
+ @client.send(symbol, *args)
122
60
  end
123
61
 
124
- class Real
125
- include Shared
62
+ def respond_to?(symbol, include_all = false)
63
+ @client.respond_to?(symbol, include_all)
64
+ end
65
+ # rubocop:enable Style/MethodMissing
126
66
 
127
- def initialize(options={})
128
- require 'rbovirt'
129
- username = options[:ovirt_username]
130
- password = options[:ovirt_password]
131
- server = options[:ovirt_server]
132
- port = options[:ovirt_port] || 8080
133
- api_path = options[:ovirt_api_path] || '/api'
134
- url = options[:ovirt_url] || "#{@scheme}://#{server}:#{port}#{api_path}"
67
+ class Mock
68
+ def initialize(options = {})
69
+ Fog::Compute::Ovirt::V3::Mock.send(:include, Fog::Compute::Ovirt::Collections)
70
+ @client = Fog::Compute::Ovirt::V3::Mock.new(options)
71
+ end
135
72
 
136
- connection_opts = {}
137
- connection_opts[:datacenter_id] = options[:ovirt_datacenter]
138
- connection_opts[:ca_cert_store] = options[:ovirt_ca_cert_store]
139
- connection_opts[:ca_cert_file] = options[:ovirt_ca_cert_file]
140
- connection_opts[:ca_no_verify] = options[:ovirt_ca_no_verify]
141
- connection_opts[:filtered_api] = options[:ovirt_filtered_api]
73
+ # rubocop:disable Style/MethodMissing
74
+ def method_missing(symbol, *args)
75
+ @client.send(symbol, *args)
76
+ end
142
77
 
143
- @client = OVIRT::Client.new(username, password, url, connection_opts)
78
+ def respond_to?(symbol, include_all = false)
79
+ @client.respond_to?(symbol, include_all)
144
80
  end
81
+ # rubocop:enable Style/MethodMissing
82
+ end
145
83
 
146
- def api_version
147
- client.api_version
84
+ class Real
85
+ def initialize(options = {})
86
+ Fog::Compute::Ovirt::V3::Real.send(:include, Fog::Compute::Ovirt::Collections)
87
+ @client = Fog::Compute::Ovirt::V3::Real.new(options)
148
88
  end
149
89
 
150
- private
90
+ # rubocop:disable Style/MethodMissing
91
+ def method_missing(symbol, *args)
92
+ @client.send(symbol, *args)
93
+ end
151
94
 
152
- def client
153
- @client
95
+ def respond_to?(symbol, include_all = false)
96
+ @client.respond_to?(symbol, include_all)
154
97
  end
98
+ # rubocop:enable Style/MethodMissing
155
99
  end
156
100
  end
157
101
  end
@@ -0,0 +1,137 @@
1
+ module Fog
2
+ module Compute
3
+ class Ovirt
4
+ class V3 < Fog::Service
5
+ requires :ovirt_username, :ovirt_password
6
+ recognizes :ovirt_url, :ovirt_server, :ovirt_port, :ovirt_api_path, :ovirt_datacenter,
7
+ :ovirt_filtered_api,
8
+ :ovirt_ca_cert_store, :ovirt_ca_cert_file, :ovirt_ca_no_verify
9
+ request_path "fog/ovirt/requests/compute/v3"
10
+
11
+ request :vm_action
12
+ request :vm_start_with_cloudinit
13
+ request :destroy_vm
14
+ request :create_vm
15
+ request :update_vm
16
+ request :datacenters
17
+ request :storage_domains
18
+ request :list_virtual_machines
19
+ request :get_virtual_machine
20
+ request :list_templates
21
+ request :get_template
22
+ request :list_instance_types
23
+ request :get_instance_type
24
+ request :list_clusters
25
+ request :get_cluster
26
+ request :add_interface
27
+ request :destroy_interface
28
+ request :update_interface
29
+ request :list_vm_interfaces
30
+ request :list_template_interfaces
31
+ request :list_networks
32
+ request :vm_ticket
33
+ request :list_vm_volumes
34
+ request :list_template_volumes
35
+ request :list_volumes
36
+ request :add_volume
37
+ request :destroy_volume
38
+ request :update_volume
39
+ request :attach_volume
40
+ request :detach_volume
41
+ request :activate_volume
42
+ request :deactivate_volume
43
+ request :get_api_version
44
+ request :list_quotas
45
+ request :get_quota
46
+ request :list_affinity_groups
47
+ request :get_affinity_group
48
+ request :list_affinity_group_vms
49
+ request :create_affinity_group
50
+ request :destroy_affinity_group
51
+ request :add_to_affinity_group
52
+ request :remove_from_affinity_group
53
+ request :list_operating_systems
54
+
55
+ module Shared
56
+ # converts an OVIRT object into an hash for fog to consume.
57
+ def ovirt_attrs(obj)
58
+ opts = { :raw => obj }
59
+ obj.instance_variables.each do |v|
60
+ key = v.to_s.delete("@").to_sym
61
+ value = obj.instance_variable_get(v)
62
+ # ignore nil values
63
+ next if value.nil?
64
+
65
+ opts[key] = case value
66
+ when OVIRT::Link
67
+ value.id
68
+ when OVIRT::TemplateVersion
69
+ value
70
+ when Array
71
+ value
72
+ when Hash
73
+ value
74
+ else
75
+ value.to_s.strip
76
+ end
77
+ end
78
+ opts
79
+ end
80
+ end
81
+
82
+ class Mock
83
+ include Shared
84
+
85
+ def initialize(_options = {})
86
+ require "rbovirt"
87
+ end
88
+
89
+ private
90
+
91
+ def client
92
+ return @client if defined?(@client)
93
+ end
94
+
95
+ # read mocks xml
96
+ def read_xml(file_name)
97
+ file_path = File.join(__dir__, "../requests", "compute/v3", "mock_files", file_name)
98
+ File.read(file_path)
99
+ end
100
+ end
101
+
102
+ class Real
103
+ include Shared
104
+
105
+ # rubocop:disable Metrics/AbcSize
106
+ def initialize(options = {})
107
+ require "rbovirt"
108
+ username = options[:ovirt_username]
109
+ password = options[:ovirt_password]
110
+ server = options[:ovirt_server]
111
+ port = options[:ovirt_port] || 8080
112
+ api_path = options[:ovirt_api_path] || "/api"
113
+ url = options[:ovirt_url] || "#{@scheme}://#{server}:#{port}#{api_path}"
114
+
115
+ connection_opts = {}
116
+ connection_opts[:datacenter_id] = options[:ovirt_datacenter]
117
+ connection_opts[:ca_cert_store] = options[:ovirt_ca_cert_store]
118
+ connection_opts[:ca_cert_file] = options[:ovirt_ca_cert_file]
119
+ connection_opts[:ca_no_verify] = options[:ovirt_ca_no_verify]
120
+ connection_opts[:filtered_api] = options[:ovirt_filtered_api]
121
+
122
+ @client = ExceptionWrapper.new(OVIRT::Client.new(username, password, url, connection_opts))
123
+ end
124
+ # rubocop:enable Metrics/AbcSize
125
+
126
+ def api_version
127
+ client.api_version
128
+ end
129
+
130
+ private
131
+
132
+ attr_reader :client
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end