Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flame-clmc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
flame
flame-clmc
Commits
9ce5f012
Commit
9ce5f012
authored
6 years ago
by
Nikolay Stanchev
Browse files
Options
Downloads
Patches
Plain Diff
Updates the network topology builder
parent
cfe4e4ca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/service/clmcservice/graphapi/views.py
+27
-3
27 additions, 3 deletions
src/service/clmcservice/graphapi/views.py
with
27 additions
and
3 deletions
src/service/clmcservice/graphapi/views.py
+
27
−
3
View file @
9ce5f012
...
...
@@ -250,7 +250,7 @@ class GraphAPI(object):
# map the dpid to the switch IP address, the IP address is in the format '/172.168.23.54:1234'
switches
[
switch
[
"
switchDPID
"
]]
=
switch
[
"
inetAddress
"
][
1
:].
split
(
"
:
"
)[
0
]
# retrieve all
links
- if SDN controller is unavailable on the given IP address return 503 Service Unavailable
# retrieve all
external links (gathered through BDDP)
- if SDN controller is unavailable on the given IP address return 503 Service Unavailable
try
:
url
=
"
http://{0}:8080{1}
"
.
format
(
sdn_controller_ip
,
"
/wm/topology/external-links/json
"
)
response
=
get
(
url
)
...
...
@@ -266,7 +266,28 @@ class GraphAPI(object):
raise
HTTPNotImplemented
(
"
The SDN controller failed to return a successful response when querying for the network topology.
"
)
try
:
links
=
response
.
json
()
external_links
=
response
.
json
()
except
ValueError
:
# response not in JSON
msg
=
"
The SDN controller returned a response which couldn
'
t be converted to JSON.
"
log
.
error
(
"
Unexpected error: {0}
"
.
format
(
msg
))
raise
HTTPNotImplemented
(
"
The SDN controller failed to return a valid JSON response when querying for the network topology.
"
)
# retrieve all local links (gathered through LLDP) - if SDN controller is unavailable on the given IP address return 503 Service Unavailable
try
:
url
=
"
http://{0}:8080{1}
"
.
format
(
sdn_controller_ip
,
"
/wm/topology/links/json
"
)
response
=
get
(
url
)
except
exceptions
.
ConnectionError
:
msg
=
"
The SDN controller is not available on IP {0} and port 8080.
"
.
format
(
sdn_controller_ip
)
log
.
error
(
"
Unexpected error: {0}
"
.
format
(
msg
))
raise
HTTPServiceUnavailable
(
"
The SDN controller couldn
'
t be reached when trying to build the network topology.
"
)
if
response
.
status_code
!=
200
:
msg
=
"
The SDN controller returned a response with status code different than 200.
"
log
.
error
(
"
Unexpected error: {0}
"
.
format
(
msg
))
raise
HTTPNotImplemented
(
"
The SDN controller failed to return a successful response when querying for the network topology.
"
)
try
:
local_links
=
response
.
json
()
except
ValueError
:
# response not in JSON
msg
=
"
The SDN controller returned a response which couldn
'
t be converted to JSON.
"
log
.
error
(
"
Unexpected error: {0}
"
.
format
(
msg
))
...
...
@@ -283,7 +304,10 @@ class GraphAPI(object):
clusters
=
{}
# build the network graph and retrieve the number of switch nodes and cluster nodes that were created
switch_count
,
clusters_count
=
build_network_graph
(
graph
,
switches
,
links
,
clusters
)
tmp_switch_count
,
tmp_clusters_count
=
build_network_graph
(
graph
,
switches
,
external_links
,
clusters
)
switch_count
,
clusters_count
=
build_network_graph
(
graph
,
switches
,
local_links
,
clusters
)
switch_count
+=
tmp_switch_count
clusters_count
+=
tmp_clusters_count
return
{
"
new_switches_count
"
:
switch_count
,
"
new_clusters_count
"
:
clusters_count
}
...
...
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