From f538621e0d65720744347f06cab5f6b6469871f8 Mon Sep 17 00:00:00 2001 From: jingxuanzhang Date: Wed, 19 Feb 2020 18:30:21 -0500 Subject: [PATCH] Generate network map from BGP local rib Signed-off-by: jingxuanzhang --- alto-basic/auto-maps/api/pom.xml | 15 ++ .../api/src/main/yang/alto-auto-maps.yang | 74 ++++++++ alto-basic/auto-maps/impl/pom.xml | 13 ++ .../impl/AltoAutoMapsBgpIpv4Updater.java | 151 ++++++++++++++++ .../impl/AltoAutoMapsConfigListener.java | 169 ++++++++++++++++++ ....java => AltoAutoMapsOpenflowUpdater.java} | 35 +++- .../alto/basic/impl/AltoAutoMapsProvider.java | 13 +- .../impl/AltoAutoMapsUpdateListenerTest.java | 6 +- .../basic/manual/maps/ManualMapsUtils.java | 44 ++++- .../src/main/yang/alto-costmap-config.yang | 2 +- .../api/src/main/yang/alto-manual-maps.yang | 27 ++- .../alto/basic/impl/AltoModelConfigImpl.java | 21 +-- .../alto/basic/impl/ManualMapsListener.java | 1 + .../alto/basic/impl/SimpleIrdRoute.java | 4 +- alto-core/northbound/impl/pom.xml | 4 + .../impl/AltoNorthboundExceptionHandler.java | 9 +- .../costmap/impl/pom.xml | 21 --- .../impl/AltoNorthboundRouteCostmap.java | 11 +- .../opendaylight/blueprint/impl-blueprint.xml | 5 + .../endpointcost/impl/pom.xml | 21 --- .../impl/AltoNorthboundRouteEndpointcost.java | 18 +- .../opendaylight/blueprint/impl-blueprint.xml | 3 + .../endpointproperty/impl/pom.xml | 21 --- .../AltoNorthboundRouteEndpointproperty.java | 17 +- .../opendaylight/blueprint/impl-blueprint.xml | 3 + .../networkmap/impl/pom.xml | 21 --- .../impl/AltoNorthboundRouteNetworkmap.java | 18 +- .../opendaylight/blueprint/impl-blueprint.xml | 3 + .../src/main/yang/alto-model-config.yang | 2 +- .../odl-alto-auto-maps/pom.xml | 28 ++- 30 files changed, 626 insertions(+), 154 deletions(-) create mode 100644 alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsBgpIpv4Updater.java create mode 100644 alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsConfigListener.java rename alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/{AltoAutoMapsUpdateListener.java => AltoAutoMapsOpenflowUpdater.java} (83%) diff --git a/alto-basic/auto-maps/api/pom.xml b/alto-basic/auto-maps/api/pom.xml index 8094f63b..661975d7 100644 --- a/alto-basic/auto-maps/api/pom.xml +++ b/alto-basic/auto-maps/api/pom.xml @@ -21,4 +21,19 @@ and is available at http://www.eclipse.org/legal/epl-v10.html 0.6.4 ODL :: alto :: ${project.artifactId} bundle + + + org.opendaylight.alto.core + alto-basic-types + ${project.version} + + + org.opendaylight.mdsal.model + ietf-yang-types-20130715 + + + org.opendaylight.mdsal.model + ietf-topology + + diff --git a/alto-basic/auto-maps/api/src/main/yang/alto-auto-maps.yang b/alto-basic/auto-maps/api/src/main/yang/alto-auto-maps.yang index 0d0baf87..1179d1d9 100644 --- a/alto-basic/auto-maps/api/src/main/yang/alto-auto-maps.yang +++ b/alto-basic/auto-maps/api/src/main/yang/alto-auto-maps.yang @@ -3,7 +3,81 @@ module alto-auto-maps { namespace "urn:alto:auto:maps"; prefix "alto-auto-maps"; + import "ietf-yang-types" { + prefix "ietf-types"; + } + + import "network-topology" { + prefix "topology"; + } + + import "alto-basic-types" { + prefix "alto-types"; + } + + organization "Yale University"; + + contact "alto-dev@lists.opendaylight.org"; + revision "2015-01-05" { description "Initial revision of alto-auto-maps model"; } + + typedef topology-type { + type enumeration { + enum openflow; + enum bgp-ipv4; + enum bgp-ls; + } + } + + // TODO: Augment to config-context of manual map + list config-context { + key "context-id"; + + leaf "context-id" { + type ietf-types:uuid; + default "00000000-0000-0000-0000-000000000000"; + } + + list resource-network-map { + key "resource-id"; + + leaf "resource-id" { + mandatory true; + type alto-types:resource-id; + } + + leaf "topology-id" { + type string; + default "flow:1"; + } + + leaf "topology-type" { + type topology-type; + default openflow; + } + + choice algorithm { + case spt-cluster { + container spt-cluster-params { + leaf spt-root { + type topology:node-id; + } + leaf num-of-clusters { + type int32; + } + } + } + case bgp-simple-as-cluster { + container bgp-simple-as-params { + // FIXME: identityref is better + leaf bgp-rib { + type string; + } + } + } + } + } + } } diff --git a/alto-basic/auto-maps/impl/pom.xml b/alto-basic/auto-maps/impl/pom.xml index f4e62594..33cc2449 100644 --- a/alto-basic/auto-maps/impl/pom.xml +++ b/alto-basic/auto-maps/impl/pom.xml @@ -25,6 +25,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html 0.7.4 + 0.9.4 @@ -69,6 +70,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html ${l2switch.version} + + org.opendaylight.bgpcep + bgp-rib-api + ${bgpcep.version} + + + + org.opendaylight.bgpcep + bgp-inet + ${bgpcep.version} + + junit diff --git a/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsBgpIpv4Updater.java b/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsBgpIpv4Updater.java new file mode 100644 index 00000000..3d7d279e --- /dev/null +++ b/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsBgpIpv4Updater.java @@ -0,0 +1,151 @@ +/* + * Copyright © 2015 Yale University 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.alto.basic.impl; + +import com.google.common.base.Optional; +import org.opendaylight.alto.basic.manual.maps.ManualMapsUtils; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.ReadTransaction; +import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.alto.auto.maps.rev150105.config.context.ResourceNetworkMap; +import org.opendaylight.yang.gen.v1.urn.alto.auto.maps.rev150105.config.context.resource.network.map.algorithm.BgpSimpleAsCluster; +import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.networkmap.rev151021.EndpointAddressType; +import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.networkmap.rev151021.endpoint.address.group.EndpointAddressGroup; +import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.networkmap.rev151021.endpoint.address.group.EndpointAddressGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.networkmap.rev151021.network.map.Map; +import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.networkmap.rev151021.network.map.MapBuilder; +import org.opendaylight.yang.gen.v1.urn.alto.types.rev150921.PidName; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.ipv4.routes.Ipv4Route; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.Segments; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.Rib; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.RibKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.LocRib; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +public class AltoAutoMapsBgpIpv4Updater implements AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(AltoAutoMapsBgpIpv4Updater.class); + + private final DataBroker dataBroker; + // private ListenerRegistration registration; + private String contextId; + private ResourceNetworkMap networkMapConfig; + + public AltoAutoMapsBgpIpv4Updater(String contextId, ResourceNetworkMap networkMapConfig, final DataBroker dataBroker) { + this.dataBroker = dataBroker; + this.contextId = contextId; + this.networkMapConfig = networkMapConfig; + registerBGPListener(); + } + + private void registerBGPListener() { + final ReadWriteTransaction wrx = dataBroker.newReadWriteTransaction(); + try { + List networkMap = computeNetworkMapByBgpIpv4(networkMapConfig); + LOG.info("Putting auto generated network-map to manual map config..."); + ManualMapsUtils.createResourceNetworkMap(contextId, networkMapConfig.getResourceId().getValue(), + networkMap, wrx); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } + wrx.submit(); + } + + private List computeNetworkMapByBgpIpv4(ResourceNetworkMap networkMapConfig) throws InterruptedException, ExecutionException { + final ReadTransaction rx = dataBroker.newReadOnlyTransaction(); + List networkMap = new LinkedList<>(); + if (networkMapConfig.getAlgorithm() instanceof BgpSimpleAsCluster) { + BgpSimpleAsCluster algorithm = (BgpSimpleAsCluster) networkMapConfig.getAlgorithm(); + String ribId = algorithm.getBgpSimpleAsParams().getBgpRib(); + InstanceIdentifier ribIID = InstanceIdentifier.builder(BgpRib.class) + .child(Rib.class, new RibKey(new RibId(ribId))) + .child(LocRib.class) + .child(Tables.class, new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)) + .build(); + try { + Optional optional = rx.read(LogicalDatastoreType.OPERATIONAL, ribIID).get(); + if (optional.isPresent()) { + Tables table = optional.get(); + if (table.getRoutes() instanceof Ipv4RoutesCase) { + Ipv4RoutesCase routesCase = (Ipv4RoutesCase) table.getRoutes(); + java.util.Map> pids = new LinkedHashMap<>(); + for (Ipv4Route route : routesCase.getIpv4Routes().getIpv4Route()) { + List segments = route.getAttributes().getAsPath().getSegments(); + String pidName = "PID0"; + if (segments != null && !segments.isEmpty()) { + List asSequence = segments.get(segments.size() - 1).getAsSequence(); + if (asSequence != null && !asSequence.isEmpty()) { + pidName = "PID" + asSequence.get(asSequence.size() - 1).getValue().toString(); + } else { + List asSet = segments.get(segments.size() - 1).getAsSet(); + if (asSet != null && !asSet.isEmpty()) { + pidName = "PID" + String.join("-", + (String[]) Arrays.stream((AsNumber[]) asSet.toArray()) + .map(s -> s.getValue().toString()) + .toArray()); + } + } + } + if (!pids.containsKey(pidName)) { + pids.put(pidName, new LinkedList<>()); + } + pids.get(pidName).add(new IpPrefix(route.getPrefix())); + } + for (java.util.Map.Entry> entry : pids.entrySet()) { + String pidName = entry.getKey(); + List prefixList = entry.getValue(); + networkMap.add(new MapBuilder() + .setPid(new PidName(pidName)) + .setEndpointAddressGroup(Arrays.asList(new EndpointAddressGroup[]{ + new EndpointAddressGroupBuilder() + .setAddressType(new EndpointAddressType(EndpointAddressType.Enumeration.Ipv4)) + .setEndpointPrefix(prefixList) + .build() + })) + .build()); + } + } else { + throw new ExecutionException("Unsupported route type", null); + } + } else { + throw new InterruptedException("BGP Local RIB not found"); + } + } catch (InterruptedException | ExecutionException e) { + throw e; + } + } else { + throw new InterruptedException("Unsupported algorithm for bgp topology"); + } + return networkMap; + } + + @Override + public void close() throws Exception { + LOG.info("BGP IPv4 updater closed"); + } +} diff --git a/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsConfigListener.java b/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsConfigListener.java new file mode 100644 index 00000000..2cf39a56 --- /dev/null +++ b/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsConfigListener.java @@ -0,0 +1,169 @@ +/* + * Copyright © 2015 Yale University 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.alto.basic.impl; + +import org.opendaylight.alto.basic.manual.maps.ManualMapsUtils; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; +import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; +import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; +import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.alto.auto.maps.rev150105.ConfigContext; +import org.opendaylight.yang.gen.v1.urn.alto.auto.maps.rev150105.config.context.ResourceNetworkMap; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +public class AltoAutoMapsConfigListener implements AutoCloseable { + + private DataBroker dataBroker; + private static final Logger LOG = LoggerFactory.getLogger(AltoAutoMapsConfigListener.class); + private final List> listenerRegs = new LinkedList<>(); + + // FIXME: Should not be a fixed iid; replace it later + // private static final String DUMMY_CONTEXT = "00000000-0000-0000-0000-000000000000"; + // private final InstanceIdentifier dummyConfigContext = InstanceIdentifier.builder( + // ConfigContext.class, new ConfigContextKey(new Uuid(DUMMY_CONTEXT))).build(); + + private InstanceIdentifier configListIID = InstanceIdentifier.builder(ConfigContext.class).build(); + private java.util.Map> updaters = new LinkedHashMap<>(); + + public void register(DataBroker dataBroker) { + this.dataBroker = dataBroker; + listenerRegs.add(dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>( + LogicalDatastoreType.CONFIGURATION, configListIID), + changes -> onConfigContextChanged(changes))); + listenerRegs.add(dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>( + LogicalDatastoreType.CONFIGURATION, configListIID.child(ResourceNetworkMap.class)), + changes -> onNetworkMapConfigured(changes))); + } + + private void onConfigContextChanged(Collection> changes) { + // TODO: Update new config context + final ReadWriteTransaction rwx = dataBroker.newReadWriteTransaction(); + + for (DataTreeModification change : changes) { + final DataObjectModification rootNode = change.getRootNode(); + final InstanceIdentifier identifier = change.getRootPath().getRootIdentifier(); + final String contextId = identifier.firstKeyOf(ConfigContext.class).getContextId().getValue(); + switch (rootNode.getModificationType()) { + case WRITE: + case SUBTREE_MODIFIED: + createConfigContext(contextId, rwx); + break; + case DELETE: + break; + } + } + rwx.submit(); + } + + private void createConfigContext(String contextId, ReadWriteTransaction rwx) { + try { + if (!ManualMapsUtils.contextExists(contextId, rwx)) { + ManualMapsUtils.createContext(contextId, rwx); + updaters.put(contextId, new LinkedHashMap<>()); + } + } catch (InterruptedException | ExecutionException e) { + LOG.error("Fail to create config context!", e); + } + } + + private void onNetworkMapConfigured(Collection> changes) { + final ReadWriteTransaction rwx = dataBroker.newReadWriteTransaction(); + + for (DataTreeModification change : changes) { + final DataObjectModification rootNode = change.getRootNode(); + final InstanceIdentifier identifier = change.getRootPath().getRootIdentifier(); + final String contextId = identifier.firstKeyOf(ConfigContext.class).getContextId().getValue(); + switch (rootNode.getModificationType()) { + case WRITE: + generateNetworkMapUpdater(contextId, rootNode.getDataAfter().getResourceId().getValue(), + rootNode.getDataAfter()); + break; + case SUBTREE_MODIFIED: + // TODO: Update configuration + break; + case DELETE: + removeNetworkMapUpdater(contextId, rootNode.getDataBefore().getResourceId().getValue(), rwx); + break; + } + } + + rwx.submit(); + } + + private void generateNetworkMapUpdater(String contextId, String resourceId, ResourceNetworkMap networkMapConfig) { + if (!updaters.containsKey(contextId)) { + updaters.put(contextId, new LinkedHashMap<>()); + } + java.util.Map contextUpdaters = updaters.get(contextId); + if (contextUpdaters.containsKey(resourceId)) { + // TODO: handle configuration updates + LOG.warn("Updating configuration not supported yet"); + return; + } + switch (networkMapConfig.getTopologyType()) { + case Openflow: + LOG.info("creating updater for OpenFlow topology..."); + contextUpdaters.put(resourceId, new AltoAutoMapsOpenflowUpdater(networkMapConfig.getTopologyId(), + contextId, resourceId, dataBroker)); + break; + case BgpIpv4: + LOG.info("creating updater for BGP IPv4 topology..."); + contextUpdaters.put(resourceId, new AltoAutoMapsBgpIpv4Updater(contextId, networkMapConfig, + dataBroker)); + break; + case BgpLs: + // TODO: BGP-LS updater + LOG.warn("BGP-LS updater not implemented yet"); + break; + default: + LOG.warn("Unsupported topology type"); + } + } + + private void removeNetworkMapUpdater(String contextId, String resourceId, WriteTransaction wx) { + if (updaters.containsKey(contextId) && updaters.get(contextId).containsKey(resourceId)) { + try { + updaters.get(contextId).get(resourceId).close(); + updaters.get(contextId).remove(resourceId); + } catch (Exception e) { + e.printStackTrace(); + } + } + InstanceIdentifier networkMapIID = + ManualMapsUtils.getResourceNetworkMapIID(contextId, resourceId); + removeMap(networkMapIID, wx); + } + + private void removeMap(InstanceIdentifier mapIID, final WriteTransaction wx) { + wx.delete(LogicalDatastoreType.CONFIGURATION, mapIID); + } + + @Override + public void close() throws Exception { + for (String contextId : updaters.keySet()) { + for (String resourceId : updaters.get(contextId).keySet()) { + updaters.get(contextId).get(resourceId).close(); + } + } + for (ListenerRegistration reg : listenerRegs) { + reg.close(); + } + } +} diff --git a/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsUpdateListener.java b/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsOpenflowUpdater.java similarity index 83% rename from alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsUpdateListener.java rename to alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsOpenflowUpdater.java index 17817363..a060692b 100644 --- a/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsUpdateListener.java +++ b/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsOpenflowUpdater.java @@ -37,26 +37,46 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AltoAutoMapsUpdateListener implements DataTreeChangeListener, AutoCloseable { +public class AltoAutoMapsOpenflowUpdater implements DataTreeChangeListener, AutoCloseable { - private static final Logger LOG = LoggerFactory.getLogger(AltoAutoMapsUpdateListener.class); + private static final Logger LOG = LoggerFactory.getLogger(AltoAutoMapsOpenflowUpdater.class); private final DataBroker dataBroker; private final ListenerRegistration registration; - private static final String TOPOLOGY_NAME = "flow:1"; + private static final String DEFAULT_TOPOLOGY_NAME = "flow:1"; + private static final String DEFAULT_CONTEXT = "00000000-0000-0000-0000-000000000000"; private static final String DEFAULT_AUTO_NETWORKMAP = "default-auto-networkmap"; // private static final String DEFAULT_AUTO_COSTMAP = "default-auto-costmap"; // private static final String DEFAULT_PID = "PID0"; + private String topologyName; + private String contextId; + private String networkmapResourceId; + + public AltoAutoMapsOpenflowUpdater(final DataBroker dataBroker) { + this.topologyName = DEFAULT_TOPOLOGY_NAME; + this.contextId = DEFAULT_CONTEXT; + this.networkmapResourceId = DEFAULT_AUTO_NETWORKMAP; + this.dataBroker = dataBroker; + this.registration = registerTopologyListener(); + } - public AltoAutoMapsUpdateListener(final DataBroker dataBroker) { + public AltoAutoMapsOpenflowUpdater(String topologyName, String contextId, String networkmapResourceId, + final DataBroker dataBroker) { + this.topologyName = topologyName; + this.contextId = contextId; + this.networkmapResourceId = networkmapResourceId; this.dataBroker = dataBroker; + this.registration = registerTopologyListener(); + } + + private ListenerRegistration registerTopologyListener() { InstanceIdentifier iid = InstanceIdentifier .builder(NetworkTopology.class) .child(Topology.class, - new TopologyKey(new TopologyId(TOPOLOGY_NAME))) + new TopologyKey(new TopologyId(this.topologyName))) .build(); - this.registration = dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>( + return dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>( LogicalDatastoreType.OPERATIONAL, iid), this); } @@ -147,7 +167,7 @@ private void mergeAddressesListToDefaultNetworkMap(List addressesList .setEndpointAddressGroup(emptyEndpointAddressGroup); networkMap.add(builder.build()); - ManualMapsUtils.createResourceNetworkMap(DEFAULT_AUTO_NETWORKMAP, networkMap, wx); + ManualMapsUtils.createResourceNetworkMap(this.contextId, this.networkmapResourceId, networkMap, wx); } private List aggregateAddressesList(List addressesList) { @@ -169,6 +189,7 @@ private List aggregateAddressesList(List addressesList) { public void close() throws Exception { closeRegistration(); LOG.info("AltoAutoMapsUpdateListener Closed"); + // TODO: Remove generated maps } private void closeRegistration() { diff --git a/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsProvider.java b/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsProvider.java index 3fed8413..08d5784f 100644 --- a/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsProvider.java +++ b/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsProvider.java @@ -15,10 +15,12 @@ public class AltoAutoMapsProvider { private static final Logger LOG = LoggerFactory.getLogger(AltoAutoMapsProvider.class); - private AltoAutoMapsUpdateListener listener; + // private AltoAutoMapsUpdateListener dummyListener; + private AltoAutoMapsConfigListener configListener = new AltoAutoMapsConfigListener(); public AltoAutoMapsProvider(final DataBroker dataBroker) { - this.listener = new AltoAutoMapsUpdateListener(dataBroker); + // this.dummyListener = new AltoAutoMapsUpdateListener(dataBroker); + this.configListener.register(dataBroker); } /** @@ -37,8 +39,11 @@ public void close() throws Exception { } private void closeListener() throws Exception { - if (listener != null) { - this.listener.close(); +// if (dummyListener != null) { +// this.dummyListener.close(); +// } + if (configListener != null) { + this.configListener.close(); } } } diff --git a/alto-basic/auto-maps/impl/src/test/java/org/opendaylight/alto/basic/impl/AltoAutoMapsUpdateListenerTest.java b/alto-basic/auto-maps/impl/src/test/java/org/opendaylight/alto/basic/impl/AltoAutoMapsUpdateListenerTest.java index 6626ded2..c03c886b 100644 --- a/alto-basic/auto-maps/impl/src/test/java/org/opendaylight/alto/basic/impl/AltoAutoMapsUpdateListenerTest.java +++ b/alto-basic/auto-maps/impl/src/test/java/org/opendaylight/alto/basic/impl/AltoAutoMapsUpdateListenerTest.java @@ -45,7 +45,7 @@ public class AltoAutoMapsUpdateListenerTest { private final DataBroker dataBroker = mock(DataBroker.class); private final ListenerRegistration registration = mock(ListenerRegistration.class); - private AltoAutoMapsUpdateListener altoAutoMapsUpdateListener; + private AltoAutoMapsOpenflowUpdater altoAutoMapsUpdateListener; private final WriteTransaction rwx = mock(WriteTransaction.class); private final InstanceIdentifier iid = InstanceIdentifier .builder(NetworkTopology.class) @@ -58,12 +58,12 @@ public class AltoAutoMapsUpdateListenerTest { public void setUp() throws Exception { when(dataBroker.registerDataTreeChangeListener( any(DataTreeIdentifier.class), - any(AltoAutoMapsUpdateListener.class) + any(AltoAutoMapsOpenflowUpdater.class) )).thenReturn(registration); when(dataBroker.newWriteOnlyTransaction()).thenReturn(rwx); - altoAutoMapsUpdateListener = new AltoAutoMapsUpdateListener(dataBroker); + altoAutoMapsUpdateListener = new AltoAutoMapsOpenflowUpdater(dataBroker); } @After diff --git a/alto-basic/manual-maps/api/src/main/java/org/opendaylight/alto/basic/manual/maps/ManualMapsUtils.java b/alto-basic/manual-maps/api/src/main/java/org/opendaylight/alto/basic/manual/maps/ManualMapsUtils.java index e0cb478a..3671bea7 100644 --- a/alto-basic/manual-maps/api/src/main/java/org/opendaylight/alto/basic/manual/maps/ManualMapsUtils.java +++ b/alto-basic/manual-maps/api/src/main/java/org/opendaylight/alto/basic/manual/maps/ManualMapsUtils.java @@ -8,6 +8,8 @@ package org.opendaylight.alto.basic.manual.maps; +import com.google.common.base.Optional; +import org.opendaylight.controller.md.sal.binding.api.ReadTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid; @@ -32,6 +34,7 @@ import java.util.LinkedList; import java.util.List; import java.util.UUID; +import java.util.concurrent.ExecutionException; public class ManualMapsUtils { @@ -53,6 +56,24 @@ public static InstanceIdentifier getContextIID(ConfigContextKey k return InstanceIdentifier.builder(ConfigContext.class, key).build(); } + public static boolean contextExists(String cid, ReadTransaction rx) + throws InterruptedException, ExecutionException { + return contextExists(new Uuid(cid), rx); + } + + public static boolean contextExists(Uuid cid, ReadTransaction rx) + throws InterruptedException, ExecutionException { + return contextExists(new ConfigContextKey(cid), rx); + } + + public static boolean contextExists(ConfigContextKey key, ReadTransaction rx) + throws InterruptedException, ExecutionException { + Optional context; + context = rx.read(LogicalDatastoreType.OPERATIONAL, getContextIID(key)).get(); + + return context.isPresent(); + } + public static InstanceIdentifier getContextListIID() { return InstanceIdentifier.builder(ConfigContext.class).build(); } @@ -109,15 +130,30 @@ public static Uuid createContext(Uuid cid, final WriteTransaction wx) { return cid; } - public static InstanceIdentifier createResourceNetworkMap(String rid, + public static InstanceIdentifier createResourceNetworkMap( + String rid, List networkMap, WriteTransaction wx) { - InstanceIdentifier iid = getResourceNetworkMapIID(rid); + return createResourceNetworkMap(DEFAULT_CONTEXT, rid, networkMap, wx); + } + + public static InstanceIdentifier createResourceNetworkMap( + String cid, + String rid, + List networkMap, + WriteTransaction wx) { + return createResourceNetworkMap(new Uuid(cid), new ResourceId(rid), networkMap, wx); + } + + public static InstanceIdentifier createResourceNetworkMap(Uuid cid, ResourceId rid, + List networkMap, + WriteTransaction wx) { + InstanceIdentifier iid = getResourceNetworkMapIID(cid, rid); ResourceNetworkMapBuilder builder = new ResourceNetworkMapBuilder() - .setTag(new Tag(UUID.nameUUIDFromBytes(rid.getBytes()) + .setTag(new Tag(UUID.nameUUIDFromBytes(rid.getValue().getBytes()) .toString() .replaceAll("-", ""))) - .setResourceId(new ResourceId(rid)) + .setResourceId(rid) .setMap(networkMap); wx.put(LogicalDatastoreType.CONFIGURATION, iid, builder.build()); return iid; diff --git a/alto-basic/manual-maps/api/src/main/yang/alto-costmap-config.yang b/alto-basic/manual-maps/api/src/main/yang/alto-costmap-config.yang index 9edd743c..dbf50c1b 100644 --- a/alto-basic/manual-maps/api/src/main/yang/alto-costmap-config.yang +++ b/alto-basic/manual-maps/api/src/main/yang/alto-costmap-config.yang @@ -34,7 +34,7 @@ module alto-costmap-config { mandatory true; type alto-types:resource-id; } - leaf tag { + leaf "tag" { mandatory true; type alto-types:tag; } diff --git a/alto-basic/manual-maps/api/src/main/yang/alto-manual-maps.yang b/alto-basic/manual-maps/api/src/main/yang/alto-manual-maps.yang index 202e120c..f2950a19 100644 --- a/alto-basic/manual-maps/api/src/main/yang/alto-manual-maps.yang +++ b/alto-basic/manual-maps/api/src/main/yang/alto-manual-maps.yang @@ -21,6 +21,10 @@ module alto-manual-maps { prefix "endpointproperty-config"; } + import "alto-basic-types" { + prefix "alto-types"; + } + import "alto-model-base" { prefix "base"; } @@ -60,13 +64,20 @@ module alto-manual-maps { // } } + grouping config-map-meta { + } + augment "alto-cfg:query/alto-cfg:input/alto-cfg:request/alto-cfg:config-request/" + "alto-cfg:config-request-message/alto-cfg:config-resource-data" { case "config-networkmap-data" { - uses networkmap-config:network-map; + container networkmap-data { + uses networkmap-config:network-map; + } } case "config-costmap-data" { - uses costmap-config:cost-map; + container costmap-data { + uses costmap-config:cost-map; + } } } @@ -79,11 +90,15 @@ module alto-manual-maps { augment "alto-cfg:query/alto-cfg:output/alto-cfg:response/alto-cfg:config-response/" + "alto-cfg:config-response-message/alto-cfg:config-response-data" { - container "config-networkmap-response-data" { - uses networkmap-config:network-map; + case "config-networkmap-response-data" { + container "networkmap-response-data" { + uses networkmap-config:network-map; + } } - container "config-costmap-response-data" { - uses costmap-config:cost-map; + case "config-costmap-response-data" { + container "costmap-response-data" { + uses costmap-config:cost-map; + } } } } diff --git a/alto-basic/manual-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoModelConfigImpl.java b/alto-basic/manual-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoModelConfigImpl.java index f9791b79..a5f5d000 100644 --- a/alto-basic/manual-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoModelConfigImpl.java +++ b/alto-basic/manual-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoModelConfigImpl.java @@ -15,7 +15,6 @@ import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.rev151021.ConfigResponseData1Builder; import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.rev151021.Meta1Builder; import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.rev151021.config.context.ResourceCostMap; import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.rev151021.config.context.ResourceNetworkMap; @@ -23,6 +22,8 @@ import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.rev151021.query.input.request.config.request.config.request.message.config.resource.data.ConfigNetworkmapData; import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.rev151021.query.output.response.config.response.config.response.message.config.response.data.ConfigCostmapResponseDataBuilder; import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.rev151021.query.output.response.config.response.config.response.message.config.response.data.ConfigNetworkmapResponseDataBuilder; +import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.rev151021.query.output.response.config.response.config.response.message.config.response.data.config.costmap.response.data.CostmapResponseDataBuilder; +import org.opendaylight.yang.gen.v1.urn.alto.manual.maps.rev151021.query.output.response.config.response.config.response.message.config.response.data.config.networkmap.response.data.NetworkmapResponseDataBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.config.rev151021.AltoModelConfigService; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.config.rev151021.QueryInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.config.rev151021.QueryOutput; @@ -32,7 +33,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.config.rev151021.alto.response.config.response.ConfigResponseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.config.rev151021.config.request.data.ConfigRequestMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.config.rev151021.config.response.data.ConfigResponseMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.config.rev151021.config.response.data.config.response.message.ConfigResponseData; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.config.rev151021.config.response.data.config.response.message.Meta; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.rev151021.alto.request.base.Request; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -72,7 +72,7 @@ protected QueryOutput readResourceNetworkMap(String rid, final ReadTransaction r outputBuilder.setType(ResourceTypeConfig.class); ConfigResponseBuilder crBuilder = new ConfigResponseBuilder(); ConfigResponseMessageBuilder crmBuilder = new ConfigResponseMessageBuilder(); - ConfigResponseData1Builder crdBuilder = new ConfigResponseData1Builder(); + ConfigNetworkmapResponseDataBuilder cnrdBuilder = new ConfigNetworkmapResponseDataBuilder(); ResourceNetworkMap result = null; String errorCode = RESPONSE_ERROR_CODE_FAILED; @@ -81,7 +81,7 @@ protected QueryOutput readResourceNetworkMap(String rid, final ReadTransaction r optional = future.checkedGet(); if (optional.isPresent()) { result = optional.get(); - crdBuilder.setConfigNetworkmapResponseData(new ConfigNetworkmapResponseDataBuilder() + cnrdBuilder.setNetworkmapResponseData(new NetworkmapResponseDataBuilder() .setResourceId(result.getResourceId()) .setTag(result.getTag()) .setMap(result.getMap()) @@ -93,7 +93,7 @@ protected QueryOutput readResourceNetworkMap(String rid, final ReadTransaction r } crmBuilder .setMeta((Meta) new Meta1Builder().setConfigResponseErrorCode(errorCode).build()) - .setConfigResponseData((ConfigResponseData) crdBuilder.build()); + .setConfigResponseData(cnrdBuilder.build()); crBuilder.setConfigResponseMessage(crmBuilder.build()); outputBuilder.setResponse(crBuilder.build()); return outputBuilder.build(); @@ -109,7 +109,7 @@ protected QueryOutput readResourceCostMap(String rid, final ReadTransaction rx) outputBuilder.setType(ResourceTypeConfig.class); ConfigResponseBuilder crBuilder = new ConfigResponseBuilder(); ConfigResponseMessageBuilder crmBuilder = new ConfigResponseMessageBuilder(); - ConfigResponseData1Builder crdBuilder = new ConfigResponseData1Builder(); + ConfigCostmapResponseDataBuilder ccrdBuilder = new ConfigCostmapResponseDataBuilder(); ResourceCostMap result = null; String errorCode = RESPONSE_ERROR_CODE_FAILED; @@ -118,7 +118,7 @@ protected QueryOutput readResourceCostMap(String rid, final ReadTransaction rx) optional = future.checkedGet(); if (optional.isPresent()) { result = optional.get(); - crdBuilder.setConfigCostmapResponseData(new ConfigCostmapResponseDataBuilder() + ccrdBuilder.setCostmapResponseData(new CostmapResponseDataBuilder() .setResourceId(result.getResourceId()) .setTag(result.getTag()) .setMeta(result.getMeta()) @@ -131,7 +131,7 @@ protected QueryOutput readResourceCostMap(String rid, final ReadTransaction rx) } crmBuilder .setMeta((Meta) new Meta1Builder().setConfigResponseErrorCode(errorCode).build()) - .setConfigResponseData((ConfigResponseData) crdBuilder.build()); + .setConfigResponseData(ccrdBuilder.build()); crBuilder.setConfigResponseMessage(crmBuilder.build()); outputBuilder.setResponse(crBuilder.build()); return outputBuilder.build(); @@ -174,10 +174,11 @@ public Future> query(QueryInput input) { } else if (requestMessage.getConfigType() == ConfigRequestMessage.ConfigType.Create) { if (requestMessage.getConfigResourceType() == "networkmap") { ConfigNetworkmapData networkmapData = (ConfigNetworkmapData) requestMessage.getConfigResourceData(); - ManualMapsUtils.createResourceNetworkMap(resourceId, networkmapData.getMap(), rwx); + ManualMapsUtils.createResourceNetworkMap(resourceId, networkmapData.getNetworkmapData().getMap(), rwx); } else if (requestMessage.getConfigResourceType() == "costmap") { ConfigCostmapData costmapData = (ConfigCostmapData) requestMessage.getConfigResourceData(); - ManualMapsUtils.createResourceCostMap(resourceId, costmapData.getMeta(), costmapData.getMap(), rwx); + ManualMapsUtils.createResourceCostMap(resourceId, costmapData.getCostmapData().getMeta(), + costmapData.getCostmapData().getMap(), rwx); } } rwx.submit(); diff --git a/alto-basic/manual-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/ManualMapsListener.java b/alto-basic/manual-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/ManualMapsListener.java index 7f2cf215..4819979e 100644 --- a/alto-basic/manual-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/ManualMapsListener.java +++ b/alto-basic/manual-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/ManualMapsListener.java @@ -56,6 +56,7 @@ public class ManualMapsListener implements AutoCloseable { public void register(DataBroker dataBroker) { this.dataBroker = dataBroker; + // FIXME: Should not be a fixed iid final InstanceIdentifier contextListIID = ManualMapsUtils.getContextListIID(); listenerRegs.add(dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>( diff --git a/alto-basic/simple-ird/impl/src/main/java/org/opendaylight/alto/basic/impl/SimpleIrdRoute.java b/alto-basic/simple-ird/impl/src/main/java/org/opendaylight/alto/basic/impl/SimpleIrdRoute.java index 62086cc4..28f5c092 100644 --- a/alto-basic/simple-ird/impl/src/main/java/org/opendaylight/alto/basic/impl/SimpleIrdRoute.java +++ b/alto-basic/simple-ird/impl/src/main/java/org/opendaylight/alto/basic/impl/SimpleIrdRoute.java @@ -72,9 +72,9 @@ public Response route(@Context HttpServletRequest req, @PathParam("path") String protected static class Rfc7285Ird { - public Map meta = new HashMap(); + public Map meta = new HashMap<>(); - public Map resources = new HashMap(); + public Map resources = new HashMap<>(); } private Rfc7285Ird convert(IrdInstance ird, HttpServletRequest req) { diff --git a/alto-core/northbound/impl/pom.xml b/alto-core/northbound/impl/pom.xml index 4feba71a..3aa87b3b 100644 --- a/alto-core/northbound/impl/pom.xml +++ b/alto-core/northbound/impl/pom.xml @@ -82,6 +82,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html javax.servlet javax.servlet-api + + com.sun.jersey + jersey-json + diff --git a/alto-core/northbound/impl/src/main/java/org/opendaylight/alto/core/northbound/impl/AltoNorthboundExceptionHandler.java b/alto-core/northbound/impl/src/main/java/org/opendaylight/alto/core/northbound/impl/AltoNorthboundExceptionHandler.java index 36394d22..149ea451 100644 --- a/alto-core/northbound/impl/src/main/java/org/opendaylight/alto/core/northbound/impl/AltoNorthboundExceptionHandler.java +++ b/alto-core/northbound/impl/src/main/java/org/opendaylight/alto/core/northbound/impl/AltoNorthboundExceptionHandler.java @@ -14,6 +14,8 @@ import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; public class AltoNorthboundExceptionHandler implements ExceptionMapper { @@ -22,8 +24,11 @@ public class AltoNorthboundExceptionHandler implements ExceptionMapper - - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - true - - - - *, - com.sun.jersey.spi.container.servlet, - org.eclipse.jetty.servlets;version="[8.1,10)" - - /alto - - - - - - diff --git a/alto-core/standard-northbound-routes/costmap/impl/src/main/java/org/opendaylight/alto/core/northbound/route/costmap/impl/AltoNorthboundRouteCostmap.java b/alto-core/standard-northbound-routes/costmap/impl/src/main/java/org/opendaylight/alto/core/northbound/route/costmap/impl/AltoNorthboundRouteCostmap.java index a24cb3a7..16d286fb 100644 --- a/alto-core/standard-northbound-routes/costmap/impl/src/main/java/org/opendaylight/alto/core/northbound/route/costmap/impl/AltoNorthboundRouteCostmap.java +++ b/alto-core/standard-northbound-routes/costmap/impl/src/main/java/org/opendaylight/alto/core/northbound/route/costmap/impl/AltoNorthboundRouteCostmap.java @@ -100,20 +100,23 @@ public void setMapService(final AltoModelCostmapService mapService) { this.mapService = mapService; } + public void setRouter(final AltoNorthboundRouter router) { + this.router = router; + } + public void init() { if (dataBroker == null) { LOG.error("Failed to init: data broker is null"); } - + register(); LOG.info("AltoNorthboundRouteCostmap initiated"); } - public void register(AltoNorthboundRouter router) { - this.router = router; - this.router.addRoute(COSTMAP_ROUTE, new AltoNorthboundRouteCostmap()); + public void register() { + this.router.addRoute(COSTMAP_ROUTE, this); } public void close() { diff --git a/alto-core/standard-northbound-routes/costmap/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/alto-core/standard-northbound-routes/costmap/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml index f77c0ada..8285dc45 100644 --- a/alto-core/standard-northbound-routes/costmap/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ b/alto-core/standard-northbound-routes/costmap/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -12,9 +12,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html odl:use-default-for-reference-types="true"> + + + + diff --git a/alto-core/standard-northbound-routes/endpointcost/impl/pom.xml b/alto-core/standard-northbound-routes/endpointcost/impl/pom.xml index 50a8d77b..645827bc 100644 --- a/alto-core/standard-northbound-routes/endpointcost/impl/pom.xml +++ b/alto-core/standard-northbound-routes/endpointcost/impl/pom.xml @@ -102,25 +102,4 @@ and is available at http://www.eclipse.org/legal/epl-v10.html - - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - true - - - - *, - com.sun.jersey.spi.container.servlet, - org.eclipse.jetty.servlets;version="[8.1,10)" - - /alto - - - - - - diff --git a/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/impl/AltoNorthboundRouteEndpointcost.java b/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/impl/AltoNorthboundRouteEndpointcost.java index a8a432b3..b38f401f 100644 --- a/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/impl/AltoNorthboundRouteEndpointcost.java +++ b/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/impl/AltoNorthboundRouteEndpointcost.java @@ -103,9 +103,10 @@ public class AltoNorthboundRouteEndpointcost implements AltoNorthboundRoute { private DataBroker dataBroker = null; - private AltoNorthboundRouter m_router = null; + private AltoNorthboundRouter router = null; + + private static AltoModelEndpointcostService mapService = null; - private static AltoModelEndpointcostService mapService = null; public void setDataBroker(DataBroker dataBroker) { this.dataBroker = dataBroker; } @@ -114,24 +115,27 @@ public void setMapService(final AltoModelEndpointcostService mapService) { this.mapService = mapService; } + public void setRouter(final AltoNorthboundRouter router) { + this.router = router; + } + public void init() { if (dataBroker == null) { LOG.error("Failed to init: data broker is null"); } - + register(); LOG.info("AltoNorthboundRouteEndpointcost initiated"); } - public void register(AltoNorthboundRouter router) { - m_router = router; - m_router.addRoute("endpointcost", new AltoNorthboundRouteEndpointcost()); + public void register() { + router.addRoute("endpointcost", this); } public void close() { - m_router.removeRoute("endpointcost"); + router.removeRoute("endpointcost"); } @Path("{path}") diff --git a/alto-core/standard-northbound-routes/endpointcost/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/alto-core/standard-northbound-routes/endpointcost/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml index 48d8b04a..2c8f6f31 100644 --- a/alto-core/standard-northbound-routes/endpointcost/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ b/alto-core/standard-northbound-routes/endpointcost/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -13,10 +13,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html + + diff --git a/alto-core/standard-northbound-routes/endpointproperty/impl/pom.xml b/alto-core/standard-northbound-routes/endpointproperty/impl/pom.xml index c023822d..2babe174 100644 --- a/alto-core/standard-northbound-routes/endpointproperty/impl/pom.xml +++ b/alto-core/standard-northbound-routes/endpointproperty/impl/pom.xml @@ -108,25 +108,4 @@ and is available at http://www.eclipse.org/legal/epl-v10.html - - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - true - - - - *, - com.sun.jersey.spi.container.servlet, - org.eclipse.jetty.servlets;version="[8.1,10)" - - /alto - - - - - - diff --git a/alto-core/standard-northbound-routes/endpointproperty/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointproperty/impl/AltoNorthboundRouteEndpointproperty.java b/alto-core/standard-northbound-routes/endpointproperty/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointproperty/impl/AltoNorthboundRouteEndpointproperty.java index 89cf8062..46147e41 100644 --- a/alto-core/standard-northbound-routes/endpointproperty/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointproperty/impl/AltoNorthboundRouteEndpointproperty.java +++ b/alto-core/standard-northbound-routes/endpointproperty/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointproperty/impl/AltoNorthboundRouteEndpointproperty.java @@ -96,9 +96,10 @@ public class AltoNorthboundRouteEndpointproperty implements AltoNorthboundRoute private DataBroker dataBroker = null; - private AltoNorthboundRouter m_router = null; + private AltoNorthboundRouter router = null; + + private static AltoModelEndpointpropertyService mapService = null; - private static AltoModelEndpointpropertyService mapService = null; public void setDataBroker(DataBroker dataBroker) { this.dataBroker = dataBroker; } @@ -107,22 +108,26 @@ public void setMapService(final AltoModelEndpointpropertyService mapService) { this.mapService = mapService; } + public void setRouter(final AltoNorthboundRouter router) { + this.router = router; + } + public void init() { if (dataBroker == null) { LOG.error("Failed to init: data broker is null"); } + register(); LOG.info("AltoNorthboundRouteEndpointProperty initiated"); } - public void register(AltoNorthboundRouter router) { - m_router = router; - m_router.addRoute("endpointproperty", new AltoNorthboundRouteEndpointproperty()); + public void register() { + router.addRoute("endpointproperty", this); } public void close() { - m_router.removeRoute("endpointproperty"); + router.removeRoute("endpointproperty"); } @Path("{path}") diff --git a/alto-core/standard-northbound-routes/endpointproperty/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/alto-core/standard-northbound-routes/endpointproperty/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml index 4b9fc864..6df26bd4 100644 --- a/alto-core/standard-northbound-routes/endpointproperty/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ b/alto-core/standard-northbound-routes/endpointproperty/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -13,10 +13,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html + + diff --git a/alto-core/standard-northbound-routes/networkmap/impl/pom.xml b/alto-core/standard-northbound-routes/networkmap/impl/pom.xml index cabcc7ee..c2c05d38 100644 --- a/alto-core/standard-northbound-routes/networkmap/impl/pom.xml +++ b/alto-core/standard-northbound-routes/networkmap/impl/pom.xml @@ -101,25 +101,4 @@ and is available at http://www.eclipse.org/legal/epl-v10.html - - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - true - - - - *, - com.sun.jersey.spi.container.servlet, - org.eclipse.jetty.servlets;version="[8.1,10)" - - /alto - - - - - - diff --git a/alto-core/standard-northbound-routes/networkmap/impl/src/main/java/org/opendaylight/alto/core/northbound/route/networkmap/impl/AltoNorthboundRouteNetworkmap.java b/alto-core/standard-northbound-routes/networkmap/impl/src/main/java/org/opendaylight/alto/core/northbound/route/networkmap/impl/AltoNorthboundRouteNetworkmap.java index 040388bf..fa6254c4 100644 --- a/alto-core/standard-northbound-routes/networkmap/impl/src/main/java/org/opendaylight/alto/core/northbound/route/networkmap/impl/AltoNorthboundRouteNetworkmap.java +++ b/alto-core/standard-northbound-routes/networkmap/impl/src/main/java/org/opendaylight/alto/core/northbound/route/networkmap/impl/AltoNorthboundRouteNetworkmap.java @@ -92,9 +92,10 @@ public class AltoNorthboundRouteNetworkmap implements AltoNorthboundRoute { private DataBroker dataBroker = null; - private AltoNorthboundRouter m_router = null; + private AltoNorthboundRouter router = null; + + private static AltoModelNetworkmapService mapService = null; - private static AltoModelNetworkmapService mapService = null; public void setDataBroker(DataBroker dataBroker) { this.dataBroker = dataBroker; } @@ -103,22 +104,26 @@ public void setMapService(final AltoModelNetworkmapService mapService) { this.mapService = mapService; } + public void setRouter(final AltoNorthboundRouter router) { + this.router = router; + } + public void init() { if (dataBroker == null) { LOG.error("Failed to init: data broker is null"); } + register(); LOG.info("AltoNorthboundRouteNetworkmap initiated"); } - public void register(AltoNorthboundRouter router) { - m_router = router; - m_router.addRoute("networkmap", new AltoNorthboundRouteNetworkmap()); + public void register() { + router.addRoute(NETWORKMAP_ROUTE, this); } public void close() { - m_router.removeRoute("networkmap"); + router.removeRoute(NETWORKMAP_ROUTE); } @Path("{path}") @@ -137,6 +142,7 @@ public Response getFullMap(@PathParam("path") String path) throws JsonProcessing if(response != null) return response; else + LOG.info("Requested networkmap does't exist"); return Response.status(404).build(); } diff --git a/alto-core/standard-northbound-routes/networkmap/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/alto-core/standard-northbound-routes/networkmap/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml index b248b4c9..d9445258 100644 --- a/alto-core/standard-northbound-routes/networkmap/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ b/alto-core/standard-northbound-routes/networkmap/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -13,10 +13,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html + + diff --git a/alto-core/standard-service-models/model-config/src/main/yang/alto-model-config.yang b/alto-core/standard-service-models/model-config/src/main/yang/alto-model-config.yang index 6804be9d..6e454521 100644 --- a/alto-core/standard-service-models/model-config/src/main/yang/alto-model-config.yang +++ b/alto-core/standard-service-models/model-config/src/main/yang/alto-model-config.yang @@ -60,7 +60,7 @@ module alto-model-config { container "config-response-message" { container "meta" { } - container "config-response-data" { + choice "config-response-data" { } } } diff --git a/alto-release-features/odl-alto-auto-maps/pom.xml b/alto-release-features/odl-alto-auto-maps/pom.xml index 95846409..d16037f8 100644 --- a/alto-release-features/odl-alto-auto-maps/pom.xml +++ b/alto-release-features/odl-alto-auto-maps/pom.xml @@ -29,6 +29,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL 0.12.4 1.7.4 0.7.4 + 0.9.4 @@ -66,13 +67,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL xml features - - ${l2switch.groupId} - odl-l2switch-hosttracker - ${l2switch.version} - xml - features - ${project.groupId} odl-alto-manual-maps @@ -90,5 +84,25 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL alto-auto-maps-impl ${project.version} + + org.opendaylight.l2switch.hosttracker + hosttracker-model + ${l2switch.version} + + + org.opendaylight.l2switch.addresstracker + addresstracker-model + ${l2switch.version} + + + org.opendaylight.bgpcep + bgp-rib-api + ${bgpcep.version} + + + org.opendaylight.bgpcep + bgp-inet + ${bgpcep.version} +