--- /dev/null
+<?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
--- /dev/null
+/*
+ * 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));
+ }
+
+}