AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 1 | """**** Scripted by Antony Silvester ****** """ |
| 2 | import json |
| 3 | from urllib import addbase |
| 4 | import os |
| 5 | |
| 6 | |
| 7 | import requests |
| 8 | from requests.auth import HTTPBasicAuth |
| 9 | |
| 10 | |
| 11 | class BgpLs: |
| 12 | |
| 13 | def __init__(self): |
| 14 | self.localAs = 100 |
| 15 | self.maxSession = 20 |
| 16 | self.lsCapability = True |
| 17 | self.holdTime = 180 |
| 18 | self.largeAsCapability = False |
| 19 | self.flowSpecCapability = 'IPV4' |
| 20 | self.flowSpecRpdCapability = False |
| 21 | self.remoteAs = 100 |
| 22 | self.peerHoldTime = 120 |
| 23 | self.connectMode = 'active' |
| 24 | self.bgpPeer = [] |
| 25 | self.routerId = '' |
| 26 | self.peerIp = '' |
| 27 | #self.org_bgp = [] |
| 28 | |
| 29 | def ipValue(self,localip,remoteip): |
| 30 | self.routerId = localip |
| 31 | self.peerIp = remoteip |
| 32 | return self.routerId , self.peerIp |
| 33 | |
| 34 | def DictoJson(self): |
| 35 | Dicdata = {} |
| 36 | org_bgp =[] |
| 37 | org_bgp.append({'peerIp': self.peerIp , 'remoteAs':self.remoteAs, |
| 38 | 'peerHoldTime':self.peerHoldTime , 'connectMode':self.connectMode }) |
| 39 | if self.routerId != '': |
| 40 | Dicdata['routerId'] = self.routerId |
| 41 | if self.localAs != '': |
| 42 | Dicdata['localAs'] = self.localAs |
| 43 | if self.maxSession != '': |
| 44 | Dicdata['maxSession'] = self.maxSession |
| 45 | if self.lsCapability != '': |
| 46 | Dicdata['lsCapability'] = self.lsCapability |
| 47 | if self.holdTime != '': |
| 48 | Dicdata['holdTime'] = self.holdTime |
| 49 | if self.largeAsCapability != '': |
| 50 | Dicdata['largeAsCapability'] = self.largeAsCapability |
| 51 | if self.flowSpecCapability != '': |
| 52 | Dicdata['flowSpecCapability'] = self.flowSpecCapability |
| 53 | if self.flowSpecRpdCapability != '': |
| 54 | Dicdata['flowSpecRpdCapability'] = self.flowSpecRpdCapability |
| 55 | if self.bgpPeer != '': |
| 56 | Dicdata['bgpPeer'] = org_bgp |
| 57 | |
| 58 | Dicdata = {'bgpapp':Dicdata} |
| 59 | Dicdata = {'org.onosproject.provider.bgp.cfg':Dicdata} |
| 60 | Dicdata = {'apps':Dicdata} |
| 61 | return json.dumps(Dicdata,indent=4) |
| 62 | |
| 63 | |
| 64 | def Comments(self): |
| 65 | print("**********************************************************************************\n") |
| 66 | |
| 67 | def Constants(self): |
| 68 | self.Ne_id_1 = '1111.1111.0011' |
| 69 | self.Ne_id_2 = '2222.2222.0022' |
| 70 | self.Ne_id_3 = '3333.3333.0033' |
| 71 | self.Ne_id_4 = '4444.4444.0044' |
| 72 | listnum = [self.Ne_id_1,self.Ne_id_2,self.Ne_id_3,self.Ne_id_4,] |
| 73 | var = [self.peerIp] |
| 74 | return var,listnum |
| 75 | |
| 76 | def apps(self): |
| 77 | self.app_bgp = 'org.onosproject.bgp' |
| 78 | self.app_bgpflow = 'org.onosproject.bgpflow' |
| 79 | self.list1 = [self.app_bgp,self.app_bgpflow] |
| 80 | return self.list1 |