vagrant-g5k 0.9.4 → 0.9.5
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 +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +98 -30
- data/Vagrantfile +25 -14
- data/Vagrantfile.multi +24 -32
- data/Vagrantfile.old +58 -65
- data/examples/gitlab/Vagrantfile +43 -0
- data/examples/gitlab/main.yml +59 -0
- data/examples/htb-netem/README.md +62 -0
- data/examples/htb-netem/Vagrantfile +40 -0
- data/examples/htb-netem/ansible.cfg +2 -0
- data/examples/htb-netem/example_latencies.png +0 -0
- data/examples/htb-netem/heat.py +57 -0
- data/examples/htb-netem/hosts.j2 +3 -0
- data/examples/htb-netem/setup.rb +54 -0
- data/examples/htb-netem/setup.yml +50 -0
- data/examples/htb-netem/test.yml +53 -0
- data/lib/vagrant-g5k/command.rb +3 -15
- data/lib/vagrant-g5k/config.rb +11 -5
- data/lib/vagrant-g5k/g5k_connection.rb +7 -10
- data/lib/vagrant-g5k/network/bridge.rb +8 -10
- data/lib/vagrant-g5k/oar.rb +5 -5
- data/lib/vagrant-g5k/util/launch_vm.sh +2 -2
- data/lib/vagrant-g5k/version.rb +1 -1
- data/test/Vagrantfile +46 -0
- metadata +14 -2
data/lib/vagrant-g5k/config.rb
CHANGED
@@ -41,17 +41,23 @@ module VagrantPlugins
|
|
41
41
|
|
42
42
|
|
43
43
|
# G5K network options
|
44
|
-
#
|
44
|
+
#
|
45
45
|
#
|
46
46
|
# @return [Hash]
|
47
47
|
attr_accessor :net
|
48
48
|
|
49
49
|
# OAR resource selection
|
50
|
-
#
|
50
|
+
#
|
51
51
|
#
|
52
52
|
# @return [String]
|
53
53
|
attr_accessor :oar
|
54
54
|
|
55
|
+
# OAR job container id
|
56
|
+
#
|
57
|
+
#
|
58
|
+
# @return [String]
|
59
|
+
attr_accessor :job_container_id
|
60
|
+
|
55
61
|
# VM resource demand
|
56
62
|
#
|
57
63
|
#
|
@@ -63,13 +69,14 @@ module VagrantPlugins
|
|
63
69
|
@project_id = nil
|
64
70
|
@site = nil
|
65
71
|
@gateway = nil
|
66
|
-
@walltime =
|
67
|
-
@oar =
|
72
|
+
@walltime = '01:00:00'
|
73
|
+
@oar = ''
|
68
74
|
@net = {
|
69
75
|
:type => 'nat'
|
70
76
|
}
|
71
77
|
@resources = {
|
72
78
|
}
|
79
|
+
@job_container_id = nil
|
73
80
|
end
|
74
81
|
|
75
82
|
def finalize!()
|
@@ -91,7 +98,6 @@ module VagrantPlugins
|
|
91
98
|
errors << "g5k image must be a Hash" if !@image.is_a?(Hash)
|
92
99
|
errors << "g5k net must be a Hash" if !@net.is_a?(Hash)
|
93
100
|
errors << "g5k resources must be a Hash" if !@resources.is_a?(Hash)
|
94
|
-
|
95
101
|
{ "G5K Provider" => errors }
|
96
102
|
end
|
97
103
|
|
@@ -23,13 +23,14 @@ module VagrantPlugins
|
|
23
23
|
@logger = Log4r::Logger.new("vagrant::g5k_connection")
|
24
24
|
@ui = env[:ui]
|
25
25
|
|
26
|
-
@provider_config = env[:machine].provider_config
|
26
|
+
@provider_config = env[:machine].provider_config
|
27
27
|
@site = @provider_config.site
|
28
28
|
@walltime = @provider_config.walltime
|
29
29
|
@image= @provider_config.image
|
30
30
|
@oar = "{#{@provider_config.oar}}/" if @provider_config.oar != ""
|
31
31
|
@resources = @provider_config.resources
|
32
32
|
@oar_unit = init_oar_unit(@resources[:cpu], @resources[:mem])
|
33
|
+
@job_container_id = @provider_config.job_container_id
|
33
34
|
@cwd = cwd
|
34
35
|
@driver = driver
|
35
36
|
@oar_driver = oar_driver
|
@@ -95,19 +96,15 @@ module VagrantPlugins
|
|
95
96
|
# NOTE: net is first due the the shape of the bridge launcher script
|
96
97
|
net = @net_driver.generate_net()
|
97
98
|
drive = _generate_drive(env)
|
98
|
-
|
99
99
|
args = [@resources[:cpu], @resources[:mem], net, drive].join(" ")
|
100
100
|
# Submitting a new job
|
101
101
|
# Getting the job_id as a ruby string
|
102
102
|
options = []
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
# this implies that nat networking won't work when core is the unit of
|
107
|
-
# deployment
|
108
|
-
options << '-t allow_classic_ssh'
|
103
|
+
if !@job_container_id.nil?
|
104
|
+
@ui.info("Using a job container = #{@job_container_id}")
|
105
|
+
options << "-t inner=#{@job_container_id}"
|
109
106
|
end
|
110
|
-
options
|
107
|
+
options += [
|
111
108
|
"-l \"#{@oar}#{@oar_unit}, walltime=#{@walltime}\"",
|
112
109
|
"--name #{env[:machine].name}",
|
113
110
|
"--checkpoint 60",
|
@@ -118,7 +115,7 @@ module VagrantPlugins
|
|
118
115
|
env[:machine].id = job_id
|
119
116
|
wait_for_vm(job_id)
|
120
117
|
end
|
121
|
-
|
118
|
+
|
122
119
|
def wait_for_vm(job_id)
|
123
120
|
@oar_driver.wait_for(job_id)
|
124
121
|
@net_driver.attach()
|
@@ -5,7 +5,7 @@ module VagrantPlugins
|
|
5
5
|
module Network
|
6
6
|
|
7
7
|
class Bridge
|
8
|
-
|
8
|
+
|
9
9
|
include VagrantPlugins::G5K
|
10
10
|
|
11
11
|
def initialize(env, driver, oar_driver)
|
@@ -21,7 +21,7 @@ module VagrantPlugins
|
|
21
21
|
def generate_net()
|
22
22
|
lockable(:lock => VagrantPlugins::G5K.subnet_lock) do
|
23
23
|
subnet_job_id = _find_subnet
|
24
|
-
if subnet_job_id.nil?
|
24
|
+
if subnet_job_id.nil?
|
25
25
|
subnet_job_id = _create_subnet
|
26
26
|
@oar_driver.wait_for(subnet_job_id)
|
27
27
|
# we can't call this inside the launcher script
|
@@ -33,7 +33,7 @@ module VagrantPlugins
|
|
33
33
|
return "BRIDGE #{_subnet_file}"
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def check_state(job_id)
|
38
38
|
subnet_job_id = _find_subnet()
|
39
39
|
return :subnet_missing if subnet_job_id.nil?
|
@@ -69,7 +69,7 @@ module VagrantPlugins
|
|
69
69
|
def _create_subnet()
|
70
70
|
options = []
|
71
71
|
options << "--name '#{@project_id}-net'"
|
72
|
-
options << "-l '
|
72
|
+
options << "-l 'slash_18=1, walltime=#{@walltime}'"
|
73
73
|
@oar_driver.submit_job('sleep 84400', options )
|
74
74
|
end
|
75
75
|
|
@@ -87,10 +87,10 @@ module VagrantPlugins
|
|
87
87
|
nil
|
88
88
|
end
|
89
89
|
|
90
|
-
# Update the subnet use
|
90
|
+
# Update the subnet use
|
91
91
|
# op is a string "+" or "-"
|
92
|
-
# if after the update the subnet use is 0
|
93
|
-
# the subnet in use is also deleted
|
92
|
+
# if after the update the subnet use is 0
|
93
|
+
# the subnet in use is also deleted
|
94
94
|
def _update_subnet_use(op)
|
95
95
|
cmd = []
|
96
96
|
cmd << "c=$(cat #{_subnet_count});"
|
@@ -98,7 +98,7 @@ module VagrantPlugins
|
|
98
98
|
cmd << "cat #{_subnet_count}"
|
99
99
|
count = @driver.exec(cmd.join(" "))
|
100
100
|
@logger.info("subnet_count = #{count}")
|
101
|
-
if count.to_i <= 0
|
101
|
+
if count.to_i <= 0
|
102
102
|
@logger.info("deleteting the associated subnet")
|
103
103
|
subnet_id = _find_subnet()
|
104
104
|
@oar_driver.delete_job(subnet_id)
|
@@ -111,5 +111,3 @@ module VagrantPlugins
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
114
|
-
|
115
|
-
|
data/lib/vagrant-g5k/oar.rb
CHANGED
@@ -3,7 +3,7 @@ require 'log4r'
|
|
3
3
|
module VagrantPlugins
|
4
4
|
module G5K
|
5
5
|
class Oar
|
6
|
-
|
6
|
+
|
7
7
|
include Vagrant::Util::Retryable
|
8
8
|
|
9
9
|
attr_accessor :driver
|
@@ -13,7 +13,7 @@ module VagrantPlugins
|
|
13
13
|
@driver = driver
|
14
14
|
@ui = ui
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def submit_job(cmd, options)
|
18
18
|
# prefix by the oarsub command
|
19
19
|
opt = _build_oar_cmd(options)
|
@@ -26,7 +26,7 @@ module VagrantPlugins
|
|
26
26
|
def delete_job(job_id, options = [])
|
27
27
|
cmd = _build_oar_cmd(options)
|
28
28
|
cmd = ["oardel", cmd, job_id].join(" ")
|
29
|
-
@driver.exec(cmd)
|
29
|
+
@driver.exec(cmd)
|
30
30
|
end
|
31
31
|
|
32
32
|
def check_job(job_id)
|
@@ -49,7 +49,7 @@ module VagrantPlugins
|
|
49
49
|
end
|
50
50
|
nil
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
def wait_for(job_id)
|
54
54
|
job = nil
|
55
55
|
begin
|
@@ -60,7 +60,7 @@ module VagrantPlugins
|
|
60
60
|
end
|
61
61
|
if job.nil? or (!job.nil? and job["state"] != "Running")
|
62
62
|
@ui.info("Waiting for the job to be running")
|
63
|
-
raise VagrantPlugins::G5K::Errors::JobNotRunning
|
63
|
+
raise VagrantPlugins::G5K::Errors::JobNotRunning
|
64
64
|
end
|
65
65
|
break
|
66
66
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# This script is originally borrowed to pmorillo
|
4
4
|
# Thanks to him !
|
5
|
-
# I've made some addition though :)
|
5
|
+
# I've made some addition though :)
|
6
6
|
|
7
7
|
# ARGS
|
8
8
|
# $1: cpu demand
|
@@ -17,7 +17,7 @@ set -x
|
|
17
17
|
function net_bridge() {
|
18
18
|
SUBNET_FILE=$1
|
19
19
|
# As we chose a stateless designe,let's calculate here the ip and mac
|
20
|
-
# assuming we got a slash_22
|
20
|
+
# assuming we got at least a slash_22
|
21
21
|
ipnumber=$(($OAR_JOB_ID % 1022))
|
22
22
|
IP_MAC=$(cat $SUBNET_FILE|head -n $((ipnumber + 1))|tail -n 1)
|
23
23
|
IP_ADDR=$(echo $IP_MAC|awk '{print $1}')
|
data/lib/vagrant-g5k/version.rb
CHANGED
data/test/Vagrantfile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
#
|
4
|
+
# Sample Vagrantfile
|
5
|
+
#
|
6
|
+
Vagrant.configure(2) do |config|
|
7
|
+
|
8
|
+
config.vm.provider "g5k" do |g5k, override|
|
9
|
+
override.nfs.functional = false
|
10
|
+
g5k.project_id = "test-vagrant-g5k"
|
11
|
+
g5k.site = "rennes"
|
12
|
+
g5k.username = "msimonin"
|
13
|
+
g5k.gateway = "access.grid5000.fr"
|
14
|
+
g5k.walltime = "00:10:00"
|
15
|
+
g5k.image = {
|
16
|
+
:path => "/home/msimonin/public/ubuntu1404-9p.qcow2",
|
17
|
+
:backing => "snapshot"
|
18
|
+
}
|
19
|
+
g5k.net = {
|
20
|
+
:type => "bridge",
|
21
|
+
# :ports => ["#{2222+i}-:22"]
|
22
|
+
}
|
23
|
+
g5k.oar = "virtual != 'none'"
|
24
|
+
g5k.resources = {
|
25
|
+
:cpu => 1,
|
26
|
+
:mem => 2048
|
27
|
+
}
|
28
|
+
end #g5k
|
29
|
+
|
30
|
+
## This define a VM.
|
31
|
+
## a g5k provider section will override top level options
|
32
|
+
## To define multiple VMs you can
|
33
|
+
## * either repeat the block
|
34
|
+
## * loop over using (1..N).each block
|
35
|
+
(1..10).each do |i|
|
36
|
+
config.vm.define "test-#{i}" do |my|
|
37
|
+
my.vm.box = "dummy"
|
38
|
+
## Configure the shared folders between your host and the VM
|
39
|
+
my.vm.synced_folder ".", "/vagrant", type: "rsync", disabled: false
|
40
|
+
## This is mandatory until #6 is fixed
|
41
|
+
## In particular this is needed for the shared folders
|
42
|
+
my.ssh.insert_key = false
|
43
|
+
end #vm
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-g5k
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthieu Simonin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: iniparse
|
@@ -149,6 +149,17 @@ files:
|
|
149
149
|
- Vagrantfile.multi
|
150
150
|
- Vagrantfile.old
|
151
151
|
- dummy.box
|
152
|
+
- examples/gitlab/Vagrantfile
|
153
|
+
- examples/gitlab/main.yml
|
154
|
+
- examples/htb-netem/README.md
|
155
|
+
- examples/htb-netem/Vagrantfile
|
156
|
+
- examples/htb-netem/ansible.cfg
|
157
|
+
- examples/htb-netem/example_latencies.png
|
158
|
+
- examples/htb-netem/heat.py
|
159
|
+
- examples/htb-netem/hosts.j2
|
160
|
+
- examples/htb-netem/setup.rb
|
161
|
+
- examples/htb-netem/setup.yml
|
162
|
+
- examples/htb-netem/test.yml
|
152
163
|
- lib/vagrant-g5k.rb
|
153
164
|
- lib/vagrant-g5k/.action.rb.swp
|
154
165
|
- lib/vagrant-g5k/.config.rb.swp
|
@@ -183,6 +194,7 @@ files:
|
|
183
194
|
- locales/en.yml
|
184
195
|
- spec/vagrant-g5k/config_spec.rb
|
185
196
|
- spec/vagrant-g5k/oar_spec.rb
|
197
|
+
- test/Vagrantfile
|
186
198
|
- vagrant-g5k.gemspec
|
187
199
|
homepage: https://github.com/msimonin/vagrant-g5k
|
188
200
|
licenses:
|