Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Reinforcement_learning_based_bgp_system
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Anurag Kumar
Reinforcement_learning_based_bgp_system
Commits
cba8df56
Commit
cba8df56
authored
Nov 29, 2021
by
Anurag Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
0b6c25e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
Controller_program/Ryu_controller_sdn/conf_mgr.py
Controller_program/Ryu_controller_sdn/conf_mgr.py
+71
-0
No files found.
Controller_program/Ryu_controller_sdn/conf_mgr.py
0 → 100644
View file @
cba8df56
# encoding: utf-8
import
json
from
ryu
import
cfg
from
netaddr
import
IPNetwork
CONF
=
cfg
.
CONF
class
BGPSpeakerManager
(
object
):
def
__init__
(
self
):
super
(
BGPSpeakerManager
,
self
)
.
__init__
()
self
.
configPath
=
CONF
.
sdn_ip_cfg_file
self
.
load_AS_configuration
()
# change in local file
def
load_AS_configuration
(
self
):
with
open
(
self
.
configPath
,
'r'
)
as
file_pointer
:
configs
=
json
.
load
(
file_pointer
)
self
.
per_dpid
=
{}
self
.
net_id
=
{}
# store network info, where KEY = 'speaker id'
bgpSpeakers
=
[]
bgpSpeakers
=
configs
[
'bgpSpeakers'
]
local_config
=
configs
[
'local'
]
self
.
as_id
=
local_config
.
get
(
'as_id'
,
65113
)
self
.
speaker_Router_IP
=
local_config
.
get
(
'speaker_Router_IP'
,
'127.0.0.1'
)
self
.
in_port
=
local_config
.
get
(
'in_port'
,
2000
)
self
.
network_id
=
local_config
.
get
(
'network_id'
,
[])
for
bgpSpeaker
in
bgpSpeakers
:
bgp_Speakers_ID
=
bgpSpeaker
[
'speaker_ids'
]
port
=
bgpSpeaker
[
'port'
]
dpid
=
bgpSpeaker
[
'dpid'
]
mac
=
bgpSpeaker
[
'mac'
]
self
.
per_dpid
.
setdefault
(
dpid
,
[])
for
bgp_speaker
in
bgp_Speakers_ID
:
self
.
per_dpid
[
dpid
]
.
append
({
'port'
:
port
,
'id'
:
bgp_speaker
,
'mac'
:
mac
})
self
.
net_id
.
setdefault
(
bgp_speaker
,
{
'dpid'
:
dpid
,
'port'
:
port
,
'mac'
:
mac
})
# def get_speaker_connect_port(self, bgp_speaker_id):
# return self.net_id.get(bgp_speaker_id)
def
speaker_MAC_Addr
(
self
,
bgp_speaker_id
):
macAddr
=
self
.
net_id
.
get
(
bgp_speaker_id
)[
'mac'
]
return
macAddr
def
get_speakers_id
(
self
):
bgp_speaker_keys
=
self
.
net_id
.
keys
()
return
bgp_speaker_keys
# def get_all_speakers_by_dpid(self, dpid):
# return self.per_dpid[dpid]
# def is_internal_host(self, ip):
# for network in self.network_id:
# nw = IPNetwork(network)
# if ip in nw:
# return True
# return False
# def get_internal_networks(self):
# return self.network_id
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment