Committed by
Gerrit Code Review
vBNG: Make the compute node to connect point map configurable
Change-Id: Icf3a695bfda63b53095d04a7bcdd8fb9b92481c8
Showing
5 changed files
with
119 additions
and
45 deletions
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +package org.onosproject.virtualbng; | ||
| 18 | + | ||
| 19 | +import org.onosproject.net.ConnectPoint; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * Configuration for a connect point. | ||
| 23 | + */ | ||
| 24 | +public class ConnectPointConfiguration { | ||
| 25 | + | ||
| 26 | + private ConnectPoint connectPoint; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * Creats a new connect point from a string representation. | ||
| 30 | + * | ||
| 31 | + * @param string connect point string | ||
| 32 | + */ | ||
| 33 | + public ConnectPointConfiguration(String string) { | ||
| 34 | + connectPoint = ConnectPoint.deviceConnectPoint(string); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * Creates a new connect point from a string representation. | ||
| 39 | + * | ||
| 40 | + * @param string connect point string | ||
| 41 | + * @return new connect point configuration | ||
| 42 | + */ | ||
| 43 | + public static ConnectPointConfiguration of(String string) { | ||
| 44 | + return new ConnectPointConfiguration(string); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * Gets the connect point. | ||
| 49 | + * | ||
| 50 | + * @return connect point | ||
| 51 | + */ | ||
| 52 | + public ConnectPoint connectPoint() { | ||
| 53 | + return connectPoint; | ||
| 54 | + } | ||
| 55 | +} |
| ... | @@ -17,13 +17,15 @@ package org.onosproject.virtualbng; | ... | @@ -17,13 +17,15 @@ package org.onosproject.virtualbng; |
| 17 | 17 | ||
| 18 | import com.fasterxml.jackson.annotation.JsonCreator; | 18 | import com.fasterxml.jackson.annotation.JsonCreator; |
| 19 | import com.fasterxml.jackson.annotation.JsonProperty; | 19 | import com.fasterxml.jackson.annotation.JsonProperty; |
| 20 | - | ||
| 21 | -import java.util.Collections; | ||
| 22 | -import java.util.List; | ||
| 23 | - | ||
| 24 | import org.onlab.packet.IpAddress; | 20 | import org.onlab.packet.IpAddress; |
| 25 | import org.onlab.packet.IpPrefix; | 21 | import org.onlab.packet.IpPrefix; |
| 26 | import org.onlab.packet.MacAddress; | 22 | import org.onlab.packet.MacAddress; |
| 23 | +import org.onosproject.net.ConnectPoint; | ||
| 24 | + | ||
| 25 | +import java.util.Collections; | ||
| 26 | +import java.util.List; | ||
| 27 | +import java.util.Map; | ||
| 28 | +import java.util.stream.Collectors; | ||
| 27 | 29 | ||
| 28 | /** | 30 | /** |
| 29 | * Contains the configuration data for virtual BNG that has been read from a | 31 | * Contains the configuration data for virtual BNG that has been read from a |
| ... | @@ -36,6 +38,7 @@ public final class VbngConfiguration { | ... | @@ -36,6 +38,7 @@ public final class VbngConfiguration { |
| 36 | private final MacAddress publicFacingMac; | 38 | private final MacAddress publicFacingMac; |
| 37 | private final IpAddress xosIpAddress; | 39 | private final IpAddress xosIpAddress; |
| 38 | private final int xosRestPort; | 40 | private final int xosRestPort; |
| 41 | + private final Map<String, ConnectPointConfiguration> hosts; | ||
| 39 | 42 | ||
| 40 | /** | 43 | /** |
| 41 | * Default constructor. | 44 | * Default constructor. |
| ... | @@ -46,6 +49,7 @@ public final class VbngConfiguration { | ... | @@ -46,6 +49,7 @@ public final class VbngConfiguration { |
| 46 | publicFacingMac = null; | 49 | publicFacingMac = null; |
| 47 | xosIpAddress = null; | 50 | xosIpAddress = null; |
| 48 | xosRestPort = 0; | 51 | xosRestPort = 0; |
| 52 | + hosts = null; | ||
| 49 | } | 53 | } |
| 50 | 54 | ||
| 51 | /** | 55 | /** |
| ... | @@ -68,12 +72,15 @@ public final class VbngConfiguration { | ... | @@ -68,12 +72,15 @@ public final class VbngConfiguration { |
| 68 | @JsonProperty("xosIpAddress") | 72 | @JsonProperty("xosIpAddress") |
| 69 | IpAddress xosIpAddress, | 73 | IpAddress xosIpAddress, |
| 70 | @JsonProperty("xosRestPort") | 74 | @JsonProperty("xosRestPort") |
| 71 | - int xosRestPort) { | 75 | + int xosRestPort, |
| 76 | + @JsonProperty("hosts") | ||
| 77 | + Map<String, ConnectPointConfiguration> hosts) { | ||
| 72 | localPublicIpPrefixes = prefixes; | 78 | localPublicIpPrefixes = prefixes; |
| 73 | this.nextHopIpAddress = nextHopIpAddress; | 79 | this.nextHopIpAddress = nextHopIpAddress; |
| 74 | this.publicFacingMac = publicFacingMac; | 80 | this.publicFacingMac = publicFacingMac; |
| 75 | this.xosIpAddress = xosIpAddress; | 81 | this.xosIpAddress = xosIpAddress; |
| 76 | this.xosRestPort = xosRestPort; | 82 | this.xosRestPort = xosRestPort; |
| 83 | + this.hosts = hosts; | ||
| 77 | } | 84 | } |
| 78 | 85 | ||
| 79 | /** | 86 | /** |
| ... | @@ -120,4 +127,13 @@ public final class VbngConfiguration { | ... | @@ -120,4 +127,13 @@ public final class VbngConfiguration { |
| 120 | public int getXosRestPort() { | 127 | public int getXosRestPort() { |
| 121 | return xosRestPort; | 128 | return xosRestPort; |
| 122 | } | 129 | } |
| 130 | + | ||
| 131 | + public Map<String, ConnectPoint> getHosts() { | ||
| 132 | + return hosts.entrySet() | ||
| 133 | + .stream() | ||
| 134 | + .collect(Collectors.toMap( | ||
| 135 | + e -> e.getKey(), | ||
| 136 | + e -> e.getValue().connectPoint() | ||
| 137 | + )); | ||
| 138 | + } | ||
| 123 | } | 139 | } | ... | ... |
| ... | @@ -16,16 +16,6 @@ | ... | @@ -16,16 +16,6 @@ |
| 16 | package org.onosproject.virtualbng; | 16 | package org.onosproject.virtualbng; |
| 17 | 17 | ||
| 18 | import com.fasterxml.jackson.databind.ObjectMapper; | 18 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 19 | - | ||
| 20 | -import java.io.File; | ||
| 21 | -import java.io.FileNotFoundException; | ||
| 22 | -import java.io.IOException; | ||
| 23 | -import java.util.Collections; | ||
| 24 | -import java.util.Iterator; | ||
| 25 | -import java.util.Map; | ||
| 26 | -import java.util.Map.Entry; | ||
| 27 | -import java.util.concurrent.ConcurrentHashMap; | ||
| 28 | - | ||
| 29 | import org.apache.felix.scr.annotations.Activate; | 19 | import org.apache.felix.scr.annotations.Activate; |
| 30 | import org.apache.felix.scr.annotations.Component; | 20 | import org.apache.felix.scr.annotations.Component; |
| 31 | import org.apache.felix.scr.annotations.Deactivate; | 21 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -33,9 +23,19 @@ import org.apache.felix.scr.annotations.Service; | ... | @@ -33,9 +23,19 @@ import org.apache.felix.scr.annotations.Service; |
| 33 | import org.onlab.packet.IpAddress; | 23 | import org.onlab.packet.IpAddress; |
| 34 | import org.onlab.packet.IpPrefix; | 24 | import org.onlab.packet.IpPrefix; |
| 35 | import org.onlab.packet.MacAddress; | 25 | import org.onlab.packet.MacAddress; |
| 26 | +import org.onosproject.net.ConnectPoint; | ||
| 36 | import org.slf4j.Logger; | 27 | import org.slf4j.Logger; |
| 37 | import org.slf4j.LoggerFactory; | 28 | import org.slf4j.LoggerFactory; |
| 38 | 29 | ||
| 30 | +import java.io.File; | ||
| 31 | +import java.io.FileNotFoundException; | ||
| 32 | +import java.io.IOException; | ||
| 33 | +import java.util.Collections; | ||
| 34 | +import java.util.Iterator; | ||
| 35 | +import java.util.Map; | ||
| 36 | +import java.util.Map.Entry; | ||
| 37 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 38 | + | ||
| 39 | /** | 39 | /** |
| 40 | * Implementation of ConfigurationService which reads virtual BNG | 40 | * Implementation of ConfigurationService which reads virtual BNG |
| 41 | * configuration from a file. | 41 | * configuration from a file. |
| ... | @@ -63,6 +63,7 @@ public class VbngConfigurationManager implements VbngConfigurationService { | ... | @@ -63,6 +63,7 @@ public class VbngConfigurationManager implements VbngConfigurationService { |
| 63 | private MacAddress macOfPublicIpAddresses; | 63 | private MacAddress macOfPublicIpAddresses; |
| 64 | private IpAddress xosIpAddress; | 64 | private IpAddress xosIpAddress; |
| 65 | private int xosRestPort; | 65 | private int xosRestPort; |
| 66 | + private Map<String, ConnectPoint> nodeToPort; | ||
| 66 | 67 | ||
| 67 | @Activate | 68 | @Activate |
| 68 | public void activate() { | 69 | public void activate() { |
| ... | @@ -104,6 +105,8 @@ public class VbngConfigurationManager implements VbngConfigurationService { | ... | @@ -104,6 +105,8 @@ public class VbngConfigurationManager implements VbngConfigurationService { |
| 104 | macOfPublicIpAddresses = config.getPublicFacingMac(); | 105 | macOfPublicIpAddresses = config.getPublicFacingMac(); |
| 105 | xosIpAddress = config.getXosIpAddress(); | 106 | xosIpAddress = config.getXosIpAddress(); |
| 106 | xosRestPort = config.getXosRestPort(); | 107 | xosRestPort = config.getXosRestPort(); |
| 108 | + nodeToPort = config.getHosts(); | ||
| 109 | + | ||
| 107 | 110 | ||
| 108 | } catch (FileNotFoundException e) { | 111 | } catch (FileNotFoundException e) { |
| 109 | log.warn("Configuration file not found: {}", configFileName); | 112 | log.warn("Configuration file not found: {}", configFileName); |
| ... | @@ -132,6 +135,11 @@ public class VbngConfigurationManager implements VbngConfigurationService { | ... | @@ -132,6 +135,11 @@ public class VbngConfigurationManager implements VbngConfigurationService { |
| 132 | return xosRestPort; | 135 | return xosRestPort; |
| 133 | } | 136 | } |
| 134 | 137 | ||
| 138 | + @Override | ||
| 139 | + public Map<String, ConnectPoint> getNodeToPort() { | ||
| 140 | + return nodeToPort; | ||
| 141 | + } | ||
| 142 | + | ||
| 135 | // TODO handle the case: the number of public IP addresses is not enough | 143 | // TODO handle the case: the number of public IP addresses is not enough |
| 136 | // for 1:1 mapping from public IP to private IP. | 144 | // for 1:1 mapping from public IP to private IP. |
| 137 | @Override | 145 | @Override | ... | ... |
| ... | @@ -15,10 +15,11 @@ | ... | @@ -15,10 +15,11 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.virtualbng; | 16 | package org.onosproject.virtualbng; |
| 17 | 17 | ||
| 18 | -import java.util.Map; | ||
| 19 | - | ||
| 20 | import org.onlab.packet.IpAddress; | 18 | import org.onlab.packet.IpAddress; |
| 21 | import org.onlab.packet.MacAddress; | 19 | import org.onlab.packet.MacAddress; |
| 20 | +import org.onosproject.net.ConnectPoint; | ||
| 21 | + | ||
| 22 | +import java.util.Map; | ||
| 22 | 23 | ||
| 23 | /** | 24 | /** |
| 24 | * Provides information about the virtual BNG configuration. | 25 | * Provides information about the virtual BNG configuration. |
| ... | @@ -54,6 +55,13 @@ public interface VbngConfigurationService { | ... | @@ -54,6 +55,13 @@ public interface VbngConfigurationService { |
| 54 | int getXosRestPort(); | 55 | int getXosRestPort(); |
| 55 | 56 | ||
| 56 | /** | 57 | /** |
| 58 | + * Gets the host to port map. | ||
| 59 | + * | ||
| 60 | + * @return host to port map | ||
| 61 | + */ | ||
| 62 | + Map<String, ConnectPoint> getNodeToPort(); | ||
| 63 | + | ||
| 64 | + /** | ||
| 57 | * Evaluates whether an IP address is an assigned public IP address. | 65 | * Evaluates whether an IP address is an assigned public IP address. |
| 58 | * | 66 | * |
| 59 | * @param ipAddress the IP address to evaluate | 67 | * @param ipAddress the IP address to evaluate | ... | ... |
| ... | @@ -15,18 +15,9 @@ | ... | @@ -15,18 +15,9 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.virtualbng; | 16 | package org.onosproject.virtualbng; |
| 17 | 17 | ||
| 18 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
| 19 | - | ||
| 20 | import com.fasterxml.jackson.databind.JsonNode; | 18 | import com.fasterxml.jackson.databind.JsonNode; |
| 21 | import com.fasterxml.jackson.databind.node.ArrayNode; | 19 | import com.fasterxml.jackson.databind.node.ArrayNode; |
| 22 | import com.fasterxml.jackson.databind.node.ObjectNode; | 20 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 23 | -import com.google.common.collect.Maps; | ||
| 24 | - | ||
| 25 | -import java.util.Iterator; | ||
| 26 | -import java.util.Map; | ||
| 27 | -import java.util.Map.Entry; | ||
| 28 | -import java.util.concurrent.ConcurrentHashMap; | ||
| 29 | - | ||
| 30 | import org.apache.felix.scr.annotations.Activate; | 21 | import org.apache.felix.scr.annotations.Activate; |
| 31 | import org.apache.felix.scr.annotations.Component; | 22 | import org.apache.felix.scr.annotations.Component; |
| 32 | import org.apache.felix.scr.annotations.Deactivate; | 23 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -42,7 +33,6 @@ import org.onosproject.core.CoreService; | ... | @@ -42,7 +33,6 @@ import org.onosproject.core.CoreService; |
| 42 | import org.onosproject.net.ConnectPoint; | 33 | import org.onosproject.net.ConnectPoint; |
| 43 | import org.onosproject.net.DeviceId; | 34 | import org.onosproject.net.DeviceId; |
| 44 | import org.onosproject.net.Host; | 35 | import org.onosproject.net.Host; |
| 45 | -import org.onosproject.net.PortNumber; | ||
| 46 | import org.onosproject.net.flow.DefaultTrafficSelector; | 36 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 47 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 37 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 48 | import org.onosproject.net.flow.TrafficSelector; | 38 | import org.onosproject.net.flow.TrafficSelector; |
| ... | @@ -56,6 +46,13 @@ import org.onosproject.net.intent.PointToPointIntent; | ... | @@ -56,6 +46,13 @@ import org.onosproject.net.intent.PointToPointIntent; |
| 56 | import org.slf4j.Logger; | 46 | import org.slf4j.Logger; |
| 57 | import org.slf4j.LoggerFactory; | 47 | import org.slf4j.LoggerFactory; |
| 58 | 48 | ||
| 49 | +import java.util.Iterator; | ||
| 50 | +import java.util.Map; | ||
| 51 | +import java.util.Map.Entry; | ||
| 52 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 53 | + | ||
| 54 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 55 | + | ||
| 59 | /** | 56 | /** |
| 60 | * This is a virtual Broadband Network Gateway (BNG) application. It mainly | 57 | * This is a virtual Broadband Network Gateway (BNG) application. It mainly |
| 61 | * has 3 functions: | 58 | * has 3 functions: |
| ... | @@ -111,9 +108,8 @@ public class VbngManager implements VbngService { | ... | @@ -111,9 +108,8 @@ public class VbngManager implements VbngService { |
| 111 | p2pIntentsToHost = new ConcurrentHashMap<>(); | 108 | p2pIntentsToHost = new ConcurrentHashMap<>(); |
| 112 | privateIpAddressMap = new ConcurrentHashMap<>(); | 109 | privateIpAddressMap = new ConcurrentHashMap<>(); |
| 113 | 110 | ||
| 114 | - setupMap(); | ||
| 115 | - | ||
| 116 | nextHopIpAddress = vbngConfigurationService.getNextHopIpAddress(); | 111 | nextHopIpAddress = vbngConfigurationService.getNextHopIpAddress(); |
| 112 | + nodeToPort = vbngConfigurationService.getNodeToPort(); | ||
| 117 | hostListener = new InternalHostListener(); | 113 | hostListener = new InternalHostListener(); |
| 118 | hostService.addListener(hostListener); | 114 | hostService.addListener(hostListener); |
| 119 | 115 | ||
| ... | @@ -136,10 +132,16 @@ public class VbngManager implements VbngService { | ... | @@ -136,10 +132,16 @@ public class VbngManager implements VbngService { |
| 136 | */ | 132 | */ |
| 137 | private void statusRecovery() { | 133 | private void statusRecovery() { |
| 138 | log.info("vBNG starts to recover from XOS record......"); | 134 | log.info("vBNG starts to recover from XOS record......"); |
| 135 | + ObjectNode map; | ||
| 136 | + try { | ||
| 139 | RestClient restClient = | 137 | RestClient restClient = |
| 140 | new RestClient(vbngConfigurationService.getXosIpAddress(), | 138 | new RestClient(vbngConfigurationService.getXosIpAddress(), |
| 141 | vbngConfigurationService.getXosRestPort()); | 139 | vbngConfigurationService.getXosRestPort()); |
| 142 | - ObjectNode map = restClient.getRest(); | 140 | + map = restClient.getRest(); |
| 141 | + } catch (Exception e) { | ||
| 142 | + log.error("Could not contact XOS", e); | ||
| 143 | + return; | ||
| 144 | + } | ||
| 143 | if (map == null) { | 145 | if (map == null) { |
| 144 | log.info("Stop to recover vBNG status due to the vBNG map " | 146 | log.info("Stop to recover vBNG status due to the vBNG map " |
| 145 | + "is null!"); | 147 | + "is null!"); |
| ... | @@ -168,21 +170,6 @@ public class VbngManager implements VbngService { | ... | @@ -168,21 +170,6 @@ public class VbngManager implements VbngService { |
| 168 | } | 170 | } |
| 169 | 171 | ||
| 170 | /** | 172 | /** |
| 171 | - * Sets up mapping from hostname to connect point. | ||
| 172 | - */ | ||
| 173 | - private void setupMap() { | ||
| 174 | - nodeToPort = Maps.newHashMap(); | ||
| 175 | - | ||
| 176 | - nodeToPort.put("cordcompute01.onlab.us", | ||
| 177 | - new ConnectPoint(FABRIC_DEVICE_ID, | ||
| 178 | - PortNumber.portNumber(48))); | ||
| 179 | - | ||
| 180 | - nodeToPort.put("cordcompute02.onlab.us", | ||
| 181 | - new ConnectPoint(FABRIC_DEVICE_ID, | ||
| 182 | - PortNumber.portNumber(47))); | ||
| 183 | - } | ||
| 184 | - | ||
| 185 | - /** | ||
| 186 | * Creates a new vBNG. | 173 | * Creates a new vBNG. |
| 187 | * | 174 | * |
| 188 | * @param privateIpAddress a private IP address | 175 | * @param privateIpAddress a private IP address | ... | ... |
-
Please register or login to post a comment