Merge "First netvirt renderer framework: Hardware Gateway (hwgw)"
authorSam Hague <shague@redhat.com>
Wed, 23 Dec 2015 23:37:30 +0000 (23:37 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 23 Dec 2015 23:37:30 +0000 (23:37 +0000)
utils/hwvtepsouthbound-utils/pom.xml [new file with mode: 0644]
utils/hwvtepsouthbound-utils/src/main/java/org/opendaylight/ovsdb/utils/hwvtepsouthbound/utils/HwvtepSouthboundUtils.java [new file with mode: 0644]
utils/pom.xml

diff --git a/utils/hwvtepsouthbound-utils/pom.xml b/utils/hwvtepsouthbound-utils/pom.xml
new file mode 100644 (file)
index 0000000..263437b
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.4.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.ovsdb</groupId>
+  <artifactId>utils.hwvtepsouthbound-utils</artifactId>
+  <version>1.2.1-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <dependencies>
+    <!-- project specific dependencies -->
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>hwvtepsouthbound-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>hwvtepsouthbound-impl</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>utils.mdsal-utils</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <!-- testing dependencies -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/utils/hwvtepsouthbound-utils/src/main/java/org/opendaylight/ovsdb/utils/hwvtepsouthbound/utils/HwvtepSouthboundUtils.java b/utils/hwvtepsouthbound-utils/src/main/java/org/opendaylight/ovsdb/utils/hwvtepsouthbound/utils/HwvtepSouthboundUtils.java
new file mode 100644 (file)
index 0000000..516baf1
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.ovsdb.utils.hwvtepsouthbound.utils;
+
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundConstants;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ConnectionInfo;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HwvtepSouthboundUtils {
+    private static final Logger LOG = LoggerFactory.getLogger(HwvtepSouthboundUtils.class);
+    private static final int HWVTEP_UPDATE_TIMEOUT = 1000;
+    private final MdsalUtils mdsalUtils;
+
+    public HwvtepSouthboundUtils(MdsalUtils mdsalUtils) {
+        this.mdsalUtils = mdsalUtils;
+    }
+
+    public static NodeId createNodeId(IpAddress ip, PortNumber port) {
+        String uriString = HwvtepSouthboundConstants.HWVTEP_URI_PREFIX + "://"
+                + String.valueOf(ip.getValue()) + ":" + port.getValue();
+        Uri uri = new Uri(uriString);
+        return new NodeId(uri);
+    }
+
+    public static Node createNode(ConnectionInfo key) {
+        NodeBuilder nodeBuilder = new NodeBuilder();
+        nodeBuilder.setNodeId(createNodeId(key.getRemoteIp(), key.getRemotePort()));
+        nodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, createHwvtepAugmentation(key));
+        return nodeBuilder.build();
+    }
+
+    public static HwvtepGlobalAugmentation createHwvtepAugmentation(ConnectionInfo key) {
+        HwvtepGlobalAugmentationBuilder hwvtepGlobalBuilder = new HwvtepGlobalAugmentationBuilder();
+        hwvtepGlobalBuilder.setConnectionInfo(key);
+        return hwvtepGlobalBuilder.build();
+    }
+
+    public static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key) {
+        return createInstanceIdentifier(key.getRemoteIp(), key.getRemotePort());
+    }
+
+    public static InstanceIdentifier<Node> createInstanceIdentifier(IpAddress ip, PortNumber port) {
+        InstanceIdentifier<Node> path = InstanceIdentifier
+                .create(NetworkTopology.class)
+                .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID))
+                .child(Node.class,createNodeKey(ip,port));
+        LOG.debug("Created hwvtep path: {}",path);
+        return path;
+    }
+
+    public static NodeKey createNodeKey(IpAddress ip, PortNumber port) {
+        return new NodeKey(createNodeId(ip, port));
+    }
+
+}
index d3a05cf4b4c076f1bbbf06a02827d83e91798624..650e6f1d729623319f6ae46002266fa944ee2005 100644 (file)
@@ -56,6 +56,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <module>neutron-utils</module>
     <module>servicehelper</module>
     <module>southbound-utils</module>
+    <module>hwvtepsouthbound-utils</module>
   </modules>
 
 <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->