ovirt 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODE2N2E3Mzk0NmQwNWI0MmViZjZjNzhiMDIyNzFkNjhlMTcyMzdjNg==
5
+ data.tar.gz: !binary |-
6
+ Y2Q3NGQzOGFkZTM2YTU4NjE0NmY4ZDU1YjljZGMwNWI5NmVjZDJkMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NzU3MDYzYjBjNzNlYjc4YmM2MWUxMDEzOTI5ZmFjNmQyYzVkY2E5YTFiMTA2
10
+ NmZkNWExOWI5ZjVmNTBmMjZmMjg2YmQxMDJlNDMzNGI0MDBmN2I2NDFlMjlj
11
+ NTQ1MWNkMjgxZGVjZjg2MDQ1MDQ0YmEyZjYzYjdmNGQ1MjUyZjI=
12
+ data.tar.gz: !binary |-
13
+ YWYxNDQzYjE5ODIwYjFkYjEyNWIyYzdhMzFlZGM1OGNiNjU4N2VkZjk1ZTVj
14
+ NzgzZTlmYWNhZTUzYTMxNWYwMGRmNjMzNzVmOTc4M2NjYjUxOTZhZjc3OWRj
15
+ OGEzN2QxYWZiYjk3Mzc0MDhmMDQ5OWQzNzA2YTkzNzk4YWNlNTE=
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2014 Red Hat, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Ovirt
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/ovirt.svg)](http://badge.fury.io/rb/ovirt)
4
+ [![Build Status](https://travis-ci.org/ManageIQ/ovirt.svg)](https://travis-ci.org/ManageIQ/ovirt)
5
+ [![Code Climate](https://codeclimate.com/github/ManageIQ/ovirt.svg)](https://codeclimate.com/github/ManageIQ/ovirt)
6
+ [![Coverage Status](http://img.shields.io/coveralls/ManageIQ/ovirt.svg)](https://coveralls.io/r/ManageIQ/ovirt)
7
+ [![Dependency Status](https://gemnasium.com/ManageIQ/ovirt.svg)](https://gemnasium.com/ManageIQ/ovirt)
8
+
9
+ Ovirt provides a simple Object Oriented interface to the REST API of oVirt and RHEV-M servers.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'ovirt'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install ovirt
24
+
25
+ ## Usage
26
+
27
+ See [examples](https://github.com/ManageIQ/ovirt/tree/master/examples) directory for usage examples.
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
data/lib/ovirt/api.rb ADDED
@@ -0,0 +1,31 @@
1
+ module Ovirt
2
+ class Api < Object
3
+
4
+ def self.parse_xml(xml)
5
+ node, hash = xml_to_hash(xml)
6
+
7
+ parse_first_node(node, :product_info, hash,
8
+ :node => [:name, :vendor])
9
+
10
+ parse_first_node_with_hash(node, 'product_info/version', hash[:product_info][:version] = {},
11
+ :attribute => [:major, :minor, :build, :revision])
12
+
13
+ hash[:summary] = {}
14
+ [:vms, :hosts, :users, :storage_domains].each do |type|
15
+ parse_first_node_with_hash(node, "summary/#{type}", hash[:summary][type] = {},
16
+ :node_to_i => [:total, :active])
17
+ end
18
+
19
+ hash[:special_objects] = {}
20
+ node.xpath('special_objects/link').each do |link|
21
+ hash[:special_objects][link['rel'].to_sym] = link['href']
22
+ end
23
+
24
+
25
+ # There should not be any actions defined on the api
26
+ hash.delete(:actions) if hash[:actions].empty?
27
+
28
+ hash
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ module Ovirt
2
+ class Cdrom < Object
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
11
+ end
12
+ end
@@ -0,0 +1,27 @@
1
+ module Ovirt
2
+ class Cluster < Object
3
+
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
+
10
+ parse_first_node(node, :cpu, hash, :attribute => [:id])
11
+ parse_first_node(node, :version, hash, :attribute_to_i => [:major, :minor])
12
+ parse_first_node(node, :error_handling, hash, :node => [:on_error])
13
+
14
+ hash[:memory_policy] = {}
15
+ parse_first_node_with_hash(node, 'memory_policy/overcommit', hash[:memory_policy][:overcommit] = {},
16
+ :attribute_to_f => [:percent])
17
+ parse_first_node_with_hash(node, 'memory_policy/transparent_hugepages', hash[:memory_policy][:transparent_hugepages] = {},
18
+ :node_to_bool => [:enabled])
19
+
20
+ hash
21
+ end
22
+
23
+ def find_network_by_name(network_name)
24
+ self.networks.detect { |n| n[:name] == network_name }
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,24 @@
1
+ module Ovirt
2
+ class DataCenter < Object
3
+
4
+ self.top_level_strings = [:name, :description, :storage_type, :storage_format]
5
+
6
+ def self.element_name
7
+ "data_center"
8
+ end
9
+
10
+ def self.parse_xml(xml)
11
+ node, hash = xml_to_hash(xml)
12
+
13
+ parse_first_node(node, :status, hash, :node => [:state])
14
+ parse_first_node(node, :version, hash, :attribute_to_i => [:major, :minor])
15
+
16
+ supported_versions_node = node.xpath('supported_versions').first
17
+ supported_versions = {}
18
+ supported_versions[:versions] = supported_versions_node.xpath('version').collect { |version_node| { :major => version_node['major'].to_i, :minor => version_node['minor'].to_i } }
19
+ hash[:supported_versions] = supported_versions
20
+
21
+ hash
22
+ end
23
+ end
24
+ end
data/lib/ovirt/disk.rb ADDED
@@ -0,0 +1,30 @@
1
+ module Ovirt
2
+ class Disk < Object
3
+
4
+ self.top_level_strings = [:name, :type, :interface, :format, :image_id]
5
+ self.top_level_booleans = [:sparse, :bootable, :wipe_after_delete, :propagate_errors]
6
+ self.top_level_integers = [:size, :provisioned_size, :actual_size]
7
+ self.top_level_objects = [:vm]
8
+
9
+ def self.parse_xml(xml)
10
+ node, hash = xml_to_hash(xml)
11
+
12
+ parse_first_node(node, :status, hash, :node => [:state])
13
+ hash[:storage_domains] = node.xpath('storage_domains/storage_domain').collect { |n| hash_from_id_and_href(n) }
14
+
15
+ if hash[:size].to_i.zero?
16
+ node.xpath('lun_storage/logical_unit/size').each do |size|
17
+ hash[:size] = size.text.to_i
18
+ end
19
+ end
20
+
21
+ hash
22
+ end
23
+
24
+ def attributes_for_new_disk
25
+ attrs = attributes.dup
26
+ attrs[:storage] = self[:storage_domains].first[:id]
27
+ attrs
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ module Ovirt
2
+ class Domain < Object
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
11
+ end
12
+ end