Committed by
Gerrit Code Review
Made SDN-IP's BGP listen port configurable
Change-Id: I98bb6bb2d500087757b57bf0ed9f5c709d459aef
Showing
2 changed files
with
43 additions
and
3 deletions
... | @@ -55,6 +55,11 @@ | ... | @@ -55,6 +55,11 @@ |
55 | </dependency> | 55 | </dependency> |
56 | 56 | ||
57 | <dependency> | 57 | <dependency> |
58 | + <groupId>org.osgi</groupId> | ||
59 | + <artifactId>org.osgi.compendium</artifactId> | ||
60 | + </dependency> | ||
61 | + | ||
62 | + <dependency> | ||
58 | <groupId>org.onosproject</groupId> | 63 | <groupId>org.onosproject</groupId> |
59 | <artifactId>onlab-thirdparty</artifactId> | 64 | <artifactId>onlab-thirdparty</artifactId> |
60 | </dependency> | 65 | </dependency> | ... | ... |
... | @@ -18,10 +18,12 @@ package org.onosproject.sdnip; | ... | @@ -18,10 +18,12 @@ package org.onosproject.sdnip; |
18 | import static org.slf4j.LoggerFactory.getLogger; | 18 | import static org.slf4j.LoggerFactory.getLogger; |
19 | 19 | ||
20 | import java.util.Collection; | 20 | import java.util.Collection; |
21 | +import java.util.Dictionary; | ||
21 | 22 | ||
22 | import org.apache.felix.scr.annotations.Activate; | 23 | import org.apache.felix.scr.annotations.Activate; |
23 | import org.apache.felix.scr.annotations.Component; | 24 | import org.apache.felix.scr.annotations.Component; |
24 | import org.apache.felix.scr.annotations.Deactivate; | 25 | import org.apache.felix.scr.annotations.Deactivate; |
26 | +import org.apache.felix.scr.annotations.Modified; | ||
25 | import org.apache.felix.scr.annotations.Reference; | 27 | import org.apache.felix.scr.annotations.Reference; |
26 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 28 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
27 | import org.apache.felix.scr.annotations.Service; | 29 | import org.apache.felix.scr.annotations.Service; |
... | @@ -38,6 +40,7 @@ import org.onosproject.sdnip.bgp.BgpRouteEntry; | ... | @@ -38,6 +40,7 @@ import org.onosproject.sdnip.bgp.BgpRouteEntry; |
38 | import org.onosproject.sdnip.bgp.BgpSession; | 40 | import org.onosproject.sdnip.bgp.BgpSession; |
39 | import org.onosproject.sdnip.bgp.BgpSessionManager; | 41 | import org.onosproject.sdnip.bgp.BgpSessionManager; |
40 | import org.onosproject.sdnip.config.SdnIpConfigurationReader; | 42 | import org.onosproject.sdnip.config.SdnIpConfigurationReader; |
43 | +import org.osgi.service.component.ComponentContext; | ||
41 | import org.slf4j.Logger; | 44 | import org.slf4j.Logger; |
42 | 45 | ||
43 | /** | 46 | /** |
... | @@ -65,6 +68,9 @@ public class SdnIp implements SdnIpService { | ... | @@ -65,6 +68,9 @@ public class SdnIp implements SdnIpService { |
65 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 68 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
66 | protected LeadershipService leadershipService; | 69 | protected LeadershipService leadershipService; |
67 | 70 | ||
71 | + private static final int DEFAULT_BGP_PORT = 2000; | ||
72 | + private int bgpPort; | ||
73 | + | ||
68 | private IntentSynchronizer intentSynchronizer; | 74 | private IntentSynchronizer intentSynchronizer; |
69 | private SdnIpConfigurationReader config; | 75 | private SdnIpConfigurationReader config; |
70 | private PeerConnectivityManager peerConnectivity; | 76 | private PeerConnectivityManager peerConnectivity; |
... | @@ -76,8 +82,9 @@ public class SdnIp implements SdnIpService { | ... | @@ -76,8 +82,9 @@ public class SdnIp implements SdnIpService { |
76 | private ControllerNode localControllerNode; | 82 | private ControllerNode localControllerNode; |
77 | 83 | ||
78 | @Activate | 84 | @Activate |
79 | - protected void activate() { | 85 | + protected void activate(ComponentContext context) { |
80 | log.info("SDN-IP started"); | 86 | log.info("SDN-IP started"); |
87 | + readComponentConfiguration(context); | ||
81 | 88 | ||
82 | appId = coreService.registerApplication(SDN_IP_APP); | 89 | appId = coreService.registerApplication(SDN_IP_APP); |
83 | config = new SdnIpConfigurationReader(); | 90 | config = new SdnIpConfigurationReader(); |
... | @@ -104,9 +111,10 @@ public class SdnIp implements SdnIpService { | ... | @@ -104,9 +111,10 @@ public class SdnIp implements SdnIpService { |
104 | leadershipService.addListener(leadershipEventListener); | 111 | leadershipService.addListener(leadershipEventListener); |
105 | leadershipService.runForLeadership(appId.name()); | 112 | leadershipService.runForLeadership(appId.name()); |
106 | 113 | ||
114 | + log.info("Starting BGP with port {}", bgpPort); | ||
115 | + | ||
107 | bgpSessionManager = new BgpSessionManager(router); | 116 | bgpSessionManager = new BgpSessionManager(router); |
108 | - // TODO: the local BGP listen port number should be configurable | 117 | + bgpSessionManager.start(bgpPort); |
109 | - bgpSessionManager.start(2000); | ||
110 | 118 | ||
111 | // TODO need to disable link discovery on external ports | 119 | // TODO need to disable link discovery on external ports |
112 | } | 120 | } |
... | @@ -125,6 +133,33 @@ public class SdnIp implements SdnIpService { | ... | @@ -125,6 +133,33 @@ public class SdnIp implements SdnIpService { |
125 | log.info("SDN-IP Stopped"); | 133 | log.info("SDN-IP Stopped"); |
126 | } | 134 | } |
127 | 135 | ||
136 | + /** | ||
137 | + * Extracts properties from the component configuration context. | ||
138 | + * | ||
139 | + * @param context the component context | ||
140 | + */ | ||
141 | + private void readComponentConfiguration(ComponentContext context) { | ||
142 | + Dictionary<?, ?> properties = context.getProperties(); | ||
143 | + try { | ||
144 | + String strPort = (String) properties.get("bgpPort"); | ||
145 | + if (strPort != null) { | ||
146 | + bgpPort = Integer.parseInt(strPort); | ||
147 | + } else { | ||
148 | + bgpPort = DEFAULT_BGP_PORT; | ||
149 | + } | ||
150 | + } catch (Exception e) { | ||
151 | + bgpPort = DEFAULT_BGP_PORT; | ||
152 | + } | ||
153 | + log.debug("BGP port is set to {}", bgpPort); | ||
154 | + } | ||
155 | + | ||
156 | + @Modified | ||
157 | + public void modified(ComponentContext context) { | ||
158 | + // Blank @Modified method to catch modifications to the context. | ||
159 | + // If no @Modified method exists, it seems @Activate is called again | ||
160 | + // when the context is modified. | ||
161 | + } | ||
162 | + | ||
128 | @Override | 163 | @Override |
129 | public Collection<BgpSession> getBgpSessions() { | 164 | public Collection<BgpSession> getBgpSessions() { |
130 | return bgpSessionManager.getBgpSessions(); | 165 | return bgpSessionManager.getBgpSessions(); | ... | ... |
-
Please register or login to post a comment