Commit cba8df56 authored by Anurag Kumar's avatar Anurag Kumar

Upload New File

parent 0b6c25e7
# 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment