Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 701ec9bd authored by Gaetan SIMO's avatar Gaetan SIMO
Browse files

[environment] now, 'available_on site' can be defined in the file environment.rb

parent 620be301
No related branches found
No related tags found
No related merge requests found
...@@ -602,6 +602,7 @@ environment 'squeeze-x64-xen-0.8' do ...@@ -602,6 +602,7 @@ environment 'squeeze-x64-xen-0.8' do
state "stable" state "stable"
file({:path => "/grid5000/images/squeeze-x64-xen-0.8.tgz", :md5 => "243961b600246379b1257b57c5905c68"}) file({:path => "/grid5000/images/squeeze-x64-xen-0.8.tgz", :md5 => "243961b600246379b1257b57c5905c68"})
kernel "2.6.26.2" kernel "2.6.26.2"
available_on %w{bordeaux grenoble lille lyon nancy orsay rennes sophia toulouse}
valid_on "bordeplage , bordereau , borderline , adonis , edel , genepi , chicon , chimint , chinqchint , chirloute , capricorne , sagittaire , graphene , griffon , gdx , netgdx , paradent , paramount , parapide , parapluie , helios , sol , suno, pastel , violette" valid_on "bordeplage , bordereau , borderline , adonis , edel , genepi , chicon , chimint , chinqchint , chirloute , capricorne , sagittaire , graphene , griffon , gdx , netgdx , paradent , paramount , parapide , parapluie , helios , sol , suno, pastel , violette"
based_on "Debian version lenny for amd64" based_on "Debian version lenny for amd64"
consoles [{:port => "ttyS0", :bps => 34800}] consoles [{:port => "ttyS0", :bps => 34800}]
......
...@@ -63,49 +63,7 @@ module G5K ...@@ -63,49 +63,7 @@ module G5K
def dns_lookup(network_address) def dns_lookup(network_address)
Resolv.getaddress(network_address) Resolv.getaddress(network_address)
end end
# Remotly execute commands, and retrieve stdout, stderr and exit code.
def ssh_exec!(ssh, command)
stdout_data = ""
stderr_data = ""
exit_code = nil
exit_signal = nil
ssh.open_channel do |channel|
channel.exec(command) do |ch, success|
unless success
abort "FAILED: couldn't execute command (ssh.channel.exec)"
end
channel.on_data do |ch,data|
stdout_data+=data
end
channel.on_extended_data do |ch,type,data|
stderr_data+=data
end
channel.on_request("exit-status") do |ch,data|
exit_code = data.read_long
end
channel.on_request("exit-signal") do |ch, data|
exit_signal = data.read_long
end
end
end
ssh.loop
[stdout_data, stderr_data, exit_code, exit_signal]
end
# Get the IP address corresponding to the host fqdn throught ssh channel
def dns_lookup_through_ssh(ssh,fqdn)
results = ssh_exec! ssh, "host #{fqdn}"
if results[2] == 0
results[0].split(" ").reverse[0]
else
fail "Failed to get ip address of '#{fqdn}' : #{results[1]}"
end
end
# Lookup a key in one of the configuration files passed to the generator # Lookup a key in one of the configuration files passed to the generator
# #
# Usage: # Usage:
...@@ -178,6 +136,17 @@ module G5K ...@@ -178,6 +136,17 @@ module G5K
def service(uid, *options, &block) def service(uid, *options, &block)
build_context(:services, uid, *options, &block) build_context(:services, uid, *options, &block)
end end
def available_on(sites_uid)
env_uid = @context[:uid]
old_context = @context
@context = @data
sites_uid.each{|site_uid|
site site_uid.to_sym, {:discard_content => true} do
environment "#{env_uid}", :refer_to => "grid5000/environments/#{env_uid}"
end
}
@context = old_context
end
def build_context(key, uid, *options, &block) def build_context(key, uid, *options, &block)
type = key.to_s.chop type = key.to_s.chop
uid = uid.to_s uid = uid.to_s
...@@ -191,7 +160,7 @@ module G5K ...@@ -191,7 +160,7 @@ module G5K
if (same_trees = @context[key].select{|tree| tree[:uid] == uid}).size > 0 if (same_trees = @context[key].select{|tree| tree[:uid] == uid}).size > 0
@context = same_trees.first @context = same_trees.first
else else
@context[key] << G5K::Tree.new.replace({:uid => uid, :type => type}) @context[key] << G5K::Tree.new.replace({:uid => uid, :type => type}.merge((options[:discard_content]) ? {:discard_content => true} : {}))
@context = @context[key].last @context = @context[key].last
end end
block.call(uid) if block block.call(uid) if block
...@@ -234,8 +203,10 @@ module G5K ...@@ -234,8 +203,10 @@ module G5K
new_content = JSON.pretty_generate(file.contents) new_content = JSON.pretty_generate(file.contents)
existing_content = File.exists?(full_path) ? File.open(full_path, "r").read : "" existing_content = File.exists?(full_path) ? File.open(full_path, "r").read : ""
if new_content.hash != existing_content.hash if new_content.hash != existing_content.hash
puts "File to be written = \t#{full_path}" unless file.has_key? :discard_content and file[:discard_content]
File.open(full_path, "w+"){ |f| f << new_content } unless options[:simulate] puts "File to be written = \t#{full_path}"
File.open(full_path, "w+"){ |f| f << new_content } unless options[:simulate]
end
end end
end end
groups.has_key?(G5K::Link) and groups[G5K::Link].each do |link| groups.has_key?(G5K::Link) and groups[G5K::Link].each do |link|
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment