Netomox DSL construct data that is based on RFC 8345 based network topology data model.
networks
+ network
+ node
| + term_point
+ link
- Networks has several networks
- Network has several nodes and links
- Node has several term_points
- Link has source and destination
- Each object has "supports" that is a reference list to other corresponding object in (another) network
- Each object has "attribute" that is additional information of the objects
- L2/L3 attribute is defined other RFC/I-D based on RFC8345
Each object has #register method that receive a block and eval it in instance (#instance_eval)
nws = Netomox::DSL::Networks.new
nws.register do
network 'network1' # Networks#network
endConstructor can receive a block (the block is evaluated by #receive)
Netomox::DSL::Networks.new do
network 'network1'
endEach object has registration method.
Netomox::DSL::Networks.new do
network 'network1' do
node 'node1' do
term_point 'tp1' do
end
end
link %w[node1 tp1 node2 tp2] do
end
end
endNetworks#networkNetwork#nodeNetwork#link: register uni-directional linkNetwork#bdlink: register bi-directional linkNode#term_point
These registration methods search object in current data.
If found same (same-name) object, then modify it #register.
If not found same object, create new object and register it.
[NOTICE] :
registration methods always return a object.
found or created one.
If you need only-find a object, use #find_foo methods in each class.
#support method register supporting-object. Args of support is reference correspond each object.
Netomox::DSL::Networks.new do
network 'network1' do
support 'networkX'
support 'networkY'
node1 = node `node1` do
support %w[networkX nodeP]
term_point 'tp1' do
support %w[networkX nodeP tpN]
end
end
end
endIt create ONLY data. does not check object existence and data consistency.
If a network specified its network type with type,
not only the network but also nodes, term points and links can own augmented attributes defined by L2/L3 topology data model.
- draft-ietf-i2rs-yang-l2-network-topology-05 - A YANG Data Model for Layer-2 Network Topologies
Netomox::NWTYPE_L2
- RFC 8346 - A YANG Data Model for Layer 3 Topologies
Netomox::NWTYPE_L3
Example:
Netomox::DSL::Networks.new do
network 'network1' do
type Netomox::NWTYPE_L2
attribute(name: 'layerX', flags: %w[foo bar])
addrs = %w[192.168.1.2]
node_attr = { name: 'tpX', mgmt_vid: 10, mgmt_addrs: addrs }
node 'nodeX' do
attribute(node_attr)
vlan_a = { id: 10, name: 'Seg.A' }
access_vlan_a = {
port_vlan_id: 10,
vlan_id_names: [vlan_a]
}
term_point 'tpX' do
attribute(access_vlan_a)
end
end
end
end[NOTICE] Topology data handled by this tool has implicit rule about link name. It assumes that a link has a name like "src-node,src-tp,dst-node,dst-tp". If you define link in topology data using netomox DSL (Netomox::DSL::Network#bdlink, bi-directional link), a link name will be settled automatically.
(1) Network#(bd)link
Netomox::DSL::Networks.new do
network 'network1' do
bdlink %w[node1 tp1 node2 tp2]
end
endit create ONLY data. does not check object existence and data consistency.
(2) Node#(bd)link_to and TermPoint#(bd)link_to
Netomox::DSL::Networks.new do
network 'network1' do
node1 = node `node1` do
term_point 'tp1'
end
node2 = node 'node2' do
term_point `tp2`
end
node1.term_point('tp1').bdlink_to(node2.term_point(tp2))
end
endIf not specified termination point, these methods are create new termination point automatically.
Netomox::DSL::Networks.new do
network 'network1' do
node1 = node `node1`
node2 = node 'node2'
node1.bdlink_to(node2) # => bdlink "node1,p0,node2,p0"
end
enddefault termination point prefix is p, it can change like below:
node1 = node `node1`
node1.tp_prefix = `eth`#links_between method searches and returns all links as array.
It finds links irrespective of node direction (src/dst).
Below examples uses this network.
nws = Netomox::DSL::Networks.new do
network 'nwX' do
node_x = node 'nodeX' do
term_point 'tpA'
end
node_y = node 'nodeY' do
term_point 'tpB'
end
node_x.bdlink_to(node_y)
node_x.bdlink_to(node_y.tp('tpB'))
node_x.tp('tpA').bdlink_to(node_y)
node_x.tp('tpA').bdlink_to(node_y.tp('tpB'))
end
end(1) Network#links_between
It returns all links specified conditions.
It can omit (src|dst)_tp_name.
opts = {
src_node_name: 'nodeX', src_tp_name: 'p0',
dst_node_name: 'nodeY', dst_tp_name: 'p0'
}
@nws.network('nwX').links_between(opts) #=> array that has 2 Links.(2) Node#links_between and TermPoint#links_between
node_x = nws.network('nwX').node('nodeX')
node_y = nws.network('nwX').node('nodeY')
node_x.links_between(node_y.term_point('tpB')) #=> array that has 4 Links.#topo_data methods generate ruby hash/array data (it called recursively for registered data).
It can convert any data format. For example, use json:
require 'json'
require 'netomox'
nws = Netomox::DSL::Networks.new do
# ...
end
puts JSON.pretty_generate(nws.topo_data)