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.
- checksums.yaml +4 -4
- data/.rubocop.yml +20 -0
- data/.rubocop_todo.yml +43 -0
- data/.travis.yml +3 -1
- data/Gemfile +1 -1
- data/Rakefile +15 -5
- data/fog-ovirt.gemspec +15 -14
- data/lib/fog/bin/ovirt.rb +1 -1
- data/lib/fog/ovirt.rb +1 -1
- data/lib/fog/ovirt/compute.rb +56 -112
- data/lib/fog/ovirt/compute/v3.rb +137 -0
- data/lib/fog/ovirt/core.rb +13 -4
- data/lib/fog/ovirt/models/compute/affinity_group.rb +2 -2
- data/lib/fog/ovirt/models/compute/affinity_groups.rb +2 -2
- data/lib/fog/ovirt/models/compute/clusters.rb +2 -2
- data/lib/fog/ovirt/models/compute/instance_types.rb +2 -2
- data/lib/fog/ovirt/models/compute/interfaces.rb +7 -5
- data/lib/fog/ovirt/models/compute/operating_systems.rb +3 -3
- data/lib/fog/ovirt/models/compute/quotas.rb +3 -3
- data/lib/fog/ovirt/models/compute/server.rb +37 -31
- data/lib/fog/ovirt/models/compute/servers.rb +2 -2
- data/lib/fog/ovirt/models/compute/template.rb +9 -9
- data/lib/fog/ovirt/models/compute/templates.rb +2 -2
- data/lib/fog/ovirt/models/compute/volume.rb +3 -3
- data/lib/fog/ovirt/models/compute/volumes.rb +6 -4
- data/lib/fog/ovirt/requests/compute/v3/activate_volume.rb +23 -0
- data/lib/fog/ovirt/requests/compute/v3/add_interface.rb +22 -0
- data/lib/fog/ovirt/requests/compute/v3/add_to_affinity_group.rb +23 -0
- data/lib/fog/ovirt/requests/compute/v3/add_volume.rb +23 -0
- data/lib/fog/ovirt/requests/compute/v3/attach_volume.rb +24 -0
- data/lib/fog/ovirt/requests/compute/v3/create_affinity_group.rb +20 -0
- data/lib/fog/ovirt/requests/compute/v3/create_vm.rb +20 -0
- data/lib/fog/ovirt/requests/compute/v3/datacenters.rb +22 -0
- data/lib/fog/ovirt/requests/compute/v3/deactivate_volume.rb +24 -0
- data/lib/fog/ovirt/requests/compute/v3/destroy_affinity_group.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/destroy_interface.rb +24 -0
- data/lib/fog/ovirt/requests/compute/v3/destroy_vm.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/destroy_volume.rb +24 -0
- data/lib/fog/ovirt/requests/compute/v3/detach_volume.rb +24 -0
- data/lib/fog/ovirt/requests/compute/v3/get_affinity_group.rb +20 -0
- data/lib/fog/ovirt/requests/compute/v3/get_api_version.rb +18 -0
- data/lib/fog/ovirt/requests/compute/v3/get_cluster.rb +19 -0
- data/lib/fog/ovirt/requests/compute/v3/get_instance_type.rb +19 -0
- data/lib/fog/ovirt/requests/compute/v3/get_quota.rb +19 -0
- data/lib/fog/ovirt/requests/compute/v3/get_template.rb +19 -0
- data/lib/fog/ovirt/requests/compute/v3/get_virtual_machine.rb +19 -0
- data/lib/fog/ovirt/requests/compute/v3/list_affinity_group_vms.rb +24 -0
- data/lib/fog/ovirt/requests/compute/v3/list_affinity_groups.rb +22 -0
- data/lib/fog/ovirt/requests/compute/v3/list_clusters.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/list_instance_types.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/list_networks.rb +18 -0
- data/lib/fog/ovirt/requests/compute/v3/list_operating_systems.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/list_quotas.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/list_template_interfaces.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/list_template_volumes.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/list_templates.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/list_virtual_machines.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/list_vm_interfaces.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/list_vm_volumes.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/list_volumes.rb +21 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/affinitygroup.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/affinitygroup_vms.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/affinitygroups.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/cluster.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/clusters.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/data_centers.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/disks.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/instance_type.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/instance_types.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/nics.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/operating_systems.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/quotas.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/storage_domains.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/template.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/templates.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/vm.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/vms.xml +0 -0
- data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/volumes.xml +0 -0
- data/lib/fog/ovirt/requests/compute/v3/remove_from_affinity_group.rb +23 -0
- data/lib/fog/ovirt/requests/compute/v3/storage_domains.rb +22 -0
- data/lib/fog/ovirt/requests/compute/v3/update_interface.rb +36 -0
- data/lib/fog/ovirt/requests/compute/v3/update_vm.rb +20 -0
- data/lib/fog/ovirt/requests/compute/v3/update_volume.rb +37 -0
- data/lib/fog/ovirt/requests/compute/v3/vm_action.rb +24 -0
- data/lib/fog/ovirt/requests/compute/v3/vm_start_with_cloudinit.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v3/vm_ticket.rb +19 -0
- data/lib/fog/ovirt/version.rb +1 -1
- data/tests/helper.rb +1 -1
- data/tests/helpers/mock_helper.rb +4 -6
- data/tests/helpers/succeeds_helper.rb +1 -1
- data/tests/ovirt/compute_tests.rb +5 -6
- data/tests/ovirt/models/compute/cluster_tests.rb +10 -13
- data/tests/ovirt/models/compute/clusters_tests.rb +3 -5
- data/tests/ovirt/models/compute/interface_tests.rb +9 -11
- data/tests/ovirt/models/compute/interfaces_tests.rb +3 -5
- data/tests/ovirt/models/compute/operating_system_tests.rb +7 -13
- data/tests/ovirt/models/compute/operating_systems_tests.rb +4 -6
- data/tests/ovirt/models/compute/server_tests.rb +29 -32
- data/tests/ovirt/models/compute/servers_tests.rb +7 -9
- data/tests/ovirt/models/compute/template_tests.rb +10 -12
- data/tests/ovirt/models/compute/templates_tests.rb +3 -5
- data/tests/ovirt/requests/compute/client_tests.rb +31 -0
- data/tests/ovirt/requests/compute/create_vm_tests.rb +7 -16
- data/tests/ovirt/requests/compute/destroy_vm_tests.rb +8 -10
- data/tests/ovirt/requests/compute/list_datacenters_tests.rb +3 -5
- data/tests/ovirt/requests/compute/list_quotas_tests.rb +2 -4
- data/tests/ovirt/requests/compute/list_storage_domains_tests.rb +3 -5
- data/tests/ovirt/requests/compute/update_vm_tests.rb +9 -11
- data/tests/ovirt/requests/compute/update_volume_tests.rb +9 -12
- metadata +70 -65
- data/lib/fog/ovirt/requests/compute/activate_volume.rb +0 -22
- data/lib/fog/ovirt/requests/compute/add_interface.rb +0 -20
- data/lib/fog/ovirt/requests/compute/add_to_affinity_group.rb +0 -21
- data/lib/fog/ovirt/requests/compute/add_volume.rb +0 -21
- data/lib/fog/ovirt/requests/compute/attach_volume.rb +0 -22
- data/lib/fog/ovirt/requests/compute/create_affinity_group.rb +0 -18
- data/lib/fog/ovirt/requests/compute/create_vm.rb +0 -18
- data/lib/fog/ovirt/requests/compute/datacenters.rb +0 -20
- data/lib/fog/ovirt/requests/compute/deactivate_volume.rb +0 -22
- data/lib/fog/ovirt/requests/compute/destroy_affinity_group.rb +0 -19
- data/lib/fog/ovirt/requests/compute/destroy_interface.rb +0 -22
- data/lib/fog/ovirt/requests/compute/destroy_vm.rb +0 -19
- data/lib/fog/ovirt/requests/compute/destroy_volume.rb +0 -22
- data/lib/fog/ovirt/requests/compute/detach_volume.rb +0 -22
- data/lib/fog/ovirt/requests/compute/get_affinity_group.rb +0 -18
- data/lib/fog/ovirt/requests/compute/get_api_version.rb +0 -16
- data/lib/fog/ovirt/requests/compute/get_cluster.rb +0 -17
- data/lib/fog/ovirt/requests/compute/get_instance_type.rb +0 -17
- data/lib/fog/ovirt/requests/compute/get_quota.rb +0 -17
- data/lib/fog/ovirt/requests/compute/get_template.rb +0 -17
- data/lib/fog/ovirt/requests/compute/get_virtual_machine.rb +0 -17
- data/lib/fog/ovirt/requests/compute/list_affinity_group_vms.rb +0 -22
- data/lib/fog/ovirt/requests/compute/list_affinity_groups.rb +0 -20
- data/lib/fog/ovirt/requests/compute/list_clusters.rb +0 -19
- data/lib/fog/ovirt/requests/compute/list_instance_types.rb +0 -19
- data/lib/fog/ovirt/requests/compute/list_networks.rb +0 -16
- data/lib/fog/ovirt/requests/compute/list_operating_systems.rb +0 -19
- data/lib/fog/ovirt/requests/compute/list_quotas.rb +0 -19
- data/lib/fog/ovirt/requests/compute/list_template_interfaces.rb +0 -19
- data/lib/fog/ovirt/requests/compute/list_template_volumes.rb +0 -19
- data/lib/fog/ovirt/requests/compute/list_templates.rb +0 -19
- data/lib/fog/ovirt/requests/compute/list_virtual_machines.rb +0 -19
- data/lib/fog/ovirt/requests/compute/list_vm_interfaces.rb +0 -19
- data/lib/fog/ovirt/requests/compute/list_vm_volumes.rb +0 -19
- data/lib/fog/ovirt/requests/compute/list_volumes.rb +0 -19
- data/lib/fog/ovirt/requests/compute/remove_from_affinity_group.rb +0 -21
- data/lib/fog/ovirt/requests/compute/storage_domains.rb +0 -20
- data/lib/fog/ovirt/requests/compute/update_interface.rb +0 -35
- data/lib/fog/ovirt/requests/compute/update_vm.rb +0 -18
- data/lib/fog/ovirt/requests/compute/update_volume.rb +0 -39
- data/lib/fog/ovirt/requests/compute/vm_action.rb +0 -22
- data/lib/fog/ovirt/requests/compute/vm_start_with_cloudinit.rb +0 -19
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6146d4fb921308e0f84cd983e1c0388cb81a8be5
|
4
|
+
data.tar.gz: 3b59c220c23dadfb77f63aaee4a6106ef169d064
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
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[
|
11
|
-
|
12
|
-
|
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
|
-
|
2
|
+
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require "fog/ovirt/version"
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = "fog-ovirt"
|
8
9
|
spec.version = Fog::Ovirt::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
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 =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
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 = [
|
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
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
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 =>
|
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
|
1
|
+
require "fog/ovirt/compute"
|
data/lib/fog/ovirt/compute.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "fog/ovirt/core"
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module Compute
|
5
5
|
class Ovirt < Fog::Service
|
6
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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
|
-
|
40
|
+
rescue ::OVIRT::OvirtException => e
|
41
|
+
raise ::Fog::Ovirt::Errors::OvirtEngineError, e
|
101
42
|
end
|
102
|
-
end
|
103
43
|
|
104
|
-
|
105
|
-
|
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
|
-
|
50
|
+
require "fog/ovirt/compute/v3"
|
112
51
|
|
113
|
-
|
114
|
-
|
115
|
-
|
52
|
+
def self.new(options = {})
|
53
|
+
super()
|
54
|
+
@client = Fog::Compute::Ovirt::V3.new(options)
|
55
|
+
end
|
116
56
|
|
117
|
-
|
118
|
-
|
119
|
-
|
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
|
-
|
125
|
-
|
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
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
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
|
-
|
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
|
-
|
147
|
-
|
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
|
-
|
90
|
+
# rubocop:disable Style/MethodMissing
|
91
|
+
def method_missing(symbol, *args)
|
92
|
+
@client.send(symbol, *args)
|
93
|
+
end
|
151
94
|
|
152
|
-
def
|
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
|