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
d68868c7
Commit
d68868c7
authored
1 year ago
by
Mohammad Ismaeel
Browse files
Options
Downloads
Patches
Plain Diff
OpticalController reading from context
parent
c95dd557
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
+30
-29
30 additions, 29 deletions
src/opticalcontroller/OpticalController.py
src/opticalcontroller/RSA.py
+3
-1
3 additions, 1 deletion
src/opticalcontroller/RSA.py
test.py
+15
-11
15 additions, 11 deletions
test.py
with
48 additions
and
41 deletions
src/opticalcontroller/OpticalController.py
+
30
−
29
View file @
d68868c7
...
@@ -5,11 +5,12 @@ from tools import *
...
@@ -5,11 +5,12 @@ from tools import *
from
variables
import
*
from
variables
import
*
from
RSA
import
RSA
from
RSA
import
RSA
import
time
,
logging
import
time
,
logging
from
common.proto.context_pb2
import
TopologyId
from
common.proto.context_pb2
import
TopologyId
,
OpticalLink
import
json
import
json
from
google.protobuf.message
import
Message
from
google.protobuf.json_format
import
MessageToDict
global
rsa
global
links_dict
rsa
=
None
rsa
=
None
...
@@ -201,9 +202,11 @@ class GetBand(Resource):
...
@@ -201,9 +202,11 @@ class GetBand(Resource):
class
GetFlows
(
Resource
):
class
GetFlows
(
Resource
):
@staticmethod
@staticmethod
def
get
():
def
get
():
#global links_dict
global
rsa
global
rsa
links
=
rsa
.
links_dict
#global links_dict
links
=
None
if
rsa
is
not
None
:
links
=
rsa
.
links_dict
try
:
try
:
if
debug
:
if
debug
:
print
(
links
)
print
(
links
)
...
@@ -218,21 +221,24 @@ class GetFlows(Resource):
...
@@ -218,21 +221,24 @@ class GetFlows(Resource):
class
GetTopology
(
Resource
):
class
GetTopology
(
Resource
):
@staticmethod
@staticmethod
def
get
(
context_id
:
str
,
topology_id
:
str
):
def
get
(
context_id
:
str
,
topology_id
:
str
):
logging
.
info
(
"
get the request
"
)
global
rsa
global
rsa
topog_id
=
TopologyId
()
topog_id
=
TopologyId
()
topog_id
.
topology_uuid
.
uuid
=
topology_id
topog_id
.
topology_uuid
.
uuid
=
topology_id
topog_id
.
context_id
.
context_uuid
.
uuid
=
context_id
topog_id
.
context_id
.
context_uuid
.
uuid
=
context_id
print
(
f
"
topog_id
{
topog_id
}
"
)
try
:
try
:
links_dict
=
{
"
optical_links
"
:[]}
links_dict
=
{
"
optical_links
"
:[]}
node_dict
=
{}
node_dict
=
{}
topo
,
nodes
=
readTopologyDataFromContext
(
topog_id
)
topo
,
nodes
=
readTopologyDataFromContext
(
topog_id
)
for
link
in
topo
:
for
link
in
topo
:
links_dict
[
"
optical_links
"
].
append
(
link
)
link_dict_type
=
MessageToDict
(
link
,
preserving_proto_field_name
=
True
)
#print(link["optical_details"]["c_slots"])
links_dict
[
"
optical_links
"
].
append
(
link_dict_type
)
for
device
in
nodes
:
for
device
in
nodes
:
dev_dic
=
{}
dev_dic
=
{}
dev_dic
=
{
dev_dic
=
{
"
id
"
:
device
.
device_id
.
device_uuid
.
uuid
,
"
id
"
:
device
.
device_id
.
device_uuid
.
uuid
,
...
@@ -243,27 +249,22 @@ class GetTopology(Resource):
...
@@ -243,27 +249,22 @@ class GetTopology(Resource):
}
}
node_dict
[
device
.
name
]
=
dev_dic
node_dict
[
device
.
name
]
=
dev_dic
#i+=1
#i+=1
print
(
f
"
refresh_optical controller optical_links_dict=
{
json
.
dump
(
links_dict
)
}
"
)
#print(f"refresh_optical controller optical_links_dict= {links_dict}")
print
(
f
"
refresh_optical controller node_dict
{
json
.
dump
(
node_dict
)
}
"
)
#print(f"refresh_optical controller node_dict {node_dict}")
rsa
=
RSA
(
node_dict
,
links_dict
)
rsa
=
RSA
(
node_dict
,
links_dict
)
return
"
ok
"
,
200
return
rsa
.
links_dict
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"
err
{
e
}
"
)
print
(
f
"
err
{
e
}
"
)
return
"
Error
"
,
40
4
return
"
Error
"
,
40
0
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
#nodes_dict, links_dict = readTopologyData(nodes_json, topology_json)
#rsa = RSA(nodes_dict, links_dict)
#print(rsa.init_link_slots2(testing))
app
.
run
(
host
=
'
0.0.0.0
'
,
port
=
10060
)
app
.
run
(
host
=
'
0.0.0.0
'
,
port
=
10060
)
This diff is collapsed.
Click to expand it.
src/opticalcontroller/RSA.py
+
3
−
1
View file @
d68868c7
...
@@ -17,7 +17,7 @@ class RSA():
...
@@ -17,7 +17,7 @@ class RSA():
self
.
l_slot_number
=
0
self
.
l_slot_number
=
0
self
.
s_slot_number
=
0
self
.
s_slot_number
=
0
self
.
optical_bands
=
{}
self
.
optical_bands
=
{}
print
(
f
"
node_ctxt
{
nodes
}
links_ctxt
{
links
}
"
)
def
init_link_slots
(
self
,
testing
):
def
init_link_slots
(
self
,
testing
):
if
not
testing
:
if
not
testing
:
...
@@ -86,7 +86,9 @@ class RSA():
...
@@ -86,7 +86,9 @@ class RSA():
self
.
g
.
printGraph
()
self
.
g
.
printGraph
()
def
initGraph2
(
self
):
def
initGraph2
(
self
):
self
.
g
=
dijsktra
.
Graph
()
self
.
g
=
dijsktra
.
Graph
()
for
n
in
self
.
nodes_dict
:
for
n
in
self
.
nodes_dict
:
self
.
g
.
add_vertex
(
n
)
self
.
g
.
add_vertex
(
n
)
for
l
in
self
.
links_dict
[
"
optical_links
"
]:
for
l
in
self
.
links_dict
[
"
optical_links
"
]:
...
...
This diff is collapsed.
Click to expand it.
test.py
+
15
−
11
View file @
d68868c7
...
@@ -83,15 +83,19 @@ def extract_value (xml_data):
...
@@ -83,15 +83,19 @@ def extract_value (xml_data):
else
:
else
:
print
(
"
element not found.
"
)
print
(
"
element not found.
"
)
def
main
()
:
if
__name__
==
'
__main__
'
:
with
manager
.
connect
(
**
device
)
as
m
:
#
with manager.connect(**device) as m:
# Perform operations on the remote machine using the 'm' object
#
# Perform operations on the remote machine using the 'm' object
# For example, you can retrieve the running configuration:
#
# For example, you can retrieve the running configuration:
#result =m.edit_config(target='running',config=edit_config)
#
#result =m.edit_config(target='running',config=edit_config)
running_config
=
m
.
get_config
(
'
running
'
).
data_xml
#
running_config = m.get_config('running').data_xml
#extract_roadm_ports(running_config)
# #extract_roadm_ports(running_config)
x
,
y
=
[
1
,
3
]
# x,y= [1,3]
print
(
x
)
# print (x)
nodes
=
{
"
t13
"
:{
"
name
"
:
"
t1
"
,
"
value
"
:
1
},
"
t2
"
:{
"
name
"
:
"
t2
"
,
"
value
"
:
2
}
}
for
n
in
nodes
:
print
(
n
)
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