vagrant-grid5000 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/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +72 -0
- data/Rakefile +1 -0
- data/Vagrantfile +15 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/dummy.box +0 -0
- data/example_box/README.md +13 -0
- data/example_box/Vagrantfile +7 -0
- data/example_box/metadata.json +3 -0
- data/lib/vagrant-grid5000.rb +18 -0
- data/lib/vagrant-grid5000/action.rb +67 -0
- data/lib/vagrant-grid5000/action/connect_grid5000.rb +23 -0
- data/lib/vagrant-grid5000/action/destroy_instance.rb +22 -0
- data/lib/vagrant-grid5000/action/read_state.rb +42 -0
- data/lib/vagrant-grid5000/action/reserve_and_deploy.rb +42 -0
- data/lib/vagrant-grid5000/config.rb +63 -0
- data/lib/vagrant-grid5000/errors.rb +11 -0
- data/lib/vagrant-grid5000/plugin.rb +73 -0
- data/lib/vagrant-grid5000/provider.rb +48 -0
- data/lib/vagrant-grid5000/version.rb +5 -0
- data/locales/en.yml +51 -0
- data/vagrant-grid5000.gemspec +24 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ec1b84367fbc0cde4fda55232d9723bef915d0ef
|
4
|
+
data.tar.gz: b134ed915853a6f1788f60ab5265890cbe907281
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 16a71937bc54eaeeb5fab2acc18fb7c74d7068349cb1e12dcddc223c369a50f754d1e2f7379fa64db6ce364f804501cedb5ae804dfb3c91896aa9f7df998da7f
|
7
|
+
data.tar.gz: c09d7c4a842808e8263415d4657134be04d7e8d28a69914cb8fdbf6f2c1a9a0234619070a18b4aba62cd80712315731dc2273ff3527ffb3401dd069466d36b09
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Lucas Nussbaum
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all 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,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Vagrant Grid5000 Provider
|
2
|
+
|
3
|
+
<span class="badges">
|
4
|
+
[][gem]
|
5
|
+
</span>
|
6
|
+
|
7
|
+
[gem]: https://rubygems.org/gems/vagrant-grid5000
|
8
|
+
|
9
|
+
This is a [Vagrant](http://www.vagrantup.com) plugin that adds a provider for
|
10
|
+
machines running on the [Grid'5000](https://www.grid5000.fr) testbed to
|
11
|
+
Vagrant.
|
12
|
+
|
13
|
+
This is still at an early state of development.
|
14
|
+
|
15
|
+
## What works
|
16
|
+
* vagrant up --provider=grid5000
|
17
|
+
* vagrant status
|
18
|
+
* vagrant ssh
|
19
|
+
* vagrant destroy
|
20
|
+
|
21
|
+
## What doesn't work
|
22
|
+
|
23
|
+
* everything else
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
```
|
28
|
+
$ vagrant plugin install vagrant-grid5000
|
29
|
+
```
|
30
|
+
|
31
|
+
Each provider needs at least one ''box''. This does not really make sense here, so we are providing a dummy one.
|
32
|
+
```
|
33
|
+
$ vagrant box add FIXME
|
34
|
+
```
|
35
|
+
|
36
|
+
Example Vagrantfile:
|
37
|
+
```ruby
|
38
|
+
Vagrant.configure("2") do |config|
|
39
|
+
|
40
|
+
# Global configuration for Grid'5000 access
|
41
|
+
config.vm.provider "grid5000" do |g5k|
|
42
|
+
# cute_parameters = { :conf_file =>"config file path" }
|
43
|
+
# see FIXME for details about allowed parameters
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
config.vm.define :my_g5k_box do |g5k|
|
48
|
+
g5k.vm.box = "dummy"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
56
|
+
|
57
|
+
## Development
|
58
|
+
|
59
|
+
To work on the `vagrant-grid5000` plugin, clone this repository out, and use
|
60
|
+
[Bundler](http://gembundler.com) to get the dependencies:
|
61
|
+
|
62
|
+
```
|
63
|
+
$ bundle
|
64
|
+
```
|
65
|
+
|
66
|
+
You can test the plugin without installing it into your Vagrant environment by
|
67
|
+
using the `Vagrantfile` in the top level of this directory and use bundler to
|
68
|
+
execute Vagrant.
|
69
|
+
```
|
70
|
+
$ bundle exec vagrant up --provider=grid5000
|
71
|
+
```
|
72
|
+
etc.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/Vagrantfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
|
6
|
+
# Global configuration for Grid'5000 access
|
7
|
+
config.vm.provider "grid5000" do |g5k|
|
8
|
+
# cute_parameters = { :conf_file =>"config file path" }
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
config.vm.define :my_g5k_box do |g5k|
|
13
|
+
g5k.vm.box = "dummy"
|
14
|
+
end
|
15
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "vagrant/grid5000"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/dummy.box
ADDED
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Vagrant Grid5000 Example Box
|
2
|
+
|
3
|
+
Vagrant providers each require a custom provider-specific box format.
|
4
|
+
This folder shows the example contents of a box for the `grid5000` provider.
|
5
|
+
To turn this into a box:
|
6
|
+
|
7
|
+
```
|
8
|
+
$ tar cvzf grid5000.box ./metadata.json ./Vagrantfile
|
9
|
+
```
|
10
|
+
|
11
|
+
This box works by using Vagrant's built-in Vagrantfile merging to setup
|
12
|
+
defaults for Grid5000. These defaults can easily be overwritten by higher-level
|
13
|
+
Vagrantfiles (such as project root Vagrantfiles).
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "vagrant-grid5000/plugin"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Grid5000
|
7
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-grid5000", __FILE__))
|
8
|
+
autoload :Action, lib_path.join("action")
|
9
|
+
autoload :Errors, lib_path.join("errors")
|
10
|
+
|
11
|
+
# This returns the path to the source of this plugin.
|
12
|
+
#
|
13
|
+
# @return [Pathname]
|
14
|
+
def self.source_root
|
15
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "cute"
|
3
|
+
|
4
|
+
require "vagrant/action/builder"
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module Grid5000
|
8
|
+
module Action
|
9
|
+
# Include the built-in modules so we can use them as top-level things.
|
10
|
+
include Vagrant::Action::Builtin
|
11
|
+
|
12
|
+
def self.action_up
|
13
|
+
Vagrant::Action::Builder.new.tap do |b|
|
14
|
+
b.use ConfigValidate
|
15
|
+
b.use ConnectGrid5000
|
16
|
+
b.use ReserveAndDeploy
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.action_ssh
|
21
|
+
Vagrant::Action::Builder.new.tap do |b|
|
22
|
+
b.use ConnectGrid5000
|
23
|
+
b.use ReadState
|
24
|
+
b.use SSHExec
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.action_ssh_run
|
29
|
+
return Vagrant::Action::Builder.new.tap do |b|
|
30
|
+
b.use ConnectGrid5000
|
31
|
+
b.use ReadState
|
32
|
+
b.use SSHRun
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.action_destroy
|
37
|
+
Vagrant::Action::Builder.new.tap do |b|
|
38
|
+
b.use ConnectGrid5000
|
39
|
+
b.use ReadState
|
40
|
+
b.use Call, DestroyConfirm do |env, b2|
|
41
|
+
if env[:result]
|
42
|
+
b2.use DestroyInstance
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# This action is called to read the state of the machine. The
|
49
|
+
# resulting state is expected to be put into the `:machine_state_id`
|
50
|
+
# key.
|
51
|
+
def self.action_read_state
|
52
|
+
Vagrant::Action::Builder.new.tap do |b|
|
53
|
+
b.use ConfigValidate
|
54
|
+
b.use ConnectGrid5000
|
55
|
+
b.use ReadState
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# The autoload farm
|
60
|
+
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
61
|
+
autoload :ReserveAndDeploy, action_root.join("reserve_and_deploy")
|
62
|
+
autoload :ReadState, action_root.join("read_state")
|
63
|
+
autoload :ConnectGrid5000, action_root.join("connect_grid5000")
|
64
|
+
autoload :DestroyInstance, action_root.join("destroy_instance")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Grid5000
|
5
|
+
module Action
|
6
|
+
# This action connects to Grid'5000, verifies credentials work, and
|
7
|
+
# puts the G5K connection object into the `:g5k` key in the environment.
|
8
|
+
class ConnectGrid5000
|
9
|
+
def initialize(app, env)
|
10
|
+
@app = app
|
11
|
+
@logger = Log4r::Logger.new("vagrant_grid5000::action::connect_grid5000")
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
env[:g5k] = Cute::G5K::API.new(env[:machine].provider_config.cute_parameters || {})
|
16
|
+
# FIXME customize logger to make it clear that ruby-cute is the one displaying messages
|
17
|
+
raise "Unable to retrieve the list of sites and find nancy in it" if not env[:g5k].site_uids.include?('nancy')
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Grid5000
|
6
|
+
module Action
|
7
|
+
class DestroyInstance
|
8
|
+
def initialize(app, env)
|
9
|
+
@app = app
|
10
|
+
@logger = Log4r::Logger.new("vagrant_grid5000::action::destroy_instance")
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
env[:g5k].release(env[:job])
|
15
|
+
env[:machine_state_id] = :destroyed
|
16
|
+
env[:machine].id = nil
|
17
|
+
@app.call(env)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Grid5000
|
5
|
+
module Action
|
6
|
+
# This action reads the state of the machine and puts it in the
|
7
|
+
# `:machine_state_id` key in the environment.
|
8
|
+
class ReadState
|
9
|
+
def initialize(app, env)
|
10
|
+
@app = app
|
11
|
+
@logger = Log4r::Logger.new("vagrant_grid5000::action::read_state")
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
env[:machine_state_id] = read_state(env)
|
16
|
+
|
17
|
+
# Carry on
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
|
21
|
+
$last_state_read = nil
|
22
|
+
def read_state(env)
|
23
|
+
|
24
|
+
return :not_created if not env[:g5k] or not env[:machine]
|
25
|
+
id = env[:machine].id
|
26
|
+
return :not_created if id.nil?
|
27
|
+
site, jobid, node = id.split(':')
|
28
|
+
|
29
|
+
if $last_state_read != nil and env[:job] and Time::now < $last_state_read + 60
|
30
|
+
# skip
|
31
|
+
else
|
32
|
+
env[:job] = env[:g5k].get_job(site, jobid)
|
33
|
+
$last_state_read = Time::now
|
34
|
+
end
|
35
|
+
env[:machine_ssh_info] = { :host => node, :port => 22, :username => 'root', :proxy_command => "ssh -W #{node}:22 #{env[:g5k].g5k_user}@access.grid5000.fr" }
|
36
|
+
return :running if env[:job]['state'] == 'running'
|
37
|
+
return :not_created
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Grid5000
|
6
|
+
module Action
|
7
|
+
class ReserveAndDeploy
|
8
|
+
def initialize(app, env)
|
9
|
+
@app = app
|
10
|
+
@logger = Log4r::Logger.new("vagrant_grid5000::action::reserve_and_deploy")
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
cfg = env[:machine].provider_config
|
15
|
+
walltime = cfg.walltime
|
16
|
+
if walltime.nil? # slightly broken: what if the local time doesn't switch DST at the same time as Europe/Paris?
|
17
|
+
if Time::now.dst?
|
18
|
+
target = '18:55:00 CEST'
|
19
|
+
else
|
20
|
+
target = '18:55:00 CET'
|
21
|
+
end
|
22
|
+
walltime = (Time::parse(target) - Time::now).to_i
|
23
|
+
walltime = format("%02d:%02d:%02d", walltime / (60*60), walltime / 60 % 60, walltime % 60)
|
24
|
+
end
|
25
|
+
if ENV['VAGRANT_DEBUG'] = 'REUSE_JOB'
|
26
|
+
job = env[:g5k].get_my_jobs(cfg.site).first
|
27
|
+
else
|
28
|
+
job = env[:g5k].reserve(:site => cfg.site, :walltime => walltime,
|
29
|
+
:properties => cfg.properties, :env => cfg.env, :keys => cfg.keys,
|
30
|
+
:name => "vagrant-grid5000")
|
31
|
+
end
|
32
|
+
env[:node] = job['assigned_nodes'].first
|
33
|
+
env[:machine_state_id] = :running
|
34
|
+
@logger.info("Node #{env[:node]} successfully started.")
|
35
|
+
env[:job] = job
|
36
|
+
env[:machine].id = "#{cfg.site}:#{job['uid']}:#{env[:node]}"
|
37
|
+
@app.call(env)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Grid5000
|
5
|
+
class Config < Vagrant.plugin("2", :config)
|
6
|
+
|
7
|
+
# This Vagrant plugin uses the Ruby-Cute library to interact with Grid'5000.
|
8
|
+
# This gives, as a hash, the parameters to pass to Ruby-Cute's initialization.
|
9
|
+
# For valid values, see:
|
10
|
+
# http://www.rubydoc.info/github/ruby-cute/ruby-cute/master/Cute%2FG5K%2FAPI%3Ainitialize
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
attr_accessor :cute_parameters
|
14
|
+
|
15
|
+
# Site to reserve resources on. (default: nancy)
|
16
|
+
# @return [String]
|
17
|
+
attr_accessor :site
|
18
|
+
|
19
|
+
# OAR properties to use when reserving resources. (default: empty ; example: cluster='graphene')
|
20
|
+
# @return [String]
|
21
|
+
attr_accessor :properties
|
22
|
+
|
23
|
+
# Walltime to use when reserving resources. (default: reserve resources until today at 6:55pm)
|
24
|
+
# @return [String]
|
25
|
+
attr_accessor :walltime
|
26
|
+
|
27
|
+
# The Grid'5000 environment to deploy (default: jessie-x64-min)
|
28
|
+
# An URL to a dsc can be specified instead.
|
29
|
+
# @return [String]
|
30
|
+
attr_accessor :env
|
31
|
+
|
32
|
+
# SSH keys to copy to the deployed machine. (default: use Ruby-Cute's default, which is to copy
|
33
|
+
# the public keys found in ~/.ssh/
|
34
|
+
# @return [String]
|
35
|
+
attr_accessor :keys
|
36
|
+
|
37
|
+
|
38
|
+
def initialize()
|
39
|
+
@cute_parameters = UNSET_VALUE
|
40
|
+
@env = UNSET_VALUE
|
41
|
+
@site = UNSET_VALUE
|
42
|
+
@keys = UNSET_VALUE
|
43
|
+
@properties = UNSET_VALUE
|
44
|
+
@walltime = UNSET_VALUE
|
45
|
+
end
|
46
|
+
|
47
|
+
def finalize!
|
48
|
+
@cute_parameters = nil if @cute_parameters == UNSET_VALUE
|
49
|
+
@site = 'nancy' if @site == UNSET_VALUE
|
50
|
+
@env = 'jessie-x64-min' if @env == UNSET_VALUE
|
51
|
+
@keys = nil if @keys == UNSET_VALUE
|
52
|
+
@properties = '' if @properties == UNSET_VALUE
|
53
|
+
@walltime = nil if @walltime == UNSET_VALUE
|
54
|
+
end
|
55
|
+
|
56
|
+
def validate(machine)
|
57
|
+
errors = _detected_errors
|
58
|
+
# errors << I18n.t("vagrant_grid5000.config.server_required") if @server.nil?
|
59
|
+
{ "Grid5000 Provider" => errors }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant Grid5000 plugin must be run within Vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
# This is a sanity check to make sure no one is attempting to install
|
8
|
+
# this into an early Vagrant version.
|
9
|
+
if Vagrant::VERSION < "1.6.0"
|
10
|
+
raise "The Vagrant Grid5000 plugin is only compatible with Vagrant 1.6+"
|
11
|
+
end
|
12
|
+
|
13
|
+
module VagrantPlugins
|
14
|
+
module Grid5000
|
15
|
+
class Plugin < Vagrant.plugin("2")
|
16
|
+
name "Grid5000"
|
17
|
+
description <<-DESC
|
18
|
+
This plugin installs a provider that allows Vagrant to interact
|
19
|
+
with the Grid5000 testbed.
|
20
|
+
DESC
|
21
|
+
|
22
|
+
config(:grid5000, :provider) do
|
23
|
+
require_relative "config"
|
24
|
+
Config
|
25
|
+
end
|
26
|
+
|
27
|
+
provider(:grid5000, parallel: true) do
|
28
|
+
# Setup logging and i18n
|
29
|
+
setup_logging
|
30
|
+
setup_i18n
|
31
|
+
|
32
|
+
# Return the provider
|
33
|
+
require_relative "provider"
|
34
|
+
Provider
|
35
|
+
end
|
36
|
+
|
37
|
+
# This initializes the internationalization strings.
|
38
|
+
def self.setup_i18n
|
39
|
+
I18n.load_path << File.expand_path("locales/en.yml", Grid5000.source_root)
|
40
|
+
I18n.reload!
|
41
|
+
end
|
42
|
+
|
43
|
+
# This sets up our log level to be whatever VAGRANT_LOG is.
|
44
|
+
def self.setup_logging
|
45
|
+
require "log4r"
|
46
|
+
|
47
|
+
level = nil
|
48
|
+
begin
|
49
|
+
level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
|
50
|
+
rescue NameError
|
51
|
+
# This means that the logging constant wasn't found,
|
52
|
+
# which is fine. We just keep `level` as `nil`. But
|
53
|
+
# we tell the user.
|
54
|
+
level = nil
|
55
|
+
end
|
56
|
+
|
57
|
+
# Some constants, such as "true" resolve to booleans, so the
|
58
|
+
# above error checking doesn't catch it. This will check to make
|
59
|
+
# sure that the log level is an integer, as Log4r requires.
|
60
|
+
level = nil if !level.is_a?(Integer)
|
61
|
+
|
62
|
+
# Set the logging level on all "vagrant" namespaced
|
63
|
+
# logs as long as we have a valid level.
|
64
|
+
if level
|
65
|
+
logger = Log4r::Logger.new("vagrant_grid5000")
|
66
|
+
logger.outputters = Log4r::Outputter.stderr
|
67
|
+
logger.level = level
|
68
|
+
logger = nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require "vagrant"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Grid5000
|
6
|
+
class Provider < Vagrant.plugin("2", :provider)
|
7
|
+
def initialize(machine)
|
8
|
+
@machine = machine
|
9
|
+
end
|
10
|
+
|
11
|
+
def action(name)
|
12
|
+
# Attempt to get the action method from the Action class if it
|
13
|
+
# exists, otherwise return nil to show that we don't support the
|
14
|
+
# given action.
|
15
|
+
action_method = "action_#{name}"
|
16
|
+
return Action.send(action_method) if Action.respond_to?(action_method)
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def ssh_info
|
21
|
+
return nil if @machine.state.id != :running
|
22
|
+
env = @machine.action("read_state")
|
23
|
+
return env[:machine_ssh_info]
|
24
|
+
end
|
25
|
+
|
26
|
+
def state
|
27
|
+
# Run a custom action we define called "read_state" which does
|
28
|
+
# what it says. It puts the state in the `:machine_state_id`
|
29
|
+
# key in the environment.
|
30
|
+
env = @machine.action("read_state")
|
31
|
+
|
32
|
+
state_id = env[:machine_state_id]
|
33
|
+
|
34
|
+
# Get the short and long description
|
35
|
+
short = I18n.t("vagrant_grid5000.states.short_#{state_id}")
|
36
|
+
long = I18n.t("vagrant_grid5000.states.long_#{state_id}")
|
37
|
+
|
38
|
+
# Return the MachineState object
|
39
|
+
Vagrant::MachineState.new(state_id, short, long)
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_s
|
43
|
+
id = @machine.id.nil? ? "n/a" : @machine.id
|
44
|
+
"Grid5000 (#{id})"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
en:
|
2
|
+
vagrant_grid5000:
|
3
|
+
warn_networks: |-
|
4
|
+
Warning! The ManagedServers provider doesn't support any of the Vagrant
|
5
|
+
high-level network configurations (`config.vm.network`). They will be ignored.
|
6
|
+
rsync_not_found_warning: |-
|
7
|
+
Warning! Folder sync disabled because the rsync binary is missing.
|
8
|
+
Make sure rsync is installed and the binary can be found in the PATH.
|
9
|
+
rsync_folder: |-
|
10
|
+
Rsyncing folder: %{hostpath} => %{guestpath}
|
11
|
+
winrm_upload: |-
|
12
|
+
Uploading with WinRM: %{hostpath} => %{guestpath}
|
13
|
+
linking_server: |-
|
14
|
+
Linking with managed server %{host}
|
15
|
+
unlinking_server: |-
|
16
|
+
Unlinking from managed server %{host}
|
17
|
+
rebooting_server: |-
|
18
|
+
Rebooting managed server %{host}
|
19
|
+
waiting_for_server: |-
|
20
|
+
Waiting for %{host} to reboot
|
21
|
+
states:
|
22
|
+
short_not_linked: |-
|
23
|
+
not linked
|
24
|
+
long_not_linked: |-
|
25
|
+
The managed server is not linked.
|
26
|
+
short_already_linked: |-
|
27
|
+
already linked
|
28
|
+
long_already_linked: |-
|
29
|
+
The managed server is already linked.
|
30
|
+
short_not_reachable: |-
|
31
|
+
not reachable
|
32
|
+
long_not_reachable: |-
|
33
|
+
The managed server is not reachable. Check if the `config.managed.server` is correct.
|
34
|
+
short_running: |-
|
35
|
+
running
|
36
|
+
long_running: |-
|
37
|
+
The managed server is running. To ssh into this machine, you can run
|
38
|
+
`vagrant ssh`. To provision the machine, you can run `vagrant provision`.
|
39
|
+
config:
|
40
|
+
server_required: |-
|
41
|
+
The IP or hostname of the server must be configured via "server"
|
42
|
+
private_key_missing: |-
|
43
|
+
The specified private key could not be found
|
44
|
+
errors:
|
45
|
+
rsync_error: |-
|
46
|
+
There was an error when attemping to rsync a shared folder.
|
47
|
+
Please inspect the error message below for more info.
|
48
|
+
|
49
|
+
Host path: %{hostpath}
|
50
|
+
Guest path: %{guestpath}
|
51
|
+
Error: %{stderr}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-grid5000/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-grid5000"
|
8
|
+
spec.version = VagrantPlugins::Grid5000::VERSION
|
9
|
+
spec.authors = ["Lucas Nussbaum"]
|
10
|
+
spec.email = ["lucas.nussbaum@loria.fr"]
|
11
|
+
|
12
|
+
spec.summary = %q{Vagrant provider plugin for Grid'5000}
|
13
|
+
spec.homepage = "https://github.com/lnussbaum/vagrant-grid5000"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_dependency "ruby-cute", "~> 0.4"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-grid5000
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lucas Nussbaum
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-cute
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.4'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.4'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- lucas.nussbaum@loria.fr
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- LICENSE.txt
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- Vagrantfile
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
69
|
+
- dummy.box
|
70
|
+
- example_box/README.md
|
71
|
+
- example_box/Vagrantfile
|
72
|
+
- example_box/metadata.json
|
73
|
+
- lib/vagrant-grid5000.rb
|
74
|
+
- lib/vagrant-grid5000/action.rb
|
75
|
+
- lib/vagrant-grid5000/action/connect_grid5000.rb
|
76
|
+
- lib/vagrant-grid5000/action/destroy_instance.rb
|
77
|
+
- lib/vagrant-grid5000/action/read_state.rb
|
78
|
+
- lib/vagrant-grid5000/action/reserve_and_deploy.rb
|
79
|
+
- lib/vagrant-grid5000/config.rb
|
80
|
+
- lib/vagrant-grid5000/errors.rb
|
81
|
+
- lib/vagrant-grid5000/plugin.rb
|
82
|
+
- lib/vagrant-grid5000/provider.rb
|
83
|
+
- lib/vagrant-grid5000/version.rb
|
84
|
+
- locales/en.yml
|
85
|
+
- vagrant-grid5000.gemspec
|
86
|
+
homepage: https://github.com/lnussbaum/vagrant-grid5000
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.4.5.1
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Vagrant provider plugin for Grid'5000
|
110
|
+
test_files: []
|
111
|
+
has_rdoc:
|