libvirt-ruby 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.
- data/.gitignore +4 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/README.rdoc +23 -0
- data/Rakefile +7 -0
- data/lib/libvirt-ruby.rb +16 -0
- data/lib/libvirt-ruby/connect.rb +11 -0
- data/lib/libvirt-ruby/domain.rb +11 -0
- data/lib/libvirt-ruby/network.rb +11 -0
- data/lib/libvirt-ruby/storage_pool.rb +11 -0
- data/lib/libvirt-ruby/storage_vol.rb +11 -0
- data/lib/libvirt-ruby/version.rb +5 -0
- data/libvirt-ruby.gemspec +24 -0
- data/spec/libvirt-ruby/connect_spec.rb +24 -0
- data/spec/libvirt-ruby/domain_spec.rb +24 -0
- data/spec/libvirt-ruby/network_spec.rb +24 -0
- data/spec/libvirt-ruby/storage_pool_spec.rb +24 -0
- data/spec/libvirt-ruby/storage_vol_spec.rb +24 -0
- data/spec/spec_helper.rb +4 -0
- metadata +97 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour --format documentation
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@libvirt-ruby
|
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
= Libvirt-Ruby {<img src="https://secure.travis-ci.org/plribeiro3000/libvirt-ruby.png" />}[http://travis-ci.org/plribeiro3000/libvirt-ruby]
|
2
|
+
|
3
|
+
Rails gem to map functions from libvirt's library to ruby.
|
4
|
+
|
5
|
+
== Install
|
6
|
+
|
7
|
+
gem install libvirt-ruby
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
You should one of the classes defined and call method dispatcher passing parameters:
|
12
|
+
first -> the method just like the one from Libvirt in C as a string
|
13
|
+
second -> the args of the function in C in the same order
|
14
|
+
|
15
|
+
Your second parameter must be an array where the last value is a symbol of what the function should return.
|
16
|
+
|
17
|
+
== Experimental
|
18
|
+
|
19
|
+
This Gem still experimental, so if you have somre problem, feel free to create a new issue.
|
20
|
+
|
21
|
+
== Future
|
22
|
+
|
23
|
+
Add Support for a ton of thigs. =D
|
data/Rakefile
ADDED
data/lib/libvirt-ruby.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require "libvirt-ruby/version"
|
3
|
+
|
4
|
+
module Libvirt
|
5
|
+
module Ruby
|
6
|
+
|
7
|
+
extend FFI::Library
|
8
|
+
ffi_lib "libvirt"
|
9
|
+
|
10
|
+
autoload :Connect, 'libvirt-ruby/connect'
|
11
|
+
autoload :Domain, 'libvirt-ruby/domain'
|
12
|
+
autoload :Network, 'libvirt-ruby/network'
|
13
|
+
autoload :StoragePool, 'libvirt-ruby/storage_pool'
|
14
|
+
autoload :StorageVol, 'libvirt-ruby/storage_vol'
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Libvirt
|
2
|
+
module Ruby
|
3
|
+
module Connect
|
4
|
+
def self.dispatcher(method, args = [])
|
5
|
+
return_type = args.delete(args.last)
|
6
|
+
attach_function ("virConnect" + method.to_s), ("virConnect" + method.to_s), args, return_type
|
7
|
+
send(("virConnect" + method.to_s), args)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Libvirt
|
2
|
+
module Ruby
|
3
|
+
module Domain
|
4
|
+
def self.dispatcher(method, args = [])
|
5
|
+
return_type = args.delete(args.last)
|
6
|
+
attach_function ("virDomain" + method.to_s), ("virDomain" + method.to_s), args, return_type
|
7
|
+
send(("virDomain" + method.to_s), args)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Libvirt
|
2
|
+
module Ruby
|
3
|
+
module Network
|
4
|
+
def self.dispatcher(method, args = [])
|
5
|
+
return_type = args.delete(args.last)
|
6
|
+
attach_function ("virNetwork" + method.to_s), ("virNetwork" + method.to_s), args, return_type
|
7
|
+
send(("virNetwork" + method.to_s), args)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Libvirt
|
2
|
+
module Ruby
|
3
|
+
module StoragePool
|
4
|
+
def self.dispatcher(method, args = [])
|
5
|
+
return_type = args.delete(args.last)
|
6
|
+
attach_function ("virStoragePool" + method.to_s), ("virStoragePool" + method.to_s), args, return_type
|
7
|
+
send(("virStoragePool" + method.to_s), args)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Libvirt
|
2
|
+
module Ruby
|
3
|
+
module StorageVol
|
4
|
+
def self.dispatcher(method, args = [])
|
5
|
+
return_type = args.delete(args.last)
|
6
|
+
attach_function ("virStorageVol" + method.to_s), ("virStorageVol" + method.to_s), args, return_type
|
7
|
+
send(("virStorageVol" + method.to_s), args)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "libvirt-ruby/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "libvirt-ruby"
|
7
|
+
s.version = Libvirt::Ruby::VERSION
|
8
|
+
s.authors = %q{Paulo Henrique Lopes Ribeiro}
|
9
|
+
s.email = %q{plribeiro3000@gmail.com}
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Ruby bindings for the Libvirt C Library}
|
12
|
+
s.description = %q{Access Libvirt's C Library through ruby classes and methods}
|
13
|
+
|
14
|
+
s.rubyforge_project = "libvirt-ruby"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = %w(lib)
|
20
|
+
|
21
|
+
s.add_runtime_dependency "ffi"
|
22
|
+
s.add_development_dependency "rake"
|
23
|
+
s.add_development_dependency "rspec"
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Libvirt::Ruby::Connect do
|
4
|
+
let(:connect) { Libvirt::Ruby::Connect }
|
5
|
+
|
6
|
+
context "when calling method #dispatcher" do
|
7
|
+
before :each do
|
8
|
+
connect.stub(:attach_function).with("virConnectClose", "virConnectClose", [], :int).and_return(true)
|
9
|
+
connect.stub(:send).with("virConnectClose", [])
|
10
|
+
end
|
11
|
+
|
12
|
+
after :each do
|
13
|
+
connect.dispatcher('Close', [:int])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should attach it as a binding for C's function" do
|
17
|
+
connect.should_receive(:attach_function).with("virConnectClose", "virConnectClose", [], :int).and_return(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should call the new attached method" do
|
21
|
+
connect.should_receive(:send).with("virConnectClose", [])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Libvirt::Ruby::Domain do
|
4
|
+
let(:domain) { Libvirt::Ruby::Domain }
|
5
|
+
|
6
|
+
context "when calling method #dispatcher" do
|
7
|
+
before :each do
|
8
|
+
domain.stub(:attach_function).with("virDomainCreate", "virDomainCreate", [], :int).and_return(true)
|
9
|
+
domain.stub(:send).with("virDomainCreate", [])
|
10
|
+
end
|
11
|
+
|
12
|
+
after :each do
|
13
|
+
domain.dispatcher('Create', [:int])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should attach it as a binding for C's function" do
|
17
|
+
domain.should_receive(:attach_function).with("virDomainCreate", "virDomainCreate", [], :int).and_return(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should call the new attached method" do
|
21
|
+
domain.should_receive(:send).with("virDomainCreate", [])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Libvirt::Ruby::Network do
|
4
|
+
let(:network) { Libvirt::Ruby::Network }
|
5
|
+
|
6
|
+
context "when calling method #dispatcher" do
|
7
|
+
before :each do
|
8
|
+
network.stub(:attach_function).with("virNetworkRef", "virNetworkRef", [], :int).and_return(true)
|
9
|
+
network.stub(:send).with("virNetworkRef", [])
|
10
|
+
end
|
11
|
+
|
12
|
+
after :each do
|
13
|
+
network.dispatcher('Ref', [:int])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should attach it as a binding for C's function" do
|
17
|
+
network.should_receive(:attach_function).with("virNetworkRef", "virNetworkRef", [], :int).and_return(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should call the new attached method" do
|
21
|
+
network.should_receive(:send).with("virNetworkRef", [])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Libvirt::Ruby::StoragePool do
|
4
|
+
let(:storage_pool) { Libvirt::Ruby::StoragePool }
|
5
|
+
|
6
|
+
context "when calling method #dispatcher" do
|
7
|
+
before :each do
|
8
|
+
storage_pool.stub(:attach_function).with("virStoragePoolRefresh", "virStoragePoolRefresh", [], :int).and_return(true)
|
9
|
+
storage_pool.stub(:send).with("virStoragePoolRefresh", [])
|
10
|
+
end
|
11
|
+
|
12
|
+
after :each do
|
13
|
+
storage_pool.dispatcher('Refresh', [:int])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should attach it as a binding for C's function" do
|
17
|
+
storage_pool.should_receive(:attach_function).with("virStoragePoolRefresh", "virStoragePoolRefresh", [], :int).and_return(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should call the new attached method" do
|
21
|
+
storage_pool.should_receive(:send).with("virStoragePoolRefresh", [])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Libvirt::Ruby::StorageVol do
|
4
|
+
let(:storage_vol) { Libvirt::Ruby::StorageVol }
|
5
|
+
|
6
|
+
context "when calling method #dispatcher" do
|
7
|
+
before :each do
|
8
|
+
storage_vol.stub(:attach_function).with("virStorageVolResize", "virStorageVolResize", [], :int).and_return(true)
|
9
|
+
storage_vol.stub(:send).with("virStorageVolResize", [])
|
10
|
+
end
|
11
|
+
|
12
|
+
after :each do
|
13
|
+
storage_vol.dispatcher('Resize', [:int])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should attach it as a binding for C's function" do
|
17
|
+
storage_vol.should_receive(:attach_function).with("virStorageVolResize", "virStorageVolResize", [], :int).and_return(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should call the new attached method" do
|
21
|
+
storage_vol.should_receive(:send).with("virStorageVolResize", [])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: libvirt-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paulo Henrique Lopes Ribeiro
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ffi
|
16
|
+
requirement: &10883940 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *10883940
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &10898920 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *10898920
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &10895140 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *10895140
|
47
|
+
description: Access Libvirt's C Library through ruby classes and methods
|
48
|
+
email: plribeiro3000@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- .rspec
|
55
|
+
- .rvmrc
|
56
|
+
- Gemfile
|
57
|
+
- README.rdoc
|
58
|
+
- Rakefile
|
59
|
+
- lib/libvirt-ruby.rb
|
60
|
+
- lib/libvirt-ruby/connect.rb
|
61
|
+
- lib/libvirt-ruby/domain.rb
|
62
|
+
- lib/libvirt-ruby/network.rb
|
63
|
+
- lib/libvirt-ruby/storage_pool.rb
|
64
|
+
- lib/libvirt-ruby/storage_vol.rb
|
65
|
+
- lib/libvirt-ruby/version.rb
|
66
|
+
- libvirt-ruby.gemspec
|
67
|
+
- spec/libvirt-ruby/connect_spec.rb
|
68
|
+
- spec/libvirt-ruby/domain_spec.rb
|
69
|
+
- spec/libvirt-ruby/network_spec.rb
|
70
|
+
- spec/libvirt-ruby/storage_pool_spec.rb
|
71
|
+
- spec/libvirt-ruby/storage_vol_spec.rb
|
72
|
+
- spec/spec_helper.rb
|
73
|
+
homepage: ''
|
74
|
+
licenses: []
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project: libvirt-ruby
|
93
|
+
rubygems_version: 1.8.10
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: Ruby bindings for the Libvirt C Library
|
97
|
+
test_files: []
|