fog-opennebula 0.0.1
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 +7 -0
- data/.gitignore +32 -0
- data/CONTRIBUTORS.md +4 -0
- data/Gemfile +9 -0
- data/LICENSE.md +20 -0
- data/README.md +95 -0
- data/Rakefile +118 -0
- data/fog-opennebula.gemspec +35 -0
- data/lib/fog/bin/opennebula.rb +32 -0
- data/lib/fog/opennebula.rb +30 -0
- data/lib/fog/opennebula/compute.rb +136 -0
- data/lib/fog/opennebula/models/compute/flavor.rb +190 -0
- data/lib/fog/opennebula/models/compute/flavors.rb +46 -0
- data/lib/fog/opennebula/models/compute/group.rb +28 -0
- data/lib/fog/opennebula/models/compute/groups.rb +38 -0
- data/lib/fog/opennebula/models/compute/interface.rb +39 -0
- data/lib/fog/opennebula/models/compute/interfaces.rb +20 -0
- data/lib/fog/opennebula/models/compute/network.rb +48 -0
- data/lib/fog/opennebula/models/compute/networks.rb +42 -0
- data/lib/fog/opennebula/models/compute/server.rb +85 -0
- data/lib/fog/opennebula/models/compute/servers.rb +33 -0
- data/lib/fog/opennebula/requests/compute/OpenNebulaVNC.rb +314 -0
- data/lib/fog/opennebula/requests/compute/get_vnc_console.rb +58 -0
- data/lib/fog/opennebula/requests/compute/image_pool.rb +33 -0
- data/lib/fog/opennebula/requests/compute/list_groups.rb +87 -0
- data/lib/fog/opennebula/requests/compute/list_networks.rb +79 -0
- data/lib/fog/opennebula/requests/compute/list_vms.rb +79 -0
- data/lib/fog/opennebula/requests/compute/template_pool.rb +120 -0
- data/lib/fog/opennebula/requests/compute/vm_allocate.rb +97 -0
- data/lib/fog/opennebula/requests/compute/vm_destroy.rb +39 -0
- data/lib/fog/opennebula/requests/compute/vm_disk_snapshot.rb +33 -0
- data/lib/fog/opennebula/requests/compute/vm_resume.rb +35 -0
- data/lib/fog/opennebula/requests/compute/vm_shutdown.rb +22 -0
- data/lib/fog/opennebula/requests/compute/vm_stop.rb +21 -0
- data/lib/fog/opennebula/requests/compute/vm_suspend.rb +38 -0
- data/lib/fog/opennebula/version.rb +9 -0
- data/tests/opennebula/compute_tests.rb +15 -0
- data/tests/opennebula/models/compute/flavor_tests.rb +34 -0
- data/tests/opennebula/models/compute/flavors_tests.rb +15 -0
- data/tests/opennebula/models/compute/group_tests.rb +25 -0
- data/tests/opennebula/models/compute/groups_tests.rb +14 -0
- data/tests/opennebula/models/compute/network_tests.rb +24 -0
- data/tests/opennebula/models/compute/networks_tests.rb +14 -0
- data/tests/opennebula/requests/compute/vm_allocate_tests.rb +70 -0
- data/tests/opennebula/requests/compute/vm_disk_snapshot_test.rb +44 -0
- data/tests/opennebula/requests/compute/vm_suspend_resume_tests.rb +45 -0
- metadata +243 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 91f7c89f1c1a67bc78c09c3fa62f80308d70588fcbe0d52cb40d4d85f3594f32
|
4
|
+
data.tar.gz: 66e522e954df4fefbc66b5c690c4c66016cdee20dd93bdc7a444528e20e6a378
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f19e806fedf93d1f02bf7aa403f300350e3f7a9d03452867571f9f2f993215d133734b64dff569bd53523c245db8f0ff9838c9591e0ad6eb3b0dd25a82c8595f
|
7
|
+
data.tar.gz: '01779ecf25b666db8646e86e012fffeee7cdae48d20b46c0dfe4448b1871895d51b2605d62743320d08cfa4b7ba67dd1b6509871174d4b879ccc942eaf130062'
|
data/.gitignore
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
*~
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
*.sw?
|
5
|
+
.rbenv
|
6
|
+
.rvmrc
|
7
|
+
.bundle
|
8
|
+
.DS_Store
|
9
|
+
.idea
|
10
|
+
.yardoc
|
11
|
+
/tests/.fog
|
12
|
+
bin/*
|
13
|
+
!bin/fog
|
14
|
+
.fog
|
15
|
+
coverage
|
16
|
+
doc/*
|
17
|
+
docs/_site/*
|
18
|
+
docs/about/supported_services.markdown
|
19
|
+
Gemfile.lock
|
20
|
+
gemfiles/*.lock
|
21
|
+
yardoc
|
22
|
+
pkg
|
23
|
+
spec/credentials.yml
|
24
|
+
vendor/*
|
25
|
+
tags
|
26
|
+
tests/digitalocean/fixtures/
|
27
|
+
|
28
|
+
providers/*/doc
|
29
|
+
build.sh
|
30
|
+
fog-opennebula-test.rb
|
31
|
+
.directory
|
32
|
+
.vscode
|
data/CONTRIBUTORS.md
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 [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,95 @@
|
|
1
|
+
# Fog::OpenNebula
|
2
|
+
|
3
|
+
[](https://opennebula.org)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Gem is not yet on rubygems, so you'll need to build the gem from source code
|
8
|
+
|
9
|
+
```bash
|
10
|
+
cd fog-opennebula
|
11
|
+
gem build fog-opennebula.gemspec
|
12
|
+
gem install fog-opennebula-0.0.1.gem
|
13
|
+
```
|
14
|
+
|
15
|
+
## Description
|
16
|
+
|
17
|
+
Interaction with [OpenNebula](http://www.opennebula.org) is done via the [Ruby OpenNebula Cloud API](http://docs.opennebula.org/stable/integration/system_interfaces/ruby.html).
|
18
|
+
|
19
|
+
**Note:** This provider is under construction! This means everything that is provided should work without problems, but there are many features not available yet. Please contribute!
|
20
|
+
|
21
|
+
## Requirements
|
22
|
+
|
23
|
+
- Ruby version 2.0.x and higher
|
24
|
+
- gems: See [gemspec](./fog-opennebula.gemspec)
|
25
|
+
- Working OpenNebula instance with XML-RPC and oneadmin user credentials
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
General proceeding:
|
30
|
+
|
31
|
+
- connect to OpenNebula xml-rpc
|
32
|
+
- create new vm object
|
33
|
+
- fetch a template/flavor from OpenNebula (this template should be predefined)
|
34
|
+
- assign the flavor/template to the vm
|
35
|
+
- change the attributes of this flavor/template (name, cpu, memory, nics....)
|
36
|
+
- save/instantiate the vm
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'fog/opennebula'
|
40
|
+
|
41
|
+
con = Fog::Compute.new(
|
42
|
+
provider: 'OpenNebula',
|
43
|
+
opennebula_username: 'oneadmin',
|
44
|
+
opennebula_password: 'password',
|
45
|
+
opennebula_endpoint: 'http://localhost:2633/RPC2'
|
46
|
+
)
|
47
|
+
|
48
|
+
# list all vms
|
49
|
+
con.servers
|
50
|
+
|
51
|
+
# list all OpenNebula templates
|
52
|
+
con.flavors
|
53
|
+
|
54
|
+
# get template with id 0
|
55
|
+
con.flavors.get 0
|
56
|
+
|
57
|
+
# list all Virtual Networks
|
58
|
+
con.networks
|
59
|
+
con.networks.get 0
|
60
|
+
|
61
|
+
# get all usergroups
|
62
|
+
con.groups
|
63
|
+
|
64
|
+
# create a new vm object (creates the object, the vm is not instantiated yet)
|
65
|
+
newvm = con.servers.new
|
66
|
+
|
67
|
+
# set the flavor of the vm
|
68
|
+
newvm.flavor = con.flavors.get 0
|
69
|
+
|
70
|
+
# set the name of the vm
|
71
|
+
newvm.name = "FooBarVM"
|
72
|
+
|
73
|
+
# set the groupid of the vm
|
74
|
+
newvm.gid = 0
|
75
|
+
|
76
|
+
# set cores and memory (MB)
|
77
|
+
newvm.flavor.vcpu = 2
|
78
|
+
newvm.flavor.memory = 256
|
79
|
+
|
80
|
+
# create a new network interface attached to the network with id 0 and virtio as driver/model
|
81
|
+
network = con.networks.get(0)
|
82
|
+
nic = con.interfaces.new({ :vnet => network, :model => "virtio"})
|
83
|
+
|
84
|
+
# Attach the new nic to our vm
|
85
|
+
newvm.flavor.nic = [ nic ]
|
86
|
+
|
87
|
+
# instantiate the new vm
|
88
|
+
newvm.save
|
89
|
+
```
|
90
|
+
|
91
|
+
## Additional Resources
|
92
|
+
|
93
|
+
- [Fog website](http://fog.io)
|
94
|
+
- [Fog repo](https://github.com/fog/fog)
|
95
|
+
- [Ruby OpenNebula Cloud API](http://docs.opennebula.org/stable/integration/system_interfaces/ruby.html)
|
data/Rakefile
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubygems/package_task'
|
5
|
+
require File.dirname(__FILE__) + '/lib/fog/opennebula'
|
6
|
+
|
7
|
+
#############################################################################
|
8
|
+
#
|
9
|
+
# Helper functions
|
10
|
+
#
|
11
|
+
#############################################################################
|
12
|
+
|
13
|
+
def name
|
14
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
15
|
+
end
|
16
|
+
|
17
|
+
def version
|
18
|
+
Fog::OpenNebula::VERSION
|
19
|
+
end
|
20
|
+
|
21
|
+
def gemspec_file
|
22
|
+
"#{name}.gemspec"
|
23
|
+
end
|
24
|
+
|
25
|
+
def gem_file
|
26
|
+
"#{name}-#{version}.gem"
|
27
|
+
end
|
28
|
+
|
29
|
+
#############################################################################
|
30
|
+
#
|
31
|
+
# Standard tasks
|
32
|
+
#
|
33
|
+
#############################################################################
|
34
|
+
|
35
|
+
GEM_NAME = name.to_s
|
36
|
+
task :default => [:test]
|
37
|
+
|
38
|
+
testcommand = 'shindont'
|
39
|
+
ENV.each do |key, val|
|
40
|
+
if key =~ /VERBOSE|DEBUG/
|
41
|
+
val =~ /1|true/ ? testcommand = 'shindo' : testcommand = 'shindont'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'Run tests'
|
46
|
+
task :test do
|
47
|
+
mock = ENV['FOG_MOCK'] || 'true'
|
48
|
+
sh("export FOG_MOCK=#{mock} && bundle exec #{testcommand} tests")
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Run mocked tests'
|
52
|
+
task :mock do
|
53
|
+
sh("export FOG_MOCK=true && bundle exec #{testcommand} tests")
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'Run live tests'
|
57
|
+
task :live do
|
58
|
+
sh("export FOG_MOCK=false && bundle exec #{testcommand} tests")
|
59
|
+
end
|
60
|
+
|
61
|
+
desc 'Open an irb session preloaded with this library'
|
62
|
+
task :console do
|
63
|
+
sh 'irb -rubygems -r ./lib/fog/opennebula.rb'
|
64
|
+
end
|
65
|
+
|
66
|
+
#############################################################################
|
67
|
+
#
|
68
|
+
# Packaging tasks
|
69
|
+
#
|
70
|
+
#############################################################################
|
71
|
+
|
72
|
+
task :release => ['release:prepare', 'release:publish']
|
73
|
+
|
74
|
+
namespace :release do
|
75
|
+
task :preflight do
|
76
|
+
unless `git branch` =~ /^\* master$/
|
77
|
+
puts 'You must be on the master branch to release!'
|
78
|
+
exit!
|
79
|
+
end
|
80
|
+
if `git tag` =~ /^\* v#{version}$/
|
81
|
+
puts "Tag v#{version} already exists!"
|
82
|
+
exit!
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
task :prepare => :preflight do
|
87
|
+
Rake::Task[:build].invoke
|
88
|
+
sh "gem install pkg/#{name}-#{version}.gem"
|
89
|
+
Rake::Task[:git_mark_release].invoke
|
90
|
+
end
|
91
|
+
|
92
|
+
task :publish do
|
93
|
+
Rake::Task[:git_push_release].invoke
|
94
|
+
Rake::Task[:gem_push].invoke
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
task :git_mark_release do
|
99
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
100
|
+
sh "git tag v#{version}"
|
101
|
+
end
|
102
|
+
|
103
|
+
task :git_push_release do
|
104
|
+
sh 'git push origin master'
|
105
|
+
sh "git push origin v#{version}"
|
106
|
+
end
|
107
|
+
|
108
|
+
task :gem_push do
|
109
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
110
|
+
end
|
111
|
+
|
112
|
+
desc "Build #{name}-#{version}.gem"
|
113
|
+
task :build do
|
114
|
+
sh 'mkdir -p pkg'
|
115
|
+
sh "gem build #{gemspec_file}"
|
116
|
+
sh "mv #{gem_file} pkg"
|
117
|
+
end
|
118
|
+
task :gem => :build
|
@@ -0,0 +1,35 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'fog/opennebula/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'fog-opennebula'
|
7
|
+
s.version = Fog::OpenNebula::VERSION
|
8
|
+
s.authors = ['Daniel Clavijo Coca']
|
9
|
+
s.email = 'dann1telecom@gmail.com'
|
10
|
+
s.summary = 'Module for the fog gem to support OpenNebula'
|
11
|
+
s.description = 'This library can be used as a module for fog or as standalone provider'
|
12
|
+
s.homepage = 'http://github.com/fog/fog-opennebula'
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.files = `git ls-files -z`.split("\x0")
|
16
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
|
20
|
+
s.required_ruby_version = '>= 2.0.0'
|
21
|
+
|
22
|
+
###### Gem dependencies ######
|
23
|
+
|
24
|
+
s.add_dependency 'fog-core', '= 2.1.0'
|
25
|
+
s.add_dependency 'fog-json', '~> 1.1'
|
26
|
+
s.add_dependency 'fog-xml', '~> 0.1'
|
27
|
+
s.add_dependency 'opennebula'
|
28
|
+
s.add_dependency 'xmlrpc', '~> 0.3.0' if RUBY_VERSION > '2.4.0'
|
29
|
+
s.add_development_dependency 'minitest'
|
30
|
+
s.add_development_dependency 'minitest-stub-const'
|
31
|
+
s.add_development_dependency 'mocha', '~> 1.1.0'
|
32
|
+
s.add_development_dependency 'rake'
|
33
|
+
s.add_development_dependency 'shindo', '~> 0.3.4'
|
34
|
+
s.add_development_dependency 'simplecov'
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module OpenNebula
|
2
|
+
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def class_for(key)
|
6
|
+
case key
|
7
|
+
when :compute
|
8
|
+
Fog::Compute::OpenNebula
|
9
|
+
else
|
10
|
+
raise ArgumentError, "Unrecognized service: #{key}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def [](service)
|
15
|
+
@connections ||= Hash.new do |hash, key|
|
16
|
+
case key
|
17
|
+
when :compute
|
18
|
+
hash[key] = Fog::Compute.new(:provider => 'OpenNebula')
|
19
|
+
else
|
20
|
+
hash[key] = raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
@connections[service]
|
24
|
+
end
|
25
|
+
|
26
|
+
def services
|
27
|
+
Fog::OpenNebula.services
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'fog/core'
|
2
|
+
require 'fog/xml'
|
3
|
+
require 'fog/json'
|
4
|
+
require 'opennebula'
|
5
|
+
|
6
|
+
module Fog
|
7
|
+
|
8
|
+
module Compute
|
9
|
+
|
10
|
+
autoload :OpenNebula, File.expand_path('opennebula/compute', __dir__)
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
module OpenNebula
|
15
|
+
|
16
|
+
extend Fog::Provider
|
17
|
+
|
18
|
+
module Errors
|
19
|
+
|
20
|
+
class ServiceError < Fog::Errors::Error; end
|
21
|
+
class SecurityError < ServiceError; end
|
22
|
+
class NotFound < ServiceError; end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
service(:compute, 'Compute')
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
module Fog
|
2
|
+
|
3
|
+
module Compute
|
4
|
+
|
5
|
+
class OpenNebula < Fog::Service
|
6
|
+
|
7
|
+
requires :opennebula_endpoint
|
8
|
+
recognizes :opennebula_username, :opennebula_password
|
9
|
+
|
10
|
+
model_path 'fog/opennebula/models/compute'
|
11
|
+
model :server
|
12
|
+
collection :servers
|
13
|
+
model :network
|
14
|
+
collection :networks
|
15
|
+
model :flavor
|
16
|
+
collection :flavors
|
17
|
+
model :interface
|
18
|
+
collection :interfaces
|
19
|
+
model :group
|
20
|
+
collection :groups
|
21
|
+
|
22
|
+
request_path 'fog/opennebula/requests/compute'
|
23
|
+
request :list_vms
|
24
|
+
request :list_groups
|
25
|
+
request :list_networks
|
26
|
+
request :vm_allocate
|
27
|
+
request :vm_destroy
|
28
|
+
request :get_vnc_console
|
29
|
+
request :vm_resume
|
30
|
+
request :vm_suspend
|
31
|
+
request :vm_stop
|
32
|
+
request :template_pool
|
33
|
+
request :vm_disk_snapshot
|
34
|
+
request :vm_shutdown
|
35
|
+
request :image_pool
|
36
|
+
|
37
|
+
class Mock
|
38
|
+
|
39
|
+
def self.data
|
40
|
+
@data ||= Hash.new do |hash, key|
|
41
|
+
hash[key] = {
|
42
|
+
'vms' => [
|
43
|
+
{
|
44
|
+
'onevm_object' => '',
|
45
|
+
'status' => 'RUNNING',
|
46
|
+
'state' => '3',
|
47
|
+
'id' => 4,
|
48
|
+
'uuid' => '5',
|
49
|
+
'gid' => '5',
|
50
|
+
'name' => 'MockVM',
|
51
|
+
'user' => 'MockUser',
|
52
|
+
'group' => 'MockGroup',
|
53
|
+
'cpu' => '2',
|
54
|
+
'memory' => '1024',
|
55
|
+
'mac' => '00:01:02:03:04:05',
|
56
|
+
'ip' => '1.1.1.1'
|
57
|
+
}
|
58
|
+
],
|
59
|
+
'image_pool' => [
|
60
|
+
{}
|
61
|
+
],
|
62
|
+
'template_pool' => [
|
63
|
+
{
|
64
|
+
'content' => %(
|
65
|
+
NAME = mock-vm
|
66
|
+
MEMORY = 512
|
67
|
+
VCPU = 1
|
68
|
+
CPU = 1
|
69
|
+
),
|
70
|
+
'id' => 1,
|
71
|
+
'name' => 'mock',
|
72
|
+
'cpu' => 1,
|
73
|
+
'vcpu' => 1,
|
74
|
+
'memory' => 512,
|
75
|
+
'sched_requirements' => 'CPUSPEED > 1000',
|
76
|
+
'sched_rank' => 'FREECPU',
|
77
|
+
'sched_ds_requirements' => 'NAME=mock',
|
78
|
+
'sched_ds_rank' => 'FREE_MB',
|
79
|
+
'disk' => {},
|
80
|
+
'nic' => {},
|
81
|
+
'os' => {
|
82
|
+
'ARCH' => 'x86_64'
|
83
|
+
},
|
84
|
+
'graphics' => {},
|
85
|
+
'raw' => %(["DATA"=>"<cpu match='exact'><model fallback='allow'>core2duo</model></cpu>", "TYPE"=>"kvm"]),
|
86
|
+
'context' => {},
|
87
|
+
'user_variables' => {}
|
88
|
+
}
|
89
|
+
]
|
90
|
+
}
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.reset
|
95
|
+
@data = nil
|
96
|
+
end
|
97
|
+
|
98
|
+
include Collections
|
99
|
+
def initialize(options = {})
|
100
|
+
@opennebula_endpoint = options[:opennebula_endpoint]
|
101
|
+
@opennebula_username = options[:opennebula_username]
|
102
|
+
@opennebula_password = options[:opennebula_password]
|
103
|
+
require 'opennebula'
|
104
|
+
end
|
105
|
+
|
106
|
+
attr_reader :client
|
107
|
+
|
108
|
+
def data
|
109
|
+
self.class.data[@opennebula_endpoint]
|
110
|
+
end
|
111
|
+
|
112
|
+
def reset_data
|
113
|
+
self.class.data.delete(@opennebula_endpoint)
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
class Real
|
119
|
+
|
120
|
+
include Collections
|
121
|
+
|
122
|
+
attr_reader :client
|
123
|
+
|
124
|
+
def initialize(options = {})
|
125
|
+
require 'opennebula'
|
126
|
+
credentials =
|
127
|
+
@client = ::OpenNebula::Client.new("#{options[:opennebula_username]}:#{options[:opennebula_password]}", options[:opennebula_endpoint])
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|