X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=hwvtepsouthbound%2Fhwvtepsouthbound-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fovsdb%2Fhwvtepsouthbound%2FHwvtepSouthboundMapper.java;h=e487f25dc2eb5855280e2edde7c531f57946137b;hb=69218909436886b7a057a7a6d14f53ce3afca203;hp=77cbcdb8a4a7be6aa96beb8dd54a3b6c5fd2bf8b;hpb=a067f79208ddab0184e63a72b5f9728edadd37c4;p=ovsdb.git diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundMapper.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundMapper.java index 77cbcdb8a..e487f25dc 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundMapper.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundMapper.java @@ -11,8 +11,11 @@ package org.opendaylight.ovsdb.hwvtepsouthbound; import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; +import java.net.UnknownHostException; + import org.opendaylight.ovsdb.lib.OvsdbClient; import org.opendaylight.ovsdb.schema.hardwarevtep.Global; +import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch; 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.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; @@ -106,15 +109,20 @@ public class HwvtepSouthboundMapper { return connectionInfoBuilder.build(); } + public static InetAddress createInetAddress(IpAddress ip) throws UnknownHostException { + if (ip.getIpv4Address() != null) { + return InetAddress.getByName(ip.getIpv4Address().getValue()); + } else if (ip.getIpv6Address() != null) { + return InetAddress.getByName(ip.getIpv6Address().getValue()); + } else { + throw new UnknownHostException("IP Address has no value"); + } + } + public static InstanceIdentifier getInstanceIdentifier(Global global) { InstanceIdentifier iid = null; - if (global.getManagersColumn() != null - && global.getManagersColumn().getData() != null) { - String iidString = global.getManagersColumn().getData().iterator().next().toString(); - iid = (InstanceIdentifier) HwvtepSouthboundUtil.deserializeInstanceIdentifier(iidString); - } else { - String nodeString = HwvtepSouthboundConstants.HWVTEP_URI_PREFIX + "://" + - HwvtepSouthboundConstants.UUID + "/" + global.getUuid().toString(); + String nodeString = HwvtepSouthboundConstants.HWVTEP_URI_PREFIX + "://" + + HwvtepSouthboundConstants.UUID + "/" + global.getUuid().toString(); NodeId nodeId = new NodeId(new Uri(nodeString)); NodeKey nodeKey = new NodeKey(nodeId); TopologyKey topoKey = new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID); @@ -122,7 +130,18 @@ public class HwvtepSouthboundMapper { .child(Topology.class, topoKey) .child(Node.class,nodeKey) .build(); - } + return iid; + } + + public static InstanceIdentifier createInstanceIdentifier(HwvtepConnectionInstance client, + PhysicalSwitch pSwitch) { + InstanceIdentifier iid = null; + String nodeString = client.getNodeKey().getNodeId().getValue() + "/physicalswitch/" + pSwitch.getName(); + NodeId nodeId = new NodeId(new Uri(nodeString)); + NodeKey nodeKey = new NodeKey(nodeId); + iid =InstanceIdentifier.builder(NetworkTopology.class) + .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID)) + .child(Node.class, nodeKey).build(); return iid; } }