gosen 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.html +64 -0
- data/README.md +41 -0
- data/VERSION +1 -1
- data/lib/gosen/deployment.rb +4 -2
- data/test/gosen/test_deployment.rb +4 -3
- data/test/gosen/test_deployment_run.rb +5 -4
- metadata +5 -3
data/README.html
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
<h1>Gosen</h1>
|
2
|
+
|
3
|
+
<p>Gosen is a Ruby library for the <a href="https://api.grid5000.fr/">Grid'5000 RESTful API</a>.
|
4
|
+
It relies on the <a href="http://github.com/crohr/restfully">Restfully library</a> for interacting with the API.</p>
|
5
|
+
|
6
|
+
<h2>Features</h2>
|
7
|
+
|
8
|
+
<p>Currently, it allows to submit deployments that retry automatically when too many nodes failed, similarly to <a href="http://www.loria.fr/~lnussbau/katapult.html">Katapult</a>.</p>
|
9
|
+
|
10
|
+
<h2>Installation</h2>
|
11
|
+
|
12
|
+
<pre><code>$ gem install gosen
|
13
|
+
</code></pre>
|
14
|
+
|
15
|
+
<h2>Usage</h2>
|
16
|
+
|
17
|
+
<p>The following example deploys the latest version of the Lenny-x64-big environment on the paramount-1 and paramount-2 nodes.
|
18
|
+
If both nodes are not successfully deployed, Gosen retries again (in this case, at most 5 deployment are submitted).</p>
|
19
|
+
|
20
|
+
<pre><code>#!/usr/bin/env ruby
|
21
|
+
|
22
|
+
require 'gosen'
|
23
|
+
require 'logger'
|
24
|
+
require 'restfully'
|
25
|
+
|
26
|
+
logger = Logger.new(STDOUT)
|
27
|
+
|
28
|
+
Restfully::Session.new(:configuration_file => '~/.grid5000') do |grid, session|
|
29
|
+
site = grid.sites[:rennes]
|
30
|
+
nodes = [ 'paramount-1.rennes.grid5000.fr', 'paramount-2.rennes.grid5000.fr' ]
|
31
|
+
deployment = Gosen::Deployment.new(site, 'lenny-x64-big', nodes,
|
32
|
+
{
|
33
|
+
:logger => logger,
|
34
|
+
:max_deploy_runs => 5,
|
35
|
+
:min_deployed_nodes => nodes.length,
|
36
|
+
:ssh_public_key => File.read(File.expand_path('~/.ssh/authorized_keys'))
|
37
|
+
})
|
38
|
+
deployment.join
|
39
|
+
end
|
40
|
+
</code></pre>
|
41
|
+
|
42
|
+
<p>The logger allows to print information about the deployment, in a style similar to Katapult:</p>
|
43
|
+
|
44
|
+
<pre><code>I, [2010-04-21T11:31:09.351803 #21673] INFO -- : Kadeploy run 1 with 2 nodes (0 already deployed, need 2 more)
|
45
|
+
I, [2010-04-21T11:37:11.817323 #21673] INFO -- : Nodes deployed: paramount-1.rennes.grid5000.fr paramount-2.rennes.grid5000.fr
|
46
|
+
I, [2010-04-21T11:37:11.817440 #21673] INFO -- : Had to run 1 kadeploy runs, deployed 2 nodes
|
47
|
+
</code></pre>
|
48
|
+
|
49
|
+
<h2>Note on Patches/Pull Requests</h2>
|
50
|
+
|
51
|
+
<ul>
|
52
|
+
<li>Fork the project.</li>
|
53
|
+
<li>Make your feature addition or bug fix.</li>
|
54
|
+
<li>Add tests for it. This is important so I don't break it in a
|
55
|
+
future version unintentionally.</li>
|
56
|
+
<li>Commit, do not mess with rakefile, version, or history.
|
57
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)</li>
|
58
|
+
<li>Send me a pull request. Bonus points for topic branches.</li>
|
59
|
+
</ul>
|
60
|
+
|
61
|
+
|
62
|
+
<h2>Copyright</h2>
|
63
|
+
|
64
|
+
<p>Copyright (c) 2010 Pierre Riteau. See LICENSE for details.</p>
|
data/README.md
CHANGED
@@ -1,6 +1,47 @@
|
|
1
1
|
# Gosen
|
2
2
|
|
3
3
|
Gosen is a Ruby library for the [Grid'5000 RESTful API](https://api.grid5000.fr/).
|
4
|
+
It relies on the [Restfully library](http://github.com/crohr/restfully) for interacting with the API.
|
5
|
+
|
6
|
+
## Features
|
7
|
+
|
8
|
+
Currently, it allows to submit deployments that retry automatically when too many nodes failed, similarly to [Katapult](http://www.loria.fr/~lnussbau/katapult.html).
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
$ gem install gosen
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
The following example deploys the latest version of the Lenny-x64-big environment on the paramount-1 and paramount-2 nodes.
|
17
|
+
If both nodes are not successfully deployed, Gosen retries again (in this case, at most 5 deployment are submitted).
|
18
|
+
|
19
|
+
#!/usr/bin/env ruby
|
20
|
+
|
21
|
+
require 'gosen'
|
22
|
+
require 'logger'
|
23
|
+
require 'restfully'
|
24
|
+
|
25
|
+
logger = Logger.new(STDOUT)
|
26
|
+
|
27
|
+
Restfully::Session.new(:base_uri => 'https://api.grid5000.fr/2.0/grid5000') do |grid, session|
|
28
|
+
site = grid.sites[:rennes]
|
29
|
+
nodes = [ 'paramount-1.rennes.grid5000.fr', 'paramount-2.rennes.grid5000.fr' ]
|
30
|
+
deployment = Gosen::Deployment.new(site, 'lenny-x64-big', nodes,
|
31
|
+
{
|
32
|
+
:logger => logger,
|
33
|
+
:max_deploy_runs => 5,
|
34
|
+
:min_deployed_nodes => nodes.length,
|
35
|
+
:ssh_public_key => File.read(File.expand_path('~/.ssh/authorized_keys'))
|
36
|
+
})
|
37
|
+
deployment.join
|
38
|
+
end
|
39
|
+
|
40
|
+
The logger allows to print information about the deployment, in a style similar to Katapult:
|
41
|
+
|
42
|
+
I, [2010-04-21T11:31:09.351803 #21673] INFO -- : Kadeploy run 1 with 2 nodes (0 already deployed, need 2 more)
|
43
|
+
I, [2010-04-21T11:37:11.817323 #21673] INFO -- : Nodes deployed: paramount-1.rennes.grid5000.fr paramount-2.rennes.grid5000.fr
|
44
|
+
I, [2010-04-21T11:37:11.817440 #21673] INFO -- : Had to run 1 kadeploy runs, deployed 2 nodes
|
4
45
|
|
5
46
|
## Note on Patches/Pull Requests
|
6
47
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/gosen/deployment.rb
CHANGED
@@ -30,8 +30,10 @@ module Gosen
|
|
30
30
|
raise Gosen::Error if @max_deploy_runs < 1
|
31
31
|
|
32
32
|
if options[:ssh_public_key]
|
33
|
-
@
|
33
|
+
@ssh_public_key = options[:ssh_public_key]
|
34
34
|
end
|
35
|
+
|
36
|
+
@api_options = options
|
35
37
|
end
|
36
38
|
|
37
39
|
def good_nodes
|
@@ -46,7 +48,7 @@ module Gosen
|
|
46
48
|
|
47
49
|
def join
|
48
50
|
@max_deploy_runs.times do |i|
|
49
|
-
@deployment_resource = Gosen::DeploymentRun.new(@site, @environment, @bad_nodes)
|
51
|
+
@deployment_resource = Gosen::DeploymentRun.new(@site, @environment, @bad_nodes, @api_options)
|
50
52
|
@logger.info("Kadeploy run #{i + 1} with #{@bad_nodes.length} nodes (#{@good_nodes.length} already deployed, need #{@min_deployed_nodes - @good_nodes.length} more)")
|
51
53
|
@deployment_resource.wait_for_completion
|
52
54
|
@deployment_resource.update_nodes
|
@@ -153,6 +153,7 @@ class TestDeployment < Test::Unit::TestCase
|
|
153
153
|
end
|
154
154
|
|
155
155
|
should 'submit new deployment runs when needed' do
|
156
|
+
@ssh_public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvwM1XBJCIMtAyQlweE7BVRtvgyKdwGTeYCI4AFlsTtti4y0Ipe5Hsygx3p7S0BHFiJsVZWDANMRwZ4tcjp8YnjnMkG2yp1jB1qgUf34t/MmEQL0KkoOk8tIIb28o7nTFYKO15mXJm9yBVS1JY8ozEfnA7s5hkrdnvM6h9Jv6VScp8C1XTKmpEy3sWOeUlmCkYftYSr1fLM/7qk9S2TnljA/CGiK9dq2mhJMjnDtulVrdpc1hbh+0oCzL6m2BfXX3v4q1ORml8o04oFeEYDN5qzZneL+FzK+YfJIidvsjZ9ziVTv+7Oy5ms4wvoKiUGNapP0v/meXXBU1KvFRof3VZQ== priteau@parallelogram.local'
|
156
157
|
@deployment_resource1 = mock()
|
157
158
|
@deployment_resource2 = mock()
|
158
159
|
@deployment_resource1.stubs(:reload)
|
@@ -170,8 +171,8 @@ class TestDeployment < Test::Unit::TestCase
|
|
170
171
|
@deployment_resource1.expects(:[]).with('result').returns(@deployment_result1)
|
171
172
|
@deployment_resource2.expects(:[]).with('result').returns(@deployment_result2)
|
172
173
|
@min_deployed_nodes = 2
|
173
|
-
@site_deployments.expects(:submit).with({ :environment => @environment, :nodes => @nodes }).returns(@deployment_resource1)
|
174
|
-
@site_deployments.expects(:submit).with({ :environment => @environment, :nodes => [ 'paramount-2.rennes.grid5000.fr'] }).returns(@deployment_resource2)
|
174
|
+
@site_deployments.expects(:submit).with({ :environment => @environment, :nodes => @nodes, :key => @ssh_public_key }).returns(@deployment_resource1)
|
175
|
+
@site_deployments.expects(:submit).with({ :environment => @environment, :nodes => [ 'paramount-2.rennes.grid5000.fr'], :key => @ssh_public_key }).returns(@deployment_resource2)
|
175
176
|
@logger.expects(:info).with("Kadeploy run 1 with 2 nodes (0 already deployed, need 2 more)")
|
176
177
|
@logger.expects(:info).with("Nodes deployed: paramount-1.rennes.grid5000.fr")
|
177
178
|
@logger.expects(:info).with("Nodes which failed: paramount-2.rennes.grid5000.fr")
|
@@ -179,7 +180,7 @@ class TestDeployment < Test::Unit::TestCase
|
|
179
180
|
@logger.expects(:info).with("Nodes deployed: paramount-2.rennes.grid5000.fr")
|
180
181
|
@logger.expects(:info).with("Had to run 2 kadeploy runs, deployed 2 nodes")
|
181
182
|
|
182
|
-
@deployment = Gosen::Deployment.new(@site, @environment, @nodes, { :logger => @logger, :min_deployed_nodes => @min_deployed_nodes, :max_deploy_runs => 2 })
|
183
|
+
@deployment = Gosen::Deployment.new(@site, @environment, @nodes, { :logger => @logger, :min_deployed_nodes => @min_deployed_nodes, :max_deploy_runs => 2, :ssh_public_key => @ssh_public_key })
|
183
184
|
@deployment.join
|
184
185
|
assert_equal(@nodes, @deployment.good_nodes)
|
185
186
|
assert_equal([], @deployment.bad_nodes)
|
@@ -58,6 +58,7 @@ class TestDeploymentRun < Test::Unit::TestCase
|
|
58
58
|
|
59
59
|
context 'A deployment run instance' do
|
60
60
|
setup do
|
61
|
+
@ssh_public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvwM1XBJCIMtAyQlweE7BVRtvgyKdwGTeYCI4AFlsTtti4y0Ipe5Hsygx3p7S0BHFiJsVZWDANMRwZ4tcjp8YnjnMkG2yp1jB1qgUf34t/MmEQL0KkoOk8tIIb28o7nTFYKO15mXJm9yBVS1JY8ozEfnA7s5hkrdnvM6h9Jv6VScp8C1XTKmpEy3sWOeUlmCkYftYSr1fLM/7qk9S2TnljA/CGiK9dq2mhJMjnDtulVrdpc1hbh+0oCzL6m2BfXX3v4q1ORml8o04oFeEYDN5qzZneL+FzK+YfJIidvsjZ9ziVTv+7Oy5ms4wvoKiUGNapP0v/meXXBU1KvFRof3VZQ== priteau@parallelogram.local'
|
61
62
|
@result = {
|
62
63
|
'paramount-1.rennes.grid5000.fr' => {
|
63
64
|
'last_cmd_stderr' => '',
|
@@ -72,12 +73,12 @@ class TestDeploymentRun < Test::Unit::TestCase
|
|
72
73
|
@resource.expects(:reload).twice
|
73
74
|
Kernel.expects(:sleep).with(Gosen::DeploymentRun::POLLING_TIME).twice
|
74
75
|
|
75
|
-
@deployments = mock()
|
76
|
-
@deployments.expects(:submit).returns(@resource)
|
77
|
-
@site = stub(:deployments => @deployments)
|
78
76
|
@environment = 'lenny-x64-base'
|
79
77
|
@nodes = [ 'paramount-1.rennes.grid5000.fr' ]
|
80
|
-
@
|
78
|
+
@deployments = mock()
|
79
|
+
@deployments.expects(:submit).with({ :environment => @environment, :nodes => @nodes, :key => @ssh_public_key}).returns(@resource)
|
80
|
+
@site = stub(:deployments => @deployments)
|
81
|
+
@deployment = Gosen::DeploymentRun.new(@site, @environment, @nodes, { :ssh_public_key => @ssh_public_key })
|
81
82
|
end
|
82
83
|
|
83
84
|
should 'wait for deployment completion and give access to the results' do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Pierre Riteau
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-22 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -79,6 +79,7 @@ extensions: []
|
|
79
79
|
|
80
80
|
extra_rdoc_files:
|
81
81
|
- LICENSE
|
82
|
+
- README.html
|
82
83
|
- README.md
|
83
84
|
files:
|
84
85
|
- .document
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- test/gosen/test_deployment_run.rb
|
96
97
|
- test/helper.rb
|
97
98
|
- test/test_gosen.rb
|
99
|
+
- README.html
|
98
100
|
has_rdoc: true
|
99
101
|
homepage: http://github.com/priteau/gosen
|
100
102
|
licenses: []
|