fog-ovirt 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +30 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +21 -0
- data/Gemfile +3 -0
- data/LICENSE.md +20 -0
- data/README.md +47 -0
- data/Rakefile +15 -0
- data/fog-ovirt.gemspec +32 -0
- data/lib/fog/bin/ovirt.rb +28 -0
- data/lib/fog/ovirt/compute.rb +155 -0
- data/lib/fog/ovirt/core.rb +16 -0
- data/lib/fog/ovirt/models/compute/affinity_group.rb +25 -0
- data/lib/fog/ovirt/models/compute/affinity_groups.rb +20 -0
- data/lib/fog/ovirt/models/compute/cluster.rb +20 -0
- data/lib/fog/ovirt/models/compute/clusters.rb +20 -0
- data/lib/fog/ovirt/models/compute/instance_type.rb +39 -0
- data/lib/fog/ovirt/models/compute/instance_types.rb +20 -0
- data/lib/fog/ovirt/models/compute/interface.rb +19 -0
- data/lib/fog/ovirt/models/compute/interfaces.rb +29 -0
- data/lib/fog/ovirt/models/compute/quota.rb +16 -0
- data/lib/fog/ovirt/models/compute/quotas.rb +20 -0
- data/lib/fog/ovirt/models/compute/server.rb +175 -0
- data/lib/fog/ovirt/models/compute/servers.rb +27 -0
- data/lib/fog/ovirt/models/compute/template.rb +58 -0
- data/lib/fog/ovirt/models/compute/templates.rb +20 -0
- data/lib/fog/ovirt/models/compute/volume.rb +36 -0
- data/lib/fog/ovirt/models/compute/volumes.rb +28 -0
- data/lib/fog/ovirt/requests/compute/activate_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/add_interface.rb +20 -0
- data/lib/fog/ovirt/requests/compute/add_to_affinity_group.rb +21 -0
- data/lib/fog/ovirt/requests/compute/add_volume.rb +21 -0
- data/lib/fog/ovirt/requests/compute/attach_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/create_affinity_group.rb +18 -0
- data/lib/fog/ovirt/requests/compute/create_vm.rb +18 -0
- data/lib/fog/ovirt/requests/compute/datacenters.rb +20 -0
- data/lib/fog/ovirt/requests/compute/deactivate_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/destroy_affinity_group.rb +19 -0
- data/lib/fog/ovirt/requests/compute/destroy_interface.rb +22 -0
- data/lib/fog/ovirt/requests/compute/destroy_vm.rb +19 -0
- data/lib/fog/ovirt/requests/compute/destroy_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/detach_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/get_affinity_group.rb +18 -0
- data/lib/fog/ovirt/requests/compute/get_api_version.rb +16 -0
- data/lib/fog/ovirt/requests/compute/get_cluster.rb +17 -0
- data/lib/fog/ovirt/requests/compute/get_instance_type.rb +17 -0
- data/lib/fog/ovirt/requests/compute/get_quota.rb +17 -0
- data/lib/fog/ovirt/requests/compute/get_template.rb +17 -0
- data/lib/fog/ovirt/requests/compute/get_virtual_machine.rb +17 -0
- data/lib/fog/ovirt/requests/compute/list_affinity_group_vms.rb +22 -0
- data/lib/fog/ovirt/requests/compute/list_affinity_groups.rb +20 -0
- data/lib/fog/ovirt/requests/compute/list_clusters.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_instance_types.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_networks.rb +16 -0
- data/lib/fog/ovirt/requests/compute/list_quotas.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_template_interfaces.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_template_volumes.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_templates.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_virtual_machines.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_vm_interfaces.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_vm_volumes.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_volumes.rb +19 -0
- data/lib/fog/ovirt/requests/compute/mock_files/affinitygroup.xml +8 -0
- data/lib/fog/ovirt/requests/compute/mock_files/affinitygroup_vms.xml +9 -0
- data/lib/fog/ovirt/requests/compute/mock_files/affinitygroups.xml +17 -0
- data/lib/fog/ovirt/requests/compute/mock_files/cluster.xml +20 -0
- data/lib/fog/ovirt/requests/compute/mock_files/clusters.xml +39 -0
- data/lib/fog/ovirt/requests/compute/mock_files/data_centers.xml +17 -0
- data/lib/fog/ovirt/requests/compute/mock_files/disks.xml +58 -0
- data/lib/fog/ovirt/requests/compute/mock_files/instance_type.xml +42 -0
- data/lib/fog/ovirt/requests/compute/mock_files/instance_types.xml +197 -0
- data/lib/fog/ovirt/requests/compute/mock_files/nics.xml +10 -0
- data/lib/fog/ovirt/requests/compute/mock_files/quotas.xml +7 -0
- data/lib/fog/ovirt/requests/compute/mock_files/storage_domains.xml +36 -0
- data/lib/fog/ovirt/requests/compute/mock_files/template.xml +39 -0
- data/lib/fog/ovirt/requests/compute/mock_files/templates.xml +110 -0
- data/lib/fog/ovirt/requests/compute/mock_files/vm.xml +52 -0
- data/lib/fog/ovirt/requests/compute/mock_files/vms.xml +152 -0
- data/lib/fog/ovirt/requests/compute/mock_files/volumes.xml +40 -0
- data/lib/fog/ovirt/requests/compute/remove_from_affinity_group.rb +21 -0
- data/lib/fog/ovirt/requests/compute/storage_domains.rb +20 -0
- data/lib/fog/ovirt/requests/compute/update_interface.rb +35 -0
- data/lib/fog/ovirt/requests/compute/update_vm.rb +18 -0
- data/lib/fog/ovirt/requests/compute/update_volume.rb +39 -0
- data/lib/fog/ovirt/requests/compute/vm_action.rb +22 -0
- data/lib/fog/ovirt/requests/compute/vm_start_with_cloudinit.rb +19 -0
- data/lib/fog/ovirt/requests/compute/vm_ticket.rb +17 -0
- data/lib/fog/ovirt/version.rb +5 -0
- data/lib/fog/ovirt.rb +1 -0
- data/spec/fog/bin/ovirt_spec.rb +10 -0
- data/spec/fog/bin_spec.rb +32 -0
- data/tests/helper.rb +1 -0
- data/tests/helpers/mock_helper.rb +16 -0
- data/tests/helpers/succeeds_helper.rb +9 -0
- data/tests/ovirt/compute_tests.rb +25 -0
- data/tests/ovirt/models/compute/cluster_tests.rb +31 -0
- data/tests/ovirt/models/compute/clusters_tests.rb +9 -0
- data/tests/ovirt/models/compute/interface_tests.rb +27 -0
- data/tests/ovirt/models/compute/interfaces_tests.rb +9 -0
- data/tests/ovirt/models/compute/server_tests.rb +51 -0
- data/tests/ovirt/models/compute/servers_tests.rb +14 -0
- data/tests/ovirt/models/compute/template_tests.rb +28 -0
- data/tests/ovirt/models/compute/templates_tests.rb +9 -0
- data/tests/ovirt/requests/compute/create_vm_tests.rb +26 -0
- data/tests/ovirt/requests/compute/destroy_vm_tests.rb +18 -0
- data/tests/ovirt/requests/compute/list_datacenters_tests.rb +13 -0
- data/tests/ovirt/requests/compute/list_quotas_tests.rb +12 -0
- data/tests/ovirt/requests/compute/list_storage_domains_tests.rb +13 -0
- data/tests/ovirt/requests/compute/update_vm_tests.rb +18 -0
- data/tests/ovirt/requests/compute/update_volume_tests.rb +20 -0
- metadata +298 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class Real
|
5
|
+
def remove_from_affinity_group(id, options = {})
|
6
|
+
raise ArgumentError, "instance id is a required parameter" unless id
|
7
|
+
raise ArgumentError, "affinity group id is a required parameter for remove-from-affinity-group" unless options.key? :id
|
8
|
+
client.delete_vm_from_affinity_group(options[:id], id)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Mock
|
13
|
+
def remove_from_affinity_group(id, options = {})
|
14
|
+
raise ArgumentError, "instance id is a required parameter" unless id
|
15
|
+
raise ArgumentError, "affinity group id is a required parameter for remove-from-affinity-group" unless options.key? :id
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class Real
|
5
|
+
def storage_domains filter={}
|
6
|
+
client.storagedomains(filter)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def storage_domains(filters = {})
|
12
|
+
xml = read_xml 'storage_domains.xml'
|
13
|
+
Nokogiri::XML(xml).xpath('/storage_domains/storage_domain').map do |sd|
|
14
|
+
OVIRT::StorageDomain::new(self, sd)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
|
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::Compute::Ovirt::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::Compute::Ovirt::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
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class Real
|
5
|
+
def update_vm(attrs)
|
6
|
+
client.update_vm(attrs)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def update_vm(attrs)
|
12
|
+
xml = read_xml('vm.xml')
|
13
|
+
OVIRT::VM::new(self, Nokogiri::XML(xml).root)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
|
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.has_key? :id
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
class Real
|
14
|
+
extend ::Fog::Compute::Ovirt::Shared
|
15
|
+
|
16
|
+
def update_volume(id, options)
|
17
|
+
check_arguments(id, options)
|
18
|
+
|
19
|
+
disk_id = options[:id]
|
20
|
+
options.delete(:id)
|
21
|
+
|
22
|
+
client.update_volume(id, disk_id, options)
|
23
|
+
true # If we come here, expect success and return true
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
class Mock
|
29
|
+
extend ::Fog::Compute::Ovirt::Shared
|
30
|
+
|
31
|
+
def update_volume(id, options)
|
32
|
+
check_arguments(id, options)
|
33
|
+
true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class Real
|
5
|
+
def vm_action(options = {})
|
6
|
+
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
|
7
|
+
raise ArgumentError, "action is a required parameter" unless options.key? :action
|
8
|
+
|
9
|
+
client.vm_action options[:id], options[:action]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Mock
|
14
|
+
def vm_action(options = {})
|
15
|
+
raise ArgumentError, "id is a required parameter" unless options.key? :id
|
16
|
+
raise ArgumentError, "action is a required parameter" unless options.key? :action
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class Real
|
5
|
+
def vm_start_with_cloudinit(options = {})
|
6
|
+
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
|
7
|
+
client.vm_start_with_cloudinit(options[:id], options[:user_data])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Mock
|
12
|
+
def vm_start_with_cloudinit(options = {})
|
13
|
+
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/fog/ovirt.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'fog/ovirt/compute'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fog/bin"
|
3
|
+
|
4
|
+
describe Fog do
|
5
|
+
describe "#providers" do
|
6
|
+
it "includes existing providers" do
|
7
|
+
assert_equal "Ovirt", Fog.providers[:ovirt]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#registered_providers" do
|
12
|
+
it "includes existing providers" do
|
13
|
+
assert_includes Fog.registered_providers, "Ovirt"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#available_providers" do
|
18
|
+
it "includes existing providers" do
|
19
|
+
assert_includes Fog.available_providers, "Ovirt" if Ovirt.available?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#services" do
|
24
|
+
it "returns Hash of services" do
|
25
|
+
assert_kind_of Hash, Fog.services
|
26
|
+
assert_includes Fog.services, :cdn
|
27
|
+
assert_includes Fog.services, :compute
|
28
|
+
assert_includes Fog.services, :dns
|
29
|
+
assert_includes Fog.services, :storage
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/tests/helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path('../../lib/fog/ovirt', __FILE__)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Use so you can run in mock mode from the command line
|
2
|
+
#
|
3
|
+
# FOG_MOCK=true fog
|
4
|
+
|
5
|
+
if ENV["FOG_MOCK"] == "true"
|
6
|
+
Fog.mock!
|
7
|
+
end
|
8
|
+
|
9
|
+
# if in mocked mode, fill in some fake credentials for us
|
10
|
+
if Fog.mock?
|
11
|
+
Fog.credentials = {
|
12
|
+
:ovirt_url => 'http://ovirt:8080/api',
|
13
|
+
:ovirt_username => 'admin@internal',
|
14
|
+
:ovirt_password => '123123'
|
15
|
+
}.merge(Fog.credentials)
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt]', ['ovirt']) do
|
2
|
+
|
3
|
+
compute = Fog::Compute[:ovirt]
|
4
|
+
|
5
|
+
tests("Compute attributes") do
|
6
|
+
%w{ ovirt_attrs }.each do |attr|
|
7
|
+
test("it should respond to #{attr}") { compute.respond_to? attr }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
tests("Compute collections") do
|
12
|
+
%w{ servers templates clusters interfaces }.each do |collection|
|
13
|
+
test("it should respond to #{collection}") { compute.respond_to? collection }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
tests("Compute requests") do
|
18
|
+
%w{ add_interface create_vm datacenters destroy_interface destroy_vm get_cluster get_template
|
19
|
+
get_virtual_machine list_clusters list_networks list_template_interfaces list_templates
|
20
|
+
list_virtual_machines list_vm_interfaces storage_domains update_interface update_vm vm_action
|
21
|
+
api_version update_volume}.each do |collection|
|
22
|
+
test("it should respond to #{collection}") { compute.respond_to? collection }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | cluster model', ['ovirt']) do
|
2
|
+
|
3
|
+
clusters = Fog::Compute[:ovirt].clusters
|
4
|
+
cluster = clusters.last
|
5
|
+
|
6
|
+
tests('The cluster model should') do
|
7
|
+
tests('have the action') do
|
8
|
+
test('reload') { cluster.respond_to? 'reload' }
|
9
|
+
%w{ networks }.each do |action|
|
10
|
+
test(action) { cluster.respond_to? action }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
tests('have attributes') do
|
14
|
+
model_attribute_hash = cluster.attributes
|
15
|
+
attributes = [ :id,
|
16
|
+
:name]
|
17
|
+
tests("The cluster model should respond to") do
|
18
|
+
attributes.each do |attribute|
|
19
|
+
test("#{attribute}") { cluster.respond_to? attribute }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
tests("The attributes hash should have key") do
|
23
|
+
attributes.each do |attribute|
|
24
|
+
test("#{attribute}") { model_attribute_hash.key? attribute }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
test('be a kind of Fog::Compute::Ovirt::Cluster') { cluster.kind_of? Fog::Compute::Ovirt::Cluster }
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | clusters collection', ['ovirt']) do
|
2
|
+
|
3
|
+
clusters = Fog::Compute[:ovirt].clusters
|
4
|
+
|
5
|
+
tests('The clusters collection') do
|
6
|
+
test('should be a kind of Fog::Compute::Ovirt::Clusters') { clusters.kind_of? Fog::Compute::Ovirt::Clusters }
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | interface model', ['ovirt']) do
|
2
|
+
|
3
|
+
interfaces = Fog::Compute[:ovirt].servers.last.interfaces
|
4
|
+
interface = interfaces.last
|
5
|
+
|
6
|
+
tests('The interface model should') do
|
7
|
+
tests('have the action') do
|
8
|
+
test('reload') { interface.respond_to? 'reload' }
|
9
|
+
end
|
10
|
+
tests('have attributes') do
|
11
|
+
model_attribute_hash = interface.attributes
|
12
|
+
attributes = [ :id, :name, :network]
|
13
|
+
tests("The interface model should respond to") do
|
14
|
+
attributes.each do |attribute|
|
15
|
+
test("#{attribute}") { interface.respond_to? attribute }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
tests("The attributes hash should have key") do
|
19
|
+
attributes.each do |attribute|
|
20
|
+
test("#{attribute}") { model_attribute_hash.key? attribute }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
test('be a kind of Fog::Compute::Ovirt::Interface') { interface.kind_of? Fog::Compute::Ovirt::Interface }
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | interfaces collection', ['ovirt']) do
|
2
|
+
|
3
|
+
interfaces = Fog::Compute[:ovirt].interfaces
|
4
|
+
|
5
|
+
tests('The interfaces collection') do
|
6
|
+
test('should be a kind of Fog::Compute::Ovirt::Interfaces') { interfaces.kind_of? Fog::Compute::Ovirt::Interfaces }
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | server model', ['ovirt']) do
|
2
|
+
|
3
|
+
servers = Fog::Compute[:ovirt].servers
|
4
|
+
server = servers.last
|
5
|
+
|
6
|
+
tests('The server model should') do
|
7
|
+
tests('have the action') do
|
8
|
+
test('reload') { server.respond_to? 'reload' }
|
9
|
+
%w{ start stop destroy reboot suspend }.each do |action|
|
10
|
+
test(action) { server.respond_to? action }
|
11
|
+
end
|
12
|
+
%w{ start reboot suspend stop }.each do |action|
|
13
|
+
test("#{action} returns successfully") {
|
14
|
+
begin
|
15
|
+
server.send(action.to_sym) ? true : false
|
16
|
+
rescue OVIRT::OvirtException
|
17
|
+
#ovirt exceptions are acceptable for the above actions.
|
18
|
+
true
|
19
|
+
end
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
tests('have attributes') do
|
24
|
+
model_attribute_hash = server.attributes
|
25
|
+
attributes = [ :id,
|
26
|
+
:name,
|
27
|
+
:description,
|
28
|
+
:profile,
|
29
|
+
:display,
|
30
|
+
:creation_time,
|
31
|
+
:os,
|
32
|
+
:status,
|
33
|
+
:cores,
|
34
|
+
:memory,
|
35
|
+
:cluster,
|
36
|
+
:template]
|
37
|
+
tests("The server model should respond to") do
|
38
|
+
attributes.each do |attribute|
|
39
|
+
test("#{attribute}") { server.respond_to? attribute }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
tests("The attributes hash should have key") do
|
43
|
+
attributes.each do |attribute|
|
44
|
+
test("#{attribute}") { model_attribute_hash.key? attribute }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
test('be a kind of Fog::Compute::Ovirt::Server') { server.kind_of? Fog::Compute::Ovirt::Server }
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | servers collection', ['ovirt']) do
|
2
|
+
|
3
|
+
servers = Fog::Compute[:ovirt].servers
|
4
|
+
|
5
|
+
tests('The servers collection') do
|
6
|
+
test('should not be empty') { not servers.empty? }
|
7
|
+
test('should be a kind of Fog::Compute::Ovirt::Servers') { servers.kind_of? Fog::Compute::Ovirt::Servers }
|
8
|
+
tests('should be able to reload itself').succeeds { servers.reload }
|
9
|
+
tests('should be able to get a model') do
|
10
|
+
tests('by instance uuid').succeeds { servers.get servers.first.id }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | template model', ['ovirt']) do
|
2
|
+
|
3
|
+
templates = Fog::Compute[:ovirt].templates
|
4
|
+
template = templates.last
|
5
|
+
|
6
|
+
tests('The template model should') do
|
7
|
+
tests('have the action') do
|
8
|
+
test('reload') { template.respond_to? 'reload' }
|
9
|
+
end
|
10
|
+
tests('have attributes') do
|
11
|
+
model_attribute_hash = template.attributes
|
12
|
+
attributes = [ :id,
|
13
|
+
:name]
|
14
|
+
tests("The template model should respond to") do
|
15
|
+
attributes.each do |attribute|
|
16
|
+
test("#{attribute}") { template.respond_to? attribute }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
tests("The attributes hash should have key") do
|
20
|
+
attributes.each do |attribute|
|
21
|
+
test("#{attribute}") { model_attribute_hash.key? attribute }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
test('be a kind of Fog::Compute::Ovirt::Template') { template.kind_of? Fog::Compute::Ovirt::Template }
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | templates collection', ['ovirt']) do
|
2
|
+
|
3
|
+
templates = Fog::Compute[:ovirt].templates
|
4
|
+
|
5
|
+
tests('The templates collection') do
|
6
|
+
test('should be a kind of Fog::Compute::Ovirt::Templates') { templates.kind_of? Fog::Compute::Ovirt::Templates }
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:ovirt] | vm_create request", 'ovirt') do
|
2
|
+
|
3
|
+
compute = Fog::Compute[:ovirt]
|
4
|
+
name_base = Time.now.to_i
|
5
|
+
|
6
|
+
tests("Create VM") do
|
7
|
+
response = compute.create_vm(:name => 'fog-'+name_base.to_s, :cluster_name => 'Default')
|
8
|
+
test("should be a kind of OVIRT::VM") { response.kind_of? OVIRT::VM}
|
9
|
+
end
|
10
|
+
|
11
|
+
tests("Create VM from template (clone)") do
|
12
|
+
response = compute.create_vm(:name => 'fog-'+(name_base+ 1).to_s, :template_name => 'hwp_small', :cluster_name => 'Default')
|
13
|
+
test("should be a kind of OVIRT::VM") { response.kind_of? OVIRT::VM}
|
14
|
+
end
|
15
|
+
|
16
|
+
tests("Fail Creating VM") do
|
17
|
+
begin
|
18
|
+
response = compute.create_vm(:name => 'fog-'+name_base.to_s, :cluster_name => 'Default')
|
19
|
+
test("should be a kind of OVIRT::VM") { response.kind_of? OVIRT::VM} #mock never raise exceptions
|
20
|
+
rescue => e
|
21
|
+
#should raise vm name already exist exception.
|
22
|
+
test("error should be a kind of OVIRT::OvirtException") { e.kind_of? OVIRT::OvirtException}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | vm_destroy request', ['ovirt']) do
|
2
|
+
|
3
|
+
compute = Fog::Compute[:ovirt]
|
4
|
+
if compute.servers.all(:search => 'fog-*').empty?
|
5
|
+
compute.create_vm(:name => 'fog-'+Time.now.to_i.to_s, :cluster_name => 'Default')
|
6
|
+
end
|
7
|
+
vm_id = compute.servers.all(:search => 'fog-*').last.id
|
8
|
+
|
9
|
+
tests('The response should') do
|
10
|
+
response = compute.destroy_vm(:id => vm_id)
|
11
|
+
test('be a success') { response ? true: false }
|
12
|
+
end
|
13
|
+
|
14
|
+
tests('The expected options') do
|
15
|
+
raises(ArgumentError, 'raises ArgumentError when id option is missing') { compute.destroy_vm }
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | datacenters request', ['ovirt']) do
|
2
|
+
|
3
|
+
compute = Fog::Compute[:ovirt]
|
4
|
+
|
5
|
+
tests("When listing all datacenters") do
|
6
|
+
|
7
|
+
response = compute.datacenters
|
8
|
+
tests("The response data format ...") do
|
9
|
+
test("it should be a kind of Array") { response.kind_of? Array }
|
10
|
+
test("be a kind of Hash") { response.first.kind_of? Hash }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | quotas request', ['ovirt']) do
|
2
|
+
|
3
|
+
compute = Fog::Compute[:ovirt]
|
4
|
+
|
5
|
+
tests("When listing all quotas") do
|
6
|
+
|
7
|
+
response = compute.quotas
|
8
|
+
tests("The response data format ...") do
|
9
|
+
test("it should be a kind of Array") { response.kind_of? Array }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | storage_domains request', ['ovirt']) do
|
2
|
+
|
3
|
+
compute = Fog::Compute[:ovirt]
|
4
|
+
|
5
|
+
tests("When listing all storage_domains") do
|
6
|
+
|
7
|
+
response = compute.storage_domains
|
8
|
+
tests("The response data format ...") do
|
9
|
+
test("it should be a kind of Array") { response.kind_of? Array }
|
10
|
+
test("be a kind of OVIRT::StorageDomain") { response.first.kind_of? OVIRT::StorageDomain }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | vm_update request', ['ovirt']) do
|
2
|
+
|
3
|
+
compute = Fog::Compute[:ovirt]
|
4
|
+
if compute.servers.all(:search => 'fog-*').empty?
|
5
|
+
compute.create_vm(:name => 'fog-'+Time.now.to_i.to_s, :cluster_name => 'Default')
|
6
|
+
end
|
7
|
+
vm = compute.servers.all(:search => 'fog-*').last
|
8
|
+
|
9
|
+
tests('The response should') do
|
10
|
+
response = compute.update_vm(:id => vm.id, :name => vm.name + 'updated')
|
11
|
+
test("be a kind of OVIRT::VM") { response.kind_of? OVIRT::VM}
|
12
|
+
end
|
13
|
+
|
14
|
+
tests('The expected options') do
|
15
|
+
raises(ArgumentError, 'raises ArgumentError when id option is missing') { compute.update_vm }
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:ovirt] | update_volume request', ['ovirt']) do
|
2
|
+
|
3
|
+
compute = Fog::Compute[:ovirt]
|
4
|
+
if compute.servers.all(:search => 'fog-*').empty?
|
5
|
+
compute.create_vm(:name => 'fog-'+Time.now.to_i.to_s, :cluster_name => 'Default')
|
6
|
+
end
|
7
|
+
vm_id = compute.servers.all(:search => 'fog-*').last
|
8
|
+
|
9
|
+
tests('The expected options') do
|
10
|
+
raises(ArgumentError, 'raises ArgumentError when vm id is missing') { compute.update_volume(nil, {:id => 1}) }
|
11
|
+
raises(ArgumentError, 'raises ArgumentError when disk_id option is missing') { compute.update_volume(1, {:any => 1}) }
|
12
|
+
end
|
13
|
+
|
14
|
+
tests('The response should') do
|
15
|
+
response = compute.update_volume(vm_id, :id => 1)
|
16
|
+
test('be a success') { response ? true: false }
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|