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
@@ -1,23 +0,0 @@
1
- module Fog
2
- module Ovirt
3
- class Compute
4
- class V3
5
- class Real
6
- def remove_from_affinity_group(id, options = {})
7
- raise ArgumentError, "instance id is a required parameter" unless id
8
- raise ArgumentError, "affinity group id is a required parameter for remove-from-affinity-group" unless options.key? :id
9
- client.delete_vm_from_affinity_group(options[:id], id)
10
- end
11
- end
12
-
13
- class Mock
14
- def remove_from_affinity_group(id, options = {})
15
- raise ArgumentError, "instance id is a required parameter" unless id
16
- raise ArgumentError, "affinity group id is a required parameter for remove-from-affinity-group" unless options.key? :id
17
- true
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,22 +0,0 @@
1
- module Fog
2
- module Ovirt
3
- class Compute
4
- class V3
5
- class Real
6
- def storage_domains(filter = {})
7
- client.storagedomains(filter)
8
- end
9
- end
10
-
11
- class Mock
12
- def storage_domains(_filters = {})
13
- xml = read_xml "storage_domains.xml"
14
- Nokogiri::XML(xml).xpath("/storage_domains/storage_domain").map do |sd|
15
- OVIRT::StorageDomain.new(self, sd)
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,36 +0,0 @@
1
- module Fog
2
- module Ovirt
3
- class Compute
4
- class V3
5
- module Shared
6
- def check_arguments(id, options)
7
- raise ArgumentError, "instance id is a required parameter" unless id
8
- raise ArgumentError, "interface id is a required parameter for update-interface" unless options.key? :id
9
- end
10
- end
11
-
12
- class Real
13
- extend ::Fog::Ovirt::Compute::V3::Shared
14
-
15
- def update_interface(id, options)
16
- check_arguments(id, options)
17
-
18
- interface_id = options[:id]
19
- options.delete(:id)
20
-
21
- client.update_interface(id, interface_id, options)
22
- end
23
- end
24
-
25
- class Mock
26
- extend ::Fog::Ovirt::Compute::V3::Shared
27
-
28
- def update_interface(id, options)
29
- check_arguments(id, options)
30
- true
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,20 +0,0 @@
1
- module Fog
2
- module Ovirt
3
- class Compute
4
- class V3
5
- class Real
6
- def update_vm(attrs)
7
- client.update_vm(attrs)
8
- end
9
- end
10
-
11
- class Mock
12
- def update_vm(_attrs)
13
- xml = read_xml("vm.xml")
14
- OVIRT::VM.new(self, Nokogiri::XML(xml).root)
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,37 +0,0 @@
1
- module Fog
2
- module Ovirt
3
- class Compute
4
- class V3
5
- module Shared
6
- def check_arguments(id, options)
7
- raise ArgumentError, "instance id is a required parameter" unless id
8
- raise ArgumentError, "disk id is a required parameter for update-volume" unless options.key? :id
9
- end
10
- end
11
-
12
- class Real
13
- extend ::Fog::Ovirt::Compute::V3::Shared
14
-
15
- def update_volume(id, options)
16
- check_arguments(id, options)
17
-
18
- disk_id = options[:id]
19
- options.delete(:id)
20
-
21
- client.update_volume(id, disk_id, options)
22
- true # If we come here, expect success and return true
23
- end
24
- end
25
-
26
- class Mock
27
- extend ::Fog::Ovirt::Compute::V3::Shared
28
-
29
- def update_volume(id, options)
30
- check_arguments(id, options)
31
- true
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,24 +0,0 @@
1
- module Fog
2
- module Ovirt
3
- class Compute
4
- class V3
5
- class Real
6
- def vm_action(options = {})
7
- raise ArgumentError, "instance id is a required parameter" unless options.key? :id
8
- raise ArgumentError, "action is a required parameter" unless options.key? :action
9
-
10
- client.vm_action options[:id], options[:action]
11
- end
12
- end
13
-
14
- class Mock
15
- def vm_action(options = {})
16
- raise ArgumentError, "id is a required parameter" unless options.key? :id
17
- raise ArgumentError, "action is a required parameter" unless options.key? :action
18
- true
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,21 +0,0 @@
1
- module Fog
2
- module Ovirt
3
- class Compute
4
- class V3
5
- class Real
6
- def vm_start_with_cloudinit(options = {})
7
- raise ArgumentError, "instance id is a required parameter" unless options.key? :id
8
- client.vm_start_with_cloudinit(options[:id], options[:user_data])
9
- end
10
- end
11
-
12
- class Mock
13
- def vm_start_with_cloudinit(options = {})
14
- raise ArgumentError, "instance id is a required parameter" unless options.key? :id
15
- true
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,19 +0,0 @@
1
- module Fog
2
- module Ovirt
3
- class Compute
4
- class V3
5
- class Real
6
- def vm_ticket(id, options = {})
7
- client.set_ticket(id, options)
8
- end
9
- end
10
-
11
- class Mock
12
- def vm_ticket(_id, _options = {})
13
- "Secret"
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,31 +0,0 @@
1
- Shindo.tests("Fog::Ovirt::Compute.new | client", ["ovirt"]) do
2
- before do
3
- @client_mock = Object.new
4
- def @client_mock.foo
5
- raise OVIRT::OvirtException, "Test"
6
- end
7
-
8
- @object_under_test = Fog::Ovirt::Compute::ExceptionWrapper.new(@client_mock)
9
- end
10
-
11
- tests("Raises the right type of exception")
12
- .raises(Fog::Ovirt::Errors::OvirtEngineError) do
13
- @object_under_test.foo
14
- end
15
-
16
- tests("The exception test is as expected").returns(true) do
17
- begin
18
- @object_under_test.foo
19
- rescue Fog::Ovirt::Errors::OvirtEngineError => e
20
- e.message == "Ovirt client returned an error: Test"
21
- end
22
- end
23
-
24
- tests("The original exception test is as expected").returns(true) do
25
- begin
26
- @object_under_test.foo
27
- rescue Fog::Ovirt::Errors::OvirtEngineError => e
28
- e.orig_exception.message == "Test"
29
- end
30
- end
31
- end
@@ -1,17 +0,0 @@
1
- Shindo.tests("Fog::Ovirt::Compute.new | vm_create request", "ovirt") do
2
- compute = Fog::Ovirt::Compute.new
3
- name_base = Time.now.to_i
4
-
5
- tests("Create VM") do
6
- response = compute.create_vm(:name => "fog-" + name_base.to_s, :cluster_name => "Default")
7
- test("should be a kind of OVIRT::VM") { response.is_a? OVIRT::VM }
8
- end
9
-
10
- tests("Create VM from template (clone)") do
11
- response = compute.create_vm(:name => "fog-" + (name_base + 1).to_s, :template_name => "hwp_small", :cluster_name => "Default")
12
- test("should be a kind of OVIRT::VM") { response.is_a? OVIRT::VM }
13
- end
14
-
15
- # TODO: Write a test for situation where creating a VM fails
16
- # mocks never raise exceptions
17
- end
@@ -1,14 +0,0 @@
1
- Shindo.tests("Fog::Ovirt::Compute | vm_destroy request", ["ovirt"]) do
2
- compute = Fog::Ovirt::Compute.new
3
- compute.create_vm(:name => "fog-" + Time.now.to_i.to_s, :cluster_name => "Default") if compute.servers.all(:search => "fog-*").empty?
4
- vm_id = compute.servers.all(:search => "fog-*").last.id
5
-
6
- tests("The response should") do
7
- response = compute.destroy_vm(:id => vm_id)
8
- test("be a success") { response ? true : false }
9
- end
10
-
11
- tests("The expected options") do
12
- raises(ArgumentError, "raises ArgumentError when id option is missing") { compute.destroy_vm }
13
- end
14
- end
@@ -1,11 +0,0 @@
1
- Shindo.tests("Fog::Ovirt::Compute | datacenters request", ["ovirt"]) do
2
- compute = Fog::Ovirt::Compute.new
3
-
4
- tests("When listing all datacenters") do
5
- response = compute.datacenters
6
- tests("The response data format ...") do
7
- test("it should be a kind of Array") { response.is_a? Array }
8
- test("be a kind of Hash") { response.first.is_a? Hash }
9
- end
10
- end
11
- end
@@ -1,10 +0,0 @@
1
- Shindo.tests("Fog::Ovirt::Compute | quotas request", ["ovirt"]) do
2
- compute = Fog::Ovirt::Compute.new
3
-
4
- tests("When listing all quotas") do
5
- response = compute.quotas
6
- tests("The response data format ...") do
7
- test("it should be a kind of Array") { response.is_a? Array }
8
- end
9
- end
10
- end
@@ -1,11 +0,0 @@
1
- Shindo.tests("Fog::Ovirt::Compute | storage_domains request", ["ovirt"]) do
2
- compute = Fog::Ovirt::Compute.new
3
-
4
- tests("When listing all storage_domains") do
5
- response = compute.storage_domains
6
- tests("The response data format ...") do
7
- test("it should be a kind of Array") { response.is_a? Array }
8
- test("be a kind of OVIRT::StorageDomain") { response.first.is_a? OVIRT::StorageDomain }
9
- end
10
- end
11
- end
@@ -1,14 +0,0 @@
1
- Shindo.tests("Fog::Ovirt::Compute | vm_update request", ["ovirt"]) do
2
- compute = Fog::Ovirt::Compute.new
3
- compute.create_vm(:name => "fog-" + Time.now.to_i.to_s, :cluster_name => "Default") if compute.servers.all(:search => "fog-*").empty?
4
- vm = compute.servers.all(:search => "fog-*").last
5
-
6
- tests("The response should") do
7
- response = compute.update_vm(:id => vm.id, :name => vm.name + "updated")
8
- test("be a kind of OVIRT::VM") { response.is_a? OVIRT::VM }
9
- end
10
-
11
- tests("The expected options") do
12
- raises(ArgumentError, "raises ArgumentError when id option is missing") { compute.update_vm }
13
- end
14
- end
@@ -1,15 +0,0 @@
1
- Shindo.tests("Fog::Ovirt::Compute | update_volume request", ["ovirt"]) do
2
- compute = Fog::Ovirt::Compute.new
3
- compute.create_vm(:name => "fog-" + Time.now.to_i.to_s, :cluster_name => "Default") if compute.servers.all(:search => "fog-*").empty?
4
- vm_id = compute.servers.all(:search => "fog-*").last
5
-
6
- tests("The expected options") do
7
- raises(ArgumentError, "raises ArgumentError when vm id is missing") { compute.update_volume(nil, :id => 1) }
8
- raises(ArgumentError, "raises ArgumentError when disk_id option is missing") { compute.update_volume(1, :any => 1) }
9
- end
10
-
11
- tests("The response should") do
12
- response = compute.update_volume(vm_id, :id => 1)
13
- test("be a success") { response ? true : false }
14
- end
15
- end