Added server mac address to Endpoint 95/35895/5
authorIcaro Camelo <icamelo@inocybe.com>
Mon, 7 Mar 2016 21:55:43 +0000 (16:55 -0500)
committerIcaro Camelo <icamelo@inocybe.com>
Tue, 22 Mar 2016 20:05:26 +0000 (16:05 -0400)
Change-Id: Id4a1b99c939cfd2939dbab6974e34b4b78ee2349
Signed-off-by: Icaro Camelo <icamelo@inocybe.com>
vpnintent/api/src/main/yang/vpnintent.yang
vpnintent/impl/src/main/java/org/opendaylight/vpnservice/impl/MappingServiceManager.java
vpnintent/impl/src/main/java/org/opendaylight/vpnservice/impl/VpnintentProvider.java
vpnintent/impl/src/test/java/org/opendaylight/vpnservice/impl/MappingServiceManagerTests.java

index efe7ef3a95c0984d375d5f0919bbdf8de6c1b4d6..c7bc0f4c749e157f51042b8a3bd2844a5c7adbd6 100644 (file)
@@ -3,6 +3,7 @@ module vpnintent {
     namespace "urn:opendaylight:params:xml:ns:yang:vpnintent";
     prefix "vpnintent";
 
+    import ietf-yang-types { prefix yang; revision-date "2010-09-24";}
     import ietf-inet-types { prefix inet; revision-date 2010-09-24;}
 
     revision "2015-01-05" {
@@ -62,6 +63,11 @@ module vpnintent {
             type string;
             description "Switch and port ID that VPN member is connected to.";
         }
+
+        leaf next-hop-mac {
+            type yang:mac-address;
+            description "server mac address";
+        }
     }
 
     grouping labels {
index 4c48d81549d96bed278626a4b507c49552dd77af..a6dc5adce72cf341e817022e30856fa2357c78bc 100644 (file)
@@ -25,6 +25,7 @@ public class MappingServiceManager {
     private String SWITCH_PORT_ID_PROPERTY = "switch_port";
     private String MPLS_LABEL_PROPERTY = "mpls_label";
     private String NEXT_HOP_PROPERTY = "next_hop";
+    private String SERVER_MAC_ADDRESS = "server_mac_address";
 
     public MappingServiceManager(IntentMappingService intentMappingService) {
         Preconditions.checkNotNull(intentMappingService);
@@ -37,14 +38,14 @@ public class MappingServiceManager {
      * @param ipPrefix
      *            Ip prefix of the member
      * @param switchPortId
    *            Switch ID and port ID (i.e. openflow:1:2)
+ *            Switch ID and port ID (i.e. openflow:1:2)
      * @param mplsLabel
-     *            MPLS label, if needed
-     * @param nextHop
-     *            Next hop in the route
+*            MPLS label, if needed
+     * @param nextHop Next Hop
+     * @param serverMacAddress Server MAC Address
      */
     public void add(final String siteName, final String ipPrefix, final String switchPortId, final Long mplsLabel,
-            final String nextHop) {
+                    final String nextHop, final String serverMacAddress) {
         Preconditions.checkNotNull(siteName);
         Preconditions.checkNotNull(ipPrefix);
         Preconditions.checkNotNull(switchPortId);
@@ -52,6 +53,7 @@ public class MappingServiceManager {
         Map<String, String> objs = new HashMap<>();
         objs.put(IP_PREFIX_PROPERTY, ipPrefix);
         objs.put(SWITCH_PORT_ID_PROPERTY, switchPortId);
+        objs.put(SERVER_MAC_ADDRESS, serverMacAddress);
 
         if (mplsLabel != null)
             objs.put(MPLS_LABEL_PROPERTY, String.valueOf(mplsLabel));
index e050402cfef0d90ab5eae68b644cfee43a7442e8..553e3a922b8fef19f3383f31ec4e187fefbc953c 100644 (file)
@@ -52,8 +52,6 @@ public class VpnintentProvider implements VpnintentService, BindingAwareProvider
     private static final Logger LOG = LoggerFactory.getLogger(VpnintentProvider.class);
     public static final InstanceIdentifier<MplsLabels> LABELS_IID = IidFactory.getMplsLabelsIid();
     public static final InstanceIdentifier<Vpns> VPN_IID = IidFactory.getVpnsIid();
-    public static final InstanceIdentifier<VpnIntents> VPN_INTENT_IID = IidFactory.getVpnIntentIid();
-    public static final InstanceIdentifier<Endpoint> ENDPOINT_IID = IidFactory.getEndpointIid();
 
     private DataBroker dataBroker;
     private IntentMappingService intentMappingService;
@@ -135,6 +133,7 @@ public class VpnintentProvider implements VpnintentService, BindingAwareProvider
     public Future<RpcResult<Void>> addVpnEndpoint(AddVpnEndpointInput input) {
         Endpoint currentEndpoint = new EndpointBuilder().setIpPrefix(input.getIpPrefix())
                 .setSiteName(input.getSiteName()).setSwitchPortId(input.getSwitchPortId())
+                .setNextHopMac(input.getNextHopMac())
                 .setKey(new EndpointKey(input.getSiteName())).build();
         VpnIntents vpn = getVpn(input.getVpnName());
         String failOverType = null;
@@ -152,9 +151,11 @@ public class VpnintentProvider implements VpnintentService, BindingAwareProvider
         Long mplsLabel = mplsManager.getUniqueLabel(currentEndpoint);
 
         // Add info into Mapping Service
+        String macAddress = currentEndpoint.getNextHopMac() != null ?
+                currentEndpoint.getNextHopMac().getValue() : null;
         MappingServiceManager msManager = new MappingServiceManager(intentMappingService);
         msManager.add(currentEndpoint.getSiteName(), extractIP(currentEndpoint.getIpPrefix()),
-                currentEndpoint.getSwitchPortId(), mplsLabel, null);
+                currentEndpoint.getSwitchPortId(), mplsLabel, null, macAddress);
 
         if (vpn.getEndpoint() != null && vpn.getEndpoint().size() > 0) {
             IntentServiceManager intentManager = new IntentServiceManager(dataBroker);
@@ -174,7 +175,7 @@ public class VpnintentProvider implements VpnintentService, BindingAwareProvider
     }
 
     /**
-     * @param IpPrefix
+     * @param ipPrefix
      *            object
      * @return String representation of IP prefix
      */
index a9c76ddf0fddca3e9d31bfff6602e28f0d7d39c0..f2fa938bae2d238e95738b0280789a5aef0e71d7 100644 (file)
@@ -30,12 +30,14 @@ public class MappingServiceManagerTests {
         String switchPortId = "openflow:1:3";
         long mplsLabel = 10L;
         String nextHop = "16.101.233.1/8";
+        String serverMacAddress = "10:40:f3:a8:86:11";
 
         Map<String, String> map = new HashMap<>();
         map.put("ip_prefix", ipPrefix);
         map.put("switch_port", switchPortId);
         map.put("mpls_label", String.valueOf(mplsLabel));
         map.put("next_hop", nextHop);
+        map.put("server_mac_address", serverMacAddress);
 
         IntentMappingService mapSvc = mock(IntentMappingService.class);
         when(mapSvc.get(any(String.class))).thenReturn(map);
@@ -43,7 +45,7 @@ public class MappingServiceManagerTests {
         MappingServiceManager manager = new MappingServiceManager(mapSvc);
 
         // Act
-        manager.add(siteName, ipPrefix, switchPortId, mplsLabel, nextHop);
+        manager.add(siteName, ipPrefix, switchPortId, mplsLabel, nextHop, serverMacAddress);
 
         Map<String, String> returnedObjs = manager.get(siteName);
 
@@ -60,17 +62,19 @@ public class MappingServiceManagerTests {
         String siteName = "UoR";
         String ipPrefix = "16.101.233.2/8";
         String switchPortId = "openflow:1:3";
+        String serverMacAddress = "10:40:f3:a8:86:11";
 
         Map<String, String> map = new HashMap<>();
         map.put("ip_prefix", ipPrefix);
         map.put("switch_port", switchPortId);
+        map.put("server_mac_address", serverMacAddress);
 
         IntentMappingService mapSvc = mock(IntentMappingService.class);
 
         MappingServiceManager manager = new MappingServiceManager(mapSvc);
 
         // Add first to delete next
-        manager.add(siteName, ipPrefix, switchPortId, null, null);
+        manager.add(siteName, ipPrefix, switchPortId, null, null, serverMacAddress);
 
         // Act
         boolean result = manager.delete(siteName);