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
data/lib/fog/ovirt/core.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require 'rbovirt'
|
1
|
+
require "fog/core"
|
2
|
+
require "fog/xml"
|
4
3
|
|
5
4
|
module Fog
|
6
5
|
module Ovirt
|
@@ -10,8 +9,18 @@ module Fog
|
|
10
9
|
class ServiceError < Fog::Errors::Error; end
|
11
10
|
class SecurityError < ServiceError; end
|
12
11
|
class NotFound < ServiceError; end
|
12
|
+
class OvirtError < Fog::Errors::Error; end
|
13
|
+
|
14
|
+
class OvirtEngineError < OvirtError
|
15
|
+
attr_reader :orig_exception
|
16
|
+
|
17
|
+
def initialize(exception)
|
18
|
+
@orig_exception = exception
|
19
|
+
super("Ovirt client returned an error: #{@orig_exception.message}")
|
20
|
+
end
|
21
|
+
end
|
13
22
|
end
|
14
23
|
|
15
|
-
service(:compute,
|
24
|
+
service(:compute, "Compute")
|
16
25
|
end
|
17
26
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/ovirt/models/compute/interface"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
@@ -9,21 +9,23 @@ module Fog
|
|
9
9
|
|
10
10
|
attr_accessor :vm
|
11
11
|
|
12
|
-
|
12
|
+
# rubocop:disable Metrics/AbcSize
|
13
|
+
def all(_filters = {})
|
13
14
|
requires :vm
|
14
15
|
if vm.is_a? Fog::Compute::Ovirt::Server
|
15
16
|
load service.list_vm_interfaces(vm.id)
|
16
17
|
elsif vm.is_a? Fog::Compute::Ovirt::Template
|
17
18
|
load service.list_template_interfaces(vm.id)
|
18
19
|
else
|
19
|
-
raise
|
20
|
+
raise ::Fog::Ovirt::Errors::OvirtError, "interfaces should have vm or template"
|
20
21
|
end
|
21
22
|
end
|
23
|
+
# rubocop:enable Metrics/AbcSize
|
22
24
|
|
23
25
|
def get(id)
|
24
26
|
new service.get_interface(id)
|
25
27
|
end
|
26
|
-
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/ovirt/models/compute/operating_system"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
@@ -10,7 +10,7 @@ module Fog
|
|
10
10
|
def all
|
11
11
|
load service.list_operating_systems
|
12
12
|
end
|
13
|
-
|
13
|
+
end
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/ovirt/models/compute/quota"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
@@ -7,7 +7,7 @@ module Fog
|
|
7
7
|
class Quotas < Fog::Collection
|
8
8
|
model Fog::Compute::Ovirt::Quota
|
9
9
|
|
10
|
-
|
10
|
+
def all(filters = {})
|
11
11
|
load service.list_quotas(filters)
|
12
12
|
end
|
13
13
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "fog/compute/models/server"
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module Compute
|
@@ -13,12 +13,12 @@ module Fog
|
|
13
13
|
attribute :description
|
14
14
|
attribute :profile
|
15
15
|
attribute :display
|
16
|
-
attribute :storage,
|
16
|
+
attribute :storage, :aliases => "disk_size"
|
17
17
|
attribute :creation_time
|
18
18
|
attribute :os
|
19
19
|
attribute :ip
|
20
20
|
attribute :status
|
21
|
-
attribute :cores,
|
21
|
+
attribute :cores, :aliases => "cpus"
|
22
22
|
attribute :memory
|
23
23
|
attribute :host
|
24
24
|
attribute :cluster
|
@@ -35,16 +35,16 @@ module Fog
|
|
35
35
|
attribute :disks
|
36
36
|
|
37
37
|
def ready?
|
38
|
-
|
38
|
+
status !~ /down/i
|
39
39
|
end
|
40
40
|
|
41
41
|
def locked?
|
42
42
|
@volumes = nil # force reload volumes
|
43
|
-
!!(status =~ /locked/i) || (attributes[:volumes]=nil) || volumes.any?{|v| !!(v.status =~ /locked/i)}
|
43
|
+
!!(status =~ /locked/i) || (attributes[:volumes] = nil) || volumes.any? { |v| !!(v.status =~ /locked/i) }
|
44
44
|
end
|
45
45
|
|
46
46
|
def stopped?
|
47
|
-
status.
|
47
|
+
status.casecmp("down").zero?
|
48
48
|
end
|
49
49
|
|
50
50
|
def mac
|
@@ -53,44 +53,44 @@ module Fog
|
|
53
53
|
|
54
54
|
def interfaces
|
55
55
|
@interfaces ||= id.nil? ? [] : Fog::Compute::Ovirt::Interfaces.new(
|
56
|
-
|
57
|
-
|
56
|
+
:service => service,
|
57
|
+
:vm => self
|
58
58
|
)
|
59
59
|
end
|
60
60
|
|
61
|
-
def add_interface
|
61
|
+
def add_interface(attrs)
|
62
62
|
wait_for { stopped? } if attrs[:blocking]
|
63
63
|
service.add_interface(id, attrs)
|
64
64
|
end
|
65
65
|
|
66
|
-
def update_interface
|
66
|
+
def update_interface(attrs)
|
67
67
|
wait_for { stopped? } if attrs[:blocking]
|
68
68
|
service.update_interface(id, attrs)
|
69
69
|
end
|
70
70
|
|
71
|
-
def destroy_interface
|
71
|
+
def destroy_interface(attrs)
|
72
72
|
wait_for { stopped? } if attrs[:blocking]
|
73
73
|
service.destroy_interface(id, attrs)
|
74
74
|
end
|
75
75
|
|
76
76
|
def volumes
|
77
77
|
@volumes ||= id.nil? ? [] : Fog::Compute::Ovirt::Volumes.new(
|
78
|
-
|
79
|
-
|
78
|
+
:service => service,
|
79
|
+
:vm => self
|
80
80
|
)
|
81
81
|
end
|
82
82
|
|
83
|
-
def add_volume
|
83
|
+
def add_volume(attrs)
|
84
84
|
wait_for { stopped? } if attrs[:blocking]
|
85
85
|
service.add_volume(id, attrs)
|
86
86
|
end
|
87
87
|
|
88
|
-
def destroy_volume
|
88
|
+
def destroy_volume(attrs)
|
89
89
|
wait_for { stopped? } if attrs[:blocking]
|
90
90
|
service.destroy_volume(id, attrs)
|
91
91
|
end
|
92
92
|
|
93
|
-
def update_volume
|
93
|
+
def update_volume(attrs)
|
94
94
|
wait_for { stopped? } if attrs[:blocking]
|
95
95
|
service.update_volume(id, attrs)
|
96
96
|
end
|
@@ -109,7 +109,7 @@ module Fog
|
|
109
109
|
wait_for { stopped? } if attrs[:blocking]
|
110
110
|
service.add_to_affinity_group(id, attrs)
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
def remove_from_affinity_group(attrs)
|
114
114
|
wait_for { stopped? } if attrs[:blocking]
|
115
115
|
service.remove_from_affinity_group(id, attrs)
|
@@ -117,23 +117,25 @@ module Fog
|
|
117
117
|
|
118
118
|
def start(options = {})
|
119
119
|
wait_for { !locked? } if options[:blocking]
|
120
|
-
service.vm_action(:id =>id, :action => :start)
|
120
|
+
service.vm_action(:id => id, :action => :start)
|
121
121
|
reload
|
122
122
|
end
|
123
123
|
|
124
|
+
# rubocop:disable Metrics/AbcSize
|
124
125
|
def start_with_cloudinit(options = {})
|
125
126
|
wait_for { !locked? } if options[:blocking]
|
126
|
-
if options[:use_custom_script]
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
service.vm_start_with_cloudinit(:id =>id, :user_data =>user_data)
|
127
|
+
user_data = if options[:use_custom_script]
|
128
|
+
{ :custom_script => options[:user_data] }
|
129
|
+
else
|
130
|
+
Hash[YAML.safe_load(options[:user_data]).map { |a| [a.first.to_sym, a.last] }]
|
131
|
+
end
|
132
|
+
service.vm_start_with_cloudinit(:id => id, :user_data => user_data)
|
132
133
|
reload
|
133
134
|
end
|
135
|
+
# rubocop:enable Metrics/AbcSize
|
134
136
|
|
135
|
-
def stop(
|
136
|
-
service.vm_action(:id =>id, :action => :stop)
|
137
|
+
def stop(_options = {})
|
138
|
+
service.vm_action(:id => id, :action => :stop)
|
137
139
|
reload
|
138
140
|
end
|
139
141
|
|
@@ -145,19 +147,23 @@ module Fog
|
|
145
147
|
start options.merge(:blocking => true)
|
146
148
|
end
|
147
149
|
|
148
|
-
def suspend(
|
149
|
-
service.vm_action(:id =>id, :action => :suspend)
|
150
|
+
def suspend(_options = {})
|
151
|
+
service.vm_action(:id => id, :action => :suspend)
|
150
152
|
reload
|
151
153
|
end
|
152
154
|
|
153
|
-
def destroy(
|
154
|
-
|
155
|
+
def destroy(_options = {})
|
156
|
+
begin
|
157
|
+
(stop unless stopped?)
|
158
|
+
rescue StandardError
|
159
|
+
nil
|
160
|
+
end # ignore failure, destroy the machine anyway.
|
155
161
|
wait_for { stopped? }
|
156
162
|
service.destroy_vm(:id => id)
|
157
163
|
end
|
158
164
|
|
159
165
|
def ticket(options = {})
|
160
|
-
raise "Can not set console ticket, Server is not ready. Server status: #{status}" unless ready?
|
166
|
+
raise ::Fog::Ovirt::Errors::OvirtError, "Can not set console ticket, Server is not ready. Server status: #{status}" unless ready?
|
161
167
|
service.vm_ticket(id, options)
|
162
168
|
end
|
163
169
|
|
@@ -11,11 +11,11 @@ module Fog
|
|
11
11
|
attribute :description
|
12
12
|
attribute :profile
|
13
13
|
attribute :display
|
14
|
-
attribute :storage,
|
14
|
+
attribute :storage, :aliases => "disk_size"
|
15
15
|
attribute :creation_time
|
16
16
|
attribute :os
|
17
17
|
attribute :status
|
18
|
-
attribute :cores,
|
18
|
+
attribute :cores, :aliases => "cpus"
|
19
19
|
attribute :memory
|
20
20
|
attribute :cluster
|
21
21
|
attribute :interfaces
|
@@ -24,28 +24,28 @@ module Fog
|
|
24
24
|
|
25
25
|
def interfaces
|
26
26
|
attributes[:interfaces] ||= id.nil? ? [] : Fog::Compute::Ovirt::Interfaces.new(
|
27
|
-
|
28
|
-
|
27
|
+
:service => service,
|
28
|
+
:vm => self
|
29
29
|
)
|
30
30
|
end
|
31
31
|
|
32
32
|
def volumes
|
33
33
|
attributes[:volumes] ||= id.nil? ? [] : Fog::Compute::Ovirt::Volumes.new(
|
34
|
-
|
35
|
-
|
34
|
+
:service => service,
|
35
|
+
:vm => self
|
36
36
|
)
|
37
37
|
end
|
38
38
|
|
39
39
|
def ready?
|
40
|
-
|
40
|
+
status !~ /down/i
|
41
41
|
end
|
42
42
|
|
43
|
-
def destroy(
|
43
|
+
def destroy(_options = {})
|
44
44
|
service.client.destroy_template(id)
|
45
45
|
end
|
46
46
|
|
47
47
|
def save
|
48
|
-
raise Fog::Errors::
|
48
|
+
raise ::Fog::Ovirt::Errors::OvirtError, "Providing an existing object may create a duplicate object" if persisted?
|
49
49
|
service.client.create_template(attributes)
|
50
50
|
end
|
51
51
|
|
@@ -3,7 +3,7 @@ module Fog
|
|
3
3
|
class Ovirt
|
4
4
|
class Volume < Fog::Model
|
5
5
|
attr_accessor :raw
|
6
|
-
DISK_SIZE_TO_GB =
|
6
|
+
DISK_SIZE_TO_GB = 1_073_741_824
|
7
7
|
identity :id
|
8
8
|
|
9
9
|
attribute :storage_domain
|
@@ -23,8 +23,8 @@ module Fog
|
|
23
23
|
attributes[:size_gb] ||= attributes[:size].to_i / DISK_SIZE_TO_GB if attributes[:size]
|
24
24
|
end
|
25
25
|
|
26
|
-
def size_gb=
|
27
|
-
attributes[:size] =
|
26
|
+
def size_gb=(size)
|
27
|
+
attributes[:size] = size.to_i * DISK_SIZE_TO_GB if size
|
28
28
|
end
|
29
29
|
|
30
30
|
def to_s
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/ovirt/models/compute/volume"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
@@ -9,7 +9,8 @@ module Fog
|
|
9
9
|
|
10
10
|
attr_accessor :vm
|
11
11
|
|
12
|
-
|
12
|
+
# rubocop:disable Metrics/AbcSize
|
13
|
+
def all(_filters = {})
|
13
14
|
if vm.is_a? Fog::Compute::Ovirt::Server
|
14
15
|
load service.list_vm_volumes(vm.id)
|
15
16
|
elsif vm.is_a? Fog::Compute::Ovirt::Template
|
@@ -18,11 +19,12 @@ module Fog
|
|
18
19
|
load service.list_volumes
|
19
20
|
end
|
20
21
|
end
|
22
|
+
# rubocop:enable Metrics/AbcSize
|
21
23
|
|
22
24
|
def get(id)
|
23
25
|
new service.get_volume(id)
|
24
26
|
end
|
25
|
-
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class V3
|
5
|
+
class Real
|
6
|
+
def activate_volume(id, options)
|
7
|
+
raise ArgumentError, "instance id is a required parameter" unless id
|
8
|
+
raise ArgumentError, "volume id is a required parameter for activate-volume" unless options.key? :id
|
9
|
+
client.activate_volume(id, options[:id])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Mock
|
14
|
+
def activate_volume(id, options)
|
15
|
+
raise ArgumentError, "instance id is a required parameter" unless id
|
16
|
+
raise ArgumentError, "volume id is a required parameter for activate-volume" unless options.key? :id
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|