rubiojr-pangea 0.1.20090403134419

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.
@@ -0,0 +1,15 @@
1
+ module Pangea
2
+ module Util
3
+
4
+ def self.humanize_bytes(bytes)
5
+ m = bytes.to_i
6
+ units = %w[Bits Bytes MB GB TB PB]
7
+ while (m/1024.0) >= 1
8
+ m = m/1024.0
9
+ units.shift
10
+ end
11
+ return m.round.to_s + " #{units[0]}"
12
+ end
13
+
14
+ end
15
+ end
data/pangea.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{pangea}
3
+ s.version = "0.1.20090403134419"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Sergio RubioSergio Rubio"]
7
+ s.date = %q{2009-04-14}
8
+ s.description = %q{Xen-API Ruby Implementation}
9
+ s.email = %q{sergio@rubio.namesergio@rubio.name}
10
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
11
+ s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "examples/base.rb", "examples/host.rb", "examples/host_cpu.rb", "examples/host_metrics.rb", "examples/vif.rb", "examples/vm.rb", "lib/memoizers/dumb_memoizer.rb", "lib/memoizers/simple_memoizer.rb", "lib/memoizers/strategy.rb", "lib/memoizers/timed_memoizer.rb", "lib/pangea.rb", "lib/pangea/cluster.rb", "lib/pangea/exceptions.rb", "lib/pangea/objects.rb", "lib/util/string.rb", "pangea.gemspec", "scripts/newrelease", "scripts/publish_release", "test/config.rb", "test/suite.rb", "test/test_network.rb", "test/test_pangea.rb", "test/test_vif.rb", "test/test_vif_metrics.rb", "test/test_vm.rb", "test/test_vm_metrics.rb"]
12
+ s.has_rdoc = true
13
+ s.homepage = %q{http://github.com/rubiojr/pangea}
14
+ s.rdoc_options = ["--main", "README.txt"]
15
+ s.require_paths = ["lib"]
16
+ s.rubyforge_project = %q{pangea}
17
+ s.rubygems_version = %q{1.3.1}
18
+ s.summary = %q{Ruby Xen API}
19
+ s.test_files = ["test/test_network.rb", "test/test_pangea.rb", "test/test_vif.rb", "test/test_vif_metrics.rb", "test/test_vm.rb", "test/test_vm_metrics.rb"]
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 2
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<term-ansicolor>, [">= 1.0"])
27
+ s.add_development_dependency(%q<hoe>, [">= 1.12.1"])
28
+ else
29
+ s.add_dependency(%q<term-ansicolor>, [">= 1.0"])
30
+ s.add_dependency(%q<hoe>, [">= 1.12.1"])
31
+ end
32
+ else
33
+ s.add_dependency(%q<term-ansicolor>, [">= 1.0"])
34
+ s.add_dependency(%q<hoe>, [">= 1.12.1"])
35
+ end
36
+ end
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+ VERSION=0.1.`ruby -r lib/pangea.rb -e 'puts Time.now.strftime("%Y%m%d%H%M%S")'`
3
+ echo $VERSION
4
+ sed -i bak "s/VERSION.*$/VERSION = \"$VERSION\"/" lib/pangea.rb
5
+ rm pkg/*.gem
6
+ rake gem
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ sh scripts/newrelase
3
+ rake publish_gem
4
+
data/test/config.rb ADDED
@@ -0,0 +1 @@
1
+ #TEST_HV = 'http://localhost:9363'
data/test/suite.rb ADDED
@@ -0,0 +1,19 @@
1
+ require 'test/unit/ui/console/testrunner'
2
+ require 'test/unit/testsuite'
3
+ require 'test/test_vm'
4
+ require 'test/test_vif_metrics'
5
+ require 'test/test_network'
6
+ require 'test/test_vif'
7
+
8
+ class TS_Pangea
9
+ def self.suite
10
+ suite = Test::Unit::TestSuite.new
11
+ suite << TestVM.suite
12
+ suite << TestVIF.suite
13
+ suite << TestNetwork.suite
14
+ suite << TestVIFMetrics.suite
15
+ return suite
16
+ end
17
+ end
18
+ Test::Unit::UI::Console::TestRunner.run(TS_Pangea)
19
+
@@ -0,0 +1,43 @@
1
+ require 'test/unit'
2
+ require 'lib/pangea'
3
+ require 'test/config.rb'
4
+
5
+ class TestNetwork< Test::Unit::TestCase
6
+
7
+ def setup
8
+ @host = Pangea::Host.connect(TEST_HV, 'foo', 'bar')
9
+ end
10
+
11
+ def test_uuid
12
+ @host.networks.each do |net|
13
+ assert( net.uuid.is_a? String )
14
+ end
15
+ end
16
+
17
+ def test_label
18
+ @host.networks.each do |net|
19
+ assert( net.label.is_a? String )
20
+ end
21
+ end
22
+
23
+ def test_default_gateway
24
+ @host.networks.each do |net|
25
+ assert( net.default_gateway.is_a?(String) || net.default_gateway.nil? )
26
+ end
27
+ end
28
+
29
+ def test_default_netmask
30
+ @host.networks.each do |net|
31
+ assert( net.default_netmask.is_a?(String) || net.default_netmask.nil? )
32
+ end
33
+ end
34
+
35
+ def test_vifs
36
+ @host.networks.each do |net|
37
+ net.vifs.each do |vif|
38
+ assert( vif.is_a? Pangea::VIF )
39
+ end
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,23 @@
1
+ require 'lib/pangea.rb'
2
+ require 'yaml'
3
+
4
+ config = nil
5
+ File.open 'config.yml' do |f|
6
+ config = YAML.load f
7
+ end
8
+
9
+ hc = Pangea::Cluster.new(config['cluster_nodes'])
10
+
11
+ hc.hosts[0].cpus.each do |hcpu|
12
+ puts hcpu.number
13
+ puts hcpu.vendor
14
+ puts hcpu.speed
15
+ puts hcpu.model_name
16
+ end
17
+ #puts hc.hosts[0].sched_policy
18
+ #puts hc.hosts[0].software_version['Xen']
19
+ #hc.hosts[0].resident_vms.each do |rvm|
20
+ # puts
21
+ # puts rvm.inspect
22
+ # puts rvm.metrics.inspect
23
+ #end
data/test/test_vif.rb ADDED
@@ -0,0 +1,59 @@
1
+ require 'test/unit'
2
+ require 'lib/pangea'
3
+ require 'test/config.rb'
4
+
5
+ class TestVIF < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @host = Pangea::Host.connect(TEST_HV, 'foo', 'bar')
9
+ end
10
+
11
+ def test_mac
12
+ @host.resident_vms.each do |vm|
13
+ vm.vifs.each do |vif|
14
+ assert( vif.mac.is_a? String )
15
+ end
16
+ end
17
+ end
18
+
19
+ def test_uuid
20
+ @host.resident_vms.each do |vm|
21
+ vm.vifs.each do |vif|
22
+ assert( vif.uuid.is_a? String )
23
+ end
24
+ end
25
+ end
26
+
27
+ def test_device
28
+ @host.resident_vms.each do |vm|
29
+ vm.vifs.each do |vif|
30
+ assert( vif.device.is_a? String )
31
+ end
32
+ end
33
+ end
34
+
35
+ def test_metrics
36
+ @host.resident_vms.each do |vm|
37
+ vm.vifs.each do |vif|
38
+ vif.metrics.is_a? Pangea::VIFMetrics
39
+ end
40
+ end
41
+ end
42
+
43
+ #def test_network
44
+ # @host.resident_vms.each do |vm|
45
+ # vm.vifs.each do |vif|
46
+ # assert( vif.network.is_a? Pangea::Network )
47
+ # end
48
+ # end
49
+ #end
50
+
51
+ def test_vm
52
+ @host.resident_vms.each do |vm|
53
+ vm.vifs.each do |vif|
54
+ assert( vif.vm.is_a? Pangea::VM )
55
+ end
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,35 @@
1
+ require 'test/unit'
2
+ require 'lib/pangea'
3
+ require 'test/config.rb'
4
+
5
+ class TestVIFMetrics < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @host = Pangea::Host.connect(TEST_HV, 'foo', 'bar')
9
+ end
10
+
11
+ def test_uuid
12
+ @host.resident_vms.each do |vm|
13
+ vm.vifs.each do |vif|
14
+ assert( vif.metrics.uuid.is_a? String )
15
+ end
16
+ end
17
+ end
18
+
19
+ def test_io_read_kbs
20
+ @host.resident_vms.each do |vm|
21
+ vm.vifs.each do |vif|
22
+ assert( vif.metrics.io_read_kbs.is_a? Float )
23
+ end
24
+ end
25
+ end
26
+
27
+ def test_io_write_kbs
28
+ @host.resident_vms.each do |vm|
29
+ vm.vifs.each do |vif|
30
+ assert( vif.metrics.io_write_kbs.is_a? Float )
31
+ end
32
+ end
33
+ end
34
+
35
+ end
data/test/test_vm.rb ADDED
@@ -0,0 +1,71 @@
1
+ require 'test/unit'
2
+ require 'lib/pangea'
3
+ require 'test/config.rb'
4
+
5
+ class TestVM < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @host = Pangea::Host.connect(TEST_HV, 'foo', 'bar')
9
+ end
10
+
11
+ def test_domid
12
+ @host.resident_vms.each do |vm|
13
+ assert( vm.domid.is_a?(Fixnum) )
14
+ end
15
+ end
16
+
17
+ def test_is_control_domain?
18
+ @host.resident_vms.each do |vm|
19
+ assert(
20
+ vm.is_control_domain?.is_a?(TrueClass) || \
21
+ vm.is_control_domain?.is_a?(FalseClass)
22
+ )
23
+ end
24
+ end
25
+
26
+ def test_actions_after_shutdown
27
+ @host.resident_vms.each do |vm|
28
+ assert( ['restart', 'destroy' ].include? vm.actions_after_shutdown )
29
+ end
30
+ end
31
+
32
+ def test_actions_after_reboot
33
+ @host.resident_vms.each do |vm|
34
+ assert( ['restart', 'destroy' ].include? vm.actions_after_reboot )
35
+ end
36
+ end
37
+
38
+ def test_pv_kernel
39
+ @host.resident_vms.each do |vm|
40
+ assert( vm.pv_kernel.is_a?(String) )
41
+ end
42
+ end
43
+
44
+ def test_vifs
45
+ @host.resident_vms.each do |vm|
46
+ vm.vifs.each do |vif|
47
+ assert( vif.is_a? Pangea::VIF )
48
+ end
49
+ end
50
+ end
51
+
52
+ def test_metrics
53
+ @host.resident_vms.each do |vm|
54
+ assert( vm.metrics.is_a? Pangea::VMMetrics )
55
+ end
56
+ end
57
+
58
+ def test_guest_metrics
59
+ @host.resident_vms.each do |vm|
60
+ assert( vm.guest_metrics.is_a? Pangea::VMGuestMetrics )
61
+ end
62
+ end
63
+
64
+ def test_resident_on
65
+ @host.resident_vms.each do |vm|
66
+ assert( vm.resident_on.is_a?(Pangea::Host) )
67
+ assert( vm.resident_on.uuid.is_a?(String) )
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,17 @@
1
+ require 'test/unit'
2
+ require 'lib/pangea'
3
+ require 'test/config.rb'
4
+
5
+ class TestVMMetrics < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @host = Pangea::Host.connect(TEST_HV, 'foo', 'bar')
9
+ end
10
+
11
+ def test_uuid
12
+ @host.resident_vms.each do |vm|
13
+ assert( vm.metrics.uuid.is_a? String )
14
+ end
15
+ end
16
+
17
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubiojr-pangea
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.20090403134419
5
+ platform: ruby
6
+ authors:
7
+ - Sergio RubioSergio Rubio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-04-14 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: term-ansicolor
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "1.0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.12.1
34
+ version:
35
+ description: Xen-API Ruby Implementation
36
+ email: sergio@rubio.namesergio@rubio.name
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - History.txt
43
+ - Manifest.txt
44
+ - README.txt
45
+ files:
46
+ - History.txt
47
+ - Manifest.txt
48
+ - README.txt
49
+ - Rakefile
50
+ - examples/base.rb
51
+ - examples/host.rb
52
+ - examples/host_cpu.rb
53
+ - examples/host_metrics.rb
54
+ - examples/vif.rb
55
+ - examples/vm.rb
56
+ - lib/memoizers/dumb_memoizer.rb
57
+ - lib/memoizers/simple_memoizer.rb
58
+ - lib/memoizers/strategy.rb
59
+ - lib/memoizers/timed_memoizer.rb
60
+ - lib/pangea.rb
61
+ - lib/pangea/cluster.rb
62
+ - lib/pangea/exceptions.rb
63
+ - lib/pangea/objects.rb
64
+ - lib/util/string.rb
65
+ - pangea.gemspec
66
+ - scripts/newrelease
67
+ - scripts/publish_release
68
+ - test/config.rb
69
+ - test/suite.rb
70
+ - test/test_network.rb
71
+ - test/test_pangea.rb
72
+ - test/test_vif.rb
73
+ - test/test_vif_metrics.rb
74
+ - test/test_vm.rb
75
+ - test/test_vm_metrics.rb
76
+ has_rdoc: true
77
+ homepage: http://github.com/rubiojr/pangea
78
+ post_install_message:
79
+ rdoc_options:
80
+ - --main
81
+ - README.txt
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ requirements: []
97
+
98
+ rubyforge_project: pangea
99
+ rubygems_version: 1.2.0
100
+ signing_key:
101
+ specification_version: 2
102
+ summary: Ruby Xen API
103
+ test_files:
104
+ - test/test_network.rb
105
+ - test/test_pangea.rb
106
+ - test/test_vif.rb
107
+ - test/test_vif_metrics.rb
108
+ - test/test_vm.rb
109
+ - test/test_vm_metrics.rb