--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.alto.alto-hosttracker</groupId>
+ <artifactId>alto-hosttracker.aggregator</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+ <groupId>org.opendaylight.alto.alto-hosttracker</groupId>
+ <artifactId>alto-hosttracker-config</artifactId>
+ <packaging>jar</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/initial/59-altohosttracker.xml
+ </file>
+ <type>xml</type>
+ <classifier>config</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2014 Cisco Systems, Inc. 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
+-->
+<snapshot>
+ <configuration>
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <module>
+ <type xmlns:prefix="urn:opendaylight:alto:alto-host-tracker-impl">
+ prefix:alto-host-tracker-impl
+ </type>
+ <name>alto-host-tracker-impl</name>
+
+ <topology-id>flow:1</topology-id>
+ <data-broker>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+ <name>binding-data-broker</name>
+ </data-broker>
+ </module>
+ </modules>
+ </data>
+ </configuration>
+
+ <required-capabilities>
+ <capability>urn:opendaylight:alto:alto-host-tracker-impl?module=alto-host-tracker-impl&revision=2014-05-28</capability>
+ </required-capabilities>
+</snapshot>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.alto.alto-hosttracker</groupId>
+ <artifactId>alto-hosttracker.aggregator</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+ <name>alto-hosttracker-impl</name>
+ <groupId>org.opendaylight.alto.alto-hosttracker</groupId>
+ <artifactId>alto-hosttracker-impl</artifactId>
+ <packaging>bundle</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${bundle.plugin.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528</Export-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ <version>${yangtools.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-sources</goal>
+ </goals>
+ <configuration>
+ <codeGenerators>
+ <generator>
+ <codeGeneratorClass>
+ org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ </codeGeneratorClass>
+ <outputBaseDir>src/main/yang-gen-config</outputBaseDir>
+ <additionalConfiguration>
+ <namespaceToPackage1>
+ urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
+ </namespaceToPackage1>
+ </additionalConfiguration>
+ </generator>
+ <generator>
+ <codeGeneratorClass>
+ org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl
+ </codeGeneratorClass>
+ <outputBaseDir>src/main/yang-gen-code</outputBaseDir>
+ </generator>
+ </codeGenerators>
+ <inspectDependencies>true</inspectDependencies>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>yang-jmx-generator-plugin</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>maven-sal-api-gen-plugin</artifactId>
+ <version>${yangtools.version}</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ <version>${yangtools.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-binding</artifactId>
+ <version>${yangtools.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-inventory</artifactId>
+ <version>${mdsal.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.l2switch.addresstracker</groupId>
+ <artifactId>addresstracker-model</artifactId>
+ <version>${l2switch.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.alto</groupId>
+ <artifactId>alto-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.l2switch.hosttracker</groupId>
+ <artifactId>hosttracker-model</artifactId>
+ <version>${l2switch.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-topology</artifactId>
+ <version>${ietf.topology.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-api</artifactId>
+ <version>${config.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-config</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.alto.alto-hosttracker</groupId>
+ <artifactId>alto-hosttracker-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+package org.opendaylight.alto.altohosttracker.plugin.internal;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ExecutionException;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.CheckedFuture;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416.DstCosts1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416.DstCosts1Builder;
+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.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+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.opendaylight.host.tracker.rev140624.HostNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.address.tracker.rev140617.AddressCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.address.tracker.rev140617.address.node.connector.Addresses;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+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.Node;
+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.opendaylight.alto.rev150404.Resources;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.ResourcesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.NetworkMaps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.NetworkMapsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.CostMaps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.CostMapsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.cost.maps.CostMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.cost.maps.CostMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.EndpointPropertyMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.EndpointPropertyMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TypedIpv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TypedEndpointAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointPropertyType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointPropertyValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.data.EndpointProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.data.EndpointPropertiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.data.EndpointPropertiesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.data.endpoint.properties.Properties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.data.endpoint.properties.PropertiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceSpecificEndpointProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TagString;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ValidIdString;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.cost.map.meta.CostType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.cost.map.meta.CostTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.dependent.vtags.DependentVtags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.dependent.vtags.DependentVtagsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.CostMode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.CostMetric;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.map.DstCosts;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.map.DstCostsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
+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;
+
+public class AltoHostTrackerImpl implements DataChangeListener {
+
+ private Pattern p;
+ private static final int CPUS = Runtime.getRuntime().availableProcessors();
+
+ /**
+ * As defined on
+ * controller/opendaylight/md-sal/topology-manager/src/main/java
+ * /org/opendaylight
+ * /md/controller/topology/manager/FlowCapableTopologyProvider.java
+ */
+ private static final String TOPOLOGY_NAME = "flow:1";
+
+ private static final String NMRESOURCEID = "hosttracker-network-map";
+
+ private static final String CMRESOURCEID = "hosttracker-cost-map";
+
+ private static final String EPMRESOURCEID = "hosttracker-endpoint-property-map";
+
+ private static final Logger log = LoggerFactory
+ .getLogger(AltoHostTrackerImpl.class);
+
+ private static Map<String, String> networkMap;
+ private static Map<String, String> endpointPropertyMap;
+
+ private final DataBroker dataService;
+ private final String topologyId;
+
+ // public static final InstanceIdentifier<Resources> ALTO_IID =
+ // InstanceIdentifier.builder(Resources.class).toInstance();
+
+ ExecutorService exec = Executors.newFixedThreadPool(CPUS);
+
+ private ListenerRegistration<DataChangeListener> hostNodeListerRegistration;
+
+ private ListenerRegistration<DataChangeListener> networkMapListerRegistration;
+
+ public AltoHostTrackerImpl(DataBroker dataService, String topologyId) {
+ networkMap = new HashMap<String, String>();
+ endpointPropertyMap = new HashMap<String, String>();
+
+ p = Pattern.compile("[0-9]+.[0-9]+.[0-9]+.[0-9]+");
+
+ Preconditions.checkNotNull(dataService,
+ "dataBrokerService should not be null.");
+ this.dataService = dataService;
+ if (topologyId == null || topologyId.isEmpty()) {
+ this.topologyId = TOPOLOGY_NAME;
+ } else {
+ this.topologyId = topologyId;
+ }
+ }
+
+ public void submit(final WriteTransaction writeTx) {
+ final CheckedFuture writeTxResultFuture = writeTx.submit();
+ Futures.addCallback(writeTxResultFuture, new FutureCallback() {
+ @Override
+ public void onSuccess(Object o) {
+ log.debug("ConcurrentHashMap write successful for tx :{}",
+ writeTx.getIdentifier());
+ }
+
+ @Override
+ public void onFailure(Throwable throwable) {
+ log.error("ConcurrentHashMap write transaction {} failed",
+ writeTx.getIdentifier(), throwable.getCause());
+ }
+ });
+ }
+
+ public void writeDefaultCostMaps() {
+ ResourceId rid = new ResourceId(new ValidIdString(CMRESOURCEID));
+
+ InstanceIdentifier<CostMaps> ALTO_CMS = InstanceIdentifier
+ .builder(Resources.class).child(CostMaps.class).build();
+
+ TagString tag = new TagString(TagGenerator.getTag(32));
+ ValidIdString vis0 = new ValidIdString("pid0");
+ PidName pid0 = new PidName(vis0);
+ ValidIdString vis1 = new ValidIdString("pid1");
+ PidName pid1 = new PidName(vis1);
+
+ DependentVtags dv = new DependentVtagsBuilder().setResourceId(rid)
+ .setTag(tag).build();
+ List<DependentVtags> dvList = new ArrayList<DependentVtags>();
+ dvList.add(dv);
+ CostType ct = new CostTypeBuilder().setCostMode(CostMode.Numerical)
+ .setCostMetric(new CostMetric("hcm"))
+ .setDescription("hosttracker cost metric").build();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Meta meta = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.MetaBuilder()
+ .setDependentVtags(dvList).setCostType(ct).build();
+
+ DstCosts1 dcs11 = new DstCosts1Builder().setCostInHosttracker(10)
+ .build();
+ DstCosts1 dcs12 = new DstCosts1Builder().setCostInHosttracker(0)
+ .build();
+ DstCosts dcs1 = new DstCostsBuilder().setDst(pid1)
+ .addAugmentation(DstCosts1.class, dcs12).build();
+ DstCosts dcs2 = new DstCostsBuilder().setDst(pid0)
+ .addAugmentation(DstCosts1.class, dcs11).build();
+ List<DstCosts> dcsList = new ArrayList<DstCosts>();
+ dcsList.add(dcs1);
+ dcsList.add(dcs2);
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Map map = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.MapBuilder()
+ .setSrc(pid1).setDstCosts(dcsList).build();
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Map> mapList = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Map>();
+
+ mapList.add(map);
+
+ CostMap cm = new CostMapBuilder().setResourceId(rid).setTag(tag)
+ .setMeta(meta).setMap(mapList).build();
+
+ List<CostMap> cmList = new ArrayList<CostMap>();
+
+ cmList.add(cm);
+
+ CostMaps cms = new CostMapsBuilder().setCostMap(cmList).build();
+
+ final WriteTransaction writeTx = this.dataService
+ .newWriteOnlyTransaction();
+ try {
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, ALTO_CMS, cms, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ submit(writeTx);
+ }
+
+ public void writeDefaultNetworkMaps() {
+ InstanceIdentifier<NetworkMaps> ALTO_NM = InstanceIdentifier
+ .builder(Resources.class).child(NetworkMaps.class).build();
+ final WriteTransaction tx = dataService.newWriteOnlyTransaction();
+ try {
+ tx.put(LogicalDatastoreType.CONFIGURATION, ALTO_NM,
+ loadNetworkMaps(), true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ submit(tx);
+ }
+
+ public void writeDefaultEndpointpropertyMap() {
+ InstanceIdentifier<EndpointPropertyMap> ALTO_EPM = InstanceIdentifier
+ .builder(Resources.class).child(EndpointPropertyMap.class)
+ .build();
+ ResourceId rid = new ResourceId(new ValidIdString(
+ "default-endpoint-property-map"));
+ TagString tag = new TagString(TagGenerator.getTag(32));
+
+ DependentVtags dv = new DependentVtagsBuilder().setResourceId(rid)
+ .setTag(tag).build();
+ List<DependentVtags> dvList = new ArrayList<DependentVtags>();
+ dvList.add(dv);
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.Meta meta = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.MetaBuilder()
+ .setDependentVtags(dvList).build();
+ TypedIpv4Address ti4 = new TypedIpv4Address("ipv4:0.0.0.0");
+ TypedEndpointAddress tea = new TypedEndpointAddress(ti4);
+ EndpointPropertyType etp = new EndpointPropertyType(
+ new ResourceSpecificEndpointProperty(
+ "default-endpoint-property-map.property"));
+ EndpointPropertyValue epv = new EndpointPropertyValue("PID1");
+
+ endpointPropertyMap.put("0.0.0.0", "ipv4");
+
+ Properties ps = new PropertiesBuilder().setPropertyType(etp)
+ .setProperty(epv).build();
+ List<Properties> psList = new ArrayList<Properties>();
+ psList.add(ps);
+
+ EndpointProperties ep = new EndpointPropertiesBuilder()
+ .setEndpoint(tea).setProperties(psList).build();
+ List<EndpointProperties> epList = new ArrayList<EndpointProperties>();
+ epList.add(ep);
+
+ EndpointPropertyMap epm = new EndpointPropertyMapBuilder()
+ .setMeta(meta).setEndpointProperties(epList).build();
+
+ final WriteTransaction tx = dataService.newWriteOnlyTransaction();
+ try {
+ tx.put(LogicalDatastoreType.CONFIGURATION, ALTO_EPM, epm, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ submit(tx);
+
+ }
+
+ private Resources buildResources() {
+ try {
+ return new ResourcesBuilder().setNetworkMaps(loadNetworkMaps())
+ .build();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ private NetworkMaps loadNetworkMaps() throws Exception {
+ return new NetworkMapsBuilder().setNetworkMap(loadNetworkMapList())
+ .build();
+ }
+
+ private List<NetworkMap> loadNetworkMapList() {
+ List<NetworkMap> networkMapList = new ArrayList<NetworkMap>();
+ ResourceId rid = new ResourceId(new ValidIdString(NMRESOURCEID));
+ TagString tag = new TagString(TagGenerator.getTag(32));
+ ValidIdString vis = new ValidIdString("pid0");
+ PidName pid = new PidName(vis);
+ IpPrefix ep = new IpPrefix(new Ipv4Prefix("0.0.0.0/0"));
+
+ this.networkMap.put("0.0.0.0/0", "pid0");
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map> mapList = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map>();
+
+ List<IpPrefix> epList = new ArrayList<IpPrefix>();
+ epList.add(ep);
+
+ EndpointAddressGroup eag = new EndpointAddressGroupBuilder()
+ .setAddressType(
+ new EndpointAddressType(
+ EndpointAddressType.Enumeration.Ipv4))
+ .setEndpointPrefix(epList).build();
+
+ List<EndpointAddressGroup> eagList = new ArrayList<EndpointAddressGroup>();
+ eagList.add(eag);
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map map = new MapBuilder()
+ .setPid(pid).setEndpointAddressGroup(eagList).build();
+
+ mapList.add(map);
+
+ NetworkMap networkMap = new NetworkMapBuilder().setResourceId(rid)
+ .setTag(tag).setMap(mapList).build();
+
+ networkMapList.add(networkMap);
+
+ return networkMapList;
+ }
+
+ public void writeTest() {
+ InstanceIdentifier<NetworkMaps> ALTO_IID = InstanceIdentifier
+ .builder(Resources.class).child(NetworkMaps.class).build();
+ final WriteTransaction tx = dataService.newWriteOnlyTransaction();
+ try {
+ tx.put(LogicalDatastoreType.CONFIGURATION, ALTO_IID,
+ loadNetworkMaps(), true);
+ } catch (Exception e) {
+ }
+ final CheckedFuture writeTxResultFuture = tx.submit();
+ Futures.addCallback(writeTxResultFuture, new FutureCallback<Void>() {
+ @Override
+ public void onSuccess(final Void result) {
+ log.info("write success.");
+ notifyCallback(true);
+ }
+
+ @Override
+ public void onFailure(final Throwable t) {
+ log.error("Failed to initiate resources", t);
+ notifyCallback(false);
+ }
+
+ void notifyCallback(final boolean result) {
+ }
+ });
+ }
+
+ public void readTest() {
+ InstanceIdentifier<Resources> resources = InstanceIdentifier.builder(
+ Resources.class).build();
+ ListenableFuture<Optional<Resources>> futureResources;
+ try (ReadOnlyTransaction readTx = dataService.newReadOnlyTransaction()) {
+ futureResources = readTx.read(LogicalDatastoreType.OPERATIONAL,
+ resources);
+ readTx.close();
+ }
+ Optional<Resources> opNodes = null;
+ try {
+ opNodes = futureResources.get();
+ } catch (ExecutionException | InterruptedException ex) {
+ log.warn(ex.getLocalizedMessage());
+ }
+ if (opNodes != null && opNodes.isPresent())
+ log.info("resources:" + opNodes.get());
+ }
+
+ public void mergeEndpointPropertyMapForAddresses(Addresses addrs) {
+ if (addrs == null) {// || addrs.getIp() == null || addrs.getMac() ==
+ // null
+ // IpPrefix ep = new IpPrefix(new Ipv4Prefix("1.1.1.1/32"));
+ // epList.add(ep);
+ return;
+ } else {
+ String ipAddress = addrs.getIp().toString();
+ String mac = addrs.getMac().toString();
+ Matcher m = p.matcher(ipAddress);
+ if (m.find())
+ ipAddress = m.group();
+ else
+ return;
+ if (endpointPropertyMap.containsKey(ipAddress))
+ return;
+
+ TypedIpv4Address ti4 = new TypedIpv4Address("ipv4:" + ipAddress);
+ TypedEndpointAddress tea = new TypedEndpointAddress(ti4);
+
+ EndpointPropertyType etp1 = new EndpointPropertyType(
+ new ResourceSpecificEndpointProperty(
+ "default-endpoint-property-map.pid"));
+ EndpointPropertyValue epv1 = new EndpointPropertyValue("PID1");
+
+ EndpointPropertyType etp2 = new EndpointPropertyType(
+ new ResourceSpecificEndpointProperty("priv:ietf-mac.prop"));
+ EndpointPropertyValue epv2 = new EndpointPropertyValue(mac);
+
+ endpointPropertyMap.put(ipAddress, "ipv4");
+
+ Properties ps1 = new PropertiesBuilder().setPropertyType(etp1)
+ .setProperty(epv1).build();
+ Properties ps2 = new PropertiesBuilder().setPropertyType(etp2)
+ .setProperty(epv2).build();
+
+ List<Properties> psList = new ArrayList<Properties>();
+ psList.add(ps1);
+ psList.add(ps2);
+
+ EndpointProperties ep = new EndpointPropertiesBuilder()
+ .setEndpoint(tea).setProperties(psList).build();
+
+ InstanceIdentifier<EndpointProperties> ALTO_EP = InstanceIdentifier
+ .builder(Resources.class)
+ .child(EndpointPropertyMap.class)
+ .child(EndpointProperties.class,
+ new EndpointPropertiesKey(tea)).build();
+
+ final WriteTransaction tx = dataService.newWriteOnlyTransaction();
+ if (tx == null)
+ return;
+ try {
+ tx.merge(LogicalDatastoreType.CONFIGURATION, ALTO_EP, ep, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ submit(tx);
+ }
+
+ }
+
+ public void mergeNetworkMapForAddressesList(List<Addresses> addrsList,
+ String resourceIdString, String pidString, String addressType) {
+ ResourceId rid = new ResourceId(new ValidIdString(resourceIdString));
+ ValidIdString vis = new ValidIdString(pidString);
+ PidName pid = new PidName(vis);
+
+ EndpointAddressType eat;
+ if (addressType == "ipv4") {
+ eat = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv4);
+ } else {
+ eat = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv6);
+ }
+
+ InstanceIdentifier<EndpointAddressGroup> ALTO_EAG = InstanceIdentifier
+ .builder(Resources.class)
+ .child(NetworkMaps.class)
+ .child(NetworkMap.class, new NetworkMapKey(rid))
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map.class,
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey(
+ pid))
+ .child(EndpointAddressGroup.class,
+ new EndpointAddressGroupKey(eat)).build();
+
+ List<IpPrefix> epList = new ArrayList<IpPrefix>();
+
+ if (addrsList == null) {
+ // IpPrefix ep = new IpPrefix(new Ipv4Prefix("1.1.1.1/32"));
+ // epList.add(ep);
+ return;
+ } else {
+ for (int i = 0; i < addrsList.size(); i++) {
+ Addresses addrs = addrsList.get(i);
+ if (addrs.getIp() == null)
+ continue;
+ String ipAddress = addrs.getIp().toString();
+
+ Matcher m = p.matcher(ipAddress);
+ if (m.find())
+ ipAddress = m.group();
+ else
+ continue;
+ ipAddress += "/32";
+ if (networkMap.containsKey(ipAddress))
+ continue;
+ IpPrefix ep = new IpPrefix(new Ipv4Prefix(ipAddress));
+ epList.add(ep);
+ networkMap.put(ipAddress, pidString);
+ }
+ }
+ if (epList.size() == 0)
+ return;
+
+ final WriteTransaction tx = dataService.newWriteOnlyTransaction();
+
+ if (tx == null)
+ return;
+
+ EndpointAddressGroup eag = new EndpointAddressGroupBuilder()
+ .setAddressType(
+ new EndpointAddressType(
+ EndpointAddressType.Enumeration.Ipv4))
+ .setEndpointPrefix(epList).build();
+
+ try {
+ tx.merge(LogicalDatastoreType.CONFIGURATION, ALTO_EAG, eag, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ submit(tx);
+ }
+
+ public void removeAddressesList(List<Addresses> addrsList,
+ String resourceIdString, String pidString, String addressType) {
+ if (addrsList == null) {
+ return;
+ } else {
+ for (int i = 0; i < addrsList.size(); i++) {
+ Addresses addrs = addrsList.get(i);
+ if (addrs.getIp() == null)
+ continue;
+ String ipAddress = addrs.getIp().toString();
+
+ Matcher m = p.matcher(ipAddress);
+ if (m.find())
+ ipAddress = m.group();
+ else
+ continue;
+
+ if (endpointPropertyMap.containsKey(ipAddress))
+ endpointPropertyMap.remove(ipAddress);
+ else
+ continue;
+
+ TypedIpv4Address ti4 = new TypedIpv4Address("ipv4:" + ipAddress);
+ TypedEndpointAddress tea = new TypedEndpointAddress(ti4);
+
+ InstanceIdentifier<EndpointProperties> ALTO_EP = InstanceIdentifier
+ .builder(Resources.class)
+ .child(EndpointPropertyMap.class)
+ .child(EndpointProperties.class,
+ new EndpointPropertiesKey(tea)).build();
+
+ final WriteTransaction writeTx = this.dataService
+ .newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.OPERATIONAL, ALTO_EP);
+ submit(writeTx);
+
+ ipAddress += "/32";
+ if (networkMap.containsKey(ipAddress))
+ networkMap.remove(ipAddress);
+ else
+ continue;
+
+ }
+ }
+
+ ResourceId rid = new ResourceId(new ValidIdString(resourceIdString));
+ ValidIdString vis = new ValidIdString(pidString);
+ PidName pid = new PidName(vis);
+
+ EndpointAddressType eat;
+ if (addressType == "ipv4") {
+ eat = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv4);
+ } else {
+ eat = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv6);
+ }
+
+ InstanceIdentifier<EndpointAddressGroup> ALTO_EAG = InstanceIdentifier
+ .builder(Resources.class)
+ .child(NetworkMaps.class)
+ .child(NetworkMap.class, new NetworkMapKey(rid))
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map.class,
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey(
+ pid))
+ .child(EndpointAddressGroup.class,
+ new EndpointAddressGroupKey(eat)).build();
+
+ List<IpPrefix> epList = new ArrayList<IpPrefix>();
+
+ Iterator iter = networkMap.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry<String, String> entry = (Map.Entry<String, String>) iter
+ .next();
+ String ipAddress = entry.getKey();
+
+ IpPrefix ep = new IpPrefix(new Ipv4Prefix(ipAddress));
+ epList.add(ep);
+ }
+
+ if (epList.size() == 0) {
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map> ALTO_MP = InstanceIdentifier
+ .builder(Resources.class)
+ .child(NetworkMaps.class)
+ .child(NetworkMap.class, new NetworkMapKey(rid))
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map.class,
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey(
+ pid)).build();
+
+ final WriteTransaction tx = dataService.newWriteOnlyTransaction();
+ if (tx == null)
+ return;
+ try {
+ tx.delete(LogicalDatastoreType.CONFIGURATION, ALTO_MP);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ submit(tx);
+ } else {
+ EndpointAddressGroup eag = new EndpointAddressGroupBuilder()
+ .setAddressType(
+ new EndpointAddressType(
+ EndpointAddressType.Enumeration.Ipv4))
+ .setEndpointPrefix(epList).build();
+
+ final WriteTransaction tx = dataService.newWriteOnlyTransaction();
+ if (tx == null)
+ return;
+ try {
+ tx.put(LogicalDatastoreType.CONFIGURATION, ALTO_EAG, eag, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ submit(tx);
+ }
+ }
+
+ public void registerAsDataChangeListener() {
+ ResourceId ridForDelete = new ResourceId(NMRESOURCEID);
+ InstanceIdentifier<NetworkMap> networkMapForDelete = InstanceIdentifier
+ .builder(Resources.class).child(NetworkMaps.class)
+ .child(NetworkMap.class, new NetworkMapKey(ridForDelete))
+ .build();
+
+ InstanceIdentifier<HostNode> hostNodes = InstanceIdentifier
+ .builder(NetworkTopology.class)//
+ .child(Topology.class,
+ new TopologyKey(new TopologyId(topologyId)))//
+ .child(Node.class).augmentation(HostNode.class).build();
+
+ InstanceIdentifier<Addresses> addrCapableNodeConnectors = //
+ InstanceIdentifier
+ .builder(Nodes.class)
+ //
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class) //
+ .child(NodeConnector.class) //
+ .augmentation(AddressCapableNodeConnector.class)//
+ .child(Addresses.class).build();
+
+ // ReadOnlyTransaction newReadOnlyTransaction =
+ // dataService.newReadOnlyTransaction();
+ InstanceIdentifier<Nodes> iins = addrCapableNodeConnectors
+ .firstIdentifierOf(Nodes.class);
+ // InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node>
+ // iin//
+ // =
+ // addrCapableNodeConnectors.firstIdentifierOf(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class);
+ // ListenableFuture<Optional<NodeConnector>> dataFuture =
+ // newReadOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, iinc);
+ ListenableFuture<Optional<Nodes>> futureNodes;
+ /*
+ * try { NodeConnector get = dataFuture.get().get();
+ * log.info("test "+get); } catch (InterruptedException |
+ * ExecutionException ex) {
+ * //java.util.logging.Logger.getLogger(HostTracker2Impl
+ * .class.getName()).log(Level.SEVERE, null, ex);
+ * log.info("exception on get"); }
+ */
+ try (ReadOnlyTransaction readTx = dataService.newReadOnlyTransaction()) {
+ futureNodes = readTx.read(LogicalDatastoreType.OPERATIONAL, iins);
+ // futureNode = readTx.read(LogicalDatastoreType.OPERATIONAL, iin);
+ readTx.close();
+ }
+ Optional<Nodes> opNodes = null;
+ try {
+ opNodes = futureNodes.get();
+ } catch (ExecutionException | InterruptedException ex) {
+ log.warn(ex.getLocalizedMessage());
+ }
+
+ List<Addresses> addrsList = new ArrayList<Addresses>();
+ if (opNodes != null && opNodes.isPresent()) {
+ // log.info("node connector:"+opNodes.get());
+ Nodes ns = opNodes.get();
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node n : ns
+ .getNode()) {
+ for (NodeConnector nc : n.getNodeConnector()) {
+ AddressCapableNodeConnector acnc = (AddressCapableNodeConnector) nc
+ .getAugmentation(AddressCapableNodeConnector.class);
+ if (acnc != null) {
+ for (Addresses addrs : acnc.getAddresses()) {
+ log.info("existing address: " + addrs);
+ addrsList.add(addrs);
+ mergeEndpointPropertyMapForAddresses(addrs);
+ }
+ }
+ }
+ }
+ }
+ mergeNetworkMapForAddressesList(addrsList, NMRESOURCEID, "pid1", "ipv4");
+ /*
+ * Futures.addCallback(dataFuture, new
+ * FutureCallback<Optional<NodeConnector>>() {
+ * @Override public void onSuccess(final Optional<NodeConnector> result)
+ * { if (result.isPresent()) { log.info("Processing NEW NODE? " +
+ * result.get().getId().getValue()); // processHost(result, dataObject,
+ * node); } }
+ * @Override public void onFailure(Throwable arg0) { } });
+ */
+
+ this.hostNodeListerRegistration = dataService
+ .registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+ hostNodes, this, DataChangeScope.SUBTREE);
+
+ this.networkMapListerRegistration = dataService
+ .registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+ networkMapForDelete, this, DataChangeScope.BASE);
+
+ // log.info("register data change");
+ }
+
+ @Override
+ public void onDataChanged(
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+ exec.submit(new Runnable() {
+ @Override
+ public void run() {
+ if (change == null) {
+ log.info("In onDataChanged: No processing done as change even is null.");
+ return;
+ }
+ Map<InstanceIdentifier<?>, DataObject> updatedData = change
+ .getUpdatedData();
+ Map<InstanceIdentifier<?>, DataObject> createdData = change
+ .getCreatedData();
+ Map<InstanceIdentifier<?>, DataObject> originalData = change
+ .getOriginalData();
+ Set<InstanceIdentifier<?>> deletedData = change
+ .getRemovedPaths();
+
+ for (InstanceIdentifier<?> iid : deletedData) {
+ log.info("deletedData");
+ if (iid.getTargetType().equals(Node.class)) {
+ Node node = ((Node) originalData.get(iid));
+ HostNode hostNode = node
+ .getAugmentation(HostNode.class);
+ if (hostNode != null) {
+ List<Addresses> addrsList = hostNode.getAddresses();
+ removeAddressesList(addrsList, NMRESOURCEID,
+ "pid1", "ipv4");
+ }
+ } else if (iid.getTargetType().equals(NetworkMap.class)) {
+ networkMap.clear();
+ endpointPropertyMap.clear();
+ close();
+ log.info("delete all!");
+ }
+ }
+
+ for (Map.Entry<InstanceIdentifier<?>, DataObject> entrySet : updatedData
+ .entrySet()) {
+ InstanceIdentifier<?> iiD = entrySet.getKey();
+ final DataObject dataObject = entrySet.getValue();
+ if (dataObject instanceof Addresses) {
+ Addresses addrs = (Addresses) dataObject;
+ log.info("updatedData addresses:" + addrs);
+ List<Addresses> addrsList = new ArrayList();
+ addrsList.add(addrs);
+ mergeNetworkMapForAddressesList(addrsList,
+ NMRESOURCEID, "pid1", "ipv4");
+ mergeEndpointPropertyMapForAddresses(addrs);
+
+ } else if (dataObject instanceof Node) {
+ log.info("updatedData node");
+ }
+ }
+
+ for (Map.Entry<InstanceIdentifier<?>, DataObject> entrySet : createdData
+ .entrySet()) {
+ InstanceIdentifier<?> iiD = entrySet.getKey();
+ final DataObject dataObject = entrySet.getValue();
+ if (dataObject instanceof Addresses) {
+ Addresses addrs = (Addresses) dataObject;
+ log.info("createdData addresses:" + addrs);
+ List<Addresses> addrsList = new ArrayList();
+ addrsList.add(addrs);
+ mergeNetworkMapForAddressesList(addrsList,
+ NMRESOURCEID, "pid1", "ipv4");
+ mergeEndpointPropertyMapForAddresses(addrs);
+ } else if (dataObject instanceof Node) {
+ log.info("createdData node");
+ }
+ }
+ }
+ });
+ }
+
+ public void close() {
+ this.hostNodeListerRegistration.close();
+ }
+}
--- /dev/null
+package org.opendaylight.alto.altohosttracker.plugin.internal;
+
+import java.util.Random;
+
+public class TagGenerator {
+ public static String getTag(int length){
+ String base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ Random random = new Random();
+ StringBuffer sb = new StringBuffer();
+ for(int i =0;i<length;i++){
+ int number = random.nextInt(base.length());
+ sb.append(base.charAt(number));
+ }
+ return sb.toString();
+ }
+}
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.alto.altohosttracker.plugin.internal.AltoHostTrackerImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AltoHostTrackerModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.AbstractAltoHostTrackerModule {
+
+ private static final Logger log = LoggerFactory.getLogger(AltoHostTrackerModule.class);
+
+ AltoHostTrackerImpl altoHostTrackerImpl;
+
+ public AltoHostTrackerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public AltoHostTrackerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.AltoHostTrackerModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ DataBroker dataService = getDataBrokerDependency();
+ if (dataService == null)log.info("data broker is null");
+
+ altoHostTrackerImpl = new AltoHostTrackerImpl(dataService, null);
+
+ altoHostTrackerImpl.writeDefaultNetworkMaps();
+ altoHostTrackerImpl.writeDefaultCostMaps();
+ altoHostTrackerImpl.writeDefaultEndpointpropertyMap();
+
+ //altoHostTrackerImpl.mergeNetworkMapForAddressesList(null, "default-network-map", "pid0", "ipv4");
+
+ altoHostTrackerImpl.registerAsDataChangeListener();
+
+ log.info("write complete.");
+ //mdHostTrackerImpl.readTest();
+ final class CloseResources implements AutoCloseable {
+ @Override
+ public void close() throws Exception {
+ if(altoHostTrackerImpl != null) {
+ altoHostTrackerImpl.close();
+ }
+ log.info("AltoHostTrackerImpl (instance {}) torn down.", this);
+ }
+ }
+ AutoCloseable ret = new CloseResources();
+ log.info("AltoHostTrackerImpl (instance {}) initialized.", ret);
+ return ret;
+ }
+
+}
--- /dev/null
+/*
+* Generated file
+*
+* Generated from: yang module name: alto-host-tracker-impl yang module local name: alto-host-tracker-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Tue Apr 14 09:35:38 PDT 2015
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528;
+public class AltoHostTrackerModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.AbstractAltoHostTrackerModuleFactory {
+
+}
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528;
+
+public final class $YangModelBindingProvider implements org.opendaylight.yangtools.yang.binding.YangModelBindingProvider {
+
+ public org.opendaylight.yangtools.yang.binding.YangModuleInfo getModuleInfo() {
+ return $YangModuleInfoImpl.getInstance();
+ }
+}
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528 ;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import java.util.Set;
+import java.util.HashSet;
+import com.google.common.collect.ImmutableSet;
+import java.io.InputStream;
+import java.io.IOException;
+public final class $YangModuleInfoImpl implements YangModuleInfo {
+
+ private static final YangModuleInfo INSTANCE = new $YangModuleInfoImpl();
+
+ private final String name = "alto-host-tracker-impl";
+ private final String namespace = "urn:opendaylight:alto:alto-host-tracker-impl";
+ private final String revision = "2014-05-28";
+ private final String resourcePath = "/META-INF/yang/alto-host-tracker-impl.yang";
+
+ private final Set<YangModuleInfo> importedModules;
+
+ public static YangModuleInfo getInstance() {
+ return INSTANCE;
+ }
+
+ private $YangModuleInfoImpl() {
+ Set<YangModuleInfo> set = new HashSet<>();
+ set.add(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.binding.rev131028.$YangModuleInfoImpl.getInstance());
+ set.add(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.$YangModuleInfoImpl.getInstance());
+ importedModules = ImmutableSet.copyOf(set);
+
+ InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath);
+ if (stream == null) {
+ throw new IllegalStateException("Resource '" + resourcePath + "' is missing");
+ }
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // Resource leak, but there is nothing we can do
+ }
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getRevision() {
+ return revision;
+ }
+
+ @Override
+ public String getNamespace() {
+ return namespace;
+ }
+
+ @Override
+ public InputStream getModuleSourceStream() throws IOException {
+ InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath);
+ if (stream == null) {
+ throw new IOException("Resource " + resourcePath + " is missing");
+ }
+ return stream;
+ }
+
+ @Override
+ public Set<YangModuleInfo> getImportedModules() {
+ return importedModules;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(this.getClass().getCanonicalName());
+ sb.append("[");
+ sb.append("name = " + name);
+ sb.append(", namespace = " + namespace);
+ sb.append(", revision = " + revision);
+ sb.append(", resourcePath = " + resourcePath);
+ sb.append(", imports = " + importedModules);
+ sb.append("]");
+ return sb.toString();
+ }
+
+
+}
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ModuleType;
+
+
+/**
+ * <p>This class represents the following YANG schema fragment defined in module <b>alto-host-tracker-impl</b>
+ * <br>(Source path: <i>META-INF/yang/alto-host-tracker-impl.yang</i>):
+ * <pre>
+ * identity alto-host-tracker-impl {
+ * base "()IdentitySchemaNodeImpl[base=null, qname=(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)module-type]";
+ * status CURRENT;
+ * }
+ * </pre>
+ * The schema path to identify an instance is
+ * <i>alto-host-tracker-impl/alto-host-tracker-impl</i>
+ *
+ */
+public abstract class AltoHostTrackerImpl extends ModuleType
+ {
+ public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.cachedReference(org.opendaylight.yangtools.yang.common.QName.create("urn:opendaylight:alto:alto-host-tracker-impl","2014-05-28","alto-host-tracker-impl"));
+
+ public AltoHostTrackerImpl() {
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+}
+
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.modules.module.Configuration;
+import org.opendaylight.yangtools.yang.binding.Augmentable;
+
+
+/**
+ * <p>This class represents the following YANG schema fragment defined in module <b>alto-host-tracker-impl</b>
+ * <br>(Source path: <i>META-INF/yang/alto-host-tracker-impl.yang</i>):
+ * <pre>
+ * case alto-host-tracker-impl {
+ * leaf topology-id {
+ * type string;
+ * }
+ * container data-broker {
+ * leaf type {
+ * type leafref;
+ * }
+ * leaf name {
+ * type leafref;
+ * }
+ * uses service-ref {
+ * refine (urn:opendaylight:alto:alto-host-tracker-impl?revision=2014-05-28)type {
+ * leaf type {
+ * type leafref;
+ * }
+ * }
+ * }
+ * }
+ * }
+ * </pre>
+ * The schema path to identify an instance is
+ * <i>alto-host-tracker-impl/modules/module/configuration/(urn:opendaylight:alto:alto-host-tracker-impl?revision=2014-05-28)alto-host-tracker-impl</i>
+ *
+ */
+public interface AltoHostTrackerImpl
+ extends
+ DataObject,
+ Augmentable<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>,
+ Configuration
+{
+
+
+
+ public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.cachedReference(org.opendaylight.yangtools.yang.common.QName.create("urn:opendaylight:alto:alto-host-tracker-impl","2014-05-28","alto-host-tracker-impl"));
+
+ java.lang.String getTopologyId();
+
+ DataBroker getDataBroker();
+
+}
+
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration;
+import java.util.Collections;
+import java.util.Map;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
+import java.util.HashMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+
+/**
+ * Class that builds {@link org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl} instances.
+ *
+ * @see org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl
+ *
+ */
+public class AltoHostTrackerImplBuilder implements Builder <org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl> {
+
+ private DataBroker _dataBroker;
+ private java.lang.String _topologyId;
+
+ Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>> augmentation = new HashMap<>();
+
+ public AltoHostTrackerImplBuilder() {
+ }
+
+ public AltoHostTrackerImplBuilder(AltoHostTrackerImpl base) {
+ this._dataBroker = base.getDataBroker();
+ this._topologyId = base.getTopologyId();
+ if (base instanceof AltoHostTrackerImplImpl) {
+ AltoHostTrackerImplImpl impl = (AltoHostTrackerImplImpl) base;
+ this.augmentation = new HashMap<>(impl.augmentation);
+ } else if (base instanceof AugmentationHolder) {
+ @SuppressWarnings("unchecked")
+ AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>) base;
+ this.augmentation = new HashMap<>(casted.augmentations());
+ }
+ }
+
+
+ public DataBroker getDataBroker() {
+ return _dataBroker;
+ }
+
+ public java.lang.String getTopologyId() {
+ return _topologyId;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <E extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>> E getAugmentation(java.lang.Class<E> augmentationType) {
+ if (augmentationType == null) {
+ throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
+ }
+ return (E) augmentation.get(augmentationType);
+ }
+
+ public AltoHostTrackerImplBuilder setDataBroker(DataBroker value) {
+ this._dataBroker = value;
+ return this;
+ }
+
+ public AltoHostTrackerImplBuilder setTopologyId(java.lang.String value) {
+ this._topologyId = value;
+ return this;
+ }
+
+ public AltoHostTrackerImplBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl> augmentation) {
+ if (augmentation == null) {
+ return removeAugmentation(augmentationType);
+ }
+ this.augmentation.put(augmentationType, augmentation);
+ return this;
+ }
+
+ public AltoHostTrackerImplBuilder removeAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>> augmentationType) {
+ this.augmentation.remove(augmentationType);
+ return this;
+ }
+
+ public AltoHostTrackerImpl build() {
+ return new AltoHostTrackerImplImpl(this);
+ }
+
+ private static final class AltoHostTrackerImplImpl implements AltoHostTrackerImpl {
+
+ public java.lang.Class<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl> getImplementedInterface() {
+ return org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl.class;
+ }
+
+ private final DataBroker _dataBroker;
+ private final java.lang.String _topologyId;
+
+ private Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>> augmentation = new HashMap<>();
+
+ private AltoHostTrackerImplImpl(AltoHostTrackerImplBuilder base) {
+ this._dataBroker = base.getDataBroker();
+ this._topologyId = base.getTopologyId();
+ switch (base.augmentation.size()) {
+ case 0:
+ this.augmentation = Collections.emptyMap();
+ break;
+ case 1:
+ final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>> e = base.augmentation.entrySet().iterator().next();
+ this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>>singletonMap(e.getKey(), e.getValue());
+ break;
+ default :
+ this.augmentation = new HashMap<>(base.augmentation);
+ }
+ }
+
+ @Override
+ public DataBroker getDataBroker() {
+ return _dataBroker;
+ }
+
+ @Override
+ public java.lang.String getTopologyId() {
+ return _topologyId;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <E extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>> E getAugmentation(java.lang.Class<E> augmentationType) {
+ if (augmentationType == null) {
+ throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
+ }
+ return (E) augmentation.get(augmentationType);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((_dataBroker == null) ? 0 : _dataBroker.hashCode());
+ result = prime * result + ((_topologyId == null) ? 0 : _topologyId.hashCode());
+ result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof DataObject)) {
+ return false;
+ }
+ if (!org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl.class.equals(((DataObject)obj).getImplementedInterface())) {
+ return false;
+ }
+ org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl other = (org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl)obj;
+ if (_dataBroker == null) {
+ if (other.getDataBroker() != null) {
+ return false;
+ }
+ } else if(!_dataBroker.equals(other.getDataBroker())) {
+ return false;
+ }
+ if (_topologyId == null) {
+ if (other.getTopologyId() != null) {
+ return false;
+ }
+ } else if(!_topologyId.equals(other.getTopologyId())) {
+ return false;
+ }
+ if (getClass() == obj.getClass()) {
+ // Simple case: we are comparing against self
+ AltoHostTrackerImplImpl otherImpl = (AltoHostTrackerImplImpl) obj;
+ if (augmentation == null) {
+ if (otherImpl.augmentation != null) {
+ return false;
+ }
+ } else if(!augmentation.equals(otherImpl.augmentation)) {
+ return false;
+ }
+ } else {
+ // Hard case: compare our augments with presence there...
+ for (Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.AltoHostTrackerImpl>> e : augmentation.entrySet()) {
+ if (!e.getValue().equals(other.getAugmentation(e.getKey()))) {
+ return false;
+ }
+ }
+ // .. and give the other one the chance to do the same
+ if (!obj.equals(this)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public java.lang.String toString() {
+ java.lang.StringBuilder builder = new java.lang.StringBuilder ("AltoHostTrackerImpl [");
+ boolean first = true;
+
+ if (_dataBroker != null) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("_dataBroker=");
+ builder.append(_dataBroker);
+ }
+ if (_topologyId != null) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("_topologyId=");
+ builder.append(_topologyId);
+ }
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("augmentation=");
+ builder.append(augmentation.values());
+ return builder.append(']').toString();
+ }
+ }
+
+}
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.Augmentable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.modules.Module;
+
+
+/**
+ * <p>This class represents the following YANG schema fragment defined in module <b>alto-host-tracker-impl</b>
+ * <br>(Source path: <i>META-INF/yang/alto-host-tracker-impl.yang</i>):
+ * <pre>
+ * container data-broker {
+ * leaf type {
+ * type leafref;
+ * }
+ * leaf name {
+ * type leafref;
+ * }
+ * uses service-ref {
+ * refine (urn:opendaylight:alto:alto-host-tracker-impl?revision=2014-05-28)type {
+ * leaf type {
+ * type leafref;
+ * }
+ * }
+ * }
+ * }
+ * </pre>
+ * The schema path to identify an instance is
+ * <i>alto-host-tracker-impl/modules/module/configuration/(urn:opendaylight:alto:alto-host-tracker-impl?revision=2014-05-28)alto-host-tracker-impl/data-broker</i>
+ *
+ * <p>To create instances of this class use {@link org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBrokerBuilder}.
+ * @see org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBrokerBuilder
+ *
+ */
+public interface DataBroker
+ extends
+ ChildOf<Module>,
+ Augmentable<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>,
+ ServiceRef
+{
+
+
+
+ public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.cachedReference(org.opendaylight.yangtools.yang.common.QName.create("urn:opendaylight:alto:alto-host-tracker-impl","2014-05-28","data-broker"));
+
+
+}
+
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl;
+import java.util.Collections;
+import java.util.Map;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
+import java.util.HashMap;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+
+/**
+ * Class that builds {@link org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker} instances.
+ *
+ * @see org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker
+ *
+ */
+public class DataBrokerBuilder implements Builder <org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker> {
+
+ private java.lang.Object _name;
+ private java.lang.Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceType> _type;
+
+ Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>> augmentation = new HashMap<>();
+
+ public DataBrokerBuilder() {
+ }
+ public DataBrokerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef arg) {
+ this._type = arg.getType();
+ this._name = arg.getName();
+ }
+
+ public DataBrokerBuilder(DataBroker base) {
+ this._name = base.getName();
+ this._type = base.getType();
+ if (base instanceof DataBrokerImpl) {
+ DataBrokerImpl impl = (DataBrokerImpl) base;
+ this.augmentation = new HashMap<>(impl.augmentation);
+ } else if (base instanceof AugmentationHolder) {
+ @SuppressWarnings("unchecked")
+ AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>) base;
+ this.augmentation = new HashMap<>(casted.augmentations());
+ }
+ }
+
+ /**
+ *Set fields from given grouping argument. Valid argument is instance of one of following types:
+ * <ul>
+ * <li>org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef</li>
+ * </ul>
+ *
+ * @param arg grouping object
+ * @throws IllegalArgumentException if given argument is none of valid types
+ */
+ public void fieldsFrom(DataObject arg) {
+ boolean isValidArg = false;
+ if (arg instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef) {
+ this._type = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef)arg).getType();
+ this._name = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef)arg).getName();
+ isValidArg = true;
+ }
+ if (!isValidArg) {
+ throw new IllegalArgumentException(
+ "expected one of: [org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef] \n" +
+ "but was: " + arg
+ );
+ }
+ }
+
+ public java.lang.Object getName() {
+ return _name;
+ }
+
+ public java.lang.Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceType> getType() {
+ return _type;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <E extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>> E getAugmentation(java.lang.Class<E> augmentationType) {
+ if (augmentationType == null) {
+ throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
+ }
+ return (E) augmentation.get(augmentationType);
+ }
+
+ public DataBrokerBuilder setName(java.lang.Object value) {
+ this._name = value;
+ return this;
+ }
+
+ public DataBrokerBuilder setType(java.lang.Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceType> value) {
+ this._type = value;
+ return this;
+ }
+
+ public DataBrokerBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker> augmentation) {
+ if (augmentation == null) {
+ return removeAugmentation(augmentationType);
+ }
+ this.augmentation.put(augmentationType, augmentation);
+ return this;
+ }
+
+ public DataBrokerBuilder removeAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>> augmentationType) {
+ this.augmentation.remove(augmentationType);
+ return this;
+ }
+
+ public DataBroker build() {
+ return new DataBrokerImpl(this);
+ }
+
+ private static final class DataBrokerImpl implements DataBroker {
+
+ public java.lang.Class<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker> getImplementedInterface() {
+ return org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker.class;
+ }
+
+ private final java.lang.Object _name;
+ private final java.lang.Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceType> _type;
+
+ private Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>> augmentation = new HashMap<>();
+
+ private DataBrokerImpl(DataBrokerBuilder base) {
+ this._name = base.getName();
+ this._type = base.getType();
+ switch (base.augmentation.size()) {
+ case 0:
+ this.augmentation = Collections.emptyMap();
+ break;
+ case 1:
+ final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>> e = base.augmentation.entrySet().iterator().next();
+ this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>>singletonMap(e.getKey(), e.getValue());
+ break;
+ default :
+ this.augmentation = new HashMap<>(base.augmentation);
+ }
+ }
+
+ @Override
+ public java.lang.Object getName() {
+ return _name;
+ }
+
+ @Override
+ public java.lang.Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceType> getType() {
+ return _type;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <E extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>> E getAugmentation(java.lang.Class<E> augmentationType) {
+ if (augmentationType == null) {
+ throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
+ }
+ return (E) augmentation.get(augmentationType);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((_name == null) ? 0 : _name.hashCode());
+ result = prime * result + ((_type == null) ? 0 : _type.hashCode());
+ result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof DataObject)) {
+ return false;
+ }
+ if (!org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker.class.equals(((DataObject)obj).getImplementedInterface())) {
+ return false;
+ }
+ org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker other = (org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker)obj;
+ if (_name == null) {
+ if (other.getName() != null) {
+ return false;
+ }
+ } else if(!_name.equals(other.getName())) {
+ return false;
+ }
+ if (_type == null) {
+ if (other.getType() != null) {
+ return false;
+ }
+ } else if(!_type.equals(other.getType())) {
+ return false;
+ }
+ if (getClass() == obj.getClass()) {
+ // Simple case: we are comparing against self
+ DataBrokerImpl otherImpl = (DataBrokerImpl) obj;
+ if (augmentation == null) {
+ if (otherImpl.augmentation != null) {
+ return false;
+ }
+ } else if(!augmentation.equals(otherImpl.augmentation)) {
+ return false;
+ }
+ } else {
+ // Hard case: compare our augments with presence there...
+ for (Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.alto.host.tracker.impl.rev140528.modules.module.configuration.alto.host.tracker.impl.DataBroker>> e : augmentation.entrySet()) {
+ if (!e.getValue().equals(other.getAugmentation(e.getKey()))) {
+ return false;
+ }
+ }
+ // .. and give the other one the chance to do the same
+ if (!obj.equals(this)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public java.lang.String toString() {
+ java.lang.StringBuilder builder = new java.lang.StringBuilder ("DataBroker [");
+ boolean first = true;
+
+ if (_name != null) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("_name=");
+ builder.append(_name);
+ }
+ if (_type != null) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("_type=");
+ builder.append(_type);
+ }
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("augmentation=");
+ builder.append(augmentation.values());
+ return builder.append(']').toString();
+ }
+ }
+
+}
--- /dev/null
+module alto-host-tracker-impl {
+
+ yang-version 1;
+ namespace "urn:opendaylight:alto:alto-host-tracker-impl";
+ prefix "alto-host-tracker-impl";
+
+ import config { prefix config; revision-date 2013-04-05; }
+ import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
+
+ description
+ "This module contains the base YANG definitions for
+ alto-host-tracker-impl implementation.";
+
+ revision 2014-05-28 {
+ description "Initial module draft.";
+ }
+
+ // This is the definition of the service implementation as a module identity.
+ identity alto-host-tracker-impl {
+ base config:module-type;
+
+ // Specifies the prefix for generated java classes.
+ config:java-name-prefix AltoHostTracker;
+ }
+
+ // Augments the 'configuration' choice node under modules/module.
+ // We consume the three main services, RPCs, DataStore, and Notifications
+ augment "/config:modules/config:module/config:configuration" {
+ case alto-host-tracker-impl {
+ when "/config:modules/config:module/config:type = 'alto-host-tracker-impl'";
+
+ leaf topology-id {
+ type string;
+ }
+ container data-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory false;
+ config:required-identity mdsal:binding-async-data-broker;
+ }
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2014 André Martins, Colin Dixon, Evan Zeller 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.altohosttracker.plugin.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.address.tracker.rev140617.address.node.connector.Addresses;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.address.tracker.rev140617.address.node.connector.AddressesBuilder;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.mock;
+
+public class AltoHostTrackerImplTest {
+
+ private AltoHostTrackerImpl altoHostTrackerImpl;
+ private Addresses addrs;
+ private DataBroker dataBroker;
+ private IpAddress ipAddress;
+ private MacAddress mac;
+
+ @Before
+ public void init(){
+ dataBroker = mock(DataBroker.class);
+ altoHostTrackerImpl = new AltoHostTrackerImpl(dataBroker,"flow:1");
+ }
+
+ @Test
+ public void onMergeEndpointPropertyMapTest() throws Exception {
+ ipAddress = new IpAddress(new Ipv4Address("10.0.0.1"));
+ mac = new MacAddress("00:00:00:00:00:01");
+ addrs = new AddressesBuilder().setIp(ipAddress).setMac(mac).build();
+ altoHostTrackerImpl.mergeEndpointPropertyMapForAddresses(addrs);
+ verify(dataBroker).newWriteOnlyTransaction();
+ }
+
+ @Test
+ public void onMergeNetworkMapTest() throws Exception {
+ ipAddress = new IpAddress(new Ipv4Address("10.0.0.1"));
+ mac = new MacAddress("00:00:00:00:00:01");
+ addrs = new AddressesBuilder().setIp(ipAddress).setMac(mac).build();
+ List<Addresses> addrsList = new ArrayList<Addresses>();
+ addrsList.add(addrs);
+ altoHostTrackerImpl.mergeNetworkMapForAddressesList(addrsList, "default-network-map", "pid1", "ipv4");
+ verify(dataBroker).newWriteOnlyTransaction();
+ }
+
+ @Test
+ public void onRemoveAddressesTest() throws Exception {
+ ipAddress = new IpAddress(new Ipv4Address("10.0.0.1"));
+ mac = new MacAddress("00:00:00:00:00:01");
+ addrs = new AddressesBuilder().setIp(ipAddress).setMac(mac).build();
+ List<Addresses> addrsList = new ArrayList<Addresses>();
+ addrsList.add(addrs);
+ altoHostTrackerImpl.removeAddressesList(addrsList, "default-network-map", "pid1", "ipv4");
+ verify(dataBroker).newWriteOnlyTransaction();
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.alto.alto-hosttracker</groupId>
+ <artifactId>alto-hosttracker.aggregator</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+ <groupId>org.opendaylight.alto.alto-hosttracker</groupId>
+ <artifactId>alto-hosttracker-model</artifactId>
+ <name>alto-hosttracker-model</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.alto</groupId>
+ <artifactId>alto-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+ <Import-Package>org.opendaylight.yangtools.yang.binding.annotations, *</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-sources</goal>
+ </goals>
+ <configuration>
+ <yangFilesRootDir>src/main/yang</yangFilesRootDir>
+ <codeGenerators>
+ <generator>
+ <codeGeneratorClass>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
+ <outputBaseDir>src/main/yang-gen-code</outputBaseDir>
+ </generator>
+ </codeGenerators>
+ <inspectDependencies>true</inspectDependencies>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>maven-sal-api-gen-plugin</artifactId>
+ <version>${yangtools.version}</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416;
+
+public final class $YangModelBindingProvider implements org.opendaylight.yangtools.yang.binding.YangModelBindingProvider {
+
+ public org.opendaylight.yangtools.yang.binding.YangModuleInfo getModuleInfo() {
+ return $YangModuleInfoImpl.getInstance();
+ }
+}
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416 ;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import java.util.Set;
+import java.util.HashSet;
+import com.google.common.collect.ImmutableSet;
+import java.io.InputStream;
+import java.io.IOException;
+public final class $YangModuleInfoImpl implements YangModuleInfo {
+
+ private static final YangModuleInfo INSTANCE = new $YangModuleInfoImpl();
+
+ private final String name = "alto-hosttracker-cost-service";
+ private final String namespace = "urn:opendaylight:alto";
+ private final String revision = "2015-04-16";
+ private final String resourcePath = "/META-INF/yang/alto-hosttracker-cost-service.yang";
+
+ private final Set<YangModuleInfo> importedModules;
+
+ public static YangModuleInfo getInstance() {
+ return INSTANCE;
+ }
+
+ private $YangModuleInfoImpl() {
+ Set<YangModuleInfo> set = new HashSet<>();
+ set.add(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.$YangModuleInfoImpl.getInstance());
+ set.add(org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.$YangModuleInfoImpl.getInstance());
+ set.add(org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.$YangModuleInfoImpl.getInstance());
+ importedModules = ImmutableSet.copyOf(set);
+
+ InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath);
+ if (stream == null) {
+ throw new IllegalStateException("Resource '" + resourcePath + "' is missing");
+ }
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // Resource leak, but there is nothing we can do
+ }
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getRevision() {
+ return revision;
+ }
+
+ @Override
+ public String getNamespace() {
+ return namespace;
+ }
+
+ @Override
+ public InputStream getModuleSourceStream() throws IOException {
+ InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath);
+ if (stream == null) {
+ throw new IOException("Resource " + resourcePath + " is missing");
+ }
+ return stream;
+ }
+
+ @Override
+ public Set<YangModuleInfo> getImportedModules() {
+ return importedModules;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(this.getClass().getCanonicalName());
+ sb.append("[");
+ sb.append("name = " + name);
+ sb.append(", namespace = " + namespace);
+ sb.append(", revision = " + revision);
+ sb.append(", resourcePath = " + resourcePath);
+ sb.append(", imports = " + importedModules);
+ sb.append("]");
+ return sb.toString();
+ }
+
+
+}
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+
+/**
+ * cost set in hosttracker
+ *
+ * <p>This class represents the following YANG schema fragment defined in module <b>alto-hosttracker-cost-service</b>
+ * <br>(Source path: <i>META-INF/yang/alto-hosttracker-cost-service .yang</i>):
+ * <pre>
+ * grouping cost {
+ * leaf cost-value {
+ * type int32;
+ * }
+ * }
+ * </pre>
+ * The schema path to identify an instance is
+ * <i>alto-hosttracker-cost-service/cost</i>
+ *
+ */
+public interface Cost
+ extends
+ DataObject
+{
+
+
+
+ public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.cachedReference(org.opendaylight.yangtools.yang.common.QName.create("urn:opendaylight:alto","2015-04-16","cost"));
+
+ java.lang.Integer getCostValue();
+
+}
+
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.map.DstCosts;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+
+public interface DstCosts1
+ extends
+ DataObject,
+ Augmentation<DstCosts>
+{
+
+
+
+
+ java.lang.Integer getCostInHosttracker();
+
+}
+
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.concepts.Builder;
+
+
+/**
+ * Class that builds {@link org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416.DstCosts1} instances.
+ *
+ * @see org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416.DstCosts1
+ *
+ */
+public class DstCosts1Builder implements Builder <org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416.DstCosts1> {
+
+ private java.lang.Integer _costInHosttracker;
+
+
+ public DstCosts1Builder() {
+ }
+
+ public DstCosts1Builder(DstCosts1 base) {
+ this._costInHosttracker = base.getCostInHosttracker();
+ }
+
+
+ public java.lang.Integer getCostInHosttracker() {
+ return _costInHosttracker;
+ }
+
+ public DstCosts1Builder setCostInHosttracker(java.lang.Integer value) {
+ this._costInHosttracker = value;
+ return this;
+ }
+
+ public DstCosts1 build() {
+ return new DstCosts1Impl(this);
+ }
+
+ private static final class DstCosts1Impl implements DstCosts1 {
+
+ public java.lang.Class<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416.DstCosts1> getImplementedInterface() {
+ return org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416.DstCosts1.class;
+ }
+
+ private final java.lang.Integer _costInHosttracker;
+
+
+ private DstCosts1Impl(DstCosts1Builder base) {
+ this._costInHosttracker = base.getCostInHosttracker();
+ }
+
+ @Override
+ public java.lang.Integer getCostInHosttracker() {
+ return _costInHosttracker;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((_costInHosttracker == null) ? 0 : _costInHosttracker.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof DataObject)) {
+ return false;
+ }
+ if (!org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416.DstCosts1.class.equals(((DataObject)obj).getImplementedInterface())) {
+ return false;
+ }
+ org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416.DstCosts1 other = (org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150416.DstCosts1)obj;
+ if (_costInHosttracker == null) {
+ if (other.getCostInHosttracker() != null) {
+ return false;
+ }
+ } else if(!_costInHosttracker.equals(other.getCostInHosttracker())) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public java.lang.String toString() {
+ java.lang.StringBuilder builder = new java.lang.StringBuilder ("DstCosts1 [");
+ boolean first = true;
+
+ if (_costInHosttracker != null) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("_costInHosttracker=");
+ builder.append(_costInHosttracker);
+ }
+ return builder.append(']').toString();
+ }
+ }
+
+}
--- /dev/null
+module alto-hosttracker-cost-service {
+ namespace "urn:opendaylight:alto";
+ prefix alto-host-track-cost;
+
+ import ietf-yang-types {prefix yang;}
+ import alto-service {prefix alto-restconf;}
+ import alto-service-types {prefix alto;}
+
+ revision 2015-04-16 {
+ description
+ "augment cost in alto-service-types";
+ }
+
+ grouping cost {
+ description "cost set in hosttracker";
+ leaf cost-value {
+ type int32;
+ }
+ }
+
+ augment "/alto-restconf:resources/alto-restconf:cost-maps/alto-restconf:cost-map/alto-restconf:map/alto-restconf:dst-costs" {
+ when "/alto-restconf:resources/alto-restconf:cost-maps/alto-restconf:cost-map/alto-restconf:meta/alto-restconf:cost-type/alto-restconf:cost-mode == 'numerical'";
+ leaf cost-in-hosttracker {
+ type int32;
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <name>alto-hosttracker.aggregator</name>
+ <parent>
+ <groupId>org.opendaylight.alto</groupId>
+ <artifactId>alto-parent</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+ <artifactId>alto-hosttracker.aggregator</artifactId>
+ <groupId>org.opendaylight.alto.alto-hosttracker</groupId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>model</module>
+ <module>implementation</module>
+ <module>config</module>
+ </modules>
+</project>