Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit c189ac10 authored by Gaetan SIMO's avatar Gaetan SIMO
Browse files

[network_equipments] added nancy network equipments

parent 22a02d14
......@@ -14,7 +14,6 @@ $LOAD_PATH.unshift(EXTRA_DIR) unless $LOAD_PATH.include?(EXTRA_DIR)
Rake.application.options.trace = true
require 'grid5000'
require 'naming-pattern'
......@@ -112,7 +111,7 @@ namespace :netlinks do
end
return if neighbor.nil?
l = coord["linecard"]
l = (coord["linecard"]||0)
p = coord["port"]
linecards[l] = {"ports"=>{}} unless linecards.has_key? l
ports = linecards[l]["ports"]
......@@ -211,7 +210,84 @@ namespace :netlinks do
end
# Print the result on a pretty message
if message.empty?
@logger.warn "No host net-link has been formated. Please correct warnings first and your cli parameters."
@logger.warn "No host net-link has been formated. Please correct warnings and your cli parameters."
else
message.map!{|m| "* #{m}"}
message.unshift "Formated Network links were saved into the following files : "
message_size = message.max{|a,b|a.size <=> b.size}.size
puts "+-#{"-" * message_size}-+"
puts message.map{|m| "| #{m} "}.join("\n")
puts "+-#{"-" * message_size}-+"
end
end
desc "Update net-links.yaml with the kavlan like config file."
task :kavlan => [:environment,:hosts] do
config_file = ENV['CONF']
abort "You must provide a CONF=, which is the path to the kavlan like config file." if config_file.nil?
host,site = @host.scan(/(\S+)\.(\S+)/).flatten
dirs = Dir.glob("generators/input/#{site}/")
if dirs.empty?
@logger.error "Failed to find a directory containing the net-links yaml file for your site '#{site}'"
next
end
message = []
dirs.each do |dir|
site = File.basename(dir)
net_links_file = File.join(dir,"net-links.yaml")
net_links_dir = File.join(dir,"net-links")
net_links = YAML::load_file(net_links_file)
net_links.keep_if do |uid,properties|
uid.match(Regexp.new(host.gsub(/\*/,'\S+'))) != nil
end
if net_links.empty?
@logger.warn "Failed to find any host described within the file #{net_links_file}."
else
# parse the kavlan like config file
config = {}
File.read(config_file).lines.each do |line|
if ((scan = line.strip.scan(/^([^.]+)\.([^.]+)\.grid5000\.fr\s+(\S+)\s+(\S+)$/)).size > 0)
uid,site,ifname,router = scan.flatten
config[router] = [] unless config.has_key? router
config[router].push({:uid=>uid,:ifname=>ifname})
end
end
updated = []
# Update the net-links with kavlan config file
net_links.each do |uid,properties|
router = config[uid]
next if router.nil?
updated.push uid
# register interfaces naming patterns
patterns = {}
browse_naming_patterns(properties["linecards"],patterns) do |dict,raw_port|
format_port(dict,raw_port,properties["linecards"])
end
# parse the ifname
router.each do |neighbor|
ifname = neighbor[:ifname]
# find the naming_pattern that correspond to this ifname
patterns.each do |np,cb|
# scan the ifname with each naming_pattern
dict = NamingPattern.encode(np,ifname)
unless dict.empty?
# Found the naming_pattern for this ifname
# So Place it where it belongs
cb.call(dict,neighbor)
break
end
end
end
end
# When all net links in a site are formated, we write them in they file.
File.open(net_links_file,'w'){|f| YAML::dump(net_links,f)}
message.push "#{net_links_file} hosts=#{updated.inspect}"
end
end
# Print the result on a pretty message
if message.empty?
@logger.warn "No host net-link has been formated. Please correct warnings and/or your cli parameters."
else
message.map!{|m| "* #{m}"}
message.unshift "Formated Network links were saved into the following files : "
......
{
"channels": {
"naming_pattern": "Po%CHANNELID%"
},
"kind": "router",
"linecards": [
{
},
{
"kind": "switch",
"naming_pattern": "%LINECARD:A%%PORT%",
"ports": [
{
......@@ -16,43 +21,39 @@
},
{
"kind": "switch",
"rate": 10000000000,
"uid": "sgraphene3"
},
{
"kind": "switch",
"rate": 10000000000,
"uid": "sgriffon2"
}
]
],
"rate": 10000
},
{
"kind": "switch",
"naming_pattern": "%LINECARD:A%%PORT%",
"ports": [
{
},
{
"kind": "switch",
"rate": 10000000000,
"uid": "sgraphene1"
},
{
"kind": "switch",
"rate": 10000000000,
"uid": "sgraphene2"
},
{
},
{
"kind": "switch",
"rate": 10000000000,
"uid": "sgraphene4"
}
]
],
"rate": 10000
},
{
"kind": "switch",
"naming_pattern": "%LINECARD:A%%PORT%",
"ports": [
{
......@@ -64,33 +65,24 @@
},
{
"kind": "switch",
"rate": 10000000000,
"uid": "sgriffon3"
},
{
"kind": "switch",
"rate": 10000000000,
"uid": "sgriffon1"
}
]
],
"rate": 10000
}
],
"mac": "00:18:71:d7:e9:00",
"model": "HP Procurve 5406zl",
"networks": [
{
"cidr": "172.16.64.0/20",
"kind": "default"
},
{
"cidr": "10.144.0.0/14",
"kind": "virtual"
}
],
"trunks": [
"routes": {
],
},
"site_uid": "nancy",
"snmp_community": "public",
"type": "network_equipment",
"uid": "gw"
"uid": "gw",
"vlans": {
"naming_pattern": "Vlan%VLANID%"
}
}
\ No newline at end of file
{
"channels": {
"naming_pattern": "Po%CHANNELID%"
},
"kind": "switch",
"linecards": [
{
"kind": "node",
"naming_pattern": "%PORT%",
"ports": [
{
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-2"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-1"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-4"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-3"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-6"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-5"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-10"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-7"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-12"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-11"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-9"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-8"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-14"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-13"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-16"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-15"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-18"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-17"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-20"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-19"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-22"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-21"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-24"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-23"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-26"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-25"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-28"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-27"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-30"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-29"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-32"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-31"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-34"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-33"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-36"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-35"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-38"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-37"
},
{
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-39"
}
]
],
"rate": 1000
},
{
"kind": "router",
"naming_pattern": "%LINECARD:A%%PORT%",
"ports": [
{
},
{
"kind": "switch",
"rate": 10000000000,
"uid": "sgravillon1"
},
{
"uid": "gw"
}
]
],
"rate": 10000
}
],
"mac": "40:01:c6:8b:e4:81",
"model": "3com 4500g",
"trunks": [
"routes": {
],
},
"site_uid": "nancy",
"snmp_community": "public",
"type": "network_equipment",
"uid": "sgraphene1"
"uid": "sgraphene1",
"vlans": {
"naming_pattern": "Vlan%VLANID%"
}
}
\ No newline at end of file
{
"channels": {
"naming_pattern": "Po%CHANNELID%"
},
"kind": "switch",
"linecards": [
{
"kind": "node",
"naming_pattern": "%PORT%",
"ports": [
{
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-40"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-41"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-42"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-43"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-44"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-45"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-46"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-47"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-48"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-49"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-50"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-51"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-52"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-53"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-54"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-55"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-56"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-57"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-58"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-59"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-60"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-61"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-62"
},
{
"kind": "node",
"rate": 1000000000,
"uid": "graphene-63"
},