From 1ae9849df4d36034d6a09f4c42743cc0f0b95ee6 Mon Sep 17 00:00:00 2001 From: jensenzhang Date: Fri, 5 Aug 2016 10:43:34 +0800 Subject: [PATCH] Support default auto-maps service Support one-group auto networkmap as default auto-maps. Initiate default ird for ird root and manual-maps. Current implementation depends on l2switch-hosttracker and alto-manual-maps service. Change-Id: I2b2ebefc60e05b307184fbadf01b41f9e6ecd37b Signed-off-by: jensenzhang --- alto-basic/auto-maps/.gitignore | 18 + alto-basic/auto-maps/api/pom.xml | 23 + .../api/src/main/yang/alto-auto-maps.yang | 9 + alto-basic/auto-maps/artifacts/pom.xml | 46 ++ alto-basic/auto-maps/cli/pom.xml | 45 ++ .../cli/api/AltoAutoMapsCliCommands.java | 17 + .../commands/AltoAutoMapsCliTestCommand.java | 53 ++ .../cli/impl/AltoAutoMapsCliCommandsImpl.java | 29 ++ .../opendaylight/blueprint/cli-blueprint.xml | 31 ++ alto-basic/auto-maps/deploy-site.xml | 50 ++ alto-basic/auto-maps/features/pom.xml | 118 +++++ .../features/src/main/features/features.xml | 42 ++ alto-basic/auto-maps/impl/pom.xml | 86 ++++ .../alto/basic/impl/AltoAutoMapsProvider.java | 39 ++ .../impl/AltoAutoMapsUpdateListener.java | 168 +++++++ .../opendaylight/blueprint/impl-blueprint.xml | 24 + .../basic/impl/AltoAutoMapsProviderTest.java | 41 ++ .../impl/AltoAutoMapsUpdateListenerTest.java | 129 +++++ alto-basic/auto-maps/it/pom.xml | 39 ++ .../alto/basic/it/AltoAutoMapsIT.java | 60 +++ alto-basic/auto-maps/karaf/pom.xml | 73 +++ alto-basic/auto-maps/pom.xml | 132 +++++ .../src/main/resources/stylesheet.css | 475 ++++++++++++++++++ alto-basic/auto-maps/src/site/site.xml | 8 + .../basic/manual/maps/ManualMapsUtils.java | 4 +- alto-basic/manual-maps/impl/pom.xml | 18 + .../alto/basic/impl/ManualMapsListener.java | 45 +- alto-basic/pom.xml | 1 + .../alto/basic/simpleird/SimpleIrdUtils.java | 36 ++ .../api/src/main/yang/alto-simple-ird.yang | 2 +- .../basic/impl/AltoSimpleIrdProvider.java | 29 +- .../route/costmap/AltoNbrCostmapUtils.java | 33 +- .../networkmap/AltoNbrNetworkmapUtils.java | 50 +- .../main/yang/alto-model-costmap-rfc7285.yang | 2 +- alto-release-features/pom.xml | 11 + .../src/main/features/features.xml | 52 +- 36 files changed, 1990 insertions(+), 48 deletions(-) create mode 100644 alto-basic/auto-maps/.gitignore create mode 100644 alto-basic/auto-maps/api/pom.xml create mode 100644 alto-basic/auto-maps/api/src/main/yang/alto-auto-maps.yang create mode 100644 alto-basic/auto-maps/artifacts/pom.xml create mode 100644 alto-basic/auto-maps/cli/pom.xml create mode 100644 alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/api/AltoAutoMapsCliCommands.java create mode 100644 alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/commands/AltoAutoMapsCliTestCommand.java create mode 100644 alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/impl/AltoAutoMapsCliCommandsImpl.java create mode 100644 alto-basic/auto-maps/cli/src/main/resources/org/opendaylight/blueprint/cli-blueprint.xml create mode 100644 alto-basic/auto-maps/deploy-site.xml create mode 100644 alto-basic/auto-maps/features/pom.xml create mode 100644 alto-basic/auto-maps/features/src/main/features/features.xml create mode 100644 alto-basic/auto-maps/impl/pom.xml create mode 100644 alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsProvider.java create mode 100644 alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsUpdateListener.java create mode 100644 alto-basic/auto-maps/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml create mode 100644 alto-basic/auto-maps/impl/src/test/java/org/opendaylight/alto/basic/impl/AltoAutoMapsProviderTest.java create mode 100644 alto-basic/auto-maps/impl/src/test/java/org/opendaylight/alto/basic/impl/AltoAutoMapsUpdateListenerTest.java create mode 100644 alto-basic/auto-maps/it/pom.xml create mode 100644 alto-basic/auto-maps/it/src/test/java/org/opendaylight/alto/basic/it/AltoAutoMapsIT.java create mode 100644 alto-basic/auto-maps/karaf/pom.xml create mode 100644 alto-basic/auto-maps/pom.xml create mode 100644 alto-basic/auto-maps/src/main/resources/stylesheet.css create mode 100644 alto-basic/auto-maps/src/site/site.xml diff --git a/alto-basic/auto-maps/.gitignore b/alto-basic/auto-maps/.gitignore new file mode 100644 index 00000000..4496250c --- /dev/null +++ b/alto-basic/auto-maps/.gitignore @@ -0,0 +1,18 @@ +*.class +**/target +bin/ +dist +**/logs +*~ +target +target-ide +.classpath +.project +.settings +.idea +xtend-gen +yang-gen-config +yang-gen-sal +classes +.DS_STORE +.metadata diff --git a/alto-basic/auto-maps/api/pom.xml b/alto-basic/auto-maps/api/pom.xml new file mode 100644 index 00000000..f404ac9b --- /dev/null +++ b/alto-basic/auto-maps/api/pom.xml @@ -0,0 +1,23 @@ + + + + 4.0.0 + + + org.opendaylight.mdsal + binding-parent + 0.9.0-SNAPSHOT + + + + org.opendaylight.alto.basic + alto-auto-maps-api + 0.3.0-SNAPSHOT + bundle + 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 new file mode 100644 index 00000000..072d9b68 --- /dev/null +++ b/alto-basic/auto-maps/api/src/main/yang/alto-auto-maps.yang @@ -0,0 +1,9 @@ +module alto-auto-maps { + yang-version 1; + namespace "urn:opendaylight:alto:basic:auto:maps"; + prefix "alto-auto-maps"; + + revision "2015-01-05" { + description "Initial revision of alto-auto-maps model"; + } +} diff --git a/alto-basic/auto-maps/artifacts/pom.xml b/alto-basic/auto-maps/artifacts/pom.xml new file mode 100644 index 00000000..84693a7f --- /dev/null +++ b/alto-basic/auto-maps/artifacts/pom.xml @@ -0,0 +1,46 @@ + + + + + 4.0.0 + + + org.opendaylight.odlparent + odlparent-lite + 1.7.0-SNAPSHOT + + + + org.opendaylight.alto.basic + alto-auto-maps-artifacts + 0.3.0-SNAPSHOT + pom + + + + + ${project.groupId} + alto-auto-maps-api + ${project.version} + + + ${project.groupId} + alto-auto-maps-impl + ${project.version} + + + ${project.groupId} + alto-auto-maps-features + ${project.version} + features + xml + + + + diff --git a/alto-basic/auto-maps/cli/pom.xml b/alto-basic/auto-maps/cli/pom.xml new file mode 100644 index 00000000..dea46b29 --- /dev/null +++ b/alto-basic/auto-maps/cli/pom.xml @@ -0,0 +1,45 @@ + + + + + 4.0.0 + + + org.opendaylight.controller + config-parent + 0.5.0-SNAPSHOT + + + + org.opendaylight.alto.basic + alto-auto-maps-cli + 0.3.0-SNAPSHOT + bundle + + + + + ${project.groupId} + alto-auto-maps-api + ${project.version} + + + + + org.apache.karaf.shell + org.apache.karaf.shell.console + ${karaf.version} + + + org.apache.karaf.shell + org.apache.karaf.shell.table + ${karaf.version} + + + diff --git a/alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/api/AltoAutoMapsCliCommands.java b/alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/api/AltoAutoMapsCliCommands.java new file mode 100644 index 00000000..73e620f0 --- /dev/null +++ b/alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/api/AltoAutoMapsCliCommands.java @@ -0,0 +1,17 @@ +/* + * Copyright © 2016 SNLAB 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.cli.api; + +public interface AltoAutoMapsCliCommands { + + /** + * Define the Karaf command method signatures and the Javadoc for each. + * Below method is just an example + */ + Object testCommand(Object testArgument); +} diff --git a/alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/commands/AltoAutoMapsCliTestCommand.java b/alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/commands/AltoAutoMapsCliTestCommand.java new file mode 100644 index 00000000..a89b5fda --- /dev/null +++ b/alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/commands/AltoAutoMapsCliTestCommand.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2016 SNLAB 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.cli.commands; + +import org.apache.karaf.shell.commands.Command; +import org.apache.karaf.shell.commands.Option; +import org.apache.karaf.shell.console.AbstractAction; +import org.opendaylight.alto.basic.cli.api.AltoAutoMapsCliCommands; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This is an example class. The class name can be renamed to match the command implementation that it will invoke. + * Specify command details by updating the fields in the Command annotation below. + */ +@Command(name = "test-command", scope = "add the scope of the command, usually project name", description = "add a description for the command") +public class AltoAutoMapsCliTestCommand extends AbstractAction { + + private static final Logger LOG = LoggerFactory.getLogger(AltoAutoMapsCliTestCommand.class); + protected final AltoAutoMapsCliCommands service; + + public AltoAutoMapsCliTestCommand(final AltoAutoMapsCliCommands service) { + this.service = service; + } + + /** + * Add the arguments required by the command. + * Any number of arguments can be added using the Option annotation + * The below argument is just an example and should be changed as per your requirements + */ + @Option(name = "-tA", + aliases = { "--testArgument" }, + description = "test command argument", + required = true, + multiValued = false) + private Object testArgument; + + @Override + protected Object doExecute() throws Exception { + /** + * Invoke commannd implementation here using the service instance. + * Implement how you want the output of the command to be displayed. + * Below is just an example. + */ + final String testMessage = (String) service.testCommand(testArgument); + return testMessage; + } +} \ No newline at end of file diff --git a/alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/impl/AltoAutoMapsCliCommandsImpl.java b/alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/impl/AltoAutoMapsCliCommandsImpl.java new file mode 100644 index 00000000..a394c742 --- /dev/null +++ b/alto-basic/auto-maps/cli/src/main/java/org/opendaylight/alto/basic/cli/impl/AltoAutoMapsCliCommandsImpl.java @@ -0,0 +1,29 @@ +/* + * Copyright © 2016 SNLAB 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.cli.impl; + +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.opendaylight.alto.basic.cli.api.AltoAutoMapsCliCommands; + +public class AltoAutoMapsCliCommandsImpl implements AltoAutoMapsCliCommands { + + private static final Logger LOG = LoggerFactory.getLogger(AltoAutoMapsCliCommandsImpl.class); + private final DataBroker dataBroker; + + public AltoAutoMapsCliCommandsImpl(final DataBroker db) { + this.dataBroker = db; + LOG.info("AltoAutoMapsCliCommandImpl initialized"); + } + + @Override + public Object testCommand(Object testArgument) { + return "This is a test implementation of test-command"; + } +} \ No newline at end of file diff --git a/alto-basic/auto-maps/cli/src/main/resources/org/opendaylight/blueprint/cli-blueprint.xml b/alto-basic/auto-maps/cli/src/main/resources/org/opendaylight/blueprint/cli-blueprint.xml new file mode 100644 index 00000000..35898bff --- /dev/null +++ b/alto-basic/auto-maps/cli/src/main/resources/org/opendaylight/blueprint/cli-blueprint.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/alto-basic/auto-maps/deploy-site.xml b/alto-basic/auto-maps/deploy-site.xml new file mode 100644 index 00000000..4b96a859 --- /dev/null +++ b/alto-basic/auto-maps/deploy-site.xml @@ -0,0 +1,50 @@ + + + + + 4.0.0 + + org.opendaylight.alto.basic + deploy-site + 0.3.0-SNAPSHOT + pom + + + latest + dav:https://nexus.opendaylight.org/content/sites/site/${project.groupId}/${stream}/ + + + + + + org.apache.maven.wagon + wagon-webdav-jackrabbit + 2.9 + + + + + + org.apache.maven.plugins + maven-site-plugin + 3.4 + + ${project.build.directory}/staged-site + + + + + + + + opendaylight-site + ${nexus.site.url} + + + diff --git a/alto-basic/auto-maps/features/pom.xml b/alto-basic/auto-maps/features/pom.xml new file mode 100644 index 00000000..ff340556 --- /dev/null +++ b/alto-basic/auto-maps/features/pom.xml @@ -0,0 +1,118 @@ + + + + 4.0.0 + + + org.opendaylight.odlparent + features-parent + 1.7.0-SNAPSHOT + + + + org.opendaylight.alto.basic + alto-auto-maps-features + 0.3.0-SNAPSHOT + ${project.artifactId} + + + 3.1.1 + + + + 0.9.0-SNAPSHOT + 1.4.0-SNAPSHOT + 1.4.0-SNAPSHOT + 1.0.0-SNAPSHOT + 0.4.0-SNAPSHOT + etc/opendaylight/karaf + + + + + + + org.opendaylight.controller + mdsal-artifacts + ${mdsal.version} + pom + import + + + org.opendaylight.netconf + restconf-artifacts + ${restconf.version} + pom + import + + + org.opendaylight.yangtools + yangtools-artifacts + ${yangtools.version} + pom + import + + + + + + + org.opendaylight.yangtools + features-yangtools + features + xml + runtime + + + org.opendaylight.mdsal.model + features-mdsal-model + ${mdsal.model.version} + features + xml + runtime + + + org.opendaylight.controller + features-mdsal + features + xml + runtime + + + org.opendaylight.netconf + features-restconf + features + xml + runtime + + + org.opendaylight.dlux + features-dlux + features + ${dlux.version} + xml + runtime + + + ${project.groupId} + alto-auto-maps-impl + ${project.version} + + + ${project.groupId} + alto-auto-maps-api + ${project.version} + + + ${project.groupId} + alto-auto-maps-cli + ${project.version} + + + diff --git a/alto-basic/auto-maps/features/src/main/features/features.xml b/alto-basic/auto-maps/features/src/main/features/features.xml new file mode 100644 index 00000000..0f9d45d0 --- /dev/null +++ b/alto-basic/auto-maps/features/src/main/features/features.xml @@ -0,0 +1,42 @@ + + + + + mvn:org.opendaylight.yangtools/features-yangtools/{{VERSION}}/xml/features + mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features + mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features + mvn:org.opendaylight.netconf/features-restconf/{{VERSION}}/xml/features + mvn:org.opendaylight.dlux/features-dlux/{{VERSION}}/xml/features + + odl-mdsal-models + mvn:org.opendaylight.alto.basic/alto-auto-maps-api/{{VERSION}} + + + odl-mdsal-broker + odl-alto-auto-maps-api + mvn:org.opendaylight.alto.basic/alto-auto-maps-impl/{{VERSION}} + + + odl-alto-auto-maps + odl-restconf + + + odl-alto-auto-maps-rest + odl-mdsal-apidocs + odl-mdsal-xsql + odl-dlux-yangui + + + odl-alto-auto-maps + mvn:org.opendaylight.alto.basic/alto-auto-maps-cli/{{VERSION}} + + + diff --git a/alto-basic/auto-maps/impl/pom.xml b/alto-basic/auto-maps/impl/pom.xml new file mode 100644 index 00000000..86b44cf7 --- /dev/null +++ b/alto-basic/auto-maps/impl/pom.xml @@ -0,0 +1,86 @@ + + + + + 4.0.0 + + + org.opendaylight.controller + config-parent + 0.5.0-SNAPSHOT + + + + org.opendaylight.alto.basic + alto-auto-maps-impl + 0.3.0-SNAPSHOT + bundle + + + 1.4.0-SNAPSHOT + 0.4.0-SNAPSHOT + + + + + ${project.groupId} + alto-auto-maps-api + ${project.version} + + + + ${project.groupId} + alto-manual-maps-api + ${project.version} + + + + org.opendaylight.alto.core + alto-service-model-networkmap-api + ${project.version} + + + + org.opendaylight.alto.core + alto-service-model-costmap-api + ${project.version} + + + + org.opendaylight.controller.model + model-topology + ${mdsal.version} + + + + org.opendaylight.l2switch.hosttracker + hosttracker-model + ${l2switch.version} + + + + org.opendaylight.l2switch.addresstracker + addresstracker-model + ${l2switch.version} + + + + + junit + junit + test + + + + org.mockito + mockito-all + test + + + 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 new file mode 100644 index 00000000..42156aea --- /dev/null +++ b/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsProvider.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2016 SNLAB 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.controller.md.sal.binding.api.DataBroker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AltoAutoMapsProvider { + + private static final Logger LOG = LoggerFactory.getLogger(AltoAutoMapsProvider.class); + + private final DataBroker dataBroker; + private AltoAutoMapsUpdateListener m_listener; + + public AltoAutoMapsProvider(final DataBroker dataBroker) { + this.dataBroker = dataBroker; + this.m_listener = new AltoAutoMapsUpdateListener(dataBroker); + } + + /** + * Method called when the blueprint container is created. + */ + public void init() { + LOG.info("AltoAutoMapsProvider Session Initiated"); + } + + /** + * Method called when the blueprint container is destroyed. + */ + public void close() { + LOG.info("AltoAutoMapsProvider Closed"); + } +} 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/AltoAutoMapsUpdateListener.java new file mode 100644 index 00000000..0df1a11e --- /dev/null +++ b/alto-basic/auto-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoAutoMapsUpdateListener.java @@ -0,0 +1,168 @@ +/* + * Copyright © 2016 SNLAB 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.DataChangeListener; +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.AsyncDataBroker; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.opendaylight.address.tracker.rev140617.address.node.connector.Addresses; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.manual.maps.networkmap.rev151021.EndpointAddressType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.manual.maps.networkmap.rev151021.endpoint.address.group.EndpointAddressGroup; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.manual.maps.networkmap.rev151021.endpoint.address.group.EndpointAddressGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.types.rev150921.PidName; +import org.opendaylight.yang.gen.v1.urn.opendaylight.host.tracker.rev140624.HostNode; +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.TopologyId; +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.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +public class AltoAutoMapsUpdateListener implements DataChangeListener, AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(AltoAutoMapsUpdateListener.class); + + private final DataBroker dataBroker; + private ListenerRegistration registration; + + private static final String TOPOLOGY_NAME = "flow:1"; + 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"; + + public AltoAutoMapsUpdateListener(final DataBroker dataBroker) { + this.dataBroker = dataBroker; + InstanceIdentifier iid = InstanceIdentifier + .builder(NetworkTopology.class) + .child(Topology.class, + new TopologyKey(new TopologyId(TOPOLOGY_NAME))) + .build(); + this.registration = dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, + iid, this, AsyncDataBroker.DataChangeScope.BASE); + } + + @Override + public void onDataChanged(AsyncDataChangeEvent, DataObject> event) { + if (event == null) { + return; + } + + final ReadWriteTransaction rwx = dataBroker.newReadWriteTransaction(); + + Map, DataObject> original = event.getOriginalData(); + + for (Map.Entry, DataObject> entry : event.getCreatedData().entrySet()) { + InstanceIdentifier iid = entry.getKey(); + DataObject created = entry.getValue(); + + if (created instanceof Topology) { + createDefaultAutoNetworkMap((Topology) created, rwx); + LOG.info("Create default auto networkmap"); + } + } + + for (InstanceIdentifier iid : event.getRemovedPaths()) { + DataObject removed = original.get(iid); + + if (removed instanceof Topology) { + emptyDefaultAutoNetworkMap(rwx); + LOG.info("Empty default auto networkmap"); + } + } + + for (Map.Entry, DataObject> entry : event.getUpdatedData().entrySet()) { + InstanceIdentifier iid = entry.getKey(); + DataObject updated = entry.getValue(); + + if (updated instanceof Topology) { + updateDefaultAutoNetworkMap((Topology) updated, rwx); + LOG.info("Update default auto networkmap"); + } + } + + rwx.submit(); + } + + private void createDefaultAutoNetworkMap(Topology topology, final WriteTransaction wx) { + for (Node node : topology.getNode()) { + HostNode hostNode = node.getAugmentation(HostNode.class); + if (hostNode != null) { + List addressesList = hostNode.getAddresses(); + mergeAddressesListToDefaultNetworkMap(addressesList, wx); + } + } + } + + private void emptyDefaultAutoNetworkMap(final WriteTransaction wx) { + mergeAddressesListToDefaultNetworkMap(new LinkedList(), wx); + } + + private void updateDefaultAutoNetworkMap(Topology topology, final WriteTransaction wx) { + // TODO: can be more efficient + emptyDefaultAutoNetworkMap(wx); + createDefaultAutoNetworkMap(topology, wx); + } + + private void mergeAddressesListToDefaultNetworkMap(List addressesList, final WriteTransaction wx) { + List networkMap = new LinkedList<>(); + org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic + .manual.maps.networkmap.rev151021.network.map.MapBuilder builder = + new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic + .manual.maps.networkmap.rev151021.network.map.MapBuilder(); + + List prefixList = aggregateAddressesList(addressesList); + + List emptyEndpointAddressGroup = new LinkedList<>(); + emptyEndpointAddressGroup.add(new EndpointAddressGroupBuilder() + .setAddressType(new EndpointAddressType(EndpointAddressType.Enumeration.Ipv4)) + .setEndpointPrefix(prefixList) + .build()); + + builder.setPid(new PidName("PID0")) + .setEndpointAddressGroup(emptyEndpointAddressGroup); + networkMap.add(builder.build()); + + ManualMapsUtils.createResourceNetworkMap(DEFAULT_AUTO_NETWORKMAP, networkMap, wx); + } + + private List aggregateAddressesList(List addressesList) { + List prefixList = new LinkedList<>(); + for (Addresses addresses : addressesList) { + if (addresses.getIp() == null) + continue; + String ipAddress = addresses.getIp().getIpv4Address().getValue(); + + IpPrefix prefix = new IpPrefix(new Ipv4Prefix(ipAddress + "/32")); + prefixList.add(prefix); + } + + return prefixList; + } + + @Override + public void close() throws Exception { + registration.close(); + LOG.info("AltoAutoMapsUpdateListener Closed"); + } +} diff --git a/alto-basic/auto-maps/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/alto-basic/auto-maps/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml new file mode 100644 index 00000000..f2de29e1 --- /dev/null +++ b/alto-basic/auto-maps/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + diff --git a/alto-basic/auto-maps/impl/src/test/java/org/opendaylight/alto/basic/impl/AltoAutoMapsProviderTest.java b/alto-basic/auto-maps/impl/src/test/java/org/opendaylight/alto/basic/impl/AltoAutoMapsProviderTest.java new file mode 100644 index 00000000..eb56bdac --- /dev/null +++ b/alto-basic/auto-maps/impl/src/test/java/org/opendaylight/alto/basic/impl/AltoAutoMapsProviderTest.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2016 SNLAB 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.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; + +import static org.mockito.Mockito.mock; + +public class AltoAutoMapsProviderTest { + + private DataBroker dataBroker = mock(DataBroker.class); + private AltoAutoMapsProvider provider; + + @Before + public void setUp() throws Exception { + provider = new AltoAutoMapsProvider(dataBroker); + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testInit() throws Exception { + provider.init(); + } + + @Test + public void testClose() throws Exception { + provider.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 new file mode 100644 index 00000000..eefae6e4 --- /dev/null +++ b/alto-basic/auto-maps/impl/src/test/java/org/opendaylight/alto/basic/impl/AltoAutoMapsUpdateListenerTest.java @@ -0,0 +1,129 @@ +/* + * Copyright © 2016 SNLAB 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.junit.After; +import org.junit.Before; +import org.junit.Test; +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.ReadWriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.address.tracker.rev140617.address.node.connector.AddressesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.host.tracker.rev140624.HostNode; +import org.opendaylight.yang.gen.v1.urn.opendaylight.host.tracker.rev140624.HostNodeBuilder; +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.TopologyId; +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.TopologyBuilder; +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.NodeBuilder; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class AltoAutoMapsUpdateListenerTest { + + private static final String TOPOLOGY_NAME = "flow:1"; + + private DataBroker dataBroker = mock(DataBroker.class); + private ListenerRegistration registration = mock(ListenerRegistration.class); + private AltoAutoMapsUpdateListener altoAutoMapsUpdateListener; + private ReadWriteTransaction rwx = mock(ReadWriteTransaction.class); + private InstanceIdentifier iid = InstanceIdentifier + .builder(NetworkTopology.class) + .child(Topology.class, + new TopologyKey(new TopologyId(TOPOLOGY_NAME))) + .build(); + + private AsyncDataChangeEvent, DataObject> mockDataChangeEvent = + mock(AsyncDataChangeEvent.class); + private Map, DataObject> original = new HashMap<>(); + private Map, DataObject> createdData = new HashMap<>(); + private Set> removedPaths = new HashSet<>(); + private Map, DataObject> updatedData = new HashMap<>(); + + @Before + public void setUp() throws Exception { + when(dataBroker.registerDataChangeListener( + any(LogicalDatastoreType.class), + any(InstanceIdentifier.class), + any(DataChangeListener.class), + any(AsyncDataBroker.DataChangeScope.class) + )).thenReturn(registration); + + when(dataBroker.newReadWriteTransaction()).thenReturn(rwx); + + altoAutoMapsUpdateListener = new AltoAutoMapsUpdateListener(dataBroker); + + original.put(iid, new TopologyBuilder().build()); + removedPaths.add(iid); + + Topology testTopology = new TopologyBuilder() + .setNode(Arrays.asList(new NodeBuilder().build())) + .build(); + createdData.put(iid, testTopology); + + Topology testTopologyWithHost = new TopologyBuilder() + .setNode(Arrays.asList(new NodeBuilder() + .addAugmentation(HostNode.class, + new HostNodeBuilder() + .setAddresses(Arrays.asList(new AddressesBuilder() + .setIp(new IpAddress(new Ipv4Address("192.168.1.100"))) + .build(), + new AddressesBuilder().build())) + .build()) + .build())) + .build(); + updatedData.put(iid, testTopologyWithHost); + + when(mockDataChangeEvent.getOriginalData()).thenReturn(original); + when(mockDataChangeEvent.getCreatedData()).thenReturn(createdData); + when(mockDataChangeEvent.getRemovedPaths()).thenReturn(removedPaths); + when(mockDataChangeEvent.getUpdatedData()).thenReturn(updatedData); + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testOnNullDataChanged() throws Exception { + altoAutoMapsUpdateListener.onDataChanged(null); + verify(rwx, never()).submit(); + } + + @Test + public void testOnDataChanged() throws Exception { + altoAutoMapsUpdateListener.onDataChanged(mockDataChangeEvent); + verify(rwx).submit(); + } + + @Test + public void testClose() throws Exception { + altoAutoMapsUpdateListener.close(); + verify(registration).close(); + } +} diff --git a/alto-basic/auto-maps/it/pom.xml b/alto-basic/auto-maps/it/pom.xml new file mode 100644 index 00000000..58e6ae79 --- /dev/null +++ b/alto-basic/auto-maps/it/pom.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + + + org.opendaylight.controller + mdsal-it-parent + 1.4.0-SNAPSHOT + + + + org.opendaylight.alto.basic + alto-auto-maps-it + 0.3.0-SNAPSHOT + bundle + + + false + org.opendaylight.alto.basic + alto-auto-maps-karaf + 0.1.0-SNAPSHOT + zip + + + + + ${project.groupId} + alto-auto-maps-features + ${project.version} + + + diff --git a/alto-basic/auto-maps/it/src/test/java/org/opendaylight/alto/basic/it/AltoAutoMapsIT.java b/alto-basic/auto-maps/it/src/test/java/org/opendaylight/alto/basic/it/AltoAutoMapsIT.java new file mode 100644 index 00000000..ea670cd4 --- /dev/null +++ b/alto-basic/auto-maps/it/src/test/java/org/opendaylight/alto/basic/it/AltoAutoMapsIT.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2016 SNLAB 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.it; + +import static org.ops4j.pax.exam.CoreOptions.composite; +import static org.ops4j.pax.exam.CoreOptions.maven; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel; +import org.ops4j.pax.exam.options.MavenUrlReference; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerClass.class) +public class AltoAutoMapsIT extends AbstractMdsalTestBase { + private static final Logger LOG = LoggerFactory.getLogger(AltoAutoMapsIT.class); + + @Override + public MavenUrlReference getFeatureRepo() { + return maven() + .groupId("org.opendaylight.alto.basic") + .artifactId("alto-auto-maps-features") + .classifier("features") + .type("xml") + .versionAsInProject(); + } + + @Override + public String getFeatureName() { + return "odl-alto-auto-maps-ui"; + } + + @Override + public Option getLoggingOption() { + Option option = editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG, + logConfiguration(AltoAutoMapsIT.class), + LogLevel.INFO.name()); + option = composite(option, super.getLoggingOption()); + return option; + } + + @Test + public void testAltoAutoMapsFeatureLoad() { + Assert.assertTrue(true); + } +} diff --git a/alto-basic/auto-maps/karaf/pom.xml b/alto-basic/auto-maps/karaf/pom.xml new file mode 100644 index 00000000..cdf761cb --- /dev/null +++ b/alto-basic/auto-maps/karaf/pom.xml @@ -0,0 +1,73 @@ + + + + 4.0.0 + + + org.opendaylight.controller + karaf-parent + 1.7.0-SNAPSHOT + + + + org.opendaylight.alto.basic + alto-auto-maps-karaf + 0.3.0-SNAPSHOT + ${project.artifactId} + + + 3.1.1 + + + + odl-alto-auto-maps-ui + + + + + + ${project.groupId} + alto-auto-maps-artifacts + ${project.version} + pom + import + + + + + + + + org.apache.karaf.features + framework + kar + + + + ${project.groupId} + alto-auto-maps-features + features + xml + runtime + + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + diff --git a/alto-basic/auto-maps/pom.xml b/alto-basic/auto-maps/pom.xml new file mode 100644 index 00000000..9b8ba44d --- /dev/null +++ b/alto-basic/auto-maps/pom.xml @@ -0,0 +1,132 @@ + + + + 4.0.0 + + + org.opendaylight.odlparent + odlparent + 1.7.0-SNAPSHOT + + + + org.opendaylight.alto.basic + alto-auto-maps-aggregator + 0.3.0-SNAPSHOT + alto-auto-maps + pom + + + 3.1.1 + + + + scm:git:ssh://git.opendaylight.org:29418/alto-auto-maps.git + scm:git:ssh://git.opendaylight.org:29418/alto-auto-maps.git + HEAD + https://wiki.opendaylight.org/view/alto-auto-maps:Main + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + org.apache.maven.plugins + maven-install-plugin + + true + + + + + + + + minimal + + true + + + api + impl + + + + + alto-dev + + api + impl + features + artifacts + + + + + alto-test + + api + impl + features + artifacts + karaf + + + + + + + maven-site + + + + + org.apache.maven.plugins + maven-javadoc-plugin + false + + + aggregate + + aggregate + + package + + + + + + + + + + ${odl.site.url}/${project.groupId}/${stream}/ + + + + opendaylight-site + ${nexus.site.url}/ + + + diff --git a/alto-basic/auto-maps/src/main/resources/stylesheet.css b/alto-basic/auto-maps/src/main/resources/stylesheet.css new file mode 100644 index 00000000..76de82bf --- /dev/null +++ b/alto-basic/auto-maps/src/main/resources/stylesheet.css @@ -0,0 +1,475 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ +body { + background-color:#ffffff; + color:#353833; + font-family:Arial, Helvetica, sans-serif; + font-size:76%; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4c6b87; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4c6b87; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-size:1.3em; +} +h1 { + font-size:1.8em; +} +h2 { + font-size:1.5em; +} +h3 { + font-size:1.4em; +} +h4 { + font-size:1.3em; +} +h5 { + font-size:1.2em; +} +h6 { + font-size:1.1em; +} +ul { + list-style-type:disc; +} +code, tt { + font-size:1.2em; +} +dt code { + font-size:1.2em; +} +table tr td dt code { + font-size:1.2em; + vertical-align:top; +} +sup { + font-size:.6em; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:.8em; + z-index:200; + margin-top:-7px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + background-image:url(resources/titlebar.gif); + background-position:left top; + background-repeat:no-repeat; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:1em; + margin:0; +} +.topNav { + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.bottomNav { + margin-top:10px; + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.subNav { + background-color:#dee3e9; + border-bottom:1px solid #9eadc0; + float:left; + width:100%; + overflow:hidden; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding:3px 6px; +} +ul.subNavList li{ + list-style:none; + float:left; + font-size:90%; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; +} +.navBarCell1Rev { + background-image:url(resources/tab.gif); + background-color:#a88834; + color:#FFFFFF; + margin: auto 5px; + border:1px solid #c9aa44; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader h1 { + font-size:1.3em; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 25px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:1.2em; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0 0 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0 0 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:1.0em; +} +.indexContainer h2 { + font-size:1.1em; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:1.1em; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:10px 0 10px 20px; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:25px; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #9eadc0; + background-color:#f9f9f9; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:1px solid #9eadc0; + border-top:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; + border-bottom:1px solid #9eadc0; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.contentContainer table, .classUseContainer table, .constantValuesContainer table { + border-bottom:1px solid #9eadc0; + width:100%; +} +.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table { + width:100%; +} +.contentContainer .description table, .contentContainer .details table { + border-bottom:none; +} +.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{ + vertical-align:top; + padding-right:20px; +} +.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast, +.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast, +.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne, +.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne { + padding-right:3px; +} +.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#FFFFFF; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + margin:0px; +} +caption a:link, caption a:hover, caption a:active, caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span { + white-space:nowrap; + padding-top:8px; + padding-left:8px; + display:block; + float:left; + background-image:url(resources/titlebar.gif); + height:18px; +} +.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd { + width:10px; + background-image:url(resources/titlebar_end.gif); + background-repeat:no-repeat; + background-position:top right; + position:relative; + float:left; +} +ul.blockList ul.blockList li.blockList table { + margin:0 0 12px 0px; + width:100%; +} +.tableSubHeadingColor { + background-color: #EEEEFF; +} +.altColor { + background-color:#eeeeef; +} +.rowColor { + background-color:#ffffff; +} +.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td { + text-align:left; + padding:3px 3px 3px 7px; +} +th.colFirst, th.colLast, th.colOne, .constantValuesContainer th { + background:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + text-align:left; + padding:3px 3px 3px 7px; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +td.colFirst, th.colFirst { + border-left:1px solid #9eadc0; + white-space:nowrap; +} +td.colLast, th.colLast { + border-right:1px solid #9eadc0; +} +td.colOne, th.colOne { + border-right:1px solid #9eadc0; + border-left:1px solid #9eadc0; +} +table.overviewSummary { + padding:0px; + margin-left:0px; +} +table.overviewSummary td.colFirst, table.overviewSummary th.colFirst, +table.overviewSummary td.colOne, table.overviewSummary th.colOne { + width:25%; + vertical-align:middle; +} +table.packageSummary td.colFirst, table.overviewSummary th.colFirst { + width:25%; + vertical-align:middle; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:.9em; +} +.block { + display:block; + margin:3px 0 0 0; +} +.strong { + font-weight:bold; +} + diff --git a/alto-basic/auto-maps/src/site/site.xml b/alto-basic/auto-maps/src/site/site.xml new file mode 100644 index 00000000..b4c328a8 --- /dev/null +++ b/alto-basic/auto-maps/src/site/site.xml @@ -0,0 +1,8 @@ + + + + + + + + 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 3e4b826a..d7f42c78 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 @@ -120,7 +120,7 @@ public class ManualMapsUtils { WriteTransaction wx) { InstanceIdentifier iid = getResourceNetworkMapIID(rid); ResourceNetworkMapBuilder builder = new ResourceNetworkMapBuilder(); - builder.setTag(new Tag(UUID.nameUUIDFromBytes(rid.getBytes()).toString())); + builder.setTag(new Tag(UUID.nameUUIDFromBytes(rid.getBytes()).toString().replaceAll("-", ""))); builder.setResourceId(new ResourceId(rid)); builder.setMap(networkMap); wx.put(LogicalDatastoreType.CONFIGURATION, iid, builder.build()); @@ -133,7 +133,7 @@ public class ManualMapsUtils { WriteTransaction wx) { InstanceIdentifier iid = getResourceCostMapIID(rid); ResourceCostMapBuilder builder = new ResourceCostMapBuilder(); - builder.setTag(new Tag(UUID.nameUUIDFromBytes(rid.getBytes()).toString())); + builder.setTag(new Tag(UUID.nameUUIDFromBytes(rid.getBytes()).toString().replaceAll("-", ""))); builder.setResourceId(new ResourceId(rid)); builder.setMap(costMap); builder.setMeta(meta); diff --git a/alto-basic/manual-maps/impl/pom.xml b/alto-basic/manual-maps/impl/pom.xml index 2d814935..66be1dad 100644 --- a/alto-basic/manual-maps/impl/pom.xml +++ b/alto-basic/manual-maps/impl/pom.xml @@ -56,6 +56,24 @@ and is available at http://www.eclipse.org/legal/epl-v10.html alto-northbound-api ${project.version} + + + org.opendaylight.alto.core + alto-northbound-route-networkmap-api + ${project.version} + + + + org.opendaylight.alto.core + alto-northbound-route-costmap-api + ${project.version} + + + + org.opendaylight.alto.basic + alto-simple-ird-api + ${project.version} + junit 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 b87a0185..9347641f 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 @@ -8,6 +8,9 @@ package org.opendaylight.alto.basic.impl; import org.opendaylight.alto.basic.manual.maps.ManualMapsUtils; +import org.opendaylight.alto.basic.simpleird.SimpleIrdUtils; +import org.opendaylight.alto.core.northbound.route.costmap.AltoNbrCostmapUtils; +import org.opendaylight.alto.core.northbound.route.networkmap.AltoNbrNetworkmapUtils; import org.opendaylight.alto.core.resourcepool.ResourcepoolUtils; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; @@ -22,6 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.manual.maps.cost import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.manual.maps.networkmap.rev151021.NetworkMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.manual.maps.rev151021.ConfigContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.ServiceContext; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.types.rev150921.ResourceId; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.config.rev151021.ResourceTypeConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.costmap.rev151021.AltoModelCostmapService; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.costmap.rev151021.ResourceTypeCostmap; @@ -88,12 +92,17 @@ public class ManualMapsListener implements AutoCloseable, DataChangeListener { for (Map.Entry, DataObject> entry : change.getUpdatedData().entrySet()) { DataObject origin = original.get(entry.getKey()); + InstanceIdentifier updatedIID = entry.getKey(); DataObject updated = entry.getValue(); if (updated instanceof NetworkMap) { - updateNetworkMap((NetworkMap) origin, (NetworkMap) updated); + updateNetworkMap((NetworkMap) origin, (NetworkMap) updated, + (InstanceIdentifier) updatedIID, rwx); + LOG.info("Update NetworkMap data from OPERATIONAL"); } else if (updated instanceof CostMap) { - updateCostMap((CostMap) origin, (CostMap) updated); + updateCostMap((CostMap) origin, (CostMap) updated, + (InstanceIdentifier) updatedIID, rwx); + LOG.info("Update CostMap data from OPERATIONAL"); } } @@ -131,15 +140,27 @@ public class ManualMapsListener implements AutoCloseable, DataChangeListener { rwx.submit(); } - private void updateNetworkMap(NetworkMap origin, NetworkMap updated) { - //TODO: No Implementation + private void updateNetworkMap(NetworkMap origin, NetworkMap updated, InstanceIdentifier updatedIID, + final WriteTransaction wx) { + ResourceId rid = updated.getResourceId(); + + LOG.info("Updating NetworkMap: " + "\n\tResource ID: " + rid.getValue()); + createNetworkMap(updated, updatedIID, wx); } - private void updateCostMap(CostMap origin, CostMap updated) { - //TODO: No Implementation + private void updateCostMap(CostMap origin, CostMap updated, InstanceIdentifier updatedIID, + final WriteTransaction wx) { + ResourceId rid = updated.getResourceId(); + + LOG.info("Updating CostMap: " + "\n\tResource ID: " + rid.getValue()); + createCostMap(updated, updatedIID, wx); } private void removeNetworkMap(InstanceIdentifier mapIID, NetworkMap removed, final WriteTransaction wx) { + SimpleIrdUtils.deleteConfigEntry(removed.getResourceId(), wx); + String path = removed.getResourceId().getValue(); + AltoNbrNetworkmapUtils.deleteRecord(path, wx); + ResourcepoolUtils.deleteResource(new Uuid(ManualMapsUtils.DEFAULT_CONTEXT), removed.getResourceId(), wx); m_networkmapServiceReg.unregisterPath(ServiceContext.class, ResourcepoolUtils.getContextTagIID(new Uuid(ManualMapsUtils.DEFAULT_CONTEXT), @@ -148,6 +169,7 @@ public class ManualMapsListener implements AutoCloseable, DataChangeListener { } private void removeCostMap(InstanceIdentifier mapIID, CostMap removed, final WriteTransaction wx) { + SimpleIrdUtils.deleteConfigEntry(removed.getResourceId(), wx); ManualMapsUtils.deleteResourceCostMap(new Uuid(ManualMapsUtils.DEFAULT_CONTEXT), removed.getResourceId(), wx); m_costmapServiceReg.unregisterPath(ServiceContext.class, ResourcepoolUtils.getContextTagIID(new Uuid(ManualMapsUtils.DEFAULT_CONTEXT), @@ -158,6 +180,7 @@ public class ManualMapsListener implements AutoCloseable, DataChangeListener { private void removeConfigContext(InstanceIdentifier iid, ConfigContext removed, final WriteTransaction wx) { ManualMapsUtils.deleteContext(removed.getContextId(), wx); removeMap(iid, wx); + // TODO: Consistency with SimpleIrd and NrbRecord } private void removeMap(InstanceIdentifier mapIID, final WriteTransaction wx) { @@ -174,6 +197,11 @@ public class ManualMapsListener implements AutoCloseable, DataChangeListener { ResourcepoolUtils.getContextTagIID(new Uuid(ManualMapsUtils.DEFAULT_CONTEXT), created.getResourceId(), created.getTag())); wx.put(LogicalDatastoreType.OPERATIONAL, createdIID, created); + + String path = created.getResourceId().getValue(); + AltoNbrNetworkmapUtils.createRecord(path, created.getResourceId(), wx); + SimpleIrdUtils.createConfigEntry(AltoNbrNetworkmapUtils.BASE_URL + "/" + path, + created.getResourceId(), new Uuid(ManualMapsUtils.DEFAULT_CONTEXT), wx); } private void createCostMap(CostMap created, InstanceIdentifier createdIID, final WriteTransaction wx) { @@ -193,6 +221,11 @@ public class ManualMapsListener implements AutoCloseable, DataChangeListener { ResourcepoolUtils.getContextTagIID(new Uuid(ManualMapsUtils.DEFAULT_CONTEXT), created.getResourceId(), created.getTag())); wx.put(LogicalDatastoreType.OPERATIONAL, createdIID, created); + + String path = created.getResourceId().getValue(); + AltoNbrCostmapUtils.createRecord(path, created.getResourceId(), wx); + SimpleIrdUtils.createConfigEntry(AltoNbrCostmapUtils.BASE_URL + "/" + path, + created.getResourceId(), new Uuid(ManualMapsUtils.DEFAULT_CONTEXT), wx); } private void createConfigContext(ConfigContext created, InstanceIdentifier createdIID, final ReadWriteTransaction rwx) { diff --git a/alto-basic/pom.xml b/alto-basic/pom.xml index 3b5f49c7..d1ae0492 100644 --- a/alto-basic/pom.xml +++ b/alto-basic/pom.xml @@ -26,6 +26,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL simple-ird manual-maps simple-ecs + auto-maps diff --git a/alto-basic/simple-ird/api/src/main/java/org/opendaylight/alto/basic/simpleird/SimpleIrdUtils.java b/alto-basic/simple-ird/api/src/main/java/org/opendaylight/alto/basic/simpleird/SimpleIrdUtils.java index 8eace00e..cf49da68 100644 --- a/alto-basic/simple-ird/api/src/main/java/org/opendaylight/alto/basic/simpleird/SimpleIrdUtils.java +++ b/alto-basic/simple-ird/api/src/main/java/org/opendaylight/alto/basic/simpleird/SimpleIrdUtils.java @@ -11,16 +11,22 @@ import java.util.concurrent.ExecutionException; import com.google.common.base.Optional; +import org.opendaylight.alto.core.resourcepool.ResourcepoolUtils; 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.inet.types.rev130715.Uri; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.IrdInstance; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.IrdInstanceKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.IrdInstanceConfiguration; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.IrdInstanceConfigurationKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.ird.entry.configuration.data.location.RelativePathBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.ird.instance.IrdEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.ird.instance.IrdEntryKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.ird.instance.configuration.IrdConfigurationEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.ird.instance.configuration.IrdConfigurationEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.ird.instance.configuration.IrdConfigurationEntryKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.types.rev150921.ResourceId; @@ -29,6 +35,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class SimpleIrdUtils { + public static final String DEFAULT_IRD_RESOURCE = "default"; + public static InstanceIdentifier getInstanceIID(String rid) { return getInstanceIID(new ResourceId(rid)); } @@ -82,4 +90,32 @@ public class SimpleIrdUtils { } return null; } + + public static void createConfigEntry(String path, ResourceId rid, Uuid cid, final WriteTransaction wx) { + createConfigEntry(path, new ResourceId(DEFAULT_IRD_RESOURCE), rid, cid, wx); + } + + public static void createConfigEntry(String path, ResourceId irdid, ResourceId rid, Uuid cid, + final WriteTransaction wx) { + IrdConfigurationEntryBuilder builder = new IrdConfigurationEntryBuilder(); + builder.setEntryId(rid); + builder.setInstance(ResourcepoolUtils.getResourceIID(cid, rid)); + builder.setLocation(new RelativePathBuilder() + .setPath(new Uri(path)) + .build()); + + InstanceIdentifier iceIID = getConfigEntryIID(irdid, rid); + + wx.put(LogicalDatastoreType.CONFIGURATION, iceIID, builder.build()); + } + + public static void deleteConfigEntry(ResourceId rid, final WriteTransaction wx) { + deleteConfigEntry(new ResourceId(DEFAULT_IRD_RESOURCE), rid, wx); + } + + public static void deleteConfigEntry(ResourceId irdid, ResourceId rid, final WriteTransaction wx) { + InstanceIdentifier iid = getConfigEntryIID(irdid, rid); + + wx.delete(LogicalDatastoreType.CONFIGURATION, iid); + } } diff --git a/alto-basic/simple-ird/api/src/main/yang/alto-simple-ird.yang b/alto-basic/simple-ird/api/src/main/yang/alto-simple-ird.yang index 8445016c..886d3a42 100644 --- a/alto-basic/simple-ird/api/src/main/yang/alto-simple-ird.yang +++ b/alto-basic/simple-ird/api/src/main/yang/alto-simple-ird.yang @@ -96,7 +96,7 @@ module alto-simple-ird { description "The context of the resources managed by this IRD instance" + "Should follow the format:" - + "/alto-resourcepool:context[alto-resourcepool:context-id='...'"; + + "/alto-resourcepool:context[alto-resourcepool:context-id='...']"; } } diff --git a/alto-basic/simple-ird/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoSimpleIrdProvider.java b/alto-basic/simple-ird/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoSimpleIrdProvider.java index 424cd4e7..f68b3b5e 100644 --- a/alto-basic/simple-ird/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoSimpleIrdProvider.java +++ b/alto-basic/simple-ird/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoSimpleIrdProvider.java @@ -7,35 +7,29 @@ */ package org.opendaylight.alto.basic.impl; -import java.util.concurrent.ExecutionException; - import org.opendaylight.alto.basic.simpleird.SimpleIrdUtils; - import org.opendaylight.alto.core.northbound.api.AltoNorthboundRoute; import org.opendaylight.alto.core.northbound.api.AltoNorthboundRouter; import org.opendaylight.alto.core.resourcepool.ResourcepoolUtils; - 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.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; - import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid; - import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.Information; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.InformationBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.IrdInstance; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.IrdInstanceConfiguration; - +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.basic.simple.ird.rev151021.IrdInstanceConfigurationBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.types.rev150921.ResourceId; - import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.concurrent.ExecutionException; + public class AltoSimpleIrdProvider implements BindingAwareProvider, AutoCloseable { public static final String ROOT_INSTANCE = "root"; @@ -76,6 +70,22 @@ public class AltoSimpleIrdProvider implements BindingAwareProvider, AutoCloseabl m_listener.register(m_dataBroker, m_iid); } + protected void createDefaultIrd() throws InterruptedException, ExecutionException { + WriteTransaction wx = m_dataBroker.newWriteOnlyTransaction(); + + IrdInstanceConfigurationBuilder builder = new IrdInstanceConfigurationBuilder(); + builder.setEntryContext(ResourcepoolUtils.getDefaultContextIID()) + .setInstanceId(new ResourceId(SimpleIrdUtils.DEFAULT_IRD_RESOURCE)); + + InstanceIdentifier iicIID = + SimpleIrdUtils.getInstanceConfigurationIID(new ResourceId(SimpleIrdUtils.DEFAULT_IRD_RESOURCE)); + + wx.put(LogicalDatastoreType.CONFIGURATION, iicIID, builder.build()); + wx.submit().get(); + + LOG.info("Create default IRD context for SimpleIrd"); + } + protected void deleteContext() throws InterruptedException, ExecutionException { WriteTransaction wx = m_dataBroker.newWriteOnlyTransaction(); ResourcepoolUtils.deleteContext(m_context, wx); @@ -100,6 +110,7 @@ public class AltoSimpleIrdProvider implements BindingAwareProvider, AutoCloseabl try { createContext(); setupListener(); + createDefaultIrd(); } catch (Exception e) { LOG.error("Failed to create top-level containers"); e.printStackTrace(); diff --git a/alto-core/standard-northbound-routes/costmap/api/src/main/java/org/opendaylight/alto/core/northbound/route/costmap/AltoNbrCostmapUtils.java b/alto-core/standard-northbound-routes/costmap/api/src/main/java/org/opendaylight/alto/core/northbound/route/costmap/AltoNbrCostmapUtils.java index 4b21b8ca..d9e5ba0b 100644 --- a/alto-core/standard-northbound-routes/costmap/api/src/main/java/org/opendaylight/alto/core/northbound/route/costmap/AltoNbrCostmapUtils.java +++ b/alto-core/standard-northbound-routes/costmap/api/src/main/java/org/opendaylight/alto/core/northbound/route/costmap/AltoNbrCostmapUtils.java @@ -7,21 +7,46 @@ */ package org.opendaylight.alto.core.northbound.route.costmap; -/** - * Created by wukunheng00 on 12/3/15. - */ - +import org.opendaylight.alto.core.resourcepool.ResourcepoolUtils; +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.inet.types.rev130715.Uri; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.costmap.rev151021.Records; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.costmap.rev151021.records.Record; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.costmap.rev151021.records.RecordBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.costmap.rev151021.records.RecordKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.types.rev150921.ResourceId; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class AltoNbrCostmapUtils { + public static final String BASE_URL = "/alto/costmap"; + public static InstanceIdentifier getRecordIID(String path) { RecordKey key = new RecordKey(new Uri(path)); return InstanceIdentifier.builder(Records.class).child(Record.class, key).build(); } + + public static String createRecord(String path, ResourceId rid, final WriteTransaction wx) { + return createRecord(path, rid, new Uuid(ResourcepoolUtils.DEFAULT_CONTEXT), wx); + } + + public static String createRecord(String path, ResourceId rid, Uuid cid, final WriteTransaction wx) { + InstanceIdentifier iid = getRecordIID(path); + RecordBuilder builder = new RecordBuilder(); + builder.setPath(new Uri(path)); + builder.setResourceIid(ResourcepoolUtils.getResourceIID(cid, rid)); + + wx.put(LogicalDatastoreType.CONFIGURATION, iid, builder.build()); + + return path; + } + + public static void deleteRecord(String path, final WriteTransaction wx) { + InstanceIdentifier iid = getRecordIID(path); + + wx.delete(LogicalDatastoreType.CONFIGURATION, iid); + } } diff --git a/alto-core/standard-northbound-routes/networkmap/api/src/main/java/org/opendaylight/alto/core/northbound/route/networkmap/AltoNbrNetworkmapUtils.java b/alto-core/standard-northbound-routes/networkmap/api/src/main/java/org/opendaylight/alto/core/northbound/route/networkmap/AltoNbrNetworkmapUtils.java index 933675cc..b8572920 100644 --- a/alto-core/standard-northbound-routes/networkmap/api/src/main/java/org/opendaylight/alto/core/northbound/route/networkmap/AltoNbrNetworkmapUtils.java +++ b/alto-core/standard-northbound-routes/networkmap/api/src/main/java/org/opendaylight/alto/core/northbound/route/networkmap/AltoNbrNetworkmapUtils.java @@ -9,19 +9,63 @@ package org.opendaylight.alto.core.northbound.route.networkmap; +import org.opendaylight.alto.core.resourcepool.ResourcepoolUtils; +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.inet.types.rev130715.Uri; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.networkmap.rev151021.Records; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.networkmap.rev151021.records.Record; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.networkmap.rev151021.records.RecordBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.networkmap.rev151021.records.RecordKey; - -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; - +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.networkmap.rev151021.records.record.AddressTypeMapping; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.networkmap.rev151021.records.record.AddressTypeMappingBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.types.rev150921.ResourceId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.networkmap.rev151021.AddressTypeIpv4; +import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.networkmap.rev151021.AddressTypeIpv6; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import java.util.LinkedList; +import java.util.List; + public class AltoNbrNetworkmapUtils { + public static final String BASE_URL = "/alto/networkmap"; + public static InstanceIdentifier getRecordIID(String path) { RecordKey key = new RecordKey(new Uri(path)); return InstanceIdentifier.builder(Records.class).child(Record.class, key).build(); } + + public static String createRecord(String path, ResourceId rid, final WriteTransaction wx) { + return createRecord(path, rid, new Uuid(ResourcepoolUtils.DEFAULT_CONTEXT), wx); + } + + public static String createRecord(String path, ResourceId rid, Uuid cid, final WriteTransaction wx) { + InstanceIdentifier iid = getRecordIID(path); + RecordBuilder builder = new RecordBuilder(); + builder.setPath(new Uri(path)); + builder.setResourceIid(ResourcepoolUtils.getResourceIID(cid, rid)); + List addressTypeMappingList = new LinkedList<>(); + addressTypeMappingList.add(new AddressTypeMappingBuilder() + .setAddressTypeString("ipv4") + .setAddressType(AddressTypeIpv4.class) + .build()); + addressTypeMappingList.add(new AddressTypeMappingBuilder() + .setAddressTypeString("ipv6") + .setAddressType(AddressTypeIpv6.class) + .build()); + builder.setAddressTypeMapping(addressTypeMappingList); + + wx.put(LogicalDatastoreType.CONFIGURATION, iid, builder.build()); + + return path; + } + + public static void deleteRecord(String path, final WriteTransaction wx) { + InstanceIdentifier iid = getRecordIID(path); + + wx.delete(LogicalDatastoreType.CONFIGURATION, iid); + } } diff --git a/alto-core/standard-service-models/model-costmap/api/src/main/yang/alto-model-costmap-rfc7285.yang b/alto-core/standard-service-models/model-costmap/api/src/main/yang/alto-model-costmap-rfc7285.yang index 11c9ba1f..3bf3116c 100644 --- a/alto-core/standard-service-models/model-costmap/api/src/main/yang/alto-model-costmap-rfc7285.yang +++ b/alto-core/standard-service-models/model-costmap/api/src/main/yang/alto-model-costmap-rfc7285.yang @@ -63,4 +63,4 @@ module alto-model-costmap-rfc7285 { -} \ No newline at end of file +} diff --git a/alto-release-features/pom.xml b/alto-release-features/pom.xml index fa4a9eb4..2c4f470b 100644 --- a/alto-release-features/pom.xml +++ b/alto-release-features/pom.xml @@ -388,5 +388,16 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL alto-simple-ecs-api ${project.version} + + + org.opendaylight.alto.basic + alto-auto-maps-impl + ${project.version} + + + org.opendaylight.alto.basic + alto-auto-maps-api + ${project.version} + diff --git a/alto-release-features/src/main/features/features.xml b/alto-release-features/src/main/features/features.xml index 5891bbf7..674777b6 100644 --- a/alto-release-features/src/main/features/features.xml +++ b/alto-release-features/src/main/features/features.xml @@ -22,6 +22,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html description='OpenDaylight :: alto :: Release'> odl-alto-core odl-alto-basic + odl-alto-extension odl-alto-simpleird odl-alto-manual-maps odl-alto-hosttracker + odl-alto-auto-maps odl-alto-northbound odl-alto-resourcepool odl-alto-standard-service-models + odl-alto-simpleird + mvn:org.opendaylight.alto.core/alto-northbound-route-networkmap-api/${project.version} + mvn:org.opendaylight.alto.core/alto-northbound-route-costmap-api/${project.version} mvn:org.opendaylight.alto.core/alto-service-model-config-api/${project.version} mvn:org.opendaylight.alto.basic/alto-manual-maps-api/${project.version} mvn:org.opendaylight.alto.basic/alto-manual-maps-impl/${project.version} @@ -194,28 +199,31 @@ and is available at http://www.eclipse.org/legal/epl-v10.html - - odl-l2switch-hosttracker - odl-l2switch-addresstracker - odl-alto-core - - mvn:org.opendaylight.alto.basic/alto-simple-ecs-api/${project.version} - mvn:org.opendaylight.alto.basic/alto-simple-ecs-impl/${project.version} - - mvn:org.opendaylight.alto.basic/alto-simple-ecs-impl/${project.version}/xml/config - - - - - odl-alto-spce - odl-alto-core - - mvn:org.opendaylight.alto.basic/alto-simple-ecs-api/${project.version} - mvn:org.opendaylight.alto.basic/alto-simple-ecs-impl/${project.version} - - mvn:org.opendaylight.alto.basic/alto-simple-ecs-impl/${project.version}/xml/config - - + odl-l2switch-hosttracker + odl-l2switch-addresstracker + odl-alto-core + + mvn:org.opendaylight.alto.basic/alto-simple-ecs-api/${project.version} + mvn:org.opendaylight.alto.basic/alto-simple-ecs-impl/${project.version} + + mvn:org.opendaylight.alto.basic/alto-simple-ecs-impl/${project.version}/xml/config + + + + + odl-mdsal-models + odl-mdsal-broker + odl-l2switch-hosttracker + odl-l2switch-addresstracker + + odl-alto-northbound + odl-alto-resourcepool + odl-alto-standard-service-models + odl-alto-manual-maps + + mvn:org.opendaylight.alto.basic/alto-auto-maps-api/${project.version} + mvn:org.opendaylight.alto.basic/alto-auto-maps-impl/${project.version}