From 3c8908edcb22a084988df76390219e8398ac70ea Mon Sep 17 00:00:00 2001 From: "Keith Burns (alagalah)" Date: Wed, 27 May 2015 21:40:19 -0700 Subject: [PATCH] Remove OpenStackEndpointGBP - not needed. Openstack GBP API integration uses standard API and was back-ported to OpenStack Juno. Change-Id: I1007410cdc6eabba5afdc362458aeddc4bb6bee4 Signed-off-by: Keith Burns (alagalah) --- features/pom.xml | 1 - features/src/main/resources/features.xml | 16 - .../impl/OpenstackEndpointProviderModule.java | 39 -- ...penstackEndpointProviderModuleFactory.java | 13 - .../openstackgbp/OpenstackGbpEndpoint.java | 598 ------------------ 5 files changed, 667 deletions(-) delete mode 100644 renderers/ofoverlay/src/main/java/org/opendaylight/controller/config/yang/config/openstack_endpoint_provider/impl/OpenstackEndpointProviderModule.java delete mode 100644 renderers/ofoverlay/src/main/java/org/opendaylight/controller/config/yang/config/openstack_endpoint_provider/impl/OpenstackEndpointProviderModuleFactory.java delete mode 100644 renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/integration/openstackgbp/OpenstackGbpEndpoint.java diff --git a/features/pom.xml b/features/pom.xml index 6b111744f..70aedd651 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -23,7 +23,6 @@ etc/opendaylight/karaf 15-groupbasedpolicy-ofoverlay.xml 15-groupbasedpolicy-opflex.xml - 15-groupbasedpolicy-openstackendpoint.xml 15-neutron-mapper.xml 15-neutron-ovsdb.xml 15-ui-backend.xml diff --git a/features/src/main/resources/features.xml b/features/src/main/resources/features.xml index 59a129077..154f3644d 100644 --- a/features/src/main/resources/features.xml +++ b/features/src/main/resources/features.xml @@ -80,22 +80,6 @@ mvn:org.opendaylight.groupbasedpolicy/groupbasedpolicy-opflex-config/${project.version}/xml/config - - - - odl-mdsal-broker - mvn:org.opendaylight.groupbasedpolicy/groupbasedpolicy-openstackendpoint-config/${project.version}/xml/config - - diff --git a/renderers/ofoverlay/src/main/java/org/opendaylight/controller/config/yang/config/openstack_endpoint_provider/impl/OpenstackEndpointProviderModule.java b/renderers/ofoverlay/src/main/java/org/opendaylight/controller/config/yang/config/openstack_endpoint_provider/impl/OpenstackEndpointProviderModule.java deleted file mode 100644 index 2fbf55532..000000000 --- a/renderers/ofoverlay/src/main/java/org/opendaylight/controller/config/yang/config/openstack_endpoint_provider/impl/OpenstackEndpointProviderModule.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.opendaylight.controller.config.yang.config.openstack_endpoint_provider.impl; - -import org.opendaylight.groupbasedpolicy.integration.openstackgbp.OpenstackGbpEndpoint; -import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.OFOverlayRenderer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.OpenstackEndpointService; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; - -public class OpenstackEndpointProviderModule - extends - org.opendaylight.controller.config.yang.config.openstack_endpoint_provider.impl.AbstractOpenstackEndpointProviderModule { - public OpenstackEndpointProviderModule( - org.opendaylight.controller.config.api.ModuleIdentifier identifier, - org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public OpenstackEndpointProviderModule( - org.opendaylight.controller.config.api.ModuleIdentifier identifier, - org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, - org.opendaylight.controller.config.yang.config.openstack_endpoint_provider.impl.OpenstackEndpointProviderModule oldModule, - java.lang.AutoCloseable oldInstance) { - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - @Override - public void customValidation() { - // add custom validation form module attributes here. - } - - @Override - public java.lang.AutoCloseable createInstance() { - - return new OpenstackGbpEndpoint(getDataBrokerDependency(), - getRpcRegistryDependency()); - - } - -} diff --git a/renderers/ofoverlay/src/main/java/org/opendaylight/controller/config/yang/config/openstack_endpoint_provider/impl/OpenstackEndpointProviderModuleFactory.java b/renderers/ofoverlay/src/main/java/org/opendaylight/controller/config/yang/config/openstack_endpoint_provider/impl/OpenstackEndpointProviderModuleFactory.java deleted file mode 100644 index fe0408a7e..000000000 --- a/renderers/ofoverlay/src/main/java/org/opendaylight/controller/config/yang/config/openstack_endpoint_provider/impl/OpenstackEndpointProviderModuleFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -/* -* Generated file -* -* Generated from: yang module name: openstack-endpoint-provider-impl yang module local name: openstack-endpoint-provider-impl -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Thu Dec 04 15:28:49 PST 2014 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.config.openstack_endpoint_provider.impl; -public class OpenstackEndpointProviderModuleFactory extends org.opendaylight.controller.config.yang.config.openstack_endpoint_provider.impl.AbstractOpenstackEndpointProviderModuleFactory { - -} diff --git a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/integration/openstackgbp/OpenstackGbpEndpoint.java b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/integration/openstackgbp/OpenstackGbpEndpoint.java deleted file mode 100644 index ad03160e1..000000000 --- a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/integration/openstackgbp/OpenstackGbpEndpoint.java +++ /dev/null @@ -1,598 +0,0 @@ -package org.opendaylight.groupbasedpolicy.integration.openstackgbp; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.OfOverlayContext; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.OfOverlayContextBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.OpenstackEndpoints; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.OpenstackEndpointsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.OpenstackEndpointService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.RegisterEndpointInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.UnregisterEndpointInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.endpoint.fields.L3Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.openstack.endpoints.Endpoint; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.openstack.endpoints.EndpointBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.openstack.endpoints.EndpointKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.openstack.endpoints.EndpointL3; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.openstack.endpoints.EndpointL3Builder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.openstack.endpoints.EndpointL3Key; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.unregister.endpoint.input.L2; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.openstackendpoint.rev141204.unregister.endpoint.input.L3; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -/* - * TODO: Remove YANG for this class, and other OpenStackGBP APIs, - * this has been replaced by standard API in Kilo and backported to Juno -*/ -@Deprecated -public class OpenstackGbpEndpoint implements AutoCloseable, - OpenstackEndpointService { - - public static final InstanceIdentifier OPENSTACKEP_IID = InstanceIdentifier - .builder(OpenstackEndpoints.class).build(); - - private static final Logger LOG = LoggerFactory - .getLogger(OpenstackGbpEndpoint.class); - - private DataBroker dataProvider; - private final ScheduledExecutorService executor; - - private final static InstanceIdentifier nodesIid = InstanceIdentifier - .builder(Nodes.class).build(); - private final static InstanceIdentifier nodeIid = InstanceIdentifier - .builder(Nodes.class).child(Node.class).build(); - private ListenerRegistration nodesReg; - - final BindingAwareBroker.RpcRegistration rpcRegistration; - - public OpenstackGbpEndpoint(DataBroker dataProvider, - RpcProviderRegistry rpcRegistry) { - super(); - this.dataProvider = dataProvider; - executor = Executors.newScheduledThreadPool(1); - - if (rpcRegistry != null) { - rpcRegistration = rpcRegistry.addRpcImplementation( - OpenstackEndpointService.class, this); - } else - rpcRegistration = null; - - if (dataProvider != null) { - InstanceIdentifier iid = InstanceIdentifier - .builder(OpenstackEndpoints.class).build(); - WriteTransaction t = this.dataProvider.newWriteOnlyTransaction(); - t.put(LogicalDatastoreType.OPERATIONAL, iid, - new OpenstackEndpointsBuilder().build()); - CheckedFuture f = t - .submit(); - Futures.addCallback(f, new FutureCallback() { - @Override - public void onFailure(Throwable t) { - LOG.error("Could not write endpoint base container", t); - } - - @Override - public void onSuccess(Void result) { - } - }); - nodesReg = dataProvider.registerDataChangeListener( - LogicalDatastoreType.OPERATIONAL, nodeIid, - new NodesListener(), DataChangeScope.SUBTREE); - } - } - - public void setDataProvider(final DataBroker salDataProvider) { - this.dataProvider = salDataProvider; - } - - @Override - public void close() throws Exception { - // When we close this service we need to shutdown our executor! - // executor.shutdown(); - - if (dataProvider != null) { - WriteTransaction tx = dataProvider.newWriteOnlyTransaction(); - tx.delete(LogicalDatastoreType.OPERATIONAL, OPENSTACKEP_IID); - Futures.addCallback(tx.submit(), new FutureCallback() { - @Override - public void onSuccess(final Void result) { - LOG.debug("Delete OS EP commit result: " + result); - } - - @Override - public void onFailure(final Throwable t) { - LOG.error("Delete of OS EP failed", t); - } - }); - } - } - - // ******************************************************************/ - /** - * Construct an endpoint with the appropriate augmentations from the - * endpoint input. This can be overridden by a concrete implementation. - * - * @param input - * the input object - */ - protected EndpointBuilder buildEndpoint(RegisterEndpointInput input) { - return new EndpointBuilder(input); - } - - /** - * Construct an L3 endpoint with the appropriate augmentations from the - * endpoint input. This can be overridden by a concrete implementation. - * - * @param input - * the input object - */ - protected EndpointL3Builder buildEndpointL3(RegisterEndpointInput input) { - return new EndpointL3Builder(input); - } - - @Override - @Deprecated - public Future> unregisterEndpoint( - UnregisterEndpointInput input) { - WriteTransaction t = dataProvider.newWriteOnlyTransaction(); - if (input.getL2() != null) { - for (L2 l2a : input.getL2()) { - EndpointKey key = new EndpointKey(l2a.getL2Context(), - l2a.getMacAddress()); - InstanceIdentifier iid = InstanceIdentifier - .builder(OpenstackEndpoints.class) - .child(Endpoint.class, key).build(); - t.delete(LogicalDatastoreType.OPERATIONAL, iid); - } - } - if (input.getL3() != null) { - for (L3 l3addr : input.getL3()) { - EndpointL3Key key3 = new EndpointL3Key(l3addr.getIpAddress(), - l3addr.getL3Context()); - InstanceIdentifier iid_l3 = InstanceIdentifier - .builder(OpenstackEndpoints.class) - .child(EndpointL3.class, key3).build(); - t.delete(LogicalDatastoreType.OPERATIONAL, iid_l3); - } - } - unregisterStandardEndpoint(input); - ListenableFuture r = t.submit(); - return Futures.transform(r, futureTrans, executor); - } - - public Future> unregisterStandardEndpoint( - UnregisterEndpointInput input) { - WriteTransaction t = dataProvider.newWriteOnlyTransaction(); - if (input.getL2() != null) { - for (L2 l2a : input.getL2()) { - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointKey key = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointKey( - l2a.getL2Context(), l2a.getMacAddress()); - if (existsL2Endpoint(key)) { - InstanceIdentifier iid = InstanceIdentifier - .builder( - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints.class) - .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint.class, - key).build(); - t.delete(LogicalDatastoreType.OPERATIONAL, iid); - } - - } - } - if (input.getL3() != null) { - for (L3 l3addr : input.getL3()) { - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Key key3 = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Key( - l3addr.getIpAddress(), l3addr.getL3Context()); - if (existsL3Endpoint(key3)) { - InstanceIdentifier iid_l3 = InstanceIdentifier - .builder(Endpoints.class) - .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3.class, - key3).build(); - t.delete(LogicalDatastoreType.OPERATIONAL, iid_l3); - } - } - } - ListenableFuture r = t.submit(); - return Futures.transform(r, futureTrans, executor); - } - - private Boolean existsL2Endpoint( - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointKey key) { - Boolean exists = false; - InstanceIdentifier iid = InstanceIdentifier - .builder(Endpoints.class) - .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint.class, - key).build(); - - if (dataProvider != null) { - Optional result; - try { - result = dataProvider.newReadOnlyTransaction() - .read(LogicalDatastoreType.OPERATIONAL, iid).get(); - if (result.isPresent()) { - exists = true; - } - } catch (InterruptedException | ExecutionException e) { - LOG.error("Caught exception in existsL2Endpoint", e); - } - } - return exists; - } - - private Boolean existsL3Endpoint( - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Key keyL3) { - Boolean exists = false; - InstanceIdentifier iidL3 = InstanceIdentifier - .builder(Endpoints.class) - .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3.class, - keyL3).build(); - if (dataProvider != null) { - Optional result; - try { - result = dataProvider.newReadOnlyTransaction() - .read(LogicalDatastoreType.OPERATIONAL, iidL3).get(); - if (result.isPresent()) { - exists = true; - } - } catch (InterruptedException | ExecutionException e) { - LOG.error("Caught exception in existsL3Endpoint",e); - } - } - return exists; - } - - @Override - @Deprecated - public Future> registerEndpoint(RegisterEndpointInput input) { - long timestamp = System.currentTimeMillis(); - - WriteTransaction t = dataProvider.newWriteOnlyTransaction(); - - if (input.getL2Context() != null && input.getMacAddress() != null) { - Endpoint ep = buildEndpoint(input).setTimestamp(timestamp).build(); - - EndpointKey key = new EndpointKey(ep.getL2Context(), - ep.getMacAddress()); - InstanceIdentifier iid = InstanceIdentifier - .builder(OpenstackEndpoints.class) - .child(Endpoint.class, key).build(); - t.put(LogicalDatastoreType.OPERATIONAL, iid, ep); - NodeInfo nodeInfo = mapNeutronPortToNodeInfo(ep.getNeutronPortId() - .getValue()); - if (nodeInfo.getNode() != null - && nodeInfo.getNodeConnector() != null) { - writeNewEp(translateEndpoint(ep, nodeInfo.getNodeConnector() - .getId(), nodeInfo.getNode().getId())); - } - } - if (input.getL3Address() != null) { - for (L3Address l3addr : input.getL3Address()) { - EndpointL3Key key3 = new EndpointL3Key(l3addr.getIpAddress(), - l3addr.getL3Context()); - EndpointL3 ep3 = buildEndpointL3(input) - .setIpAddress(key3.getIpAddress()) - .setL3Context(key3.getL3Context()) - .setTimestamp(timestamp).build(); - InstanceIdentifier iid_l3 = InstanceIdentifier - .builder(OpenstackEndpoints.class) - .child(EndpointL3.class, key3).build(); - t.put(LogicalDatastoreType.OPERATIONAL, iid_l3, ep3); - NodeInfo nodeInfo = mapNeutronPortToNodeInfo(ep3 - .getNeutronPortId().toString()); - if (nodeInfo.getNode() != null - && nodeInfo.getNodeConnector() != null) { - writeNewEpL3(translateEndpointL3(ep3, nodeInfo - .getNodeConnector().getId(), nodeInfo.getNode() - .getId())); - } - } - } - ListenableFuture r = t.submit(); - return Futures.transform(r, futureTrans, executor); - // Now check for Nodes that match the neutron port id - } - - // A wrapper class around node, noeConnector info so we can pass a final - // object inside OnSuccess anonymous inner class - private static class NodeInfo { - NodeConnector nodeConnector; - Node node; - - private NodeInfo() { - - } - - private NodeInfo(NodeConnector nc, Node node) { - this.nodeConnector = nc; - this.node = node; - } - - private Node getNode() { - return this.node; - } - - private NodeConnector getNodeConnector() { - return this.nodeConnector; - } - - public void setNodeConnector(NodeConnector nodeConnector) { - this.nodeConnector = nodeConnector; - } - - public void setNode(Node node) { - this.node = node; - } - } - - private NodeInfo mapNeutronPortToNodeInfo(final String neutronPortId) { - final NodeInfo nodeInfo = new NodeInfo(); - - if (dataProvider != null) { - - ListenableFuture> future = dataProvider - .newReadOnlyTransaction().read( - LogicalDatastoreType.OPERATIONAL, nodesIid); - - Futures.addCallback(future, new FutureCallback>() { - @Override - public void onSuccess(Optional result) { - if (result.isPresent()) { - Nodes nodes = result.get(); - for (Node node : nodes.getNode()) { - if (node.getNodeConnector() != null) { - for (NodeConnector nc : node.getNodeConnector()) { - FlowCapableNodeConnector fcnc = nc - .getAugmentation(FlowCapableNodeConnector.class); - if (fcnc.getName().equals(neutronPortId)) { - nodeInfo.setNode(node); - nodeInfo.setNodeConnector(nc); - } - } - } - } - - } - } - - @Override - public void onFailure(Throwable t) { - LOG.error("Count not read switch information", t); - } - }); - } - return nodeInfo; - } - - private Future> writeNewEp( - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint ep) { - WriteTransaction t = dataProvider.newWriteOnlyTransaction(); - InstanceIdentifier iid = InstanceIdentifier - .builder( - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints.class) - .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint.class, - ep.getKey()).build(); - t.put(LogicalDatastoreType.OPERATIONAL, iid, ep); - ListenableFuture r = t.submit(); - return Futures.transform(r, futureTrans, executor); - - } - - private Future> writeNewEpL3( - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3 ep) { - WriteTransaction t = dataProvider.newWriteOnlyTransaction(); - InstanceIdentifier iid = InstanceIdentifier - .builder( - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints.class) - .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3.class, - ep.getKey()).build(); - t.put(LogicalDatastoreType.OPERATIONAL, iid, ep); - ListenableFuture r = t.submit(); - return Futures.transform(r, futureTrans, executor); - - } - - private boolean validEp(Endpoint endpoint) { - return (endpoint != null && endpoint.getTenant() != null - && endpoint.getEndpointGroup() != null - && endpoint.getL2Context() != null && endpoint.getMacAddress() != null); - } - - private org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint translateEndpoint( - Endpoint ep, NodeConnectorId nodeConnectorId, NodeId nodeId) { - OfOverlayContextBuilder ofOverlayAugmentation = new OfOverlayContextBuilder(); - ofOverlayAugmentation.setNodeId(nodeId); - ofOverlayAugmentation.setNodeConnectorId(nodeConnectorId); - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointBuilder newEpBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointBuilder(); - newEpBuilder.addAugmentation(OfOverlayContext.class, - ofOverlayAugmentation.build()); - newEpBuilder.setCondition(ep.getCondition()); - newEpBuilder.setEndpointGroup(ep.getEndpointGroup()); - newEpBuilder.setL2Context(ep.getL2Context()); - newEpBuilder.setMacAddress(ep.getMacAddress()); - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointKey newEpKey = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointKey( - ep.getL2Context(), ep.getMacAddress()); - newEpBuilder.setKey(newEpKey); - List newL3AddressList = new ArrayList<>(); - if (ep.getL3Address() != null) { - for (L3Address l3 : ep.getL3Address()) { - LOG.debug(l3.toString()); - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3AddressBuilder newL3AddressBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3AddressBuilder(); - newL3AddressBuilder.setIpAddress(l3.getIpAddress()); - newL3AddressBuilder.setL3Context(l3.getL3Context()); - newL3AddressList.add(newL3AddressBuilder.build()); - } - } - newEpBuilder.setL3Address(newL3AddressList); - newEpBuilder.setTenant(ep.getTenant()); - newEpBuilder.setTimestamp(ep.getTimestamp()); - return newEpBuilder.build(); - } - - private org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3 translateEndpointL3( - EndpointL3 ep, NodeConnectorId nodeConnectorId, NodeId nodeId) { - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Builder newEpL3Builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Builder(); - - newEpL3Builder.setCondition(ep.getCondition()); - newEpL3Builder.setIpAddress(ep.getIpAddress()); - newEpL3Builder.setL3Context(ep.getL3Context()); - newEpL3Builder.setEndpointGroup(ep.getEndpointGroup()); - newEpL3Builder.setL2Context(ep.getL2Context()); - newEpL3Builder.setMacAddress(ep.getMacAddress()); - - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Key newEpL3Key = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Key( - ep.getIpAddress(), ep.getL3Context()); - newEpL3Builder.setKey(newEpL3Key); - List newL3AddressList = new ArrayList<>(); - for (L3Address l3 : ep.getL3Address()) { - LOG.debug(l3.toString()); - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3AddressBuilder newL3AddressBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3AddressBuilder(); - newL3AddressBuilder.setIpAddress(l3.getIpAddress()); - newL3AddressBuilder.setL3Context(l3.getL3Context()); - newL3AddressList.add(newL3AddressBuilder.build()); - } - newEpL3Builder.setL3Address(newL3AddressList); - newEpL3Builder.setTenant(ep.getTenant()); - newEpL3Builder.setTimestamp(ep.getTimestamp()); - return newEpL3Builder.build(); - } - - private void updateOfOverlayEndpoint(final String neutronPortId, - final NodeConnectorId nodeConnectorId, final NodeId nodeId) { - - if (dataProvider != null) { - InstanceIdentifier iid = InstanceIdentifier - .builder(OpenstackEndpoints.class).build(); - ListenableFuture> future = dataProvider - .newReadOnlyTransaction().read( - LogicalDatastoreType.OPERATIONAL, iid); - Futures.addCallback(future, - new FutureCallback>() { - @Override - public void onSuccess( - Optional result) { - if (result.isPresent()) { - OpenstackEndpoints openstackEndpoints = result - .get(); - if (openstackEndpoints.getEndpoint() != null) { - for (Endpoint ep : openstackEndpoints - .getEndpoint()) { - if (validEp(ep) - && ep.getNeutronPortId() - .getValue() - .equals(neutronPortId)) { - LOG.debug("Match: " + ep.toString()); - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint newEp = translateEndpoint( - ep, nodeConnectorId, nodeId); - writeNewEp(newEp); - LOG.debug(newEp.toString()); - } - } - } - if (openstackEndpoints.getEndpointL3() != null) { - for (EndpointL3 ep : openstackEndpoints - .getEndpointL3()) { - if (ep.getNeutronPortId().getValue() - .equals(neutronPortId)) { - LOG.debug("L3 Match: " - + ep.toString()); - org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3 newEpL3 = translateEndpointL3( - ep, nodeConnectorId, nodeId); - writeNewEpL3(newEpL3); - LOG.debug(newEpL3.toString()); - } - } - } - } - } - - @Override - public void onFailure(Throwable t) { - LOG.error("Count not read switch information", t); - } - }); - } - } - - private class NodesListener implements DataChangeListener { - @Override - public void onDataChanged( - AsyncDataChangeEvent, DataObject> change) { - for (DataObject dao : change.getCreatedData().values()) { - if (!(dao instanceof Node)) - continue; - Node node = (Node) dao; - if (node.getNodeConnector() != null) { - for (NodeConnector nc : node.getNodeConnector()) { - FlowCapableNodeConnector fcnc = nc - .getAugmentation(FlowCapableNodeConnector.class); - if (fcnc.getName().matches( - "tap[a-f,0-9]{8}-[a-f,0-9]{2}")) { - LOG.debug("Created Tap:" + fcnc.getName() + ": " - + nc.getId() + " : " + node.getId()); - updateOfOverlayEndpoint(fcnc.getName(), nc.getId(), - node.getId()); - } - } - } - } - for (DataObject dao : change.getUpdatedData().values()) { - if (!(dao instanceof Node)) - continue; - Node node = (Node) dao; - if (node.getNodeConnector() != null) { - for (NodeConnector nc : node.getNodeConnector()) { - FlowCapableNodeConnector fcnc = nc - .getAugmentation(FlowCapableNodeConnector.class); - if (fcnc.getName().matches( - "tap[a-f,0-9]{8}-[a-f,0-9]{2}")) { - LOG.debug("Updated Tap:" + fcnc.getName() + ": " - + nc.getId() + " : " + node.getId()); - updateOfOverlayEndpoint(fcnc.getName(), nc.getId(), - node.getId()); - } - } - } - } - } - } - - Function> futureTrans = new Function>() { - @Override - public RpcResult apply(Void input) { - return RpcResultBuilder. success().build(); - } - }; -} -- 2.36.6