topologygenerator 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/command_line/command_line_arguments.rb +5 -1
- data/lib/network_topologies_examples/tree_topology.rb +3 -3
- data/lib/providers/apis/opendaylight_topology_provider.rb +112 -0
- data/lib/providers/customs/object_topology_provider.rb +15 -0
- data/lib/topologygenerator/version.rb +1 -1
- data/lib/topologygenerator.rb +10 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eafb2543e3876c05948503909a8e60e442cac869
|
4
|
+
data.tar.gz: fd22daaaaf90d9e9db7a67374259b6bb534e7e85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91dbd5028611587905f8394e0e57f4daec0be02df4d2de1c8ab0a677e20a299ec413296b21c9a037ad736982223c486a29376017f17ff816f2f6ee8c08a5dd33
|
7
|
+
data.tar.gz: 5da9d2b2594e9e3727b3af542dd142e54c8f5653b896c6b5adcac7d5561ea3026db75db5f62fdda5a4c4dbce3a2675a2c8f023cad33e7d701d6cea4f6b69d45c
|
@@ -35,12 +35,16 @@ class CommandLineArguments
|
|
35
35
|
options.default :outDir => 'output'
|
36
36
|
options.default :dirBuilders => 'builders_examples/pdm_builders/PhaseI'
|
37
37
|
new_source = options.name
|
38
|
-
raise ArgumentError, "The source '#{new_source}' is not one of the expected. Please type source --help to more information." unless ['ONOS','CUSTOM'].include? new_source
|
38
|
+
raise ArgumentError, "The source '#{new_source}' is not one of the expected. Please type source --help to more information." unless ['ONOS','OPENDAYLIGHT','CUSTOM'].include? new_source
|
39
39
|
|
40
40
|
if new_source == 'ONOS'
|
41
41
|
new_uri_resource = options.uri
|
42
42
|
new_uri_resource = ask 'http source for ONOS?:(example http://127.0.0.1:8181/onos/v1/)' unless new_uri_resource
|
43
43
|
raise ArgumentError, "You must specify a valid http source when the option ONOS is selected. #{new_uri_resource} is not a valid one" unless new_uri_resource =~ /\A#{URI::regexp(['http', 'https'])}\z/
|
44
|
+
elsif new_source == 'OPENDAYLIGHT'
|
45
|
+
new_uri_resource = options.uri
|
46
|
+
new_uri_resource = ask 'http source for OPENDAYLIGHT?:(example http://localhost:8080/restconf/operational/network-topology:network-topology/topology/flow:1/)' unless new_uri_resource
|
47
|
+
raise ArgumentError, "You must specify a valid http source when the option OPENDAYLIGHT is selected. #{new_uri_resource} is not a valid one" unless new_uri_resource =~ /\A#{URI::regexp(['http', 'https'])}\z/
|
44
48
|
elsif new_source == 'CUSTOM'
|
45
49
|
new_uri_resource = options.uri
|
46
50
|
new_uri_resource = ask 'uri source for CUSTOM?:(example network_topologies_examples/tree_topology.rb)' unless new_uri_resource
|
@@ -62,7 +62,7 @@ module NetworkTopology
|
|
62
62
|
flow_1_path.add_link link3
|
63
63
|
@topology.add_flow "Flow1",
|
64
64
|
10,
|
65
|
-
flow_1_path,
|
65
|
+
[flow_1_path],
|
66
66
|
(ExponentialDistribution.new 1.0/6875),
|
67
67
|
(ConstantDistribution.new 1000*8)
|
68
68
|
|
@@ -71,7 +71,7 @@ module NetworkTopology
|
|
71
71
|
flow_2_path.add_link link3
|
72
72
|
@topology.add_flow "Flow2",
|
73
73
|
15,
|
74
|
-
flow_2_path,
|
74
|
+
[flow_2_path],
|
75
75
|
(ExponentialDistribution.new 1.0/6875),
|
76
76
|
(ConstantDistribution.new 1000*8)
|
77
77
|
|
@@ -80,7 +80,7 @@ module NetworkTopology
|
|
80
80
|
flow_3_path.add_link link5
|
81
81
|
@topology.add_flow "Flow3",
|
82
82
|
20,
|
83
|
-
flow_3_path,
|
83
|
+
[flow_3_path],
|
84
84
|
(ExponentialDistribution.new 1.0/6875),
|
85
85
|
(ConstantDistribution.new 1000*8)
|
86
86
|
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'typhoeus'
|
2
|
+
require_relative "../interface_topology_provider.rb"
|
3
|
+
require_relative "../../network_entities/topology.rb"
|
4
|
+
require_relative '../../network_entities/abstracts/path.rb'
|
5
|
+
|
6
|
+
class OpendaylightTopologyProvider < ITopologyProvider
|
7
|
+
|
8
|
+
attr_accessor :uri_resource
|
9
|
+
|
10
|
+
def initialize(new_uri_resource)
|
11
|
+
raise ArgumentError, 'No uri recieved as parameter' unless new_uri_resource
|
12
|
+
@uri_resource = new_uri_resource
|
13
|
+
@topology = Topology.new
|
14
|
+
end
|
15
|
+
|
16
|
+
=begin
|
17
|
+
This is who it looks like the xml received by the opendaylight api
|
18
|
+
|
19
|
+
<topology>
|
20
|
+
<topology-id>flow:1</topology-id>
|
21
|
+
<node>
|
22
|
+
<node-id>openflow:1</node-id>
|
23
|
+
<inventory-node-ref>/a:nodes/a:node[a:id='openflow:1']</inventory-node-ref>
|
24
|
+
<termination-point>
|
25
|
+
<tp-id>openflow:1:2</tp-id>
|
26
|
+
<inventory-node-connector-ref>/a:nodes/a:node[a:id='openflow:1']/a:node-connector[a:id='openflow:1:2']</inventory-node-connector-ref>
|
27
|
+
</termination-point>
|
28
|
+
<termination-point>
|
29
|
+
<tp-id>openflow:1:1</tp-id>
|
30
|
+
<inventory-node-connector-ref>/a:nodes/a:node[a:id='openflow:1']/a:node-connector[a:id='openflow:1:1']</inventory-node-connector-ref>
|
31
|
+
</termination-point>
|
32
|
+
<termination-point>
|
33
|
+
<tp-id>openflow:1:LOCAL</tp-id>
|
34
|
+
<inventory-node-connector-ref>/a:nodes/a:node[a:id='openflow:1']/a:node-connector[a:id='openflow:1:LOCAL']</inventory-node-connector-ref>
|
35
|
+
</termination-point>
|
36
|
+
</node>
|
37
|
+
<node>
|
38
|
+
<node-id>host:52:57:c6:e4:b3:33</node-id>
|
39
|
+
<id>52:57:c6:e4:b3:33</id>
|
40
|
+
<addresses>
|
41
|
+
<id>1</id>
|
42
|
+
<mac>52:57:c6:e4:b3:33</mac>
|
43
|
+
<ip>10.0.0.2</ip>
|
44
|
+
<first-seen>1480973744947</first-seen>
|
45
|
+
<last-seen>1480973744947</last-seen>
|
46
|
+
</addresses>
|
47
|
+
<attachment-points>
|
48
|
+
<tp-id>openflow:2:2</tp-id>
|
49
|
+
<active>true</active>
|
50
|
+
<corresponding-tp>host:52:57:c6:e4:b3:33</corresponding-tp>
|
51
|
+
</attachment-points>
|
52
|
+
<termination-point>
|
53
|
+
<tp-id>host:52:57:c6:e4:b3:33</tp-id>
|
54
|
+
</termination-point>
|
55
|
+
</node>
|
56
|
+
<link>
|
57
|
+
<link-id>openflow:1:2</link-id>
|
58
|
+
<source>
|
59
|
+
<source-node>openflow:1</source-node>
|
60
|
+
<source-tp>openflow:1:2</source-tp>
|
61
|
+
</source>
|
62
|
+
<destination>
|
63
|
+
<dest-node>openflow:2</dest-node>
|
64
|
+
<dest-tp>openflow:2:1</dest-tp>
|
65
|
+
</destination>
|
66
|
+
</link>
|
67
|
+
<link>
|
68
|
+
<link-id>host:5e:66:e6:c2:d0:02/openflow:3:1</link-id>
|
69
|
+
<source>
|
70
|
+
<source-node>host:5e:66:e6:c2:d0:02</source-node>
|
71
|
+
<source-tp>host:5e:66:e6:c2:d0:02</source-tp>
|
72
|
+
</source>
|
73
|
+
<destination>
|
74
|
+
<dest-node>openflow:3</dest-node>
|
75
|
+
<dest-tp>openflow:3:1</dest-tp>
|
76
|
+
</destination>
|
77
|
+
</link>
|
78
|
+
</topology>
|
79
|
+
=end
|
80
|
+
|
81
|
+
def get_topology
|
82
|
+
response = Typhoeus.get "#{@uri_resource}/restconf/operational/network-topology:network-topology/topology/flow:1/", userpwd:"admin:admin"
|
83
|
+
topology_json_response = (JSON.parse response.body)['topology'].first
|
84
|
+
nodes_info = topology_json_response['node']
|
85
|
+
links_info = topology_json_response['link']
|
86
|
+
|
87
|
+
nodes_info.each do |node|
|
88
|
+
if node['node-id'].include? 'openflow'
|
89
|
+
@topology.add_router node['node-id']
|
90
|
+
else
|
91
|
+
@topology.add_host node['node-id'], node['ip'], node['mac']
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
links_info.each do |link|
|
96
|
+
source = @topology.get_element_by_id link['source']['source-node']
|
97
|
+
destiny = @topology.get_element_by_id link['destination']['dest-node']
|
98
|
+
|
99
|
+
#TODO: WHICH IS THE FORM OF FINDING THE PORT OF THE HOST?
|
100
|
+
source_port = (source.is_a? Host) ? 1 : (link['source']['source-tp'].gsub "#{source.id}:", '').to_i
|
101
|
+
destiny_port = (destiny.is_a? Host) ? 1 : (link['destination']['dest-tp'].gsub "#{destiny.id}:", '').to_i
|
102
|
+
|
103
|
+
@topology.add_link link['link-id'], source, source_port, destiny, destiny_port
|
104
|
+
end
|
105
|
+
|
106
|
+
@topology.topology_elements
|
107
|
+
end
|
108
|
+
|
109
|
+
def get_path_between(source, destination)
|
110
|
+
raise NotImplementedError, "OpenDayLight provider: This method is not implemented!"
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ObjectTopologyProvider < ITopologyProvider
|
2
|
+
attr_reader :uri_resource
|
3
|
+
|
4
|
+
def initialize(topology)
|
5
|
+
@topology = topology
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_topology
|
9
|
+
@topology
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_path_between(source, destination)
|
13
|
+
raise NotImplementedError, "ITopologyProvider: Implement this method in a child class"
|
14
|
+
end
|
15
|
+
end
|
data/lib/topologygenerator.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require_relative "topologygenerator/version"
|
2
2
|
require_relative 'providers/apis/onos_topology_provider.rb'
|
3
|
+
require_relative 'providers/apis/opendaylight_topology_provider.rb'
|
3
4
|
require_relative 'providers/customs/custom_topology_provider.rb'
|
5
|
+
require_relative 'providers/customs/object_topology_provider.rb'
|
4
6
|
require_relative 'output_builder.rb'
|
5
7
|
require 'byebug'
|
6
8
|
|
@@ -8,6 +10,8 @@ require 'byebug'
|
|
8
10
|
class Topologygenerator
|
9
11
|
attr_reader :topology_provider, :output_builder
|
10
12
|
|
13
|
+
LIST_PROVIDERS_IMPLEMENTED = ['ONOS', 'OPENDAYLIGHT','CUSTOM', 'OBJECT'] #TODO: Receive the providers from t
|
14
|
+
|
11
15
|
def initialize(arguments)
|
12
16
|
validate arguments
|
13
17
|
@arguments = arguments
|
@@ -15,10 +19,12 @@ class Topologygenerator
|
|
15
19
|
case @arguments['source']
|
16
20
|
when 'ONOS'
|
17
21
|
@topology_provider = OnosTopologyProvider.new @arguments['uri_resource']
|
22
|
+
when 'OPENDAYLIGHT'
|
23
|
+
@topology_provider = OpendaylightTopologyProvider.new @arguments['uri_resource']
|
18
24
|
when 'CUSTOM'
|
19
25
|
@topology_provider = CustomTopologyProvider.new @arguments['uri_resource']
|
20
|
-
|
21
|
-
|
26
|
+
when 'OBJECT'
|
27
|
+
@topology_provider = ObjectTopologyProvider.new @arguments['uri_resource']
|
22
28
|
end
|
23
29
|
end
|
24
30
|
|
@@ -32,5 +38,7 @@ class Topologygenerator
|
|
32
38
|
["source","directory_concrete_builders","output_directory", "uri_resource"].each do |argument_name|
|
33
39
|
raise ArgumentError, "It is mandatory that arguments has a #{argument_name}" unless arguments.key? argument_name
|
34
40
|
end
|
41
|
+
|
42
|
+
raise ArgumentError, "The source: #{arguments['source']} is not one of the expected" unless LIST_PROVIDERS_IMPLEMENTED.include? arguments['source']
|
35
43
|
end
|
36
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: topologygenerator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrés Laurito
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -148,7 +148,9 @@ files:
|
|
148
148
|
- lib/network_topologies_examples/tree_topology.rb
|
149
149
|
- lib/output_builder.rb
|
150
150
|
- lib/providers/apis/onos_topology_provider.rb
|
151
|
+
- lib/providers/apis/opendaylight_topology_provider.rb
|
151
152
|
- lib/providers/customs/custom_topology_provider.rb
|
153
|
+
- lib/providers/customs/object_topology_provider.rb
|
152
154
|
- lib/providers/interface_topology_provider.rb
|
153
155
|
- lib/topologygenerator.rb
|
154
156
|
- lib/topologygenerator/version.rb
|