ovirt 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4692aaa3e0f3118a4d794df4b468de40d22c9cc
4
- data.tar.gz: 1a4443cbe30a58e4ff163bf43cad68d642a9ca15
3
+ metadata.gz: 06c3dc71f62f380fe6f34bd2a57ac7045cbc6501
4
+ data.tar.gz: 5fb4c4175f5c0729050355ee261b33d8ded8ca04
5
5
  SHA512:
6
- metadata.gz: ebc8be1e7aa00ab6ad93f5bdfd196c12709fcdf2882a6645c8e3b0d360e8c9c5dcbda806e7e01d7e10325e3ac86954c3232ac4b70f3b7afe6067387afc634f3b
7
- data.tar.gz: d89c8c9f6ea61b805ba7534fa1bbd1c25da11b069c87a780211c05e712ae9355cec71e94c2c565e34cdc87537e5aa7860fe998eccf4c512584fb8bba4babb3b7
6
+ metadata.gz: cfc2d50e1f7613163f7dfbf2d148f0f6fab804853d07eece7a28f13d4d6fe4f21a442faee757d0d5cc5bbe088b07dfc27f35e6191a2955cc0c388ac0f71cd9b5
7
+ data.tar.gz: 1a0b881e2fcf033a2e7b9d515c7cb7487672163093dbda275a0dbc5633af0025d322b6e37e07fef0b4d39113232200a542423d80f4752df65fe8d4dd23af3f61
data/lib/ovirt/api.rb CHANGED
@@ -1,9 +1,6 @@
1
1
  module Ovirt
2
2
  class Api < Base
3
-
4
- def self.parse_xml(xml)
5
- node, hash = xml_to_hash(xml)
6
-
3
+ def self.parse_node_extended(node, hash)
7
4
  parse_first_node(node, :product_info, hash,
8
5
  :node => [:name, :vendor])
9
6
 
@@ -24,8 +21,6 @@ module Ovirt
24
21
 
25
22
  # There should not be any actions defined on the api
26
23
  hash.delete(:actions) if hash[:actions].empty?
27
-
28
- hash
29
24
  end
30
25
  end
31
26
  end
data/lib/ovirt/base.rb CHANGED
@@ -77,6 +77,10 @@ module Ovirt
77
77
  end
78
78
  end
79
79
 
80
+ def self.has_first_node?(node, path)
81
+ node.xpath(path.to_s).first.present?
82
+ end
83
+
80
84
  def self.top_level_objects=(keys)
81
85
  @top_level_objects = keys
82
86
  end
@@ -117,6 +121,11 @@ module Ovirt
117
121
  @top_level_timestamps ||= []
118
122
  end
119
123
 
124
+ def self.parse_xml(xml)
125
+ node, hash = xml_to_hash(xml)
126
+ parse_node_extended(node, hash) if respond_to?(:parse_node_extended)
127
+ hash
128
+ end
120
129
 
121
130
  def self.xml_to_hash(xml)
122
131
  node = xml_to_nokogiri(xml)
@@ -248,19 +257,14 @@ module Ovirt
248
257
 
249
258
  def method_missing(m, *args)
250
259
  if @relationships.has_key?(m)
251
- rel_str = m.to_s
252
- rel_str = 'storage_domains' if rel_str == 'storagedomains'
253
- rel_str = 'data_centers' if rel_str == 'datacenters'
254
- singular = rel_str.singularize
255
- klass = Ovirt.const_get(singular.camelize)
256
- xml = @service.resource_get(@relationships[m])
257
- doc = Nokogiri::XML(xml)
258
- return doc.root.xpath(singular).collect { |node| klass.create_from_xml(@service, node) }
260
+ relationship(m)
261
+ elsif @operations.has_key?(m)
262
+ operation(m, args)
263
+ elsif @attributes.has_key?(m)
264
+ @attributes[m]
265
+ else
266
+ super
259
267
  end
260
-
261
- return operation(m, args) if @operations.has_key?(m)
262
-
263
- super
264
268
  end
265
269
 
266
270
  def operation(method, *args)
@@ -276,6 +280,21 @@ module Ovirt
276
280
  end
277
281
  end
278
282
 
283
+ def relationship(rel)
284
+ if @relationships.has_key?(rel.to_sym)
285
+ rel_str = rel.to_s
286
+ rel_str = 'storage_domains' if rel_str == 'storagedomains'
287
+ rel_str = 'data_centers' if rel_str == 'datacenters'
288
+ singular = rel_str.singularize
289
+ klass = Ovirt.const_get(singular.camelize)
290
+ xml = @service.resource_get(@relationships[rel])
291
+ doc = Nokogiri::XML(xml)
292
+ doc.root.xpath(singular).collect { |node| klass.create_from_xml(@service, node) }
293
+ else
294
+ raise "Relationship:<#{rel}> is not available for object <#{self.class.name}>"
295
+ end
296
+ end
297
+
279
298
  def destroy
280
299
  @service.resource_delete(@attributes[:href])
281
300
  end
data/lib/ovirt/cdrom.rb CHANGED
@@ -1,12 +1,5 @@
1
1
  module Ovirt
2
2
  class Cdrom < Base
3
-
4
- self.top_level_objects = [:vm, :file]
5
-
6
- def self.parse_xml(xml)
7
- node, hash = xml_to_hash(xml)
8
-
9
- hash
10
- end
3
+ self.top_level_objects = [:vm, :file]
11
4
  end
12
- end
5
+ end
data/lib/ovirt/cluster.rb CHANGED
@@ -1,12 +1,9 @@
1
1
  module Ovirt
2
2
  class Cluster < Base
3
+ self.top_level_strings = [:name, :description]
4
+ self.top_level_objects = [:data_center, :scheduling_policy]
3
5
 
4
- self.top_level_strings = [:name, :description]
5
- self.top_level_objects = [:data_center, :scheduling_policy]
6
-
7
- def self.parse_xml(xml)
8
- node, hash = xml_to_hash(xml)
9
-
6
+ def self.parse_node_extended(node, hash)
10
7
  parse_first_node(node, :cpu, hash, :attribute => [:id])
11
8
  parse_first_node(node, :version, hash, :attribute_to_i => [:major, :minor])
12
9
  parse_first_node(node, :error_handling, hash, :node => [:on_error])
@@ -16,8 +13,6 @@ module Ovirt
16
13
  :attribute_to_f => [:percent])
17
14
  parse_first_node_with_hash(node, 'memory_policy/transparent_hugepages', hash[:memory_policy][:transparent_hugepages] = {},
18
15
  :node_to_bool => [:enabled])
19
-
20
- hash
21
16
  end
22
17
 
23
18
  def find_network_by_name(network_name)
@@ -1,15 +1,12 @@
1
1
  module Ovirt
2
2
  class DataCenter < Base
3
-
4
- self.top_level_strings = [:name, :description, :storage_type, :storage_format]
3
+ self.top_level_strings = [:name, :description, :storage_type, :storage_format]
5
4
 
6
5
  def self.element_name
7
6
  "data_center"
8
7
  end
9
8
 
10
- def self.parse_xml(xml)
11
- node, hash = xml_to_hash(xml)
12
-
9
+ def self.parse_node_extended(node, hash)
13
10
  parse_first_node(node, :status, hash, :node => [:state])
14
11
  parse_first_node(node, :version, hash, :attribute_to_i => [:major, :minor])
15
12
 
@@ -17,8 +14,6 @@ module Ovirt
17
14
  supported_versions = {}
18
15
  supported_versions[:versions] = supported_versions_node.xpath('version').collect { |version_node| { :major => version_node['major'].to_i, :minor => version_node['minor'].to_i } }
19
16
  hash[:supported_versions] = supported_versions
20
-
21
- hash
22
17
  end
23
18
  end
24
19
  end
data/lib/ovirt/disk.rb CHANGED
@@ -1,14 +1,11 @@
1
1
  module Ovirt
2
2
  class Disk < Base
3
-
4
3
  self.top_level_strings = [:name, :type, :interface, :format, :image_id]
5
4
  self.top_level_booleans = [:sparse, :bootable, :wipe_after_delete, :propagate_errors]
6
5
  self.top_level_integers = [:size, :provisioned_size, :actual_size]
7
6
  self.top_level_objects = [:vm]
8
7
 
9
- def self.parse_xml(xml)
10
- node, hash = xml_to_hash(xml)
11
-
8
+ def self.parse_node_extended(node, hash)
12
9
  parse_first_node(node, :status, hash, :node => [:state])
13
10
  hash[:storage_domains] = node.xpath('storage_domains/storage_domain').collect { |n| hash_from_id_and_href(n) }
14
11
 
@@ -17,8 +14,6 @@ module Ovirt
17
14
  hash[:size] = size.text.to_i
18
15
  end
19
16
  end
20
-
21
- hash
22
17
  end
23
18
 
24
19
  def attributes_for_new_disk
data/lib/ovirt/domain.rb CHANGED
@@ -1,12 +1,5 @@
1
1
  module Ovirt
2
2
  class Domain < Base
3
-
4
- self.top_level_strings = [:name]
5
-
6
- def self.parse_xml(xml)
7
- node, hash = xml_to_hash(xml)
8
-
9
- hash
10
- end
3
+ self.top_level_strings = [:name]
11
4
  end
12
5
  end
data/lib/ovirt/event.rb CHANGED
@@ -1,15 +1,12 @@
1
1
  module Ovirt
2
2
  class Event < Base
3
-
4
3
  self.top_level_strings = [:description, :severity]
5
4
  self.top_level_integers = [:code]
6
5
  self.top_level_timestamps = [:time]
7
6
  self.top_level_objects = [:cdrom, :cluster, :data_center, :disk, :domain, :file, :group, :host, :host_nic, :network, :nic, :permission, :permit, :role, :snapshot, :storage, :storage_domain, :tag, :template, :user, :vm, :vmpool]
8
7
 
9
- def self.parse_xml(xml)
10
- node, hash = xml_to_hash(xml)
8
+ def self.parse_node_extended(_node, hash)
11
9
  set_event_name(hash)
12
- hash
13
10
  end
14
11
 
15
12
  def self.set_event_name(hash)
@@ -489,4 +486,4 @@ module Ovirt
489
486
  9501 => "TASK_CLEARING_ASYNC_TASK",
490
487
  }
491
488
  end
492
- end
489
+ end
data/lib/ovirt/file.rb CHANGED
@@ -1,13 +1,6 @@
1
1
  module Ovirt
2
2
  class File < Base
3
-
4
- self.top_level_strings = [:name]
5
- self.top_level_objects = [:storage_domain]
6
-
7
- def self.parse_xml(xml)
8
- node, hash = xml_to_hash(xml)
9
-
10
- hash
11
- end
3
+ self.top_level_strings = [:name]
4
+ self.top_level_objects = [:storage_domain]
12
5
  end
13
6
  end
data/lib/ovirt/group.rb CHANGED
@@ -1,12 +1,5 @@
1
1
  module Ovirt
2
2
  class Group < Base
3
-
4
3
  self.top_level_strings = [:name]
5
-
6
- def self.parse_xml(xml)
7
- node, hash = xml_to_hash(xml)
8
-
9
- hash
10
- end
11
4
  end
12
5
  end
data/lib/ovirt/host.rb CHANGED
@@ -1,19 +1,25 @@
1
1
  module Ovirt
2
2
  class Host < Base
3
+ self.top_level_strings = [:name, :type, :address]
4
+ self.top_level_integers = [:port, :memory, :max_scheduling_memory]
5
+ self.top_level_booleans = [:storage_manager]
6
+ self.top_level_objects = [:cluster]
3
7
 
4
- self.top_level_strings = [:name, :type, :address]
5
- self.top_level_integers = [:port]
6
- self.top_level_booleans = [:storage_manager]
7
- self.top_level_objects = [:cluster]
8
-
9
- def self.parse_xml(xml)
10
- node, hash = xml_to_hash(xml)
11
-
8
+ def self.parse_node_extended(node, hash)
12
9
  hash[:relationships][:host_nics] = hash[:relationships].delete(:nics)
13
10
 
11
+ parse_first_node(node, :certificate, hash,
12
+ :node => [:organization, :subject])
13
+
14
14
  parse_first_node(node, :status, hash,
15
15
  :node => [:state])
16
16
 
17
+ parse_first_node(node, :version, hash,
18
+ :attribute => [:major, :minor, :build, :revision, :full_version])
19
+
20
+ parse_first_node(node, :hardware_information, hash,
21
+ :node => [:manufacturer, :version, :serial_number, :product_name, :uuid, :family])
22
+
17
23
  parse_first_node(node, :power_management, hash,
18
24
  :attribute => [:type],
19
25
  :node => [:address, :username, :options],
@@ -28,17 +34,31 @@ module Ovirt
28
34
  parse_first_node(node, :iscsi, hash,
29
35
  :node => [:initiator])
30
36
 
37
+ parse_first_node(node, :ssh, hash,
38
+ :node => [:port, :fingerprint])
39
+
31
40
  parse_first_node(node, :cpu, hash,
32
41
  :node => [:name],
33
42
  :node_to_i => [:speed])
34
43
 
35
- parse_first_node_with_hash(node, 'cpu/topology', hash.store_path(:cpu, :topology, {}),
36
- :attribute_to_i => [:sockets, :cores])
44
+ if has_first_node?(node, 'cpu/topology')
45
+ parse_first_node_with_hash(node, 'cpu/topology', hash.store_path(:cpu, :topology, {}),
46
+ :attribute_to_i => [:sockets, :cores])
47
+ end
37
48
 
38
49
  parse_first_node(node, :summary, hash,
39
50
  :node_to_i => [:active, :migrating, :total])
40
51
 
41
- hash
52
+ parse_first_node(node, :os, hash,
53
+ :attribute => [:type])
54
+
55
+ if has_first_node?(node, 'os/version')
56
+ parse_first_node_with_hash(node, 'os/version', hash.store_path(:os, :version, {}),
57
+ :attribute => [:full_version])
58
+ end
59
+
60
+ parse_first_node(node, :libvirt_version, hash,
61
+ :attribute => [:major, :minor, :build, :revision, :full_version])
42
62
  end
43
63
  end
44
64
  end
@@ -1,6 +1,5 @@
1
1
  module Ovirt
2
2
  class HostNic < Base
3
-
4
3
  self.top_level_strings = [:name, :boot_protocol]
5
4
  self.top_level_integers = [:speed]
6
5
  self.top_level_objects = [:host, :network]
@@ -9,9 +8,7 @@ module Ovirt
9
8
  "host_nic"
10
9
  end
11
10
 
12
- def self.parse_xml(xml)
13
- node, hash = xml_to_hash(xml)
14
-
11
+ def self.parse_node_extended(node, hash)
15
12
  parse_first_node(node, :status, hash, :node => [:state])
16
13
  parse_first_node(node, :mac, hash, :attribute => [:address])
17
14
  parse_first_node(node, :ip, hash, :attribute => [:address, :netmask, :gateway])
@@ -31,8 +28,6 @@ module Ovirt
31
28
  hash[:bonding][:slaves][:host_nics] << {:id => slave[:id], :href => slave[:href]}
32
29
  end
33
30
  end
34
-
35
- hash
36
31
  end
37
32
  end
38
33
  end
data/lib/ovirt/network.rb CHANGED
@@ -1,16 +1,11 @@
1
1
  module Ovirt
2
2
  class Network < Base
3
-
4
3
  self.top_level_strings = [:name, :description]
5
4
  self.top_level_booleans = [:stp, :display]
6
5
  self.top_level_objects = [:data_center, :cluster, :vlan]
7
6
 
8
- def self.parse_xml(xml)
9
- node, hash = xml_to_hash(xml)
10
-
7
+ def self.parse_node_extended(node, hash)
11
8
  parse_first_node(node, :status, hash, :node => [:state])
12
-
13
- hash
14
9
  end
15
10
  end
16
11
  end
data/lib/ovirt/nic.rb CHANGED
@@ -1,16 +1,11 @@
1
1
  module Ovirt
2
2
  class Nic < Base
3
+ self.top_level_strings = [:name, :interface]
4
+ self.top_level_objects = [:vm, :network]
3
5
 
4
- self.top_level_strings = [:name, :interface]
5
- self.top_level_objects = [:vm, :network]
6
-
7
- def self.parse_xml(xml)
8
- node, hash = xml_to_hash(xml)
9
-
6
+ def self.parse_node_extended(node, hash)
10
7
  parse_first_node(node, :network, hash, :node => [:name])
11
8
  parse_first_node(node, :mac, hash, :attribute => [:address])
12
-
13
- hash
14
9
  end
15
10
 
16
11
  def attributes_for_new_nic
@@ -1,11 +1,8 @@
1
1
  module Ovirt
2
2
  class Permission < Base
3
+ self.top_level_objects = [:role, :user]
3
4
 
4
- self.top_level_objects = [:role, :user]
5
-
6
- def self.parse_xml(xml)
7
- node, hash = xml_to_hash(xml)
8
-
5
+ def self.parse_node_extended(node, hash)
9
6
  [:template].each do |type|
10
7
  subject_node = node.xpath(type.to_s).first
11
8
  next if subject_node.nil?
@@ -13,8 +10,6 @@ module Ovirt
13
10
  subject[:type] = type
14
11
  hash[:subject] = subject
15
12
  end
16
-
17
- hash
18
13
  end
19
14
  end
20
15
  end
data/lib/ovirt/permit.rb CHANGED
@@ -1,14 +1,7 @@
1
1
  module Ovirt
2
2
  class Permit < Base
3
-
4
3
  self.top_level_strings = [:name]
5
4
  self.top_level_booleans = [:administrative]
6
5
  self.top_level_objects = [:role]
7
-
8
- def self.parse_xml(xml)
9
- node, hash = xml_to_hash(xml)
10
-
11
- hash
12
- end
13
6
  end
14
7
  end
data/lib/ovirt/role.rb CHANGED
@@ -1,13 +1,6 @@
1
1
  module Ovirt
2
2
  class Role < Base
3
-
4
3
  self.top_level_strings = [:name, :description]
5
4
  self.top_level_booleans = [:administrative, :mutable]
6
-
7
- def self.parse_xml(xml)
8
- node, hash = xml_to_hash(xml)
9
-
10
- hash
11
- end
12
5
  end
13
6
  end
data/lib/ovirt/service.rb CHANGED
@@ -135,6 +135,18 @@ module Ovirt
135
135
  uri
136
136
  end
137
137
 
138
+ def self.ovirt?(options)
139
+ options[:username] = options[:password] = "_unused"
140
+ !self.new(options).engine_ssh_public_key.to_s.blank?
141
+ rescue RestClient::ResourceNotFound
142
+ false
143
+ end
144
+
145
+ def engine_ssh_public_key
146
+ require "rest-client"
147
+ RestClient::Resource.new("#{base_uri}/engine.ssh.key.txt", resource_options).get
148
+ end
149
+
138
150
  def paginate_resource_get(path = nil, sort_by=:name, direction=:asc)
139
151
  log_header = "#{self.class.name}#paginate_resource_get"
140
152
  page = 1
@@ -1,16 +1,9 @@
1
1
  module Ovirt
2
2
  class Snapshot < Base
3
-
4
3
  self.top_level_strings = [:description, :snapshot_status, :type]
5
4
  self.top_level_timestamps = [:date]
6
5
  self.top_level_objects = [:vm]
7
6
 
8
- def self.parse_xml(xml)
9
- node, hash = xml_to_hash(xml)
10
-
11
- hash
12
- end
13
-
14
7
  def initialize(service, options = {})
15
8
  super
16
9
  @relationships[:disks] = self[:href] + "/disks"
@@ -1,11 +1,8 @@
1
1
  module Ovirt
2
2
  class Statistic < Base
3
+ self.top_level_strings = [:name, :description, :type, :unit]
3
4
 
4
- self.top_level_strings = [:name, :description, :type, :unit]
5
-
6
- def self.parse_xml(xml)
7
- node, hash = xml_to_hash(xml)
8
-
5
+ def self.parse_node_extended(node, hash)
9
6
  values = []
10
7
  values_node = node.xpath('values').first
11
8
  values_type = values_node['type']
@@ -30,8 +27,6 @@ module Ovirt
30
27
  parent[:type] = type
31
28
  hash[:parent] = parent
32
29
  end
33
-
34
- hash
35
30
  end
36
31
  end
37
32
  end
data/lib/ovirt/storage.rb CHANGED
@@ -1,14 +1,9 @@
1
1
  module Ovirt
2
2
  class Storage < Base
3
+ self.top_level_objects = [:host]
3
4
 
4
- self.top_level_objects = [:host]
5
-
6
- def self.parse_xml(xml)
7
- node, hash = xml_to_hash(xml)
8
-
5
+ def self.parse_node_extended(node, hash)
9
6
  parse_first_node(node, :volume_group, hash, :attribute => [:id])
10
-
11
- hash
12
7
  end
13
8
  end
14
9
  end
@@ -1,18 +1,15 @@
1
1
  module Ovirt
2
2
  class StorageDomain < Base
3
-
4
- self.top_level_strings = [:name, :type, :storage_format]
5
- self.top_level_booleans = [:master]
6
- self.top_level_integers = [:available, :used, :committed]
7
- self.top_level_objects = [:data_center]
3
+ self.top_level_strings = [:name, :type, :storage_format]
4
+ self.top_level_booleans = [:master]
5
+ self.top_level_integers = [:available, :used, :committed]
6
+ self.top_level_objects = [:data_center]
8
7
 
9
8
  def self.element_name
10
9
  "storage_domain"
11
10
  end
12
11
 
13
- def self.parse_xml(xml)
14
- node, hash = xml_to_hash(xml)
15
-
12
+ def self.parse_node_extended(node, hash)
16
13
  parse_first_node(node, :status, hash, :node => [:state])
17
14
  parse_first_node(node, :storage, hash, :node => [:type, :address, :path])
18
15
  parse_first_node(node, :storage, hash, :attribute => [:id])
@@ -32,8 +29,6 @@ module Ovirt
32
29
  end
33
30
  end
34
31
  end
35
-
36
- hash
37
32
  end
38
33
 
39
34
  def self.iso_storage_domain(service)
data/lib/ovirt/tag.rb CHANGED
@@ -1,12 +1,9 @@
1
1
  module Ovirt
2
2
  class Tag < Base
3
-
4
3
  self.top_level_strings = [:name, :description]
5
4
  self.top_level_objects = [:host, :user, :vm]
6
5
 
7
- def self.parse_xml(xml)
8
- node, hash = xml_to_hash(xml)
9
-
6
+ def self.parse_node_extended(node, hash)
10
7
  parent_node = node.xpath('parent').first
11
8
  unless parent_node.nil?
12
9
  tag_node = parent_node.xpath('tag').first
@@ -16,8 +13,6 @@ module Ovirt
16
13
  hash[:parent] = parent
17
14
  end
18
15
  end
19
-
20
- hash
21
16
  end
22
17
  end
23
18
  end
@@ -1,20 +1,17 @@
1
1
  module Ovirt
2
2
  class Template < Base
3
-
4
3
  self.top_level_strings = [:name, :description, :type]
5
4
  self.top_level_booleans = [:stateless]
6
5
  self.top_level_integers = [:memory]
7
6
  self.top_level_timestamps = [:creation_time]
8
7
  self.top_level_objects = [:cluster]
9
8
 
10
- def self.parse_xml(xml)
11
- node, hash = xml_to_hash(xml)
12
-
9
+ def self.parse_node_extended(node, hash)
13
10
  parse_first_node(node, :status, hash, :node => [:state])
14
11
 
15
12
  parse_first_node(node, :display, hash,
16
13
  :node => [:type, :address],
17
- :node_to_i => [:port, :monitors])
14
+ :node_to_i => [:port, :monitors, :secure_port])
18
15
 
19
16
  parse_first_node(node, :usb, hash,
20
17
  :node_to_bool => [:enabled])
@@ -41,9 +38,6 @@ module Ovirt
41
38
  node.xpath('custom_properties/custom_property').each do |ca|
42
39
  hash[:custom_attributes] << {:name => ca[:name], :value => ca[:value]}
43
40
  end
44
-
45
-
46
- hash
47
41
  end
48
42
 
49
43
  def os_type
data/lib/ovirt/user.rb CHANGED
@@ -1,15 +1,11 @@
1
1
  module Ovirt
2
2
  class User < Base
3
-
4
3
  self.top_level_strings = [:name, :description, :domain, :user_name]
5
4
  self.top_level_booleans = [:logged_in]
6
5
 
7
- def self.parse_xml(xml)
8
- node, hash = xml_to_hash(xml)
6
+ def self.parse_node_extended(node, hash)
9
7
  groups_node = node.xpath('groups').first
10
8
  hash[:groups] = groups_node.xpath('group').collect { |group_node| group_node.text } unless groups_node.nil?
11
-
12
- hash
13
9
  end
14
10
  end
15
11
  end
data/lib/ovirt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ovirt
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/ovirt/vm.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  module Ovirt
2
2
  class Vm < Template
3
-
4
3
  self.top_level_strings = [:name, :origin, :type, :description]
5
4
  self.top_level_booleans = [:stateless]
6
5
  self.top_level_integers = [:memory]
data/lib/ovirt/vmpool.rb CHANGED
@@ -1,14 +1,7 @@
1
1
  module Ovirt
2
2
  class Vmpool < Base
3
-
4
- self.top_level_strings = [:name, :description]
5
- self.top_level_integers = [:size]
6
- self.top_level_objects = [:cluster, :template]
7
-
8
- def self.parse_xml(xml)
9
- node, hash = xml_to_hash(xml)
10
-
11
- hash
12
- end
3
+ self.top_level_strings = [:name, :description]
4
+ self.top_level_integers = [:size]
5
+ self.top_level_objects = [:cluster, :template]
13
6
  end
14
7
  end
data/spec/service_spec.rb CHANGED
@@ -28,6 +28,25 @@ EOX
28
28
  end
29
29
  end
30
30
 
31
+ context ".ovirt?" do
32
+ it "false when ResourceNotFound" do
33
+ described_class.any_instance.should_receive(:engine_ssh_public_key).and_raise(RestClient::ResourceNotFound)
34
+ described_class.ovirt?(:server => "127.0.0.1").should be false
35
+ end
36
+
37
+ it "true when key non-empty" do
38
+ fake_key = "ssh-rsa " + ("A" * 372) + " ovirt-engine\n"
39
+ described_class.any_instance.should_receive(:engine_ssh_public_key).and_return(fake_key)
40
+ described_class.ovirt?(:server => "127.0.0.1").should be true
41
+ end
42
+
43
+ it "false when key empty" do
44
+ fake_key = "\n"
45
+ described_class.any_instance.should_receive(:engine_ssh_public_key).and_return(fake_key)
46
+ described_class.ovirt?(:server => "127.0.0.1").should be false
47
+ end
48
+ end
49
+
31
50
  context "#base_uri" do
32
51
  let(:defaults) { {:username => nil, :password => nil}}
33
52
  subject { described_class.new(defaults.merge(@options)).send(:base_uri) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ovirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Frey
@@ -9,10 +9,11 @@ authors:
9
9
  - Keenan Brock
10
10
  - Joe Rafaniello
11
11
  - Greg Blomquist
12
+ - Martin Povolny
12
13
  autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
- date: 2015-01-22 00:00:00.000000000 Z
16
+ date: 2015-02-26 00:00:00.000000000 Z
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
18
19
  name: bundler
@@ -130,14 +131,14 @@ dependencies:
130
131
  name: rest-client
131
132
  requirement: !ruby/object:Gem::Requirement
132
133
  requirements:
133
- - - "~>"
134
+ - - ">="
134
135
  - !ruby/object:Gem::Version
135
136
  version: 1.7.2
136
137
  type: :runtime
137
138
  prerelease: false
138
139
  version_requirements: !ruby/object:Gem::Requirement
139
140
  requirements:
140
- - - "~>"
141
+ - - ">="
141
142
  - !ruby/object:Gem::Version
142
143
  version: 1.7.2
143
144
  description: Ovirt provides a simple Object Oriented interface to the REST API of
@@ -148,6 +149,7 @@ email:
148
149
  - keenan@thebrocks.net
149
150
  - jrafanie@redhat.com
150
151
  - gblomqui@redhat.com
152
+ - mpovolny@redhat.com
151
153
  executables: []
152
154
  extensions: []
153
155
  extra_rdoc_files: []