diff --git a/README.md b/README.md index 6975a2a..aa5ecc4 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ end ``` > Due to the dynamic nature of the subnet reserved on Grid'5000, IPs of the VMs will change accross reboots +> a /18 is reserved but only the first 1024 ips are reserved for the VMs. That means you can use the remaining ips without any conflict. ## Note on resource demand diff --git a/lib/vagrant-g5k/network/bridge.rb b/lib/vagrant-g5k/network/bridge.rb index 5407ee2..dfca044 100644 --- a/lib/vagrant-g5k/network/bridge.rb +++ b/lib/vagrant-g5k/network/bridge.rb @@ -5,7 +5,7 @@ module G5K module Network class Bridge - + include VagrantPlugins::G5K def initialize(env, driver, oar_driver) @@ -21,7 +21,7 @@ def initialize(env, driver, oar_driver) def generate_net() lockable(:lock => VagrantPlugins::G5K.subnet_lock) do subnet_job_id = _find_subnet - if subnet_job_id.nil? + if subnet_job_id.nil? subnet_job_id = _create_subnet @oar_driver.wait_for(subnet_job_id) # we can't call this inside the launcher script @@ -33,7 +33,7 @@ def generate_net() return "BRIDGE #{_subnet_file}" end end - + def check_state(job_id) subnet_job_id = _find_subnet() return :subnet_missing if subnet_job_id.nil? @@ -69,7 +69,7 @@ def _cwd() def _create_subnet() options = [] options << "--name '#{@project_id}-net'" - options << "-l 'slash_22=1, walltime=#{@walltime}'" + options << "-l 'slash_18=1, walltime=#{@walltime}'" @oar_driver.submit_job('sleep 84400', options ) end @@ -87,10 +87,10 @@ def _find_subnet() nil end - # Update the subnet use + # Update the subnet use # op is a string "+" or "-" - # if after the update the subnet use is 0 - # the subnet in use is also deleted + # if after the update the subnet use is 0 + # the subnet in use is also deleted def _update_subnet_use(op) cmd = [] cmd << "c=$(cat #{_subnet_count});" @@ -98,7 +98,7 @@ def _update_subnet_use(op) cmd << "cat #{_subnet_count}" count = @driver.exec(cmd.join(" ")) @logger.info("subnet_count = #{count}") - if count.to_i <= 0 + if count.to_i <= 0 @logger.info("deleteting the associated subnet") subnet_id = _find_subnet() @oar_driver.delete_job(subnet_id) @@ -111,5 +111,3 @@ def _update_subnet_use(op) end end end - - diff --git a/lib/vagrant-g5k/util/launch_vm.sh b/lib/vagrant-g5k/util/launch_vm.sh index 30767a2..530b66f 100755 --- a/lib/vagrant-g5k/util/launch_vm.sh +++ b/lib/vagrant-g5k/util/launch_vm.sh @@ -2,7 +2,7 @@ # This script is originally borrowed to pmorillo # Thanks to him ! -# I've made some addition though :) +# I've made some addition though :) # ARGS # $1: cpu demand @@ -17,7 +17,7 @@ set -x function net_bridge() { SUBNET_FILE=$1 # As we chose a stateless designe,let's calculate here the ip and mac - # assuming we got a slash_22 + # assuming we got at least a slash_22 ipnumber=$(($OAR_JOB_ID % 1022)) IP_MAC=$(cat $SUBNET_FILE|head -n $((ipnumber + 1))|tail -n 1) IP_ADDR=$(echo $IP_MAC|awk '{print $1}')