Merge "Expand implementation of Neutron Service APIs in Lisp ." into develop
authorLori Jakab <lojakab@cisco.com>
Thu, 28 Aug 2014 19:51:10 +0000 (19:51 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 28 Aug 2014 19:51:10 +0000 (19:51 +0000)
12 files changed:
mappingservice/implementation/pom.xml
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/Activator.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/AdSalLispInventoryService.java [new file with mode: 0644]
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/IAdSalLispInventoryService.java [new file with mode: 0644]
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/IPAddressNodeProperty.java [new file with mode: 0644]
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/NodeConnectorFactory.java [new file with mode: 0644]
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/NodeFactory.java [new file with mode: 0644]
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/XtrIdNodeProperty.java [new file with mode: 0644]
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/LispNotificationHelper.java
mappingservice/integrationtest/pom.xml
mappingservice/integrationtest/src/main/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceTestHelper.java

index 93574943f8d717d9a32c7d42e126520def788ef9..5a46552300f8097698002cfbf28646b487f0c42f 100644 (file)
@@ -32,6 +32,7 @@
                                                </Export-Package>
                                                <Import-Package>
                                                        javax.xml.bind,
+                                                       javax.xml.bind.annotation,
                                                        org.opendaylight.yang.gen.v1.lispflowmapping.rev131031,
                                                        org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidrecords,
                                                        org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords,
@@ -58,6 +59,8 @@
                                                        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
                                                        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924,
                                                        org.opendaylight.controller.sal.core,
+                                                       org.opendaylight.controller.sal.inventory,
+                                                       org.opendaylight.controller.sal.utils,
                                                        org.apache.felix.dm,
                                                        org.apache.commons.lang3,
                                                        org.apache.commons.lang3.tuple,
index 6984528cc2b573913655eb20b6a1c546ee593a78..d307d6baaf4d2c0fa897eb0a3bbd033a442b8c45 100644 (file)
@@ -14,54 +14,75 @@ import java.util.Hashtable;
 import org.apache.felix.dm.Component;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
+import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
+import org.opendaylight.controller.sal.utils.INodeFactory;
+import org.opendaylight.lispflowmapping.implementation.inventory.AdSalLispInventoryService;
+import org.opendaylight.lispflowmapping.implementation.inventory.IAdSalLispInventoryService;
+import org.opendaylight.lispflowmapping.implementation.inventory.NodeConnectorFactory;
+import org.opendaylight.lispflowmapping.implementation.inventory.NodeFactory;
 import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Main application activator class for registering the dependencies and
  * initialising the Mapping Service application.
- * 
+ *
  */
 
 public class Activator extends ComponentActivatorAbstractBase {
+    protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
 
     /**
      * Function called when the activator starts just after some initializations
      * are done by the ComponentActivatorAbstractBase.
-     * 
+     *
      */
     @Override
     public void init() {
+        logger.debug("Registering \"LISP\" NodeID and NodeConnectorID types");
+        Node.NodeIDType.registerIDType("LISP", String.class);
+        NodeConnector.NodeConnectorIDType.registerIDType("LISP", String.class, "LISP");
     }
 
     /**
      * Function called when the activator stops just before the cleanup done by
      * ComponentActivatorAbstractBase
-     * 
+     *
      */
     @Override
     public void destroy() {
+        logger.debug("Unregistering \"LISP\" NodeID and NodeConnectorID types");
+        Node.NodeIDType.unRegisterIDType("LISP");
+        NodeConnector.NodeConnectorIDType.unRegisterIDType("LISP");
     }
 
     /**
      * Function that is used to communicate to dependency manager the list of
      * known implementations for services inside a container
-     * 
-     * 
+     *
+     *
      * @return An array containing all the CLASS objects that will be
      *         instantiated in order to get an fully working implementation
      *         Object
      */
     @Override
     public Object[] getImplementations() {
-        Object[] res = { LispMappingService.class };
+        Object[] res = {  NodeFactory.class, NodeConnectorFactory.class,
+                          AdSalLispInventoryService.class, LispMappingService.class };
         return res;
     }
 
     /**
      * Function that is called when configuration of the dependencies is
      * required.
-     * 
+     *
      * @param c
      *            dependency manager Component object, used for configuring the
      *            dependencies exported and imported
@@ -75,8 +96,43 @@ public class Activator extends ComponentActivatorAbstractBase {
      */
     @Override
     public void configureInstance(Component c, Object imp, String containerName) {
+        if (imp.equals(NodeFactory.class)) {
+            // export the service to be used by SAL
+            Dictionary<String, Object> props = new Hashtable<String, Object>();
+            // Set the protocolPluginType property which will be used
+            // by SAL
+            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "LISP");
+            props.put("protocolName", "LISP");
+            c.setInterface(INodeFactory.class.getName(), props);
+        }
+
+        if (imp.equals(NodeConnectorFactory.class)) {
+            // export the service to be used by SAL
+            Dictionary<String, Object> props = new Hashtable<String, Object>();
+            // Set the protocolPluginType property which will be used
+            // by SAL
+            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "LISP");
+            props.put("protocolName", "LISP");
+            c.setInterface(INodeConnectorFactory.class.getName(), props);
+        }
+
+         if (imp.equals(AdSalLispInventoryService.class)) {
+            logger.debug("Exporting AdSalLispInventoryService for IAdSalLispInventoryService and IPluginInInventoryService interfaces");
+            Dictionary<String, Object> props = new Hashtable<String, Object>();
+            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "LISP");
+            c.setInterface(
+                    new String[] {IPluginInInventoryService.class.getName(),
+                            IAdSalLispInventoryService.class.getName()}, props);
+            c.add(createServiceDependency()
+                    .setService(IPluginOutInventoryService.class, "(scope=Global)")
+                    .setCallbacks("setPluginOutInventoryServices",
+                            "unsetPluginOutInventoryServices")
+                    .setRequired(true));
+        }
+
         if (imp.equals(LispMappingService.class)) {
             // export the service
+            logger.debug("Exporting LispMappingService for IFlowMapping interface");
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("name", "mappingservice");
             c.setInterface(new String[] { IFlowMapping.class.getName() }, props);
@@ -84,8 +140,10 @@ public class Activator extends ComponentActivatorAbstractBase {
                     .setRequired(true));
             c.add(createServiceDependency().setService(BindingAwareBroker.class).setRequired(true)
                     .setCallbacks("setBindingAwareBroker", "unsetBindingAwareBroker"));
+            c.add(createServiceDependency().setService(IAdSalLispInventoryService.class).setRequired(true)
+                    .setCallbacks("setInventoryService", "unsetInventoryService"));
         }
-    }
+   }
 
     /**
      * Method which tells how many Global implementations are supported by the
@@ -94,8 +152,8 @@ public class Activator extends ComponentActivatorAbstractBase {
      * destroyed only at time of bundle destruction, this is the major
      * difference with the implementation retrieved via getImplementations where
      * all of them are assumed to be in a container !
-     * 
-     * 
+     *
+     *
      * @return The list of implementations the bundle will support, in Global
      *         version
      */
@@ -106,7 +164,7 @@ public class Activator extends ComponentActivatorAbstractBase {
 
     /**
      * Configure the dependency for a given instance Global
-     * 
+     *
      * @param c
      *            Component assigned for this instance, this will be what will
      *            be used for configuration
@@ -117,6 +175,5 @@ public class Activator extends ComponentActivatorAbstractBase {
      */
     @Override
     protected void configureGlobalInstance(Component c, Object imp) {
-
     }
 }
index 631dc3d7e09160dea1d8b57ee2836e1b202b04cb..2933199fab18f0c063fccddcf0da3da236f2b8a2 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.lispflowmapping.implementation;
 
+import java.net.InetAddress;
+
 import org.apache.commons.lang3.tuple.MutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.eclipse.osgi.framework.console.CommandInterpreter;
@@ -20,6 +22,7 @@ import org.opendaylight.controller.sal.binding.api.NotificationService;
 import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
 import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceKey;
 import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceNoMaskKey;
+import org.opendaylight.lispflowmapping.implementation.inventory.IAdSalLispInventoryService;
 import org.opendaylight.lispflowmapping.implementation.lisp.MapResolver;
 import org.opendaylight.lispflowmapping.implementation.lisp.MapServer;
 import org.opendaylight.lispflowmapping.implementation.serializer.LispMessage;
@@ -81,6 +84,7 @@ public class LispMappingService implements CommandProvider, IFlowMapping, Bindin
     private ConsumerContext session;
 
     private NotificationService notificationService;
+    private IAdSalLispInventoryService inventoryService;
 
     class LispIpv4AddressInMemoryConverter implements ILispTypeConverter<Ipv4Address, Integer> {
     }
@@ -94,8 +98,24 @@ public class LispMappingService implements CommandProvider, IFlowMapping, Bindin
     class MappingServiceNoMaskKeyConvertor implements ILispTypeConverter<MappingServiceNoMaskKey, Integer> {
     }
 
+    public IAdSalLispInventoryService getInventoryService() {
+        return inventoryService;
+    }
+
+    public void setInventoryService(IAdSalLispInventoryService inventoryService) {
+        logger.debug("Setting inventoryService");
+        this.inventoryService = inventoryService;
+    }
+
+    public void unsetInventoryService(IAdSalLispInventoryService inventoryService) {
+        logger.debug("Unsetting inventoryService");
+        if (this.inventoryService == inventoryService) {
+            this.inventoryService = null;
+        }
+    }
+
     void setBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
-        logger.trace("BindingAwareBroker set!");
+        logger.debug("BindingAwareBroker set!");
         BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
         bindingAwareBroker.registerConsumer(this, bundleContext);
     }
@@ -111,12 +131,12 @@ public class LispMappingService implements CommandProvider, IFlowMapping, Bindin
     }
 
     void setLispDao(ILispDAO dao) {
-        logger.trace("LispDAO set in LispMappingService");
+        logger.debug("LispDAO set in LispMappingService");
         basicInit(dao);
     }
 
     void unsetLispDao(ILispDAO dao) {
-        logger.trace("LispDAO was unset in LispMappingService");
+        logger.debug("LispDAO was unset in LispMappingService");
         mapServer = null;
         mapResolver = null;
         lispDao = null;
@@ -281,7 +301,16 @@ public class LispMappingService implements CommandProvider, IFlowMapping, Bindin
 
         @Override
         public void onNotification(AddMapping mapRegisterNotification) {
-            MapNotify mapNotify = handleMapRegister(mapRegisterNotification.getMapRegister(), smr);
+            MapRegister mapRegister = mapRegisterNotification.getMapRegister();
+            InetAddress address = LispNotificationHelper.getInetAddressFromIpAddress(mapRegisterNotification.getTransportAddress().getIpAddress());
+            if (mapRegister.isXtrSiteIdPresent()) {
+                byte[] xtrId = mapRegister.getXtrId();
+                inventoryService.addNode(address, xtrId);
+            } else {
+                inventoryService.addNode(address, null);
+            }
+
+            MapNotify mapNotify = handleMapRegister(mapRegister, smr);
             if (mapNotify != null) {
                 TransportAddressBuilder tab = new TransportAddressBuilder();
                 tab.setIpAddress(mapRegisterNotification.getTransportAddress().getIpAddress());
diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/AdSalLispInventoryService.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/AdSalLispInventoryService.java
new file mode 100644 (file)
index 0000000..1254aa3
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.lispflowmapping.implementation.inventory;
+
+import java.net.InetAddress;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
+import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
+import org.opendaylight.controller.sal.utils.HexEncode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AdSalLispInventoryService implements IAdSalLispInventoryService, IPluginInInventoryService {
+    private static final Logger logger = LoggerFactory.getLogger(AdSalLispInventoryService.class);
+
+    private ConcurrentMap<Node, Map<String, Property>> nodeProps;
+    private ConcurrentMap<NodeConnector, Map<String, Property>> nodeConnectorProps;
+    private final Set<IPluginOutInventoryService> pluginOutInventoryServices =
+            new CopyOnWriteArraySet<IPluginOutInventoryService>();
+
+    /**
+     * Function called by the dependency manager when all the required
+     * dependencies are satisfied
+     *
+     */
+    public void init() {
+        nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
+        nodeConnectorProps = new ConcurrentHashMap<NodeConnector, Map<String, Property>>();
+        logger.debug("Registering \"LISP\" NodeID and NodeConnectorID types");
+        Node.NodeIDType.registerIDType("LISP", String.class);
+        NodeConnector.NodeConnectorIDType.registerIDType("LISP", String.class, "LISP");
+    }
+
+    /**
+     * Function called by the dependency manager when at least one dependency
+     * become unsatisfied or when the component is shutting down because for
+     * example bundle is being stopped.
+     *
+     */
+    public void destroy() {
+    }
+
+    /**
+     * Function called by dependency manager after "init ()" is called and after
+     * the services provided by the class are registered in the service registry
+     *
+     */
+    public void start() {
+    }
+
+    /**
+     * Function called by the dependency manager before the services exported by
+     * the component are unregistered, this will be followed by a "destroy ()"
+     * calls
+     *
+     */
+    public void stop() {
+    }
+
+    public String getXtrNodeId(InetAddress address) {
+        return address.getHostAddress();
+    }
+
+    public String getXtrNodeId(InetAddress address, byte[] xtrId) {
+        return address.getHostAddress() + "|" + HexEncode.bytesToHexString(xtrId);
+    }
+
+    public Set<Property> getXtrNodeProps(InetAddress address) {
+        IPAddressNodeProperty addressProp = new IPAddressNodeProperty(address);
+        Set<Property> props = new HashSet<Property>();
+        props.add(addressProp);
+        return props;
+    }
+
+    public Set<Property> getXtrNodeProps(InetAddress address, byte[] xtrId) {
+        IPAddressNodeProperty addressProp = new IPAddressNodeProperty(address);
+        XtrIdNodeProperty xtrIdProp = new XtrIdNodeProperty(xtrId);
+        Set<Property> props = new HashSet<Property>();
+        props.add(addressProp);
+        props.add(xtrIdProp);
+        return props;
+    }
+
+    public Node createLispNode(String nodeId) {
+        Node node = null;
+        try {
+            node = new Node("LISP", nodeId);
+        } catch (ConstructionException e) {
+            logger.error("Error creating LISP node with identifier " + nodeId, e);
+        }
+        return node;
+    }
+
+    @Override
+    public void addNode(Node node, Set<Property> props) {
+        Map<String, Property> nProp = nodeProps.get(node);
+        if (nProp == null) {
+            nProp = new HashMap<String, Property>();
+        } else {
+            logger.debug("Not adding LISP node with identifier {} to inventory: node already exists", node);
+            return;
+        }
+        for (Property prop : props) {
+            nProp.put(prop.getName(), prop);
+        }
+        nodeProps.put(node, nProp);
+        for (IPluginOutInventoryService service : pluginOutInventoryServices) {
+            service.updateNode(node, UpdateType.ADDED, props);
+        }
+        logger.info("Added LISP node with identifier {} to inventory", node);
+        logger.debug("nodeProps " + nodeProps);
+    }
+
+    @Override
+    public void removeNode(Node node) {
+        nodeProps.remove(node);
+        for (IPluginOutInventoryService service : pluginOutInventoryServices) {
+            service.updateNode(node, UpdateType.REMOVED, null);
+        }
+        logger.info("Removed LISP node with identifier {} from inventory", node.getNodeIDString());
+    }
+
+    @Override
+    public void addNode(InetAddress address, byte[] xtrId) {
+        if (xtrId != null) {
+            Node node = createLispNode(getXtrNodeId(address, xtrId));
+            Set<Property> props = getXtrNodeProps(address, xtrId);
+            addNode(node, props);
+        } else {
+            Node node = createLispNode(getXtrNodeId(address));
+            Set<Property> props = getXtrNodeProps(address);
+            addNode(node, props);
+        }
+    }
+
+    public void setPluginOutInventoryServices(IPluginOutInventoryService service) {
+        logger.trace("Added inventory service " + service);
+        this.pluginOutInventoryServices.add(service);
+    }
+
+    public void unsetPluginOutInventoryServices(IPluginOutInventoryService service) {
+        logger.trace("Removed inventory service " + service);
+        this.pluginOutInventoryServices.remove(service);
+    }
+
+    @Override
+    public ConcurrentMap<Node, Map<String, Property>> getNodeProps() {
+        return nodeProps;
+    }
+
+    @Override
+    public ConcurrentMap<NodeConnector, Map<String, Property>> getNodeConnectorProps(
+            Boolean refresh) {
+        return nodeConnectorProps;
+    }
+
+    @Override
+    public Set<Node> getConfiguredNotConnectedNodes() {
+        return Collections.emptySet();
+    }
+}
diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/IAdSalLispInventoryService.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/IAdSalLispInventoryService.java
new file mode 100644 (file)
index 0000000..5a47205
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.lispflowmapping.implementation.inventory;
+
+import java.net.InetAddress;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
+
+public interface IAdSalLispInventoryService extends IPluginInInventoryService {
+    public void addNode(InetAddress address, byte[] xtrId);
+    public void addNode(Node node, Set<Property> props);
+    public void removeNode(Node node);
+}
diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/IPAddressNodeProperty.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/IPAddressNodeProperty.java
new file mode 100644 (file)
index 0000000..81cf63a
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.lispflowmapping.implementation.inventory;
+
+import java.net.InetAddress;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.opendaylight.controller.sal.core.Property;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class IPAddressNodeProperty extends Property implements Cloneable {
+    private static final long serialVersionUID = 1L;
+    @XmlElement(name="value")
+    private final InetAddress address;
+    public static final String name = "IPAddress";
+
+    /*
+     * Private constructor used for JAXB mapping
+     */
+    private IPAddressNodeProperty() {
+        super(name);
+        this.address = null;
+    }
+
+    public IPAddressNodeProperty(InetAddress address) {
+        super(name);
+        this.address = address;
+    }
+
+    @Override
+    public String getStringValue() {
+        if (address == null) return null;
+        return this.address.getHostAddress();
+    }
+
+    @Override
+    public Property clone() {
+        return new IPAddressNodeProperty(this.address);
+    }
+
+    public InetAddress getAddress() {
+        return address;
+    }
+}
diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/NodeConnectorFactory.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/NodeConnectorFactory.java
new file mode 100644 (file)
index 0000000..091476d
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.lispflowmapping.implementation.inventory;
+
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
+import org.opendaylight.controller.sal.core.Node;
+
+public class NodeConnectorFactory implements INodeConnectorFactory
+    {
+      void init() {
+      }
+
+      /**
+       * Function called by the dependency manager when at least one dependency
+       * become unsatisfied or when the component is shutting down because for
+       * example bundle is being stopped.
+       *
+       */
+      void destroy() {
+      }
+
+      /**
+       * Function called by dependency manager after "init ()" is called and after
+       * the services provided by the class are registered in the service registry
+       *
+       */
+      void start() {
+      }
+
+      /**
+       * Function called by the dependency manager before the services exported by
+       * the component are unregistered, this will be followed by a "destroy ()"
+       * calls
+       *
+       */
+      void stop() {
+      }
+
+      public NodeConnector fromStringNoNode(String typeStr, String IDStr,
+              Node n){
+          if(typeStr.equals("LISP")){
+              try {
+                  return new NodeConnector(typeStr, IDStr, n);
+              } catch (Exception ex) {
+                  return null;
+              }
+          }
+          return null;
+      }
+}
\ No newline at end of file
diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/NodeFactory.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/NodeFactory.java
new file mode 100644 (file)
index 0000000..6fabf45
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.lispflowmapping.implementation.inventory;
+
+import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.controller.sal.utils.INodeFactory;
+import org.opendaylight.controller.sal.core.Node;
+
+public class NodeFactory implements INodeFactory
+    {
+      void init() {
+      }
+
+      /**
+       * Function called by the dependency manager when at least one dependency
+       * become unsatisfied or when the component is shutting down because for
+       * example bundle is being stopped.
+       *
+       */
+      void destroy() {
+      }
+
+      /**
+       * Function called by dependency manager after "init ()" is called and after
+       * the services provided by the class are registered in the service registry
+       *
+       */
+      void start() {
+      }
+
+      /**
+       * Function called by the dependency manager before the services exported by
+       * the component are unregistered, this will be followed by a "destroy ()"
+       * calls
+       *
+       */
+      void stop() {
+      }
+
+      public Node fromString(String nodeType, String nodeId){
+          if(nodeType.equals("LISP"))
+              try {
+                  return new Node("LISP", nodeId);
+              } catch(ConstructionException e) {
+                  return null;
+              }
+          return null;
+      }
+}
\ No newline at end of file
diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/XtrIdNodeProperty.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/inventory/XtrIdNodeProperty.java
new file mode 100644 (file)
index 0000000..debbf47
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.lispflowmapping.implementation.inventory;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.utils.HexEncode;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class XtrIdNodeProperty extends Property implements Cloneable {
+    private static final long serialVersionUID = 1L;
+    @XmlElement(name="value")
+    private final byte[] xtrId;
+    public static final String name = "xTR-ID";
+
+    /*
+     * Private constructor used for JAXB mapping
+     */
+    private XtrIdNodeProperty() {
+        super(name);
+        this.xtrId = null;
+    }
+
+    public XtrIdNodeProperty(byte[] xtrId) {
+        super(name);
+        this.xtrId = xtrId;
+    }
+
+    @Override
+    public String getStringValue() {
+        if (xtrId == null) return null;
+        return HexEncode.bytesToHexString(this.xtrId);
+    }
+
+    @Override
+    public Property clone() {
+        return new XtrIdNodeProperty(this.xtrId);
+    }
+
+    public byte[] getXtrId() {
+        return xtrId;
+    }
+}
index 0d1d7ec2d5d4d2d6fa8e87aefded3d5c2273abfe..33759f2dabc1ebb676d97bfc6becae69d71fba12 100644 (file)
@@ -38,7 +38,8 @@ public class LispNotificationHelper {
     public static MapRegister convertMapRegister(org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRegister mapRegister) {
         return new MapRegisterBuilder().setAuthenticationData(mapRegister.getAuthenticationData())
                 .setEidToLocatorRecord(mapRegister.getEidToLocatorRecord()).setKeyId(mapRegister.getKeyId()).setNonce(mapRegister.getNonce())
-                .setProxyMapReply(mapRegister.isProxyMapReply()).setWantMapNotify(mapRegister.isWantMapNotify()).build();
+                .setProxyMapReply(mapRegister.isProxyMapReply()).setWantMapNotify(mapRegister.isWantMapNotify())
+                .setXtrSiteIdPresent(mapRegister.isXtrSiteIdPresent()).setXtrId(mapRegister.getXtrId()).setSiteId(mapRegister.getSiteId()).build();
     }
 
     public static MapRequest convertMapRequest(org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest mapRequest) {
index 897028973b099beb3bea8471b6e5f89b9dde9c88..800a9cd1df10380ce78104a08d7908b57b6d0a10 100644 (file)
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal.implementation</artifactId>
+    </dependency>
 
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index fee52352651d3f42e11e840dcef65c0afcb43313..97879e59fc507ba23379215401dbb8202e73aca0 100644 (file)
@@ -175,6 +175,9 @@ public class MappingServiceTestHelper {
                         "org.eclipse.virgo.util.osgi").versionAsInProject(), mavenBundle("geminiweb", "org.eclipse.virgo.util.osgi.manifest")
                         .versionAsInProject(), mavenBundle("geminiweb", "org.eclipse.virgo.util.parser.manifest").versionAsInProject(),
 
+                // AD-SAL for Inventory
+                mavenBundle("org.opendaylight.controller", "sal.implementation").versionAsInProject(),
+
                 // Our bundles
                 mavenBundle("org.opendaylight.controller", "clustering.stub").versionAsInProject(), //
                 mavenBundle("org.opendaylight.controller", "clustering.services").versionAsInProject(), //