Commit c1c38fe5 authored by Jérémie Gaidamour's avatar Jérémie Gaidamour

[dev] Removed old_generators/

parent f35be460
source :rubygems
gem 'json_pure', '~> 1.5'
gem 'restfully','1.0.5'
gem "rake", ">= 0.9.2.2"
gem "net-admin-common",
:git => "ssh://g5kadmin@git.grid5000.fr/srv/git/repos/net-admin-common",
:tag => "2.5.3"
gem "cacti-play",
:git => "ssh://g5kadmin@git.grid5000.fr/srv/git/repos/cacti-play",
:tag => "2.8"
gem "weathermap",
:git => "ssh://g5kadmin@git.grid5000.fr/srv/git/repos/weathermap",
:tag => "5.8.4"
GIT
remote: ssh://g5kadmin@git.grid5000.fr/srv/git/repos/cacti-play
revision: 4a2b6cb6ae2d9f791a4529737491ea02eeeb58c8
tag: 2.8
specs:
cacti-play (2.7.4)
net-admin-common (>= 2.5.3)
GIT
remote: ssh://g5kadmin@git.grid5000.fr/srv/git/repos/net-admin-common
revision: 3985600064a0a583ee9a47b4d51c97bc94f291a2
tag: 2.5.3
specs:
net-admin-common (2.5.3)
net-ssh (>= 2.3.0)
net-ssh-multi (>= 1.1)
rest-client (>= 1.6.7)
GIT
remote: ssh://g5kadmin@git.grid5000.fr/srv/git/repos/weathermap
revision: a258691fb1bdfa8db04897fd593bc2f9d3264b53
tag: 5.8.4
specs:
weathermap (5.8.2)
cacti-play (>= 2.7.4)
interpolator (>= 0.15)
ipaddress (>= 0.8.0)
json (>= 1.7.0)
net-admin-common (>= 2.5.3)
GEM
remote: http://rubygems.org/
specs:
addressable (2.3.2)
backports (2.6.3)
bond (0.4.2)
interpolator (0.15)
ipaddress (0.8.0)
json (1.7.4)
json_pure (1.7.4)
mime-types (1.19)
net-ssh (2.6.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
net-ssh-multi (1.1)
net-ssh (>= 2.1.4)
net-ssh-gateway (>= 0.99.0)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rake (0.9.2.2)
rb-readline (0.4.2)
rest-client (1.6.7)
mime-types (>= 1.16)
rest-client-components (1.2.0)
rack (>= 1.0.1)
rest-client (>= 1.6.0, < 1.7.0)
restfully (1.0.5)
addressable
backports
json (~> 1.5)
rack-cache
rb-readline
rest-client (~> 1.6)
rest-client-components
ripl (= 0.6.1)
ripl-color_streams
ripl-multi_line
ripl-play (~> 0.2.1)
ripl-short_errors
ripl (0.6.1)
bond (~> 0.4.0)
ripl-color_streams (0.1.2)
ripl (>= 0.2.8)
ripl-multi_line (0.3.0)
ripl (>= 0.3.6)
ripl-play (0.2.1)
ripl (>= 0.3.0)
ripl-short_errors (0.1.0)
ripl (>= 0.2.8)
PLATFORMS
ruby
DEPENDENCIES
cacti-play!
json_pure (~> 1.5)
net-admin-common!
rake (>= 0.9.2.2)
restfully (= 1.0.5)
weathermap!
This diff is collapsed.
This diff is collapsed.
# File : reference-repository/examples/net-links.json
# This is how the json file on the network API would look like.
# All comments are include in front of each property
{
"type": "network_equipment", # The same for all network equipments. This is used by the API generator ! To not confuse with "kind" property which is used to distinguish network equipments kinds.
"model": "xx", # the model must start with the constructor (Cisco,HP Procurve,Foundry,...) followed by the version (3750,...). This is anyway how constructors usually describe they equipments.
"kind": "xx", # This tells what kind of network_equipement it is (router,switch,virtual,...)
"uid": "xx" # This equipment's uid
"site": "xx" # This equipment's site uid
"snmp_community": "public" # the Read-Only SNMP community. Its is "public" on all equipments since decision in PS-61.
"vlans": {
"1":{"addresses":[],"description":"default"}
"100": { # 100 is the vlan id
"addresses": [ # vlan interface ip address, by order of priority. The first one being the primary ip address, the other one are secondary ip addr
"172.16.68.254", # The primary ip address
"10.47.255.254", # The secondary ip address
]
"mac": "FF:FF:FF:FF:FE" , # The vlan interface mac address. most often, this value is the same on all vlans
"description": "PRODUCTION" # A description for the vlan
}
"naming_pattern": "Vlan%VLANID%" # The vlan interface naming pattern. So the vlan 100 is on interface "vlan100"
}
"routes": {
"172.16.47.0/20": { # 172.16.47.0/20 is the destination network address
"status": "static", # Can be "connected" or "static". "static" means this route was define by a command line on the router.
"via": "192.168.4.14", # gateway of this network, if status == static. Of course this gateway must be join-able by one of the network equipment vlan interface.
}
"172.16.95.0/20": { # 172.16.95.0/20 is the destination network address
"status": "connected", # Can be "connected" or "static". "connected" means the destination network correspond to one of our local interfaces (vlan interface). This type of route is usually added automatically by the network equipment's Operating System when an IP address is added to a local interface.
}
}
"channels": {
"200": [ # 200 is the port channel id
{
"linecard": "2", # the linecard number
"port": "7", # the port number on the linecard
},
{
"linecard": "3", # the linecard number
"port": "7", # the port number on the linecard
}
]
"naming_pattern": "Po%CHANNELID%"; # The naming pattern of all Channel Ports. The port channel 200 is on interface "Po200".
"190": [ # 190 is the port channel id
{
"linecard": "1", # the linecard number
"port": "8", # the port number on the linecard
},
{
"linecard": "2", # the linecard number
"port": "8", # the port number on the linecard
}
{
"linecard": "3", # the linecard number
"port": "8", # the port number on the linecard
}
]
}
"linecards": [
{},
{
"rate": "1G", # The rate of all interfaces on this linecard. unless overriden within port description
"naming_pattern" : "Gi%LINECARD%/%PORT%", # the naming pattern of all interfaces on this linecard. unless overriden within port description
"kind": "node", # The kind of all neighbors on all interfaces on this linecard. unless overriden within port description
"ports":[
{
"uid": "<cluster>-<node_id>", # The neighbor uid on this link. This should be used to identify links aggregations (not necessary channels, just link aggregation).
},
{
"uid": "server_uid", # The neighbor uid on this link.
"kind": "server", # Redefinition of the neighbor's kind, according to the one already defined on the linecard description.
}
]
},
{
"rate": "1G",
"naming_pattern" : "Gi%LINECARD%/%PORT%",
"kind": "node",
"ports":[
{
"uid": "netgdx-1",
"port": "eth0", # The neighbor's port name on this link. This is mainly useful when the neighbor has many ports and is not described in the network API. Typically, "node"s and "server"s.
},
{
"uid": "netgdx-1", # Second link to the node "netgdx-1"
"port": "eth1", # The neighbor's port name on this link.
},
{
"uid": "netgdx-1", # Third link to the node "netgdx-1"
"port": "eth2", # The neighbor's port name on this link.
}
]
},
{
"rate": "1G",
"naming_pattern" : "Gi%LINECARD%/%PORT%",
"kind": "switch",
"ports":[
{
"uid": "<cluster>-<node_id>",
"kind": "node", # Redefinition of the neighbor's kind
},
{
"uid": "switch01",
},
{
"uid": "switch01", # The second link to the switch "switch01". But nothis says it is a Port-Channel. For now it is just 2 links aggregated for "switch01". You will have to look into "channels" to find if there is a port channel on these ports. Notice that they is no need to specify the neighbor "port" on this link. In fact that that information is redundant since "switch01" should be described in the network API where they would be its links to this network equipment. So setting "port" here can even be confusing if it is coherent with the one in the "switch01" API description.
}
]
},
{
"rate": "10G", # Ha, interesting, the 10G links
"naming_pattern" : "Te%LINECARD%/%PORT%", # The naming pattern of 10G interfaces on this linecard
"kind": "virtual",
"ports":[
{
"uid": "renater-lille",
"site": "renater", # 'renater-lille' is a virtual network equipment on site 'renater'. This its description is in the grid5000's network API level.
},
{
"uid": "gw1-h.net-admin.lille.inria.fr", # This can be the link to the local labo. Not necessarily described on our network API, but definitely a 'virtual' network equipment
}
]
}
]
}
# File : reference-repository/examples/net-links.yaml
---
gw:
model: cisco
kind: router
site: lille
snmp_community: public
vlans:
naming_pattern: Vlan%VLANID%
routes: {}
linecards:
1:
naming_pattern: Te%LINECARD%/%PORT%
kind: virtual
rate: 10000
ports: {}
2:
naming_pattern: Gi%LINECARD%/%PORT%
kind: node
rate: 1000
ports: {}
channels:
naming_pattern: Po%CHANNELID%
switch01:
model: cisco
kind: router
snmp_community: public
vlans:
naming_pattern: Vlan%VLANID%
routes: {}
channels:
naming_pattern: Po%CHANNELID%
linecards:
1:
naming_pattern: Te%LINECARD%/%PORT%
kind: virtual
rate: 1000
ports:
2: renater-lille
3:
kind: router
kind: gw.orsay.grid5000.fr
3:
naming_pattern: Gi%LINECARD%/%PORT%
kind: node
rate: 1000
ports:
2: chimint-14
3: chimint-14
4: chimint-14
5: chimint-14
4:
naming_pattern: Gi%LINECARD%/%PORT%
kind: server
rate: 1000
ports:
0: srv-stock
1:
kind: switch
uid: sw-admin1
source :rubygems
gem "snmp", "1.1.0"
GEM
remote: http://rubygems.org/
specs:
snmp (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
snmp (= 1.1.0)
#!/usr/bin/env ruby
ROOT_DIR = File.expand_path('../..', __FILE__)
LIB_DIR = File.join(ROOT_DIR, "lib")
$LOAD_PATH.unshift LIB_DIR unless $LOAD_PATH.include?(LIB_DIR)
require 'naming-pattern'
#naming_pattern = "Vlan%VLANID%"
#naming_pattern = "Po%CHANNELID%"
#naming_pattern = "Te%LINECARD%/%PORT%"
#naming_pattern = "Gi%LINECARD%/%PORT%"
naming_pattern = "Gi%LINECARD%/%PORT%"
#naming_pattern = "Gi%UNO:sd:1%/%DOS:1%"
naming_pattern = "%LINECARD:A%%PORT%"
#ifname = "Gi2/7"
ifname = "D4"
def usage
puts "Usage : #{ENV["_"]} naming_pattern interface"
end
if ARGV.size != 2
usage
exit!
end
naming_pattern,ifname = ARGV
dict = NamingPattern.encode(naming_pattern,ifname)
puts "#{naming_pattern} + #{ifname} \t => \t #{dict.inspect}"
ifname = NamingPattern.decode(naming_pattern,dict)
puts "#{naming_pattern} + #{dict.inspect} \t => \t #{ifname.inspect}"
#!/usr/bin/env ruby
ROOT_DIR = File.expand_path('../..', __FILE__)
LIB_DIR = File.join(ROOT_DIR, "lib")
$LOAD_PATH.unshift LIB_DIR unless $LOAD_PATH.include?(LIB_DIR)
require 'net-links-engine'
netlinks = NetLinksEngine.new
netlinks.parse!(ARGV)
netlinks.run!
#!/usr/bin/env ruby
# Author:: Pascal Morillon (<pascal.morillon@irisa.fr>)
# Date:: Thu Dec 08 15:48:23 +0100 2011
#
require 'yaml'
site = 'rennes'
clusters = %w{paramount paradent parapide parapluie}
primary_eth = {
"paramount" => "eth0",
"paradent" => "eth0",
"parapide" => "eth0",
"parapluie" => "eth1"
}
not_referenced = []
conf = ""
clusters.each do |cluster|
yamldoc = YAML.load(File.read(File.join("generators", "input", "#{site}-#{cluster}.yaml")))
nodes = yamldoc.sort { |a,b| a.first.split('-')[1].to_i <=> b.first.split('-')[1].to_i }
nodes.each do |node|
if node.last["network_interfaces"][primary_eth[cluster]]["switch_port"].nil?
not_referenced << node.first
next
end
conf += "!\n"
conf += "interface GigabitEthernet#{node.last["network_interfaces"][primary_eth[cluster]]["switch_port"].split('i').last}\n"
conf += " description #{node.first}\n"
conf += " switchport access vlan 100\n"
end
end
conf += "!\n"
puts conf
if not_referenced.length > 0
STDERR.puts "Not referenced nodes :"
STDERR.puts not_referenced.inspect
end
#!/usr/bin/env ruby
# Author:: Pascal Morillon (<pascal.morillon@irisa.fr>)
# Date:: Thu Dec 08 13:47:03 +0100 2011
#
require 'yaml'
site = 'rennes'
clusters = %w{paramount paradent parapide parapluie}
primary_eth = {
"paramount" => "eth0",
"paradent" => "eth0",
"parapide" => "eth0",
"parapluie" => "eth1"
}
clusters.each do |cluster|
conf = ""
yamldoc = YAML.load(File.read(File.join("generators", "input", "#{site}-#{cluster}.yaml")))
nodes = yamldoc.sort { |a,b| a.first.split('-')[1].to_i <=> b.first.split('-')[1].to_i }
conf += "# Cluster #{cluster} - production network vlan100\n"
conf += "group {\n"
conf += "\n"
nodes.each do |node|
conf += " host #{node.first} {\n"
conf += " hardware ethernet #{node.last["network_interfaces"][primary_eth[cluster]]["mac"]};\n"
conf += " fixed-address #{node.last["network_interfaces"][primary_eth[cluster]]["ip"]};\n"
conf += " }\n"
conf += "\n"
end
conf += "}\n"
conf += "\n"
conf += "\n"
conf += "# Cluster #{cluster} - management network vlan101\n"
conf += "group {\n"
conf += "\n"
nodes.each do |node|
conf += " host #{node.first}-bmc {\n"
conf += " hardware ethernet #{node.last["network_interfaces"]["bmc"]["mac"]};\n"
conf += " fixed-address #{node.last["network_interfaces"]["bmc"]["ip"]};\n"
conf += " }\n"
conf += "\n"
end
conf += "}\n"
conf += "\n"
conf += "\n"
puts conf
end
#!/usr/bin/env ruby
# Author:: Pascal Morillon (<pascal.morillon@irisa.fr>)
# Date:: Wed Dec 07 14:14:02 +0100 2011
#
require 'yaml'
$cluster = "parapluie"
case $cluster
when "paramount"
$site = "rennes"
$default_eth = "eth0"
$hp_net = "myri0"
$ip_prefix = "172.16.96"
$nb_nodes = 33
when "paradent"
$site = "rennes"
$default_eth = "eth0"
$hp_net = false
$ip_prefix = "172.16.97"
$nb_nodes = 64
when "parapide"
$site = "rennes"
$default_eth = "eth0"
$hp_net = "ib0"
$ip_prefix = "172.16.98"
$nb_nodes = 25
when "parapluie"
$site = "rennes"
$default_eth = "eth1"
$hp_net = "ib0"
$ip_prefix = "172.16.99"
$nb_nodes = 40
else
raise "Cluster #{$cluster} is not yet supported ! Check script code..."
end
yamldoc = YAML.load(File.read(File.join("generators", "input", "#{$site}-#{$cluster}.yaml")))
(1..$nb_nodes).each do |index|
ip_tab = $ip_prefix.split('.')
eth_ip = (ip_tab << index.to_s).join('.')
bmc_ip = [ip_tab[0], "17", ip_tab[2], index.to_s].join('.')
hp_ip = [ip_tab[0], "18", ip_tab[2], index.to_s].join('.')
yamldoc["#{$cluster}-#{index}"]["network_interfaces"]["bmc"]["ip"] = bmc_ip
yamldoc["#{$cluster}-#{index}"]["network_interfaces"][$default_eth]["ip"] = eth_ip
yamldoc["#{$cluster}-#{index}"]["network_interfaces"][$hp_net]["ip"] = hp_ip if $hp_net
end
puts yamldoc.to_yaml
require 'optparse'
require 'logger'
class CmdLineScript
def initialize
@version = "0.1"
end
def sanitize(str)
str.strip.downcase.gsub(/\s+/,"-")
end
def parse!(args,params=[])
args.push("-h") if args.empty?
# Save the user options
user_args = args.dup
args.clear
@parsing_args = args
@prev_parsing_args_size = @parsing_args.size
@min_opt_index = 0
@options_loaded = []
@opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename(ENV["_"])} [options]"
opts.on_tail("--version", "Display the version.") do |v|
puts @version
exit(0)
end
opts.on_tail("-h", "--help", "You are looking at it.") do
puts opts.help
exit(0)
end
end
@options = {}
if block_given?
yield
elsif params.is_a? Array
until params.empty?
k = params.shift
v = params.shift
add_option k,v
end
else
fail "This method must receive a block or an Array "
end
add_option :logger
# Merge first options with user's options (priority to user options)
merge_options user_args
@prev_parsing_args_size = @parsing_args.size
@opt_parser.parse!(@parsing_args)
end
def add_option(opt_sym,opt_dft=nil)
current_parsing_args_size = @parsing_args.size
parser_opts_nb = @prev_parsing_args_size - current_parsing_args_size
@min_opt_index -= parser_opts_nb
unless @options_loaded.include? opt_sym
opt_str = opt_sym_to_str opt_sym
dft_aft = send("option_#{opt_sym.to_s}",opt_sym,opt_str,opt_dft)
opt_dft = dft_aft unless dft_aft.nil? or dft_aft.kind_of? OptionParser
default_args opt_str, opt_dft
@options_loaded.push opt_sym
end
@prev_parsing_args_size = @parsing_args.size
end
# Find the index of a given option within the arguments that are being parsed
# Return -1 if the argument is not found.
def option_index(opt)
@parsing_args.each_with_index{|o,idx|
if o == opt
return idx
end
}
return -1
end
def opt_sym_to_str(opt_sym)
"--"+opt_sym.to_s.gsub(/_/,'-')
end
def opt_str_to_sym(opt_str)
opt_str.gsub(/^--/,"").gsub(/-/,"_").to_sym
end
# Set the argument for an option.
# If the option has already been parsed, set its value,
# Otherwise, set its value within the parsing arguments.
def set_arg(opt,arg,params={})