fog-ovirt 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +1 -1
- data/fog-ovirt.gemspec +1 -0
- data/lib/fog/ovirt/compute/v3.rb +1 -1
- data/lib/fog/ovirt/compute/v4.rb +163 -0
- data/lib/fog/ovirt/compute.rb +32 -11
- data/lib/fog/ovirt/requests/compute/v4/add_interface.rb +41 -0
- data/lib/fog/ovirt/requests/compute/v4/add_volume.rb +54 -0
- data/lib/fog/ovirt/requests/compute/v4/create_vm.rb +62 -0
- data/lib/fog/ovirt/requests/compute/v4/datacenters.rb +22 -0
- data/lib/fog/ovirt/requests/compute/v4/destroy_interface.rb +24 -0
- data/lib/fog/ovirt/requests/compute/v4/destroy_vm.rb +23 -0
- data/lib/fog/ovirt/requests/compute/v4/destroy_volume.rb +25 -0
- data/lib/fog/ovirt/requests/compute/v4/get_api_version.rb +18 -0
- data/lib/fog/ovirt/requests/compute/v4/get_cluster.rb +19 -0
- data/lib/fog/ovirt/requests/compute/v4/get_instance_type.rb +19 -0
- data/lib/fog/ovirt/requests/compute/v4/get_quota.rb +20 -0
- data/lib/fog/ovirt/requests/compute/v4/get_template.rb +19 -0
- data/lib/fog/ovirt/requests/compute/v4/get_virtual_machine.rb +19 -0
- data/lib/fog/ovirt/requests/compute/v4/list_clusters.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v4/list_instance_types.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v4/list_networks.rb +18 -0
- data/lib/fog/ovirt/requests/compute/v4/list_operating_systems.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v4/list_quotas.rb +22 -0
- data/lib/fog/ovirt/requests/compute/v4/list_template_interfaces.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v4/list_template_volumes.rb +27 -0
- data/lib/fog/ovirt/requests/compute/v4/list_templates.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v4/list_virtual_machines.rb +28 -0
- data/lib/fog/ovirt/requests/compute/v4/list_vm_interfaces.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v4/list_vm_volumes.rb +30 -0
- data/lib/fog/ovirt/requests/compute/v4/list_volumes.rb +21 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/affinitygroup.xml +8 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/affinitygroup_vms.xml +9 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/affinitygroups.xml +17 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/cluster.xml +27 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/clusters.xml +53 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/data_centers.xml +21 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/disks.xml +54 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/instance_type.xml +50 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/instance_types.xml +233 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/nics.xml +12 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/operating_systems.xml +10 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/quotas.xml +7 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/storage_domains.xml +34 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/template.xml +45 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/templates.xml +128 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/vm.xml +58 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/vms.xml +170 -0
- data/lib/fog/ovirt/requests/compute/v4/mock_files/volumes.xml +36 -0
- data/lib/fog/ovirt/requests/compute/v4/storage_domains.rb +27 -0
- data/lib/fog/ovirt/requests/compute/v4/update_interface.rb +35 -0
- data/lib/fog/ovirt/requests/compute/v4/update_volume.rb +36 -0
- data/lib/fog/ovirt/requests/compute/v4/vm_action.rb +26 -0
- data/lib/fog/ovirt/requests/compute/v4/vm_ticket.rb +19 -0
- data/lib/fog/ovirt/version.rb +1 -1
- data/tests/ovirt/requests/compute/{client_tests.rb → v3/client_tests.rb} +0 -0
- data/tests/ovirt/requests/compute/{create_vm_tests.rb → v3/create_vm_tests.rb} +0 -0
- data/tests/ovirt/requests/compute/{destroy_vm_tests.rb → v3/destroy_vm_tests.rb} +0 -0
- data/tests/ovirt/requests/compute/{list_datacenters_tests.rb → v3/list_datacenters_tests.rb} +0 -0
- data/tests/ovirt/requests/compute/{list_quotas_tests.rb → v3/list_quotas_tests.rb} +0 -0
- data/tests/ovirt/requests/compute/{list_storage_domains_tests.rb → v3/list_storage_domains_tests.rb} +0 -0
- data/tests/ovirt/requests/compute/{update_vm_tests.rb → v3/update_vm_tests.rb} +0 -0
- data/tests/ovirt/requests/compute/{update_volume_tests.rb → v3/update_volume_tests.rb} +0 -0
- data/tests/ovirt/requests/compute/v4/client_tests.rb +31 -0
- data/tests/ovirt/requests/compute/v4/create_vm_tests.rb +17 -0
- data/tests/ovirt/requests/compute/v4/destroy_vm_tests.rb +16 -0
- data/tests/ovirt/requests/compute/v4/list_datacenters_tests.rb +11 -0
- data/tests/ovirt/requests/compute/v4/list_quotas_tests.rb +10 -0
- data/tests/ovirt/requests/compute/v4/list_storage_domains_tests.rb +11 -0
- data/tests/ovirt/requests/compute/v4/update_volume_tests.rb +17 -0
- metadata +96 -19
@@ -0,0 +1,170 @@
|
|
1
|
+
<vms>
|
2
|
+
<vm href="/api/vms/5ee86332-7b19-465b-8801-2a12ed0d6c1b" id="5ee86332-7b19-465b-8801-2a12ed0d6c1b">
|
3
|
+
<name>test-vm1</name>
|
4
|
+
<link href="/api/vms/5ee86332-7b19-465b-8801-2a12ed0d6c1b/disks" rel="disks"/>
|
5
|
+
<link href="/api/vms/5ee86332-7b19-465b-8801-2a12ed0d6c1b/nics" rel="nics"/>
|
6
|
+
<link href="/api/vms/5ee86332-7b19-465b-8801-2a12ed0d6c1b/cdroms" rel="cdroms"/>
|
7
|
+
<link href="/api/vms/5ee86332-7b19-465b-8801-2a12ed0d6c1b/snapshots" rel="snapshots"/>
|
8
|
+
<link href="/api/vms/5ee86332-7b19-465b-8801-2a12ed0d6c1b/tags" rel="tags"/>
|
9
|
+
<link href="/api/vms/5ee86332-7b19-465b-8801-2a12ed0d6c1b/permissions" rel="permissions"/>
|
10
|
+
<link href="/api/vms/5ee86332-7b19-465b-8801-2a12ed0d6c1b/statistics" rel="statistics"/>
|
11
|
+
<type>server</type>
|
12
|
+
<status>down</status>
|
13
|
+
<memory>1073741824</memory>
|
14
|
+
<cpu>
|
15
|
+
<topology>
|
16
|
+
<cores>4</cores>
|
17
|
+
<sockets>1</sockets>
|
18
|
+
</topology>
|
19
|
+
</cpu>
|
20
|
+
<os>
|
21
|
+
<type>unassigned</type>
|
22
|
+
<boot>
|
23
|
+
<devices>
|
24
|
+
<device>network</device>
|
25
|
+
</devices>
|
26
|
+
</boot>
|
27
|
+
<kernel/>
|
28
|
+
<initrd/>
|
29
|
+
<cmdline/>
|
30
|
+
</os>
|
31
|
+
<high_availability>
|
32
|
+
<enabled>false</enabled>
|
33
|
+
<priority>1</priority>
|
34
|
+
</high_availability>
|
35
|
+
<display>
|
36
|
+
<type>spice</type>
|
37
|
+
<monitors>1</monitors>
|
38
|
+
</display>
|
39
|
+
<cluster href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95" id="99408929-82cf-4dc7-a532-9d998063fa95"/>
|
40
|
+
<template href="/api/templates/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000"/>
|
41
|
+
<start_time>2012-02-06T10:47:32.214Z</start_time>
|
42
|
+
<creation_time>2012-01-31T07:45:13.068Z</creation_time>
|
43
|
+
<origin>rhev</origin>
|
44
|
+
<stateless>false</stateless>
|
45
|
+
<placement_policy>
|
46
|
+
<affinity>migratable</affinity>
|
47
|
+
</placement_policy>
|
48
|
+
<memory_policy>
|
49
|
+
<guaranteed>536870912</guaranteed>
|
50
|
+
</memory_policy>
|
51
|
+
<usb>
|
52
|
+
<enabled>true</enabled>
|
53
|
+
</usb>
|
54
|
+
</vm>
|
55
|
+
<vm href="/api/vms/349764bb-eba3-4466-abef-f18f4c40c9f1" id="349764bb-eba3-4466-abef-f18f4c40c9f1">
|
56
|
+
<name>fosdem</name>
|
57
|
+
<link href="/api/vms/349764bb-eba3-4466-abef-f18f4c40c9f1/disks" rel="disks"/>
|
58
|
+
<link href="/api/vms/349764bb-eba3-4466-abef-f18f4c40c9f1/nics" rel="nics"/>
|
59
|
+
<link href="/api/vms/349764bb-eba3-4466-abef-f18f4c40c9f1/cdroms" rel="cdroms"/>
|
60
|
+
<link href="/api/vms/349764bb-eba3-4466-abef-f18f4c40c9f1/snapshots" rel="snapshots"/>
|
61
|
+
<link href="/api/vms/349764bb-eba3-4466-abef-f18f4c40c9f1/tags" rel="tags"/>
|
62
|
+
<link href="/api/vms/349764bb-eba3-4466-abef-f18f4c40c9f1/permissions" rel="permissions"/>
|
63
|
+
<link href="/api/vms/349764bb-eba3-4466-abef-f18f4c40c9f1/statistics" rel="statistics"/>
|
64
|
+
<type>server</type>
|
65
|
+
<status>down</status>
|
66
|
+
<memory>536870912</memory>
|
67
|
+
<cpu>
|
68
|
+
<topology>
|
69
|
+
<cores>1</cores>
|
70
|
+
<sockets>1</sockets>
|
71
|
+
</topology>
|
72
|
+
</cpu>
|
73
|
+
<os>
|
74
|
+
<type>unassigned</type>
|
75
|
+
<boot>
|
76
|
+
<devices>
|
77
|
+
<device>hd</device>
|
78
|
+
</devices>
|
79
|
+
</boot>
|
80
|
+
<kernel/>
|
81
|
+
<initrd/>
|
82
|
+
<cmdline/>
|
83
|
+
</os>
|
84
|
+
<high_availability>
|
85
|
+
<enabled>false</enabled>
|
86
|
+
<priority>1</priority>
|
87
|
+
</high_availability>
|
88
|
+
<display>
|
89
|
+
<type>spice</type>
|
90
|
+
<address>host</address>
|
91
|
+
<port>5902</port>
|
92
|
+
<secure_port>5903</secure_port>
|
93
|
+
<monitors>1</monitors>
|
94
|
+
</display>
|
95
|
+
<host href="/api/hosts/3690fafa-4b4c-11e1-8b7b-5254009970cc" id="3690fafa-4b4c-11e1-8b7b-5254009970cc"/>
|
96
|
+
<cluster href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95" id="99408929-82cf-4dc7-a532-9d998063fa95"/>
|
97
|
+
<template href="/api/templates/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000"/>
|
98
|
+
<start_time>2012-02-05T11:04:39.217Z</start_time>
|
99
|
+
<creation_time>2012-02-05T10:53:30.484Z</creation_time>
|
100
|
+
<origin>rhev</origin>
|
101
|
+
<stateless>false</stateless>
|
102
|
+
<placement_policy>
|
103
|
+
<affinity>migratable</affinity>
|
104
|
+
</placement_policy>
|
105
|
+
<memory_policy>
|
106
|
+
<guaranteed>536870912</guaranteed>
|
107
|
+
</memory_policy>
|
108
|
+
<usb>
|
109
|
+
<enabled>true</enabled>
|
110
|
+
</usb>
|
111
|
+
</vm>
|
112
|
+
<vm href="/api/vms/52b9406e-cf66-4867-8655-719a094e324c" id="52b9406e-cf66-4867-8655-719a094e324c">
|
113
|
+
<name>vm01</name>
|
114
|
+
<link href="/api/vms/52b9406e-cf66-4867-8655-719a094e324c/disks" rel="disks"/>
|
115
|
+
<link href="/api/vms/52b9406e-cf66-4867-8655-719a094e324c/nics" rel="nics"/>
|
116
|
+
<link href="/api/vms/52b9406e-cf66-4867-8655-719a094e324c/cdroms" rel="cdroms"/>
|
117
|
+
<link href="/api/vms/52b9406e-cf66-4867-8655-719a094e324c/snapshots" rel="snapshots"/>
|
118
|
+
<link href="/api/vms/52b9406e-cf66-4867-8655-719a094e324c/tags" rel="tags"/>
|
119
|
+
<link href="/api/vms/52b9406e-cf66-4867-8655-719a094e324c/permissions" rel="permissions"/>
|
120
|
+
<link href="/api/vms/52b9406e-cf66-4867-8655-719a094e324c/statistics" rel="statistics"/>
|
121
|
+
<type>server</type>
|
122
|
+
<status>down</status>
|
123
|
+
<memory>805306368</memory>
|
124
|
+
<cpu>
|
125
|
+
<topology>
|
126
|
+
<cores>1</cores>
|
127
|
+
<sockets>1</sockets>
|
128
|
+
</topology>
|
129
|
+
</cpu>
|
130
|
+
<os>
|
131
|
+
<type>unassigned</type>
|
132
|
+
<boot>
|
133
|
+
<devices>
|
134
|
+
<device>network</device>
|
135
|
+
<device>hd</device>
|
136
|
+
</devices>
|
137
|
+
</boot>
|
138
|
+
<kernel/>
|
139
|
+
<initrd/>
|
140
|
+
<cmdline/>
|
141
|
+
</os>
|
142
|
+
<high_availability>
|
143
|
+
<enabled>false</enabled>
|
144
|
+
<priority>1</priority>
|
145
|
+
</high_availability>
|
146
|
+
<display>
|
147
|
+
<type>spice</type>
|
148
|
+
<address>host</address>
|
149
|
+
<port>5900</port>
|
150
|
+
<secure_port>5901</secure_port>
|
151
|
+
<monitors>1</monitors>
|
152
|
+
</display>
|
153
|
+
<host href="/api/hosts/3690fafa-4b4c-11e1-8b7b-5254009970cc" id="3690fafa-4b4c-11e1-8b7b-5254009970cc"/>
|
154
|
+
<cluster href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95" id="99408929-82cf-4dc7-a532-9d998063fa95"/>
|
155
|
+
<template href="/api/templates/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000"/>
|
156
|
+
<start_time>2012-02-05T11:00:33.222Z</start_time>
|
157
|
+
<creation_time>2012-01-31T07:21:10.667Z</creation_time>
|
158
|
+
<origin>rhev</origin>
|
159
|
+
<stateless>false</stateless>
|
160
|
+
<placement_policy>
|
161
|
+
<affinity>migratable</affinity>
|
162
|
+
</placement_policy>
|
163
|
+
<memory_policy>
|
164
|
+
<guaranteed>536870912</guaranteed>
|
165
|
+
</memory_policy>
|
166
|
+
<usb>
|
167
|
+
<enabled>true</enabled>
|
168
|
+
</usb>
|
169
|
+
</vm>
|
170
|
+
</vms>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<disks>
|
2
|
+
<disk href="/api/vms/192cdd3f-3281-4e20-b81d-93bdc57ac387/disks/9f68ecfd-218b-4f80-8e7a-e70b2ab054cd" id="9f68ecfd-218b-4f80-8e7a-e70b2ab054cd">
|
3
|
+
<name>Disk 2</name>
|
4
|
+
<link href="/api/vms/192cdd3f-3281-4e20-b81d-93bdc57ac387/disks/9f68ecfd-218b-4f80-8e7a-e70b2ab054cd/statistics" rel="statistics"/>
|
5
|
+
<vm href="/api/vms/192cdd3f-3281-4e20-b81d-93bdc57ac387" id="192cdd3f-3281-4e20-b81d-93bdc57ac387"/>
|
6
|
+
<storage_domains>
|
7
|
+
<storage_domain id="cba62b33-887a-410c-b367-e3d9229a72f7"/>
|
8
|
+
</storage_domains>
|
9
|
+
<provisioned_size>5368709120</provisioned_size>
|
10
|
+
<type>data</type>
|
11
|
+
<status>ok</status>
|
12
|
+
<interface>virtio</interface>
|
13
|
+
<format>raw</format>
|
14
|
+
<sparse>true</sparse>
|
15
|
+
<bootable>false</bootable>
|
16
|
+
<wipe_after_delete>false</wipe_after_delete>
|
17
|
+
<propagate_errors>false</propagate_errors>
|
18
|
+
</disk>
|
19
|
+
<disk href="/api/vms/192cdd3f-3281-4e20-b81d-93bdc57ac387/disks/e373b1a5-6c89-43f1-9a2d-cdf674412349" id="e373b1a5-6c89-43f1-9a2d-cdf674412349">
|
20
|
+
<name>Disk 1</name>
|
21
|
+
<link href="/api/vms/192cdd3f-3281-4e20-b81d-93bdc57ac387/disks/e373b1a5-6c89-43f1-9a2d-cdf674412349/statistics" rel="statistics"/>
|
22
|
+
<vm href="/api/vms/192cdd3f-3281-4e20-b81d-93bdc57ac387" id="192cdd3f-3281-4e20-b81d-93bdc57ac387"/>
|
23
|
+
<storage_domains>
|
24
|
+
<storage_domain id="cba62b33-887a-410c-b367-e3d9229a72f7"/>
|
25
|
+
</storage_domains>
|
26
|
+
<provisioned_size>8589934592</provisioned_size>
|
27
|
+
<type>system</type>
|
28
|
+
<status>ok</status>
|
29
|
+
<interface>virtio</interface>
|
30
|
+
<format>cow</format>
|
31
|
+
<sparse>true</sparse>
|
32
|
+
<bootable>true</bootable>
|
33
|
+
<wipe_after_delete>false</wipe_after_delete>
|
34
|
+
<propagate_errors>false</propagate_errors>
|
35
|
+
</disk>
|
36
|
+
</disks>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class V4
|
5
|
+
class Real
|
6
|
+
def storage_domains(filter = {})
|
7
|
+
filter = filter.dup
|
8
|
+
role_filter = filter.delete(:role)
|
9
|
+
client.system_service.storage_domains_service.list(filter).collect do |sd|
|
10
|
+
# Filter by role is not supported by the search language. The work around is to list all, then filter.
|
11
|
+
role_filter.nil? || sd.type == role_filter ? sd : nil
|
12
|
+
end.compact
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def storage_domains(_filters = {})
|
18
|
+
xml = read_xml "storage_domains.xml"
|
19
|
+
Nokogiri::XML(xml).xpath("/storage_domains/storage_domain").map do |sd|
|
20
|
+
OvirtSDK4::Reader.read(sd.to_s)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class V4
|
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::V4::Shared
|
14
|
+
|
15
|
+
def update_interface(id, options)
|
16
|
+
check_arguments(id, options)
|
17
|
+
|
18
|
+
interface_id = options[:id]
|
19
|
+
nic = client.system_service.vms_service.vm_service(id).nics_service.nic_service(interface_id)
|
20
|
+
nic.update(nic, options)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Mock
|
25
|
+
extend ::Fog::Compute::Ovirt::V4::Shared
|
26
|
+
|
27
|
+
def update_interface(id, options)
|
28
|
+
check_arguments(id, options)
|
29
|
+
true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class V4
|
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::Compute::Ovirt::V4::Shared
|
14
|
+
|
15
|
+
def update_volume(id, options)
|
16
|
+
check_arguments(id, options)
|
17
|
+
|
18
|
+
disk_id = options[:id]
|
19
|
+
disk_attachment = client.system_service.vms_service.vm_service(id).disk_attachments_service.attachment_service(disk_id)
|
20
|
+
disk_attachment.update(disk_attachment, options)
|
21
|
+
true # If we come here, expect success and return true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
extend ::Fog::Compute::Ovirt::V4::Shared
|
27
|
+
|
28
|
+
def update_volume(id, options)
|
29
|
+
check_arguments(id, options)
|
30
|
+
true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class V4
|
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
|
+
vm_service = client.system_service.vms_service.vm_service(options[:id])
|
11
|
+
vm_service.public_send(options[:action])
|
12
|
+
vm_service.get.status
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def vm_action(options = {})
|
18
|
+
raise ArgumentError, "id is a required parameter" unless options.key? :id
|
19
|
+
raise ArgumentError, "action is a required parameter" unless options.key? :action
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class V4
|
5
|
+
class Real
|
6
|
+
def vm_ticket(id, options = {})
|
7
|
+
client.system_service.vms_service.vm_service(id).ticket(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
|
data/lib/fog/ovirt/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/tests/ovirt/requests/compute/{list_datacenters_tests.rb → v3/list_datacenters_tests.rb}
RENAMED
File without changes
|
File without changes
|
data/tests/ovirt/requests/compute/{list_storage_domains_tests.rb → v3/list_storage_domains_tests.rb}
RENAMED
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:ovirt] | 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::Compute::Ovirt::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
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:ovirt] v4 | vm_create request", "ovirt") do
|
2
|
+
compute = Fog::Compute.new(:provider => :ovirt, :api_version => "v4")
|
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 OvirtSDK4::Vm") { response.is_a? OvirtSDK4::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 OvirtSDK4::Vm") { response.is_a? OvirtSDK4::Vm }
|
13
|
+
end
|
14
|
+
|
15
|
+
# TODO: Write a test for situation where creating a VM fails
|
16
|
+
# mocks never raise exceptions
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:ovirt] v4 | vm_destroy request", ["ovirt"]) do
|
2
|
+
compute = Fog::Compute.new(:provider => :ovirt, :api_version => "v4")
|
3
|
+
if compute.servers.all(:search => "fog-*").empty?
|
4
|
+
compute.create_vm(:name => "fog-" + Time.now.to_i.to_s, :cluster_name => "Default")
|
5
|
+
end
|
6
|
+
vm_id = compute.servers.all(:search => "fog-*").last.id
|
7
|
+
|
8
|
+
tests("The response should") do
|
9
|
+
response = compute.destroy_vm(:id => vm_id)
|
10
|
+
test("be a success") { response ? true : false }
|
11
|
+
end
|
12
|
+
|
13
|
+
tests("The expected options") do
|
14
|
+
raises(ArgumentError, "raises ArgumentError when id option is missing") { compute.destroy_vm }
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:ovirt] v4 | datacenters request", ["ovirt"]) do
|
2
|
+
compute = Fog::Compute.new(:provider => :ovirt, :api_version => "v4")
|
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
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:ovirt] v4 | quotas request", ["ovirt"]) do
|
2
|
+
compute = Fog::Compute.new(:provider => :ovirt, :api_version => "v4")
|
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
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:ovirt] v4 | storage_domains request", ["ovirt"]) do
|
2
|
+
compute = Fog::Compute.new(:provider => :ovirt, :api_version => "v4")
|
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 OvirtSDK4::StorageDomain") { response.first.is_a? OvirtSDK4::StorageDomain }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:ovirt] v4 | update_volume request", ["ovirt"]) do
|
2
|
+
compute = Fog::Compute.new(:provider => :ovirt, :api_version => "v4")
|
3
|
+
if compute.servers.all(:search => "fog-*").empty?
|
4
|
+
compute.create_vm(:name => "fog-" + Time.now.to_i.to_s, :cluster_name => "Default")
|
5
|
+
end
|
6
|
+
vm_id = compute.servers.all(:search => "fog-*").last
|
7
|
+
|
8
|
+
tests("The expected options") do
|
9
|
+
raises(ArgumentError, "raises ArgumentError when vm id is missing") { compute.update_volume(nil, :id => 1) }
|
10
|
+
raises(ArgumentError, "raises ArgumentError when disk_id option is missing") { compute.update_volume(1, :any => 1) }
|
11
|
+
end
|
12
|
+
|
13
|
+
tests("The response should") do
|
14
|
+
response = compute.update_volume(vm_id, :id => 1)
|
15
|
+
test("be a success") { response ? true : false }
|
16
|
+
end
|
17
|
+
end
|