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.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +20 -0
  3. data/.rubocop_todo.yml +43 -0
  4. data/.travis.yml +3 -1
  5. data/Gemfile +1 -1
  6. data/Rakefile +15 -5
  7. data/fog-ovirt.gemspec +15 -14
  8. data/lib/fog/bin/ovirt.rb +1 -1
  9. data/lib/fog/ovirt.rb +1 -1
  10. data/lib/fog/ovirt/compute.rb +56 -112
  11. data/lib/fog/ovirt/compute/v3.rb +137 -0
  12. data/lib/fog/ovirt/core.rb +13 -4
  13. data/lib/fog/ovirt/models/compute/affinity_group.rb +2 -2
  14. data/lib/fog/ovirt/models/compute/affinity_groups.rb +2 -2
  15. data/lib/fog/ovirt/models/compute/clusters.rb +2 -2
  16. data/lib/fog/ovirt/models/compute/instance_types.rb +2 -2
  17. data/lib/fog/ovirt/models/compute/interfaces.rb +7 -5
  18. data/lib/fog/ovirt/models/compute/operating_systems.rb +3 -3
  19. data/lib/fog/ovirt/models/compute/quotas.rb +3 -3
  20. data/lib/fog/ovirt/models/compute/server.rb +37 -31
  21. data/lib/fog/ovirt/models/compute/servers.rb +2 -2
  22. data/lib/fog/ovirt/models/compute/template.rb +9 -9
  23. data/lib/fog/ovirt/models/compute/templates.rb +2 -2
  24. data/lib/fog/ovirt/models/compute/volume.rb +3 -3
  25. data/lib/fog/ovirt/models/compute/volumes.rb +6 -4
  26. data/lib/fog/ovirt/requests/compute/v3/activate_volume.rb +23 -0
  27. data/lib/fog/ovirt/requests/compute/v3/add_interface.rb +22 -0
  28. data/lib/fog/ovirt/requests/compute/v3/add_to_affinity_group.rb +23 -0
  29. data/lib/fog/ovirt/requests/compute/v3/add_volume.rb +23 -0
  30. data/lib/fog/ovirt/requests/compute/v3/attach_volume.rb +24 -0
  31. data/lib/fog/ovirt/requests/compute/v3/create_affinity_group.rb +20 -0
  32. data/lib/fog/ovirt/requests/compute/v3/create_vm.rb +20 -0
  33. data/lib/fog/ovirt/requests/compute/v3/datacenters.rb +22 -0
  34. data/lib/fog/ovirt/requests/compute/v3/deactivate_volume.rb +24 -0
  35. data/lib/fog/ovirt/requests/compute/v3/destroy_affinity_group.rb +21 -0
  36. data/lib/fog/ovirt/requests/compute/v3/destroy_interface.rb +24 -0
  37. data/lib/fog/ovirt/requests/compute/v3/destroy_vm.rb +21 -0
  38. data/lib/fog/ovirt/requests/compute/v3/destroy_volume.rb +24 -0
  39. data/lib/fog/ovirt/requests/compute/v3/detach_volume.rb +24 -0
  40. data/lib/fog/ovirt/requests/compute/v3/get_affinity_group.rb +20 -0
  41. data/lib/fog/ovirt/requests/compute/v3/get_api_version.rb +18 -0
  42. data/lib/fog/ovirt/requests/compute/v3/get_cluster.rb +19 -0
  43. data/lib/fog/ovirt/requests/compute/v3/get_instance_type.rb +19 -0
  44. data/lib/fog/ovirt/requests/compute/v3/get_quota.rb +19 -0
  45. data/lib/fog/ovirt/requests/compute/v3/get_template.rb +19 -0
  46. data/lib/fog/ovirt/requests/compute/v3/get_virtual_machine.rb +19 -0
  47. data/lib/fog/ovirt/requests/compute/v3/list_affinity_group_vms.rb +24 -0
  48. data/lib/fog/ovirt/requests/compute/v3/list_affinity_groups.rb +22 -0
  49. data/lib/fog/ovirt/requests/compute/v3/list_clusters.rb +21 -0
  50. data/lib/fog/ovirt/requests/compute/v3/list_instance_types.rb +21 -0
  51. data/lib/fog/ovirt/requests/compute/v3/list_networks.rb +18 -0
  52. data/lib/fog/ovirt/requests/compute/v3/list_operating_systems.rb +21 -0
  53. data/lib/fog/ovirt/requests/compute/v3/list_quotas.rb +21 -0
  54. data/lib/fog/ovirt/requests/compute/v3/list_template_interfaces.rb +21 -0
  55. data/lib/fog/ovirt/requests/compute/v3/list_template_volumes.rb +21 -0
  56. data/lib/fog/ovirt/requests/compute/v3/list_templates.rb +21 -0
  57. data/lib/fog/ovirt/requests/compute/v3/list_virtual_machines.rb +21 -0
  58. data/lib/fog/ovirt/requests/compute/v3/list_vm_interfaces.rb +21 -0
  59. data/lib/fog/ovirt/requests/compute/v3/list_vm_volumes.rb +21 -0
  60. data/lib/fog/ovirt/requests/compute/v3/list_volumes.rb +21 -0
  61. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/affinitygroup.xml +0 -0
  62. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/affinitygroup_vms.xml +0 -0
  63. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/affinitygroups.xml +0 -0
  64. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/cluster.xml +0 -0
  65. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/clusters.xml +0 -0
  66. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/data_centers.xml +0 -0
  67. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/disks.xml +0 -0
  68. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/instance_type.xml +0 -0
  69. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/instance_types.xml +0 -0
  70. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/nics.xml +0 -0
  71. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/operating_systems.xml +0 -0
  72. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/quotas.xml +0 -0
  73. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/storage_domains.xml +0 -0
  74. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/template.xml +0 -0
  75. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/templates.xml +0 -0
  76. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/vm.xml +0 -0
  77. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/vms.xml +0 -0
  78. data/lib/fog/ovirt/requests/compute/{mock_files → v3/mock_files}/volumes.xml +0 -0
  79. data/lib/fog/ovirt/requests/compute/v3/remove_from_affinity_group.rb +23 -0
  80. data/lib/fog/ovirt/requests/compute/v3/storage_domains.rb +22 -0
  81. data/lib/fog/ovirt/requests/compute/v3/update_interface.rb +36 -0
  82. data/lib/fog/ovirt/requests/compute/v3/update_vm.rb +20 -0
  83. data/lib/fog/ovirt/requests/compute/v3/update_volume.rb +37 -0
  84. data/lib/fog/ovirt/requests/compute/v3/vm_action.rb +24 -0
  85. data/lib/fog/ovirt/requests/compute/v3/vm_start_with_cloudinit.rb +21 -0
  86. data/lib/fog/ovirt/requests/compute/v3/vm_ticket.rb +19 -0
  87. data/lib/fog/ovirt/version.rb +1 -1
  88. data/tests/helper.rb +1 -1
  89. data/tests/helpers/mock_helper.rb +4 -6
  90. data/tests/helpers/succeeds_helper.rb +1 -1
  91. data/tests/ovirt/compute_tests.rb +5 -6
  92. data/tests/ovirt/models/compute/cluster_tests.rb +10 -13
  93. data/tests/ovirt/models/compute/clusters_tests.rb +3 -5
  94. data/tests/ovirt/models/compute/interface_tests.rb +9 -11
  95. data/tests/ovirt/models/compute/interfaces_tests.rb +3 -5
  96. data/tests/ovirt/models/compute/operating_system_tests.rb +7 -13
  97. data/tests/ovirt/models/compute/operating_systems_tests.rb +4 -6
  98. data/tests/ovirt/models/compute/server_tests.rb +29 -32
  99. data/tests/ovirt/models/compute/servers_tests.rb +7 -9
  100. data/tests/ovirt/models/compute/template_tests.rb +10 -12
  101. data/tests/ovirt/models/compute/templates_tests.rb +3 -5
  102. data/tests/ovirt/requests/compute/client_tests.rb +31 -0
  103. data/tests/ovirt/requests/compute/create_vm_tests.rb +7 -16
  104. data/tests/ovirt/requests/compute/destroy_vm_tests.rb +8 -10
  105. data/tests/ovirt/requests/compute/list_datacenters_tests.rb +3 -5
  106. data/tests/ovirt/requests/compute/list_quotas_tests.rb +2 -4
  107. data/tests/ovirt/requests/compute/list_storage_domains_tests.rb +3 -5
  108. data/tests/ovirt/requests/compute/update_vm_tests.rb +9 -11
  109. data/tests/ovirt/requests/compute/update_volume_tests.rb +9 -12
  110. metadata +70 -65
  111. data/lib/fog/ovirt/requests/compute/activate_volume.rb +0 -22
  112. data/lib/fog/ovirt/requests/compute/add_interface.rb +0 -20
  113. data/lib/fog/ovirt/requests/compute/add_to_affinity_group.rb +0 -21
  114. data/lib/fog/ovirt/requests/compute/add_volume.rb +0 -21
  115. data/lib/fog/ovirt/requests/compute/attach_volume.rb +0 -22
  116. data/lib/fog/ovirt/requests/compute/create_affinity_group.rb +0 -18
  117. data/lib/fog/ovirt/requests/compute/create_vm.rb +0 -18
  118. data/lib/fog/ovirt/requests/compute/datacenters.rb +0 -20
  119. data/lib/fog/ovirt/requests/compute/deactivate_volume.rb +0 -22
  120. data/lib/fog/ovirt/requests/compute/destroy_affinity_group.rb +0 -19
  121. data/lib/fog/ovirt/requests/compute/destroy_interface.rb +0 -22
  122. data/lib/fog/ovirt/requests/compute/destroy_vm.rb +0 -19
  123. data/lib/fog/ovirt/requests/compute/destroy_volume.rb +0 -22
  124. data/lib/fog/ovirt/requests/compute/detach_volume.rb +0 -22
  125. data/lib/fog/ovirt/requests/compute/get_affinity_group.rb +0 -18
  126. data/lib/fog/ovirt/requests/compute/get_api_version.rb +0 -16
  127. data/lib/fog/ovirt/requests/compute/get_cluster.rb +0 -17
  128. data/lib/fog/ovirt/requests/compute/get_instance_type.rb +0 -17
  129. data/lib/fog/ovirt/requests/compute/get_quota.rb +0 -17
  130. data/lib/fog/ovirt/requests/compute/get_template.rb +0 -17
  131. data/lib/fog/ovirt/requests/compute/get_virtual_machine.rb +0 -17
  132. data/lib/fog/ovirt/requests/compute/list_affinity_group_vms.rb +0 -22
  133. data/lib/fog/ovirt/requests/compute/list_affinity_groups.rb +0 -20
  134. data/lib/fog/ovirt/requests/compute/list_clusters.rb +0 -19
  135. data/lib/fog/ovirt/requests/compute/list_instance_types.rb +0 -19
  136. data/lib/fog/ovirt/requests/compute/list_networks.rb +0 -16
  137. data/lib/fog/ovirt/requests/compute/list_operating_systems.rb +0 -19
  138. data/lib/fog/ovirt/requests/compute/list_quotas.rb +0 -19
  139. data/lib/fog/ovirt/requests/compute/list_template_interfaces.rb +0 -19
  140. data/lib/fog/ovirt/requests/compute/list_template_volumes.rb +0 -19
  141. data/lib/fog/ovirt/requests/compute/list_templates.rb +0 -19
  142. data/lib/fog/ovirt/requests/compute/list_virtual_machines.rb +0 -19
  143. data/lib/fog/ovirt/requests/compute/list_vm_interfaces.rb +0 -19
  144. data/lib/fog/ovirt/requests/compute/list_vm_volumes.rb +0 -19
  145. data/lib/fog/ovirt/requests/compute/list_volumes.rb +0 -19
  146. data/lib/fog/ovirt/requests/compute/remove_from_affinity_group.rb +0 -21
  147. data/lib/fog/ovirt/requests/compute/storage_domains.rb +0 -20
  148. data/lib/fog/ovirt/requests/compute/update_interface.rb +0 -35
  149. data/lib/fog/ovirt/requests/compute/update_vm.rb +0 -18
  150. data/lib/fog/ovirt/requests/compute/update_volume.rb +0 -39
  151. data/lib/fog/ovirt/requests/compute/vm_action.rb +0 -22
  152. data/lib/fog/ovirt/requests/compute/vm_start_with_cloudinit.rb +0 -19
  153. data/lib/fog/ovirt/requests/compute/vm_ticket.rb +0 -17
@@ -1,6 +1,5 @@
1
- require 'fog/core'
2
- require 'fog/xml'
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, 'Compute')
24
+ service(:compute, "Compute")
16
25
  end
17
26
  end
@@ -3,11 +3,11 @@ module Fog
3
3
  class Ovirt
4
4
  class AffinityGroup < Fog::Model
5
5
  identity :id
6
-
6
+
7
7
  attribute :name
8
8
  attribute :positive
9
9
  attribute :enforcing
10
-
10
+
11
11
  def vms
12
12
  id.nil? ? [] : service.list_affinity_group_vms(id)
13
13
  end
@@ -1,5 +1,5 @@
1
- require 'fog/core/collection'
2
- require 'fog/ovirt/models/compute/affinity_group'
1
+ require "fog/core/collection"
2
+ require "fog/ovirt/models/compute/affinity_group"
3
3
 
4
4
  module Fog
5
5
  module Compute
@@ -1,5 +1,5 @@
1
- require 'fog/core/collection'
2
- require 'fog/ovirt/models/compute/cluster'
1
+ require "fog/core/collection"
2
+ require "fog/ovirt/models/compute/cluster"
3
3
 
4
4
  module Fog
5
5
  module Compute
@@ -1,5 +1,5 @@
1
- require 'fog/core/collection'
2
- require 'fog/ovirt/models/compute/instance_type'
1
+ require "fog/core/collection"
2
+ require "fog/ovirt/models/compute/instance_type"
3
3
 
4
4
  module Fog
5
5
  module Compute
@@ -1,5 +1,5 @@
1
- require 'fog/core/collection'
2
- require 'fog/ovirt/models/compute/interface'
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
- def all(filters = {})
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 'interfaces should have vm or template'
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
- end
28
+ end
27
29
  end
28
30
  end
29
31
  end
@@ -1,5 +1,5 @@
1
- require 'fog/core/collection'
2
- require 'fog/ovirt/models/compute/operating_system'
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
- end
13
+ end
14
14
  end
15
15
  end
16
16
  end
@@ -1,5 +1,5 @@
1
- require 'fog/core/collection'
2
- require 'fog/ovirt/models/compute/quota'
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
- def all(filters = {})
10
+ def all(filters = {})
11
11
  load service.list_quotas(filters)
12
12
  end
13
13
 
@@ -1,4 +1,4 @@
1
- require 'fog/compute/models/server'
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, :aliases => 'disk_size'
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, :aliases => 'cpus'
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
- !(status =~ /down/i)
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.downcase == 'down'
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
- :service => service,
57
- :vm => self
56
+ :service => service,
57
+ :vm => self
58
58
  )
59
59
  end
60
60
 
61
- def add_interface attrs
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 attrs
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 attrs
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
- :service => service,
79
- :vm => self
78
+ :service => service,
79
+ :vm => self
80
80
  )
81
81
  end
82
82
 
83
- def add_volume attrs
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 attrs
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 attrs
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
- user_data = { :custom_script => options[:user_data] }
128
- else
129
- user_data = Hash[YAML.load(options[:user_data]).map{|a| [a.first.to_sym, a.last]}]
130
- end
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(options = {})
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(options = {})
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(options = {})
154
- (stop unless stopped?) rescue nil #ignore failure, destroy the machine anyway.
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
 
@@ -1,5 +1,5 @@
1
- require 'fog/core/collection'
2
- require 'fog/ovirt/models/compute/server'
1
+ require "fog/core/collection"
2
+ require "fog/ovirt/models/compute/server"
3
3
 
4
4
  module Fog
5
5
  module Compute
@@ -11,11 +11,11 @@ module Fog
11
11
  attribute :description
12
12
  attribute :profile
13
13
  attribute :display
14
- attribute :storage, :aliases => 'disk_size'
14
+ attribute :storage, :aliases => "disk_size"
15
15
  attribute :creation_time
16
16
  attribute :os
17
17
  attribute :status
18
- attribute :cores, :aliases => 'cpus'
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
- :service => service,
28
- :vm => self
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
- :service => service,
35
- :vm => self
34
+ :service => service,
35
+ :vm => self
36
36
  )
37
37
  end
38
38
 
39
39
  def ready?
40
- !(status =~ /down/i)
40
+ status !~ /down/i
41
41
  end
42
42
 
43
- def destroy(options = {})
43
+ def destroy(_options = {})
44
44
  service.client.destroy_template(id)
45
45
  end
46
46
 
47
47
  def save
48
- raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
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
 
@@ -1,5 +1,5 @@
1
- require 'fog/core/collection'
2
- require 'fog/ovirt/models/compute/template'
1
+ require "fog/core/collection"
2
+ require "fog/ovirt/models/compute/template"
3
3
 
4
4
  module Fog
5
5
  module Compute
@@ -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 = 1073741824
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= s
27
- attributes[:size] = s.to_i * DISK_SIZE_TO_GB if s
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 'fog/core/collection'
2
- require 'fog/ovirt/models/compute/volume'
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
- def all(filters = {})
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
- end
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