Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
c95dd557
Commit
c95dd557
authored
1 year ago
by
Andrea Sgambelluri
Browse files
Options
Downloads
Patches
Plain Diff
"temp system"
parent
6c633636
No related branches found
No related tags found
2 merge requests
!294
Release TeraFlowSDN 4.0
,
!284
Resolve: "(CNIT) Multi-Granular Optical Nodes and Optical Transpoders management"
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/opticalcontroller/OpticalController.py
+32
-24
32 additions, 24 deletions
src/opticalcontroller/OpticalController.py
src/opticalcontroller/RSA.py
+1
-0
1 addition, 0 deletions
src/opticalcontroller/RSA.py
src/opticalcontroller/tools.py
+6
-6
6 additions, 6 deletions
src/opticalcontroller/tools.py
with
39 additions
and
30 deletions
src/opticalcontroller/OpticalController.py
+
32
−
24
View file @
c95dd557
...
...
@@ -6,6 +6,7 @@ from variables import *
from
RSA
import
RSA
import
time
,
logging
from
common.proto.context_pb2
import
TopologyId
import
json
...
...
@@ -200,21 +201,24 @@ class GetBand(Resource):
class
GetFlows
(
Resource
):
@staticmethod
def
get
():
global
links_dict
#global links_dict
global
rsa
links
=
rsa
.
links_dict
try
:
if
debug
:
print
(
links
_dict
)
return
links
_dict
,
200
print
(
links
)
return
links
,
200
except
:
return
"
Error
"
,
404
@optical.route
(
'
/GetTopology/<path:context_id>/<path:topology_id>
'
,
methods
=
[
'
GET
'
])
@optical.response
(
200
,
'
Success
'
)
@optical.response
(
404
,
'
Error, not found
'
)
class
GetTopology
(
Resource
):
@staticmethod
def
get
(
context_id
:
str
,
topology_id
:
str
):
global
rsa
topog_id
=
TopologyId
()
topog_id
.
topology_uuid
.
uuid
=
topology_id
topog_id
.
context_id
.
context_uuid
.
uuid
=
context_id
...
...
@@ -222,26 +226,30 @@ class GetTopology(Resource):
try
:
links_dict
=
{
"
optical_links
"
:[]}
node_dict
=
{}
i
=
0
nodes
,
topo
=
readTopologyDataFromContext
(
topog_id
)
topo
,
nodes
=
readTopologyDataFromContext
(
topog_id
)
for
node
in
nodes
:
links_dict
[
"
optical_links
"
].
append
(
node
)
for
device
in
topo
:
dic
=
{}
dic
=
{
"
id
"
:
device
.
device_id
.
device_uuid
.
uuid
,
"
ip
"
:
f
"
10.30.2.
{
207
+
i
}
"
,
"
port
"
:
"
50001
"
,
"
type
"
:
"
OC-ROADM
"
if
device
.
device_type
==
"
optical-roadm
"
else
"
OC-ROADM
"
,
"
driver
"
:
"
OpticalOC
"
}
node_dict
[
device
.
name
]
=
dic
i
+=
1
print
(
f
"
refresh_opticacontroller optical_links_dict
{
links_dict
}
"
)
print
(
f
"
refresh_opticacontroller node_dict
{
node_dict
}
"
)
rsa
=
RSA
(
node_dict
,
links_dict
)
return
"
Done
"
for
link
in
topo
:
links_dict
[
"
optical_links
"
].
append
(
link
)
#print(link["optical_details"]["c_slots"])
for
device
in
nodes
:
dev_dic
=
{}
dev_dic
=
{
"
id
"
:
device
.
device_id
.
device_uuid
.
uuid
,
#"ip":f"10.30.2.{207+i}",
#"port":"50001",
"
type
"
:
"
OC-ROADM
"
if
device
.
device_type
==
"
optical-roadm
"
else
"
OC-TP
"
,
"
driver
"
:
"
OpticalOC
"
}
node_dict
[
device
.
name
]
=
dev_dic
#i+=1
print
(
f
"
refresh_optical controller optical_links_dict=
{
json
.
dump
(
links_dict
)
}
"
)
print
(
f
"
refresh_optical controller node_dict
{
json
.
dump
(
node_dict
)
}
"
)
rsa
=
RSA
(
node_dict
,
links_dict
)
return
rsa
.
links_dict
except
Exception
as
e
:
print
(
f
"
err
{
e
}
"
)
return
"
Error
"
,
404
...
...
@@ -252,7 +260,7 @@ class GetTopology(Resource):
if
__name__
==
'
__main__
'
:
nodes_dict
,
links_dict
=
readTopologyData
(
nodes_json
,
topology_json
)
#
nodes_dict, links_dict = readTopologyData(nodes_json, topology_json)
#rsa = RSA(nodes_dict, links_dict)
...
...
This diff is collapsed.
Click to expand it.
src/opticalcontroller/RSA.py
+
1
−
0
View file @
c95dd557
...
...
@@ -18,6 +18,7 @@ class RSA():
self
.
s_slot_number
=
0
self
.
optical_bands
=
{}
print
(
f
"
node_ctxt
{
nodes
}
links_ctxt
{
links
}
"
)
def
init_link_slots
(
self
,
testing
):
if
not
testing
:
for
l
in
self
.
links_dict
[
"
optical_links
"
]:
...
...
This diff is collapsed.
Click to expand it.
src/opticalcontroller/tools.py
+
6
−
6
View file @
c95dd557
...
...
@@ -143,9 +143,9 @@ def readTopologyData(nodes, topology):
nodes_file
.
close
()
topo_file
.
close
()
return
nodes
,
topo
def
readTopologyDataFromContext
(
topology_id
:
TopologyId
):
def
readTopologyDataFromContext
(
topology_id
:
TopologyId
):
ctx_client
=
ContextClient
()
ctx_client
.
connect
()
topo_details
=
ctx_client
.
GetTopologyDetails
(
topology_id
)
...
...
@@ -153,7 +153,7 @@ def readTopologyDataFromContext(topology_id:TopologyId):
nodes
=
topo_details
.
devices
ctx_client
.
close
()
return
topo
,
nodes
def
reverse_links
(
links
):
temp_links
=
links
.
copy
()
...
...
@@ -167,7 +167,7 @@ def reverse_links(links):
def
get_links_from_node
(
topology
,
node
):
result
=
{}
for
link
in
topology
[
"
links
"
]:
for
link
in
topology
[
"
optical_
links
"
]:
if
"
{}-
"
.
format
(
node
)
in
link
[
"
name
"
]:
result
[
link
[
"
name
"
]]
=
link
return
result
...
...
@@ -175,7 +175,7 @@ def get_links_from_node(topology, node):
def
get_links_to_node
(
topology
,
node
):
result
=
{}
for
link
in
topology
[
"
links
"
]:
for
link
in
topology
[
"
optical_
links
"
]:
if
"
-{}
"
.
format
(
node
)
in
link
[
"
name
"
]:
result
[
link
[
"
name
"
]]
=
link
return
result
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment