summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/virtualbng
diff options
context:
space:
mode:
authorAshlee Young <ashlee@wildernessvoice.com>2015-11-03 14:08:10 -0800
committerAshlee Young <ashlee@wildernessvoice.com>2015-11-03 14:08:10 -0800
commit643ee33289bd2cb9e6afbfb09b4ed72d467ba1c2 (patch)
treec2c376a44a359544fe3d4c45eb0cc0e2ec4a7080 /framework/src/onos/apps/virtualbng
parent46eeb79b54345bdafb6055b8ee4bad4ce8b01274 (diff)
This updates ONOS src tree to commit id
03fa5e571cabbd001ddb1598847e1150b11c7333 Change-Id: I13b554026d6f902933e35887d29bd5fdb669c0bd Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/apps/virtualbng')
-rw-r--r--framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/ConnectPointConfiguration.java55
-rw-r--r--framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfiguration.java27
-rw-r--r--framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfigurationManager.java28
-rw-r--r--framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfigurationService.java12
-rw-r--r--framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngManager.java49
5 files changed, 123 insertions, 48 deletions
diff --git a/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/ConnectPointConfiguration.java b/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/ConnectPointConfiguration.java
new file mode 100644
index 00000000..ff516d71
--- /dev/null
+++ b/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/ConnectPointConfiguration.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.virtualbng;
+
+import org.onosproject.net.ConnectPoint;
+
+/**
+ * Configuration for a connect point.
+ */
+public class ConnectPointConfiguration {
+
+ private ConnectPoint connectPoint;
+
+ /**
+ * Creats a new connect point from a string representation.
+ *
+ * @param string connect point string
+ */
+ public ConnectPointConfiguration(String string) {
+ connectPoint = ConnectPoint.deviceConnectPoint(string);
+ }
+
+ /**
+ * Creates a new connect point from a string representation.
+ *
+ * @param string connect point string
+ * @return new connect point configuration
+ */
+ public static ConnectPointConfiguration of(String string) {
+ return new ConnectPointConfiguration(string);
+ }
+
+ /**
+ * Gets the connect point.
+ *
+ * @return connect point
+ */
+ public ConnectPoint connectPoint() {
+ return connectPoint;
+ }
+}
diff --git a/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfiguration.java b/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfiguration.java
index ee2cbeaa..1841675f 100644
--- a/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfiguration.java
+++ b/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfiguration.java
@@ -17,13 +17,15 @@ package org.onosproject.virtualbng;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.Collections;
-import java.util.List;
-
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
+import org.onosproject.net.ConnectPoint;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
/**
* Contains the configuration data for virtual BNG that has been read from a
@@ -36,6 +38,7 @@ public final class VbngConfiguration {
private final MacAddress publicFacingMac;
private final IpAddress xosIpAddress;
private final int xosRestPort;
+ private final Map<String, ConnectPointConfiguration> hosts;
/**
* Default constructor.
@@ -46,6 +49,7 @@ public final class VbngConfiguration {
publicFacingMac = null;
xosIpAddress = null;
xosRestPort = 0;
+ hosts = null;
}
/**
@@ -57,6 +61,7 @@ public final class VbngConfiguration {
* public IP addresses
* @param xosIpAddress the XOS server IP address
* @param xosRestPort the port of the XOS server for REST
+ * @param hosts map of hosts
*/
@JsonCreator
public VbngConfiguration(@JsonProperty("localPublicIpPrefixes")
@@ -68,12 +73,15 @@ public final class VbngConfiguration {
@JsonProperty("xosIpAddress")
IpAddress xosIpAddress,
@JsonProperty("xosRestPort")
- int xosRestPort) {
+ int xosRestPort,
+ @JsonProperty("hosts")
+ Map<String, ConnectPointConfiguration> hosts) {
localPublicIpPrefixes = prefixes;
this.nextHopIpAddress = nextHopIpAddress;
this.publicFacingMac = publicFacingMac;
this.xosIpAddress = xosIpAddress;
this.xosRestPort = xosRestPort;
+ this.hosts = hosts;
}
/**
@@ -120,4 +128,13 @@ public final class VbngConfiguration {
public int getXosRestPort() {
return xosRestPort;
}
+
+ public Map<String, ConnectPoint> getHosts() {
+ return hosts.entrySet()
+ .stream()
+ .collect(Collectors.toMap(
+ e -> e.getKey(),
+ e -> e.getValue().connectPoint()
+ ));
+ }
}
diff --git a/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfigurationManager.java b/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfigurationManager.java
index d27d6904..eb83e06c 100644
--- a/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfigurationManager.java
+++ b/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfigurationManager.java
@@ -16,16 +16,6 @@
package org.onosproject.virtualbng;
import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -33,9 +23,19 @@ import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
+import org.onosproject.net.ConnectPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+
/**
* Implementation of ConfigurationService which reads virtual BNG
* configuration from a file.
@@ -63,6 +63,7 @@ public class VbngConfigurationManager implements VbngConfigurationService {
private MacAddress macOfPublicIpAddresses;
private IpAddress xosIpAddress;
private int xosRestPort;
+ private Map<String, ConnectPoint> nodeToPort;
@Activate
public void activate() {
@@ -104,6 +105,8 @@ public class VbngConfigurationManager implements VbngConfigurationService {
macOfPublicIpAddresses = config.getPublicFacingMac();
xosIpAddress = config.getXosIpAddress();
xosRestPort = config.getXosRestPort();
+ nodeToPort = config.getHosts();
+
} catch (FileNotFoundException e) {
log.warn("Configuration file not found: {}", configFileName);
@@ -132,6 +135,11 @@ public class VbngConfigurationManager implements VbngConfigurationService {
return xosRestPort;
}
+ @Override
+ public Map<String, ConnectPoint> getNodeToPort() {
+ return nodeToPort;
+ }
+
// TODO handle the case: the number of public IP addresses is not enough
// for 1:1 mapping from public IP to private IP.
@Override
diff --git a/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfigurationService.java b/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfigurationService.java
index ef8698a0..68c048f4 100644
--- a/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfigurationService.java
+++ b/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngConfigurationService.java
@@ -15,10 +15,11 @@
*/
package org.onosproject.virtualbng;
-import java.util.Map;
-
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
+import org.onosproject.net.ConnectPoint;
+
+import java.util.Map;
/**
* Provides information about the virtual BNG configuration.
@@ -54,6 +55,13 @@ public interface VbngConfigurationService {
int getXosRestPort();
/**
+ * Gets the host to port map.
+ *
+ * @return host to port map
+ */
+ Map<String, ConnectPoint> getNodeToPort();
+
+ /**
* Evaluates whether an IP address is an assigned public IP address.
*
* @param ipAddress the IP address to evaluate
diff --git a/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngManager.java b/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngManager.java
index 5e82b7e8..e03b25e8 100644
--- a/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngManager.java
+++ b/framework/src/onos/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngManager.java
@@ -15,18 +15,9 @@
*/
package org.onosproject.virtualbng;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Maps;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -42,7 +33,6 @@ import org.onosproject.core.CoreService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Host;
-import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
@@ -56,6 +46,13 @@ import org.onosproject.net.intent.PointToPointIntent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* This is a virtual Broadband Network Gateway (BNG) application. It mainly
* has 3 functions:
@@ -111,9 +108,8 @@ public class VbngManager implements VbngService {
p2pIntentsToHost = new ConcurrentHashMap<>();
privateIpAddressMap = new ConcurrentHashMap<>();
- setupMap();
-
nextHopIpAddress = vbngConfigurationService.getNextHopIpAddress();
+ nodeToPort = vbngConfigurationService.getNodeToPort();
hostListener = new InternalHostListener();
hostService.addListener(hostListener);
@@ -136,10 +132,16 @@ public class VbngManager implements VbngService {
*/
private void statusRecovery() {
log.info("vBNG starts to recover from XOS record......");
- RestClient restClient =
- new RestClient(vbngConfigurationService.getXosIpAddress(),
- vbngConfigurationService.getXosRestPort());
- ObjectNode map = restClient.getRest();
+ ObjectNode map;
+ try {
+ RestClient restClient =
+ new RestClient(vbngConfigurationService.getXosIpAddress(),
+ vbngConfigurationService.getXosRestPort());
+ map = restClient.getRest();
+ } catch (Exception e) {
+ log.error("Could not contact XOS", e);
+ return;
+ }
if (map == null) {
log.info("Stop to recover vBNG status due to the vBNG map "
+ "is null!");
@@ -168,21 +170,6 @@ public class VbngManager implements VbngService {
}
/**
- * Sets up mapping from hostname to connect point.
- */
- private void setupMap() {
- nodeToPort = Maps.newHashMap();
-
- nodeToPort.put("cordcompute01.onlab.us",
- new ConnectPoint(FABRIC_DEVICE_ID,
- PortNumber.portNumber(48)));
-
- nodeToPort.put("cordcompute02.onlab.us",
- new ConnectPoint(FABRIC_DEVICE_ID,
- PortNumber.portNumber(47)));
- }
-
- /**
* Creates a new vBNG.
*
* @param privateIpAddress a private IP address