fog-ovirt 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +30 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +21 -0
- data/Gemfile +3 -0
- data/LICENSE.md +20 -0
- data/README.md +47 -0
- data/Rakefile +15 -0
- data/fog-ovirt.gemspec +32 -0
- data/lib/fog/bin/ovirt.rb +28 -0
- data/lib/fog/ovirt/compute.rb +155 -0
- data/lib/fog/ovirt/core.rb +16 -0
- data/lib/fog/ovirt/models/compute/affinity_group.rb +25 -0
- data/lib/fog/ovirt/models/compute/affinity_groups.rb +20 -0
- data/lib/fog/ovirt/models/compute/cluster.rb +20 -0
- data/lib/fog/ovirt/models/compute/clusters.rb +20 -0
- data/lib/fog/ovirt/models/compute/instance_type.rb +39 -0
- data/lib/fog/ovirt/models/compute/instance_types.rb +20 -0
- data/lib/fog/ovirt/models/compute/interface.rb +19 -0
- data/lib/fog/ovirt/models/compute/interfaces.rb +29 -0
- data/lib/fog/ovirt/models/compute/quota.rb +16 -0
- data/lib/fog/ovirt/models/compute/quotas.rb +20 -0
- data/lib/fog/ovirt/models/compute/server.rb +175 -0
- data/lib/fog/ovirt/models/compute/servers.rb +27 -0
- data/lib/fog/ovirt/models/compute/template.rb +58 -0
- data/lib/fog/ovirt/models/compute/templates.rb +20 -0
- data/lib/fog/ovirt/models/compute/volume.rb +36 -0
- data/lib/fog/ovirt/models/compute/volumes.rb +28 -0
- data/lib/fog/ovirt/requests/compute/activate_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/add_interface.rb +20 -0
- data/lib/fog/ovirt/requests/compute/add_to_affinity_group.rb +21 -0
- data/lib/fog/ovirt/requests/compute/add_volume.rb +21 -0
- data/lib/fog/ovirt/requests/compute/attach_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/create_affinity_group.rb +18 -0
- data/lib/fog/ovirt/requests/compute/create_vm.rb +18 -0
- data/lib/fog/ovirt/requests/compute/datacenters.rb +20 -0
- data/lib/fog/ovirt/requests/compute/deactivate_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/destroy_affinity_group.rb +19 -0
- data/lib/fog/ovirt/requests/compute/destroy_interface.rb +22 -0
- data/lib/fog/ovirt/requests/compute/destroy_vm.rb +19 -0
- data/lib/fog/ovirt/requests/compute/destroy_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/detach_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/get_affinity_group.rb +18 -0
- data/lib/fog/ovirt/requests/compute/get_api_version.rb +16 -0
- data/lib/fog/ovirt/requests/compute/get_cluster.rb +17 -0
- data/lib/fog/ovirt/requests/compute/get_instance_type.rb +17 -0
- data/lib/fog/ovirt/requests/compute/get_quota.rb +17 -0
- data/lib/fog/ovirt/requests/compute/get_template.rb +17 -0
- data/lib/fog/ovirt/requests/compute/get_virtual_machine.rb +17 -0
- data/lib/fog/ovirt/requests/compute/list_affinity_group_vms.rb +22 -0
- data/lib/fog/ovirt/requests/compute/list_affinity_groups.rb +20 -0
- data/lib/fog/ovirt/requests/compute/list_clusters.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_instance_types.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_networks.rb +16 -0
- data/lib/fog/ovirt/requests/compute/list_quotas.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_template_interfaces.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_template_volumes.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_templates.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_virtual_machines.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_vm_interfaces.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_vm_volumes.rb +19 -0
- data/lib/fog/ovirt/requests/compute/list_volumes.rb +19 -0
- data/lib/fog/ovirt/requests/compute/mock_files/affinitygroup.xml +8 -0
- data/lib/fog/ovirt/requests/compute/mock_files/affinitygroup_vms.xml +9 -0
- data/lib/fog/ovirt/requests/compute/mock_files/affinitygroups.xml +17 -0
- data/lib/fog/ovirt/requests/compute/mock_files/cluster.xml +20 -0
- data/lib/fog/ovirt/requests/compute/mock_files/clusters.xml +39 -0
- data/lib/fog/ovirt/requests/compute/mock_files/data_centers.xml +17 -0
- data/lib/fog/ovirt/requests/compute/mock_files/disks.xml +58 -0
- data/lib/fog/ovirt/requests/compute/mock_files/instance_type.xml +42 -0
- data/lib/fog/ovirt/requests/compute/mock_files/instance_types.xml +197 -0
- data/lib/fog/ovirt/requests/compute/mock_files/nics.xml +10 -0
- data/lib/fog/ovirt/requests/compute/mock_files/quotas.xml +7 -0
- data/lib/fog/ovirt/requests/compute/mock_files/storage_domains.xml +36 -0
- data/lib/fog/ovirt/requests/compute/mock_files/template.xml +39 -0
- data/lib/fog/ovirt/requests/compute/mock_files/templates.xml +110 -0
- data/lib/fog/ovirt/requests/compute/mock_files/vm.xml +52 -0
- data/lib/fog/ovirt/requests/compute/mock_files/vms.xml +152 -0
- data/lib/fog/ovirt/requests/compute/mock_files/volumes.xml +40 -0
- data/lib/fog/ovirt/requests/compute/remove_from_affinity_group.rb +21 -0
- data/lib/fog/ovirt/requests/compute/storage_domains.rb +20 -0
- data/lib/fog/ovirt/requests/compute/update_interface.rb +35 -0
- data/lib/fog/ovirt/requests/compute/update_vm.rb +18 -0
- data/lib/fog/ovirt/requests/compute/update_volume.rb +39 -0
- data/lib/fog/ovirt/requests/compute/vm_action.rb +22 -0
- data/lib/fog/ovirt/requests/compute/vm_start_with_cloudinit.rb +19 -0
- data/lib/fog/ovirt/requests/compute/vm_ticket.rb +17 -0
- data/lib/fog/ovirt/version.rb +5 -0
- data/lib/fog/ovirt.rb +1 -0
- data/spec/fog/bin/ovirt_spec.rb +10 -0
- data/spec/fog/bin_spec.rb +32 -0
- data/tests/helper.rb +1 -0
- data/tests/helpers/mock_helper.rb +16 -0
- data/tests/helpers/succeeds_helper.rb +9 -0
- data/tests/ovirt/compute_tests.rb +25 -0
- data/tests/ovirt/models/compute/cluster_tests.rb +31 -0
- data/tests/ovirt/models/compute/clusters_tests.rb +9 -0
- data/tests/ovirt/models/compute/interface_tests.rb +27 -0
- data/tests/ovirt/models/compute/interfaces_tests.rb +9 -0
- data/tests/ovirt/models/compute/server_tests.rb +51 -0
- data/tests/ovirt/models/compute/servers_tests.rb +14 -0
- data/tests/ovirt/models/compute/template_tests.rb +28 -0
- data/tests/ovirt/models/compute/templates_tests.rb +9 -0
- data/tests/ovirt/requests/compute/create_vm_tests.rb +26 -0
- data/tests/ovirt/requests/compute/destroy_vm_tests.rb +18 -0
- data/tests/ovirt/requests/compute/list_datacenters_tests.rb +13 -0
- data/tests/ovirt/requests/compute/list_quotas_tests.rb +12 -0
- data/tests/ovirt/requests/compute/list_storage_domains_tests.rb +13 -0
- data/tests/ovirt/requests/compute/update_vm_tests.rb +18 -0
- data/tests/ovirt/requests/compute/update_volume_tests.rb +20 -0
- metadata +298 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bc52a94f5d8a1853ec82917020fb19675199d879
|
4
|
+
data.tar.gz: 7db52539a92ec7434d74b55dd3bca1cc2836d506
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e15a97d9edaab2e3faa45b6ce593af20be206b0e826bb658166d9a089436e6d68d24a6b1ad1305c86f247b53153b5c341dcba164ec619735a88fe337cada518a
|
7
|
+
data.tar.gz: b94bfcb40da72705457decf083c852d13e6b13421cf2e3a324cb067ef11cd23f2da59f265900767c413166a1b08166046bb4be1c501d327adfa2d01c69ec9275
|
data/.gitignore
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
*~
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
*.sw?
|
5
|
+
.rbenv
|
6
|
+
.rvmrc
|
7
|
+
.ruby-gemset
|
8
|
+
.ruby-version
|
9
|
+
.bundle
|
10
|
+
.DS_Store
|
11
|
+
.idea
|
12
|
+
.yardoc
|
13
|
+
/tests/.fog
|
14
|
+
bin/*
|
15
|
+
!bin/fog
|
16
|
+
.fog
|
17
|
+
coverage
|
18
|
+
doc/*
|
19
|
+
docs/_site/*
|
20
|
+
docs/about/supported_services.markdown
|
21
|
+
Gemfile.lock
|
22
|
+
gemfiles/*.lock
|
23
|
+
yardoc
|
24
|
+
pkg
|
25
|
+
spec/credentials.yml
|
26
|
+
vendor/*
|
27
|
+
tags
|
28
|
+
tests/digitalocean/fixtures/
|
29
|
+
|
30
|
+
providers/*/doc
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
## Getting Involved
|
2
|
+
|
3
|
+
New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
|
4
|
+
|
5
|
+
### Coding
|
6
|
+
|
7
|
+
* Pick a task:
|
8
|
+
* Offer feedback on open [pull requests](https://github.com/fog/fog-ovirt/pulls).
|
9
|
+
* Review open [issues](https://github.com/fog/fog-ovirt/issues) for things to help on.
|
10
|
+
* [Create an issue](https://github.com/fog/fog-ovirt/issues/new) to start a discussion on additions or features.
|
11
|
+
* Fork the project, add your changes and tests to cover them in a topic branch.
|
12
|
+
* Commit your changes and rebase against `fog/fog-ovirt` to ensure everything is up to date.
|
13
|
+
* [Submit a pull request](https://github.com/fog/fog-ovirt/compare/)
|
14
|
+
|
15
|
+
### Non-Coding
|
16
|
+
|
17
|
+
* Offer feedback on open [issues](https://github.com/fog/fog-ovirt/issues).
|
18
|
+
* Organize or volunteer at events.
|
data/CONTRIBUTORS.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
* Amos Benari <abenari@redhat.com>
|
2
|
+
* Baptiste Agasse <baptiste.agasse@lyra-network.com>
|
3
|
+
* Bert Hajee <hajee@moretIA.com>
|
4
|
+
* Dan Peterson <dpiddy@gmail.com>
|
5
|
+
* Erik van Pienbroek <erik.vanpienbroek@prorail.nl>
|
6
|
+
* Evan J. Felix <evan.felix@pnnl.gov>
|
7
|
+
* Ilja Bobkevic <ilja.bobkevic@unibet.com>
|
8
|
+
* Ivan Nečas <inecas@redhat.com>
|
9
|
+
* James Herdman <james.herdman@me.com>
|
10
|
+
* Jason Montleon <jmontleo@redhat.com>
|
11
|
+
* Jesse Hallett <jesse@galois.com>
|
12
|
+
* karmab <karimboumedhel@gmail.com>
|
13
|
+
* Lance Ivy <lance@cainlevy.net>
|
14
|
+
* Matt Darby <matt.darby@rackspace.com>
|
15
|
+
* Ohad Levy <ohadlevy@redhat.com>
|
16
|
+
* Paul Thornthwaite <paul@brightbox.co.uk>
|
17
|
+
* Paul Thornthwaite <tokengeek@gmail.com>
|
18
|
+
* Pavol Dilung <pavol.dilung@gmail.com>
|
19
|
+
* Tom Caspy <tcaspy@gmail.com>
|
20
|
+
* Ori Rabin <orabin@redhat.com>
|
21
|
+
* Wesley Beary <geemus@gmail.com>
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2009-2016 [CONTRIBUTORS.md](CONTRIBUTORS.md)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Fog::Ovirt
|
2
|
+
|
3
|
+
fog-ovirt is an ovirt provider for [fog](https://github.com/fog/fog).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fog-ovirt'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fog-ovirt
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Require the gem:
|
24
|
+
```ruby
|
25
|
+
require 'fog/ovirt'
|
26
|
+
```
|
27
|
+
|
28
|
+
Connect to ovirt instance:
|
29
|
+
```ruby
|
30
|
+
|
31
|
+
compute = Fog::Compute.new(
|
32
|
+
:provider => "ovirt",
|
33
|
+
:ovirt_username => user,
|
34
|
+
:ovirt_password => password,
|
35
|
+
:ovirt_url => url,
|
36
|
+
:ovirt_datacenter => uuid,
|
37
|
+
:ovirt_ca_cert_store => ca_cert_store
|
38
|
+
)
|
39
|
+
```
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Please refer to [CONTRIBUTING.md](CONTRIBUTING.md).
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
Please refer to [LICENSE.md](LICENSE.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
# require 'rake/testtask'
|
3
|
+
|
4
|
+
# Rake::TestTask.new do |t|
|
5
|
+
# t.libs << 'spec/'
|
6
|
+
# t.test_files = Rake::FileList['spec/**/*_spec.rb']
|
7
|
+
# t.verbose = true
|
8
|
+
# end
|
9
|
+
|
10
|
+
mock = ENV['FOG_MOCK'] || 'true'
|
11
|
+
task :test do
|
12
|
+
sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/ovirt")
|
13
|
+
end
|
14
|
+
|
15
|
+
task(:default => [:test])
|
data/fog-ovirt.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fog/ovirt/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'fog-ovirt'
|
8
|
+
spec.version = Fog::Ovirt::VERSION
|
9
|
+
spec.authors = ['Ori Rabin']
|
10
|
+
spec.email = ['orabin@redhat.com']
|
11
|
+
|
12
|
+
spec.summary = "Module for the 'fog' gem to support Ovirt."
|
13
|
+
spec.description = 'This library can be used as a module for `fog`.'
|
14
|
+
spec.homepage = 'https://github.com/fog/fog-ovirt'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.test_files = spec.files.grep(%r{^tests\/})
|
19
|
+
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency("fog-core", "~> 1.45")
|
23
|
+
spec.add_dependency("fog-json")
|
24
|
+
spec.add_dependency("fog-xml", "~> 0.1.1")
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
27
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rubocop', '~> 0.34'
|
30
|
+
spec.add_development_dependency 'shindo', '~> 0.3'
|
31
|
+
spec.add_development_dependency("rbovirt", "0.1.3")
|
32
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Ovirt < Fog::Bin
|
2
|
+
class << self
|
3
|
+
def class_for(key)
|
4
|
+
case key
|
5
|
+
when :compute
|
6
|
+
Fog::Compute::Ovirt
|
7
|
+
else
|
8
|
+
raise ArgumentError, "Unrecognized service: #{key}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def [](service)
|
13
|
+
@@connections ||= Hash.new do |hash, key|
|
14
|
+
hash[key] = case key
|
15
|
+
when :compute
|
16
|
+
Fog::Compute.new(:provider => 'Ovirt')
|
17
|
+
else
|
18
|
+
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
@@connections[service]
|
22
|
+
end
|
23
|
+
|
24
|
+
def services
|
25
|
+
Fog::Ovirt.services
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'fog/ovirt/core'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class Ovirt < Fog::Service
|
6
|
+
requires :ovirt_username, :ovirt_password
|
7
|
+
recognizes :ovirt_url, :ovirt_server, :ovirt_port, :ovirt_api_path, :ovirt_datacenter,
|
8
|
+
:ovirt_filtered_api,
|
9
|
+
:ovirt_ca_cert_store, :ovirt_ca_cert_file, :ovirt_ca_no_verify
|
10
|
+
|
11
|
+
model_path 'fog/ovirt/models/compute'
|
12
|
+
model :server
|
13
|
+
collection :servers
|
14
|
+
model :template
|
15
|
+
collection :templates
|
16
|
+
model :instance_type
|
17
|
+
collection :instance_types
|
18
|
+
model :cluster
|
19
|
+
collection :clusters
|
20
|
+
model :interface
|
21
|
+
collection :interfaces
|
22
|
+
model :volume
|
23
|
+
collection :volumes
|
24
|
+
model :quota
|
25
|
+
collection :quotas
|
26
|
+
model :affinity_group
|
27
|
+
collection :affinity_groups
|
28
|
+
|
29
|
+
request_path 'fog/ovirt/requests/compute'
|
30
|
+
|
31
|
+
request :vm_action
|
32
|
+
request :vm_start_with_cloudinit
|
33
|
+
request :destroy_vm
|
34
|
+
request :create_vm
|
35
|
+
request :update_vm
|
36
|
+
request :datacenters
|
37
|
+
request :storage_domains
|
38
|
+
request :list_virtual_machines
|
39
|
+
request :get_virtual_machine
|
40
|
+
request :list_templates
|
41
|
+
request :get_template
|
42
|
+
request :list_instance_types
|
43
|
+
request :get_instance_type
|
44
|
+
request :list_clusters
|
45
|
+
request :get_cluster
|
46
|
+
request :add_interface
|
47
|
+
request :destroy_interface
|
48
|
+
request :update_interface
|
49
|
+
request :list_vm_interfaces
|
50
|
+
request :list_template_interfaces
|
51
|
+
request :list_networks
|
52
|
+
request :vm_ticket
|
53
|
+
request :list_vm_volumes
|
54
|
+
request :list_template_volumes
|
55
|
+
request :list_volumes
|
56
|
+
request :add_volume
|
57
|
+
request :destroy_volume
|
58
|
+
request :update_volume
|
59
|
+
request :attach_volume
|
60
|
+
request :detach_volume
|
61
|
+
request :activate_volume
|
62
|
+
request :deactivate_volume
|
63
|
+
request :get_api_version
|
64
|
+
request :list_quotas
|
65
|
+
request :get_quota
|
66
|
+
request :list_affinity_groups
|
67
|
+
request :get_affinity_group
|
68
|
+
request :list_affinity_group_vms
|
69
|
+
request :create_affinity_group
|
70
|
+
request :destroy_affinity_group
|
71
|
+
request :add_to_affinity_group
|
72
|
+
request :remove_from_affinity_group
|
73
|
+
|
74
|
+
module Shared
|
75
|
+
# converts an OVIRT object into an hash for fog to consume.
|
76
|
+
def ovirt_attrs obj
|
77
|
+
opts = {:raw => obj}
|
78
|
+
obj.instance_variables.each do |v|
|
79
|
+
key = v.to_s.gsub("@","").to_sym
|
80
|
+
value = obj.instance_variable_get(v)
|
81
|
+
#ignore nil values
|
82
|
+
next if value.nil?
|
83
|
+
|
84
|
+
opts[key] = case value
|
85
|
+
when OVIRT::Link
|
86
|
+
value.id
|
87
|
+
when OVIRT::TemplateVersion
|
88
|
+
value
|
89
|
+
when Array
|
90
|
+
value
|
91
|
+
when Hash
|
92
|
+
value
|
93
|
+
else
|
94
|
+
value.to_s.strip
|
95
|
+
end
|
96
|
+
end
|
97
|
+
opts
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class Mock
|
102
|
+
include Shared
|
103
|
+
|
104
|
+
def initialize(options={})
|
105
|
+
require 'rbovirt'
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def client
|
111
|
+
return @client if defined?(@client)
|
112
|
+
end
|
113
|
+
|
114
|
+
#read mocks xml
|
115
|
+
def read_xml(file_name)
|
116
|
+
file_path = File.join(File.dirname(__FILE__),"requests","compute","mock_files",file_name)
|
117
|
+
File.read(file_path)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
class Real
|
122
|
+
include Shared
|
123
|
+
|
124
|
+
def initialize(options={})
|
125
|
+
require 'rbovirt'
|
126
|
+
username = options[:ovirt_username]
|
127
|
+
password = options[:ovirt_password]
|
128
|
+
server = options[:ovirt_server]
|
129
|
+
port = options[:ovirt_port] || 8080
|
130
|
+
api_path = options[:ovirt_api_path] || '/api'
|
131
|
+
url = options[:ovirt_url] || "#{@scheme}://#{server}:#{port}#{api_path}"
|
132
|
+
|
133
|
+
connection_opts = {}
|
134
|
+
connection_opts[:datacenter_id] = options[:ovirt_datacenter]
|
135
|
+
connection_opts[:ca_cert_store] = options[:ovirt_ca_cert_store]
|
136
|
+
connection_opts[:ca_cert_file] = options[:ovirt_ca_cert_file]
|
137
|
+
connection_opts[:ca_no_verify] = options[:ovirt_ca_no_verify]
|
138
|
+
connection_opts[:filtered_api] = options[:ovirt_filtered_api]
|
139
|
+
|
140
|
+
@client = OVIRT::Client.new(username, password, url, connection_opts)
|
141
|
+
end
|
142
|
+
|
143
|
+
def api_version
|
144
|
+
client.api_version
|
145
|
+
end
|
146
|
+
|
147
|
+
private
|
148
|
+
|
149
|
+
def client
|
150
|
+
@client
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fog/core'
|
2
|
+
require 'fog/xml'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Ovirt
|
6
|
+
extend Fog::Provider
|
7
|
+
|
8
|
+
module Errors
|
9
|
+
class ServiceError < Fog::Errors::Error; end
|
10
|
+
class SecurityError < ServiceError; end
|
11
|
+
class NotFound < ServiceError; end
|
12
|
+
end
|
13
|
+
|
14
|
+
service(:compute, 'Compute')
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class AffinityGroup < Fog::Model
|
5
|
+
identity :id
|
6
|
+
|
7
|
+
attribute :name
|
8
|
+
attribute :positive
|
9
|
+
attribute :enforcing
|
10
|
+
|
11
|
+
def vms
|
12
|
+
id.nil? ? [] : service.list_affinity_group_vms(id)
|
13
|
+
end
|
14
|
+
|
15
|
+
def destroy
|
16
|
+
service.destroy_affinity_group(id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/ovirt/models/compute/affinity_group'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Ovirt
|
7
|
+
class AffinityGroups < Fog::Collection
|
8
|
+
model Fog::Compute::Ovirt::AffinityGroup
|
9
|
+
|
10
|
+
def all(filters = {})
|
11
|
+
load service.list_affinity_groups(filters)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
new service.get_affinity_group(id)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/ovirt/models/compute/cluster'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Ovirt
|
7
|
+
class Clusters < Fog::Collection
|
8
|
+
model Fog::Compute::Ovirt::Cluster
|
9
|
+
|
10
|
+
def all(filters = {})
|
11
|
+
load service.list_clusters(filters)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
new service.get_cluster(id)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class InstanceType < Fog::Model
|
5
|
+
identity :id
|
6
|
+
|
7
|
+
attr_accessor :raw
|
8
|
+
|
9
|
+
attribute :name
|
10
|
+
attribute :description
|
11
|
+
attribute :memory
|
12
|
+
attribute :cores
|
13
|
+
attribute :creation_time
|
14
|
+
attribute :os
|
15
|
+
attribute :ha
|
16
|
+
attribute :ha_priority
|
17
|
+
attribute :display
|
18
|
+
attribute :usb
|
19
|
+
attribute :migration_downtime
|
20
|
+
attribute :type
|
21
|
+
attribute :status
|
22
|
+
attribute :cpu_shares
|
23
|
+
attribute :boot_menu
|
24
|
+
attribute :origin
|
25
|
+
attribute :stateless
|
26
|
+
attribute :delete_protected
|
27
|
+
attribute :sso
|
28
|
+
attribute :timezone
|
29
|
+
attribute :migration
|
30
|
+
attribute :io_threads
|
31
|
+
attribute :memory_garanteed
|
32
|
+
|
33
|
+
def to_s
|
34
|
+
name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/ovirt/models/compute/instance_type'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Ovirt
|
7
|
+
class InstanceTypes < Fog::Collection
|
8
|
+
model Fog::Compute::Ovirt::InstanceType
|
9
|
+
|
10
|
+
def all(filters = {})
|
11
|
+
load service.list_instance_types(filters)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
new service.get_instance_type(id)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class Interface < Fog::Model
|
5
|
+
attr_accessor :raw
|
6
|
+
identity :id
|
7
|
+
|
8
|
+
attribute :name
|
9
|
+
attribute :network
|
10
|
+
attribute :interface
|
11
|
+
attribute :mac
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/ovirt/models/compute/interface'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Ovirt
|
7
|
+
class Interfaces < Fog::Collection
|
8
|
+
model Fog::Compute::Ovirt::Interface
|
9
|
+
|
10
|
+
attr_accessor :vm
|
11
|
+
|
12
|
+
def all(filters = {})
|
13
|
+
requires :vm
|
14
|
+
if vm.is_a? Fog::Compute::Ovirt::Server
|
15
|
+
load service.list_vm_interfaces(vm.id)
|
16
|
+
elsif vm.is_a? Fog::Compute::Ovirt::Template
|
17
|
+
load service.list_template_interfaces(vm.id)
|
18
|
+
else
|
19
|
+
raise 'interfaces should have vm or template'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(id)
|
24
|
+
new service.get_interface(id)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/ovirt/models/compute/quota'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Ovirt
|
7
|
+
class Quotas < Fog::Collection
|
8
|
+
model Fog::Compute::Ovirt::Quota
|
9
|
+
|
10
|
+
def all(filters = {})
|
11
|
+
load service.list_quotas(filters)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
new service.get_quota(id)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|