<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
<version>1.7.0-SNAPSHOT</version>
+ <relativePath/>
</parent>
<groupId>org.opendaylight.alto.basic.endpointcostservice</groupId>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
<version>1.7.0-SNAPSHOT</version>
+ <relativePath/>
</parent>
<groupId>org.opendaylight.alto.basic</groupId>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
<version>1.7.0-SNAPSHOT</version>
+ <relativePath/>
</parent>
<groupId>org.opendaylight.alto.basic</groupId>
+++ /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</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
-
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>alto-commons</artifactId>
- <packaging>bundle</packaging>
-
- <build>
- <plugins>
- <plugin> <!-- OSGi plugin -->
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>*</Import-Package>
- <Export-Package>
- org.opendaylight.alto.commons.*;
- org.opendaylight.alto.commons.helper.*;
- org.opendaylight.alto.commons.types.*;
- org.opendaylight.alto.commons.types.rfc7285.*;
- </Export-Package>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <artifactId>junit</artifactId>
- <groupId>junit</groupId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-model</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.helper;
-
-public abstract class Converter<I, O> {
- private I _in = null;
- private O _out = null;
-
- public Converter() {
- }
-
- public Converter(I in) {
- this._in = in;
- this._out = convert();
- }
-
- public O convert() {
- return (O)_convert();
- }
-
- protected abstract Object _convert();
-
- public O convert(I in) {
- return reset(in).out();
- }
-
- public Converter<I, O> reset(I in) {
- this._in = in;
- this._out = convert();
- return this;
- }
-
- public I in() {
- return _in;
- }
-
- public O out() {
- return _out;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.helper;
-
-import java.net.UnknownHostException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.opendaylight.alto.commons.types.Subnet;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap;
-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.TypedEndpointAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
-
-public class NetworkMapIpPrefixHelper {
- private Map<IpPrefix, PidName> prefixToPID = new HashMap<IpPrefix, PidName>();
- private Map<IpPrefix, Subnet> prefixToSubnet = new HashMap<IpPrefix, Subnet>();
- private boolean initiated = false;
-
- public void update(NetworkMap networkMap) throws UnknownHostException {
- clear();
- if (networkMap == null) {
- return;
- }
-
- for (org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map map : networkMap
- .getMap()) {
- for (EndpointAddressGroup group : map.getEndpointAddressGroup()) {
- for (IpPrefix prefix : group.getEndpointPrefix()) {
- this.prefixToPID.put(prefix, map.getPid());
- this.prefixToSubnet.put(prefix,
- new Subnet(group.getAddressType(), prefix));
- }
- }
- }
- initiated = true;
- }
-
- public void clear() {
- this.initiated = false;
- this.prefixToPID.clear();
- this.prefixToSubnet.clear();
- }
-
- public boolean initiated() {
- return this.initiated;
- }
-
- public Map<TypedEndpointAddress, PidName> getPIDsByEndpointAddresses(
- List<TypedEndpointAddress> addresses) {
- Map<TypedEndpointAddress, PidName> pids = new HashMap<TypedEndpointAddress, PidName>();
- for (TypedEndpointAddress address : addresses) {
- PidName pid = null;
- try {
- pid = getPIDByEndpointAddress(address);
- } catch (UnknownHostException e) {
- e.printStackTrace();
- }
- pids.put(address, pid);
- }
- return pids;
- }
-
- public PidName getPIDByEndpointAddress(TypedEndpointAddress address)
- throws UnknownHostException {
- int maxLen = -1;
- PidName pid = null;
- for (IpPrefix prefix : this.prefixToSubnet.keySet()) {
- Subnet sn = this.prefixToSubnet.get(prefix);
- if (sn.match(address) && sn.getSubnetLength() > maxLen) {
- pid = this.prefixToPID.get(prefix);
- maxLen = sn.getSubnetLength();
- }
- }
- return pid;
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.helper;
-
-import java.util.Dictionary;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@SuppressWarnings("rawtypes")
-public class ServiceHelper {
- private static final Logger logger = LoggerFactory
- .getLogger(ServiceHelper.class);
-
- /**
- * Register a Global Service in the OSGi service registry
- *
- * @param clazz
- * The target class
- * @param instance
- * of the object exporting the service, be careful the object must
- * implement/extend clazz else the registration will fail unless a
- * ServiceFactory is passed as parameter
- * @param properties
- * The properties to be attached to the service registration
- * @return the ServiceRegistration if registration happened, null otherwise
- */
- public static ServiceRegistration registerGlobalServiceWReg(Class<?> clazz,
- Object instance, Dictionary<String, Object> properties) {
- try {
- BundleContext bCtx = FrameworkUtil.getBundle(instance.getClass())
- .getBundleContext();
- if (bCtx == null) {
- logger.error("Could not retrieve the BundleContext");
- return null;
- }
-
- ServiceRegistration registration = bCtx.registerService(clazz.getName(),
- instance, properties);
- return registration;
- } catch (Exception e) {
- logger.error("Exception {} while registering the service {}",
- e.getMessage(), instance.toString());
- }
- return null;
- }
-
- /**
- * Retrieve global instance of a class via OSGI registry, if there are many
- * only the first is returned.
- *
- * @param clazz
- * The target class
- * @param bundle
- * The caller
- */
- public static Object getGlobalInstance(Class<?> clazz, Object bundle) {
- return getGlobalInstance(clazz, bundle, null);
- }
-
-
- /**
- * Retrieve global instance of a class via OSGI registry, if there are many
- * only the first is returned. On this version an LDAP type of filter is
- * applied
- *
- * @param clazz
- * The target class
- * @param bundle
- * The caller
- * @param serviceFilter
- * LDAP filter to be applied in the search
- */
- public static Object getGlobalInstance(Class<?> clazz, Object bundle,
- String serviceFilter) {
- Object[] instances = getGlobalInstances(clazz, bundle, serviceFilter);
- if (instances != null) {
- return instances[0];
- }
- return null;
- }
-
- /**
- * Retrieve all the Instances of a Service, optionally filtered via
- * serviceFilter if non-null else all the results are returned if null
- *
- * @param clazz
- * The target class
- * @param bundle
- * The caller
- * @param serviceFilter
- * LDAP filter to be applied in the search
- */
- @SuppressWarnings("unchecked")
- public static Object[] getGlobalInstances(Class<?> clazz, Object bundle,
- String serviceFilter) {
- Object instances[] = null;
- try {
- BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass())
- .getBundleContext();
-
- ServiceReference[] services = bCtx.getServiceReferences(clazz.getName(),
- serviceFilter);
-
- if (services != null) {
- instances = new Object[services.length];
- for (int i = 0; i < services.length; i++) {
- instances[i] = bCtx.getService(services[i]);
- }
- }
- } catch (Exception e) {
- logger.error("Instance reference is NULL");
- }
- return instances;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.helper;
-
-public class TypeWrapper<T extends TypeWrapper, E> {
-
- private E data = null;
-
- public static <T extends TypeWrapper, E> T wrap(T wrapper, E data) {
- wrapper.set(data);
- return wrapper;
- }
-
- public TypeWrapper() {
- data = null;
- }
-
- public TypeWrapper(E data) {
- this.data = data;
- }
-
- public TypeWrapper(TypeWrapper<T, E> wrapper) {
- this.set(wrapper.get());
- }
-
- public E get() {
- return this.data;
- }
-
- public void set(E newData) {
- this.data = newData;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types;
-
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TypedEndpointAddress;
-
-public class Subnet {
- private EndpointAddressType.Enumeration type;
- private int bits;
-
- private int ipv4Subnet;
- private int ipv4Mask;
-
- private int[] ipv6Subnet = new int[4];
- private int[] ipv6Mask = new int[4];
-
- private String prefix;
-
- public Subnet(EndpointAddressType type, IpPrefix prefix)
- throws UnknownHostException {
- this.type = type.getEnumeration();
-
- if (EndpointAddressType.Enumeration.Ipv4.equals(this.type)) {
- subNet(prefix.getIpv4Prefix());
- this.prefix = prefix.getIpv4Prefix().getValue();
- } else if (EndpointAddressType.Enumeration.Ipv6.equals(this.type)) {
- subNet(prefix.getIpv6Prefix());
- this.prefix = prefix.getIpv6Prefix().getValue();
- }
- }
-
- private void subNet(Ipv6Prefix ipv6Prefix) throws UnknownHostException {
- String[] value = ipv6Prefix.getValue().split("[/]");
- this.bits = Integer.parseInt(value[1]);
- ipv6Mask();
- this.ipv6Subnet = ipv6ToInt(value[0]);
- }
-
- private void ipv6Mask() {
- if (this.bits <= 32) {
- this.ipv6Mask[0] = -1 << (32 - this.bits);
- this.ipv6Mask[1] = 0;
- this.ipv6Mask[2] = 0;
- this.ipv6Mask[3] = 0;
- }
-
- if (this.bits > 32 && this.bits <= 64) {
- this.ipv6Mask[0] = -1;
- this.ipv6Mask[1] = -1 << (64 - this.bits);
- this.ipv6Mask[2] = 0;
- this.ipv6Mask[3] = 0;
- }
-
- if (this.bits > 64 && this.bits <= 96) {
- this.ipv6Mask[0] = -1;
- this.ipv6Mask[1] = -1;
- this.ipv6Mask[2] = -1 << (96 - this.bits);
- this.ipv6Mask[3] = 0;
- }
-
- if (this.bits > 96 && this.bits <= 128) {
- this.ipv6Mask[0] = -1;
- this.ipv6Mask[1] = -1;
- this.ipv6Mask[2] = -1;
- this.ipv6Mask[3] = -1 << (128 - this.bits);
- }
- }
-
- private void subNet(Ipv4Prefix ipv4Prefix) throws UnknownHostException {
- String[] value = ipv4Prefix.getValue().split("/");
- this.bits = Integer.parseInt(value[1]);
- this.ipv4Mask = -1 << (32 - this.bits);
- this.ipv4Subnet = ipv4ToInt(value[0]);
- }
-
- private int ipv4ToInt(String addr) throws UnknownHostException {
- Inet4Address a = (Inet4Address) InetAddress.getByName(addr);
- byte[] b = a.getAddress();
- int addrInt = ((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16)
- | ((b[2] & 0xFF) << 8) | ((b[3] & 0xFF) << 0);
- return addrInt;
- }
-
- private int[] ipv6ToInt(String address) throws UnknownHostException {
- Inet6Address addr = (Inet6Address) InetAddress.getByName(address);
- byte[] b = addr.getAddress();
- int addr1 = ((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16)
- | ((b[2] & 0xFF) << 8) | ((b[3] & 0xFF) << 0);
-
- int addr2 = ((b[4] & 0xFF) << 24) | ((b[5] & 0xFF) << 16)
- | ((b[6] & 0xFF) << 8) | ((b[7] & 0xFF) << 0);
-
- int addr3 = ((b[8] & 0xFF) << 24) | ((b[9] & 0xFF) << 16)
- | ((b[10] & 0xFF) << 8) | ((b[11] & 0xFF) << 0);
-
- int addr4 = ((b[12] & 0xFF) << 24) | ((b[13] & 0xFF) << 16)
- | ((b[14] & 0xFF) << 8) | ((b[15] & 0xFF) << 0);
- int[] addrs = { addr1, addr2, addr3, addr4 };
- return addrs;
- }
-
- public boolean match(TypedEndpointAddress address)
- throws UnknownHostException {
- if (EndpointAddressType.Enumeration.Ipv4.equals(this.type) && address.getTypedIpv4Address() != null) {
- int addr = ipv4ToInt(address.getTypedIpv4Address().getValue().replace("ipv4:", ""));
- return ((ipv4Subnet & ipv4Mask) == (addr & ipv4Mask));
- }
-
- if (EndpointAddressType.Enumeration.Ipv6.equals(this.type) && address.getTypedIpv6Address() != null) {
- int[] addr = ipv6ToInt(address.getTypedIpv6Address().getValue().replace("ipv6:", ""));
- return ((ipv6Subnet[0] & ipv6Mask[0]) == (addr[0] & ipv6Mask[0]))
- && ((ipv6Subnet[1] & ipv6Mask[1]) == (addr[1] & ipv6Mask[1]))
- && ((ipv6Subnet[2] & ipv6Mask[2]) == (addr[2] & ipv6Mask[2]))
- && ((ipv6Subnet[3] & ipv6Mask[3]) == (addr[3] & ipv6Mask[3]));
- }
- return false;
- }
-
- public int getSubnetLength() {
- return this.bits;
- }
-
- public String getIpPrefix() {
- return this.prefix;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostRequest;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.EndpointCostServiceInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.EndpointCostServiceInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.input.CostType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.input.CostTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.input.Endpoints;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.input.EndpointsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.CostMetricBuilder;
-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.TypedEndpointAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TypedEndpointAddressBuilder;
-
-public class CostRequest2EndpointCostServiceInputConverter extends
- Converter<CostRequest, EndpointCostServiceInput> {
-
- public CostRequest2EndpointCostServiceInputConverter() {
- }
-
- public CostRequest2EndpointCostServiceInputConverter(CostRequest _in) {
- super(_in);
- }
-
- @Override
- protected Object _convert() {
- RFC7285CostType rfcCostType = in().costType;
-
- CostType costType = new CostTypeBuilder()
- .setCostMetric(CostMetricBuilder.getDefaultInstance(rfcCostType.metric))
- .setCostMode(CostMode.valueOf(capitalizeFirstLetter(rfcCostType.mode)))
- .setDescription(rfcCostType.description).build();
-
- List<TypedEndpointAddress> srcs = toTypedEndpointAddressList(in().endpoints.src);
- List<TypedEndpointAddress> dsts = toTypedEndpointAddressList(in().endpoints.dst);
- Endpoints endpoints = new EndpointsBuilder().setSrcs(srcs).setDsts(dsts).build();
-
- EndpointCostServiceInput input = new EndpointCostServiceInputBuilder()
- .setCostType(costType)
- .setEndpoints(endpoints)
- .build();
-
- return input;
- }
-
- private List<TypedEndpointAddress> toTypedEndpointAddressList(List<String> addresses) {
- List<TypedEndpointAddress> result = new ArrayList<TypedEndpointAddress>();
- for (String address : addresses) {
- result.add(TypedEndpointAddressBuilder.getDefaultInstance(address));
- }
- return result;
- }
-
- private String capitalizeFirstLetter(String str) {
- str = str.toLowerCase();
- return str.substring(0, 1).toUpperCase() + str.substring(1);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostResponse;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.costdefault.rev150507.DstCosts1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.EndpointCostServiceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.EndpointCostService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.EndpointCostMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.endpoint.cost.map.DstCosts;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.meta.CostType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TypedEndpointAddress;
-
-public class EndpointCostServiceOutput2CostResponseConverter extends
- Converter<EndpointCostServiceOutput, CostResponse> {
-
- private static final String NUMERICAL_MODE = "numerical";
- private static final String ORDINAL_MODE = "ordinal";
- private static final String ROUTING_COST_METRIC = "routingcost";
- private static final String HOP_COUNT_METRIC = "hopcount";
-
- public EndpointCostServiceOutput2CostResponseConverter() {
- }
-
- public EndpointCostServiceOutput2CostResponseConverter(EndpointCostServiceOutput _in) {
- super(_in);
- }
-
- @Override
- protected Object _convert() {
- CostResponse resp = new CostResponse();
- EndpointCostService ecService = this.in().getEndpointCostService();
- CostType costType = ecService.getMeta().getCostType();
-
- resp.meta = new CostResponse.Meta();
- resp.meta.costType = new RFC7285CostType();
- resp.meta.costType.mode = costType.getCostMode().name().toLowerCase();
- resp.meta.costType.metric = String.valueOf(costType.getCostMetric().getValue()).toLowerCase();
- resp.meta.costType.description = costType.getDescription();
-
- resp.answer = new HashMap<String, Map<String, Object>>();
- for (EndpointCostMap ecm : ecService.getEndpointCostMap()) {
- TypedEndpointAddress src = ecm.getSrc();
- Map<String, Object> map = new HashMap<String, Object>();
- for (DstCosts dstCosts : ecm.getDstCosts()) {
- String dst = String.valueOf(dstCosts.getDst().getValue());
- String cost = dstCosts.getAugmentation(DstCosts1.class).getCostDefault().toString();
- map.put(dst, cost(resp.meta.costType.mode, resp.meta.costType.metric, cost));
- }
- resp.answer.put(String.valueOf(src.getValue()), map);
- }
- return resp;
- }
-
- private Object cost(String mode, String metric, String cost) {
- if (ORDINAL_MODE.equals(mode.toLowerCase())) {
- return Integer.parseInt(cost);
- }
-
- if (NUMERICAL_MODE.equals(mode.toLowerCase())) {
- if (HOP_COUNT_METRIC.equals(metric.toLowerCase())) {
- return Integer.parseInt(cost);
- } else if (ROUTING_COST_METRIC.equals(metric.toLowerCase())) {
- return Double.parseDouble(cost);
- }
- }
- return cost;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import java.util.LinkedList;
-
-import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.model150404.ModelCostMap;
-import org.opendaylight.alto.commons.types.model150404.ModelCostMapData;
-import org.opendaylight.alto.commons.types.model150404.ModelCostMapMeta;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
-
-public class RFC2ModelCostMapConverter extends
- Converter<RFC7285CostMap, ModelCostMap> {
-
- protected RFC2ModelCostMapMetaConverter metaConv = new RFC2ModelCostMapMetaConverter();
- protected RFC2ModelCostMapDataConverter dataConv = new RFC2ModelCostMapDataConverter();
-
- public RFC2ModelCostMapConverter() {
- }
-
- public RFC2ModelCostMapConverter(RFC7285CostMap _in) {
- super(_in);
- }
-
- @Override
- protected Object _convert() {
- ModelCostMap out = new ModelCostMap();
- out.rid = ModelCostMapMeta.getCostMapResourceId(
- in().meta.netmap_tags.get(0).rid, in().meta.costType.metric,
- in().meta.costType.mode);
-
- // TODO: replace the dummy one in the future
- out.tag = "da65eca2eb7a10ce8b059740b0b2e3f8eb1d4786";
-
- out.meta = metaConv.convert(in().meta);
- out.map = new LinkedList<ModelCostMapData>();
- for (String src : in().map.keySet()) {
- ModelCostMapData data = new ModelCostMapData();
- data.src = src;
- data.dstCosts = dataConv.convert(in().map.get(src));
- out.map.add(data);
- }
- return out;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.model150404.ModelDstCosts;
-
-public class RFC2ModelCostMapDataConverter
- extends Converter<Map<String, Object>, List<ModelDstCosts>> {
-
- public RFC2ModelCostMapDataConverter() {
- }
-
- public RFC2ModelCostMapDataConverter(Map<String, Object> _in) {
- super(_in);
- }
-
- @Override
- protected Object _convert() {
- List<ModelDstCosts> dstCostsList = new LinkedList<ModelDstCosts>();
- for (String dst : in().keySet()) {
- //TODO: Should support different implementations
- ModelDstCosts dstCosts = new ModelDstCosts();
- dstCosts.dst = dst;
- dstCosts.costDefault = in().get(dst).toString();
- dstCostsList.add(dstCosts);
- }
- return dstCostsList;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.model150404.ModelCostMapMeta;
-import org.opendaylight.alto.commons.types.model150404.ModelDependentVtag;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
-
-public class RFC2ModelCostMapMetaConverter
- extends Converter<RFC7285CostMap.Meta, ModelCostMapMeta>{
-
- public RFC2ModelCostMapMetaConverter() {
- }
-
- public RFC2ModelCostMapMetaConverter(RFC7285CostMap.Meta _in) {
- super(_in);
- }
-
- @Override
- protected Object _convert() {
- ModelCostMapMeta modelMeta = new ModelCostMapMeta();
-
- ModelDependentVtag dvtag = new ModelDependentVtag();
- dvtag.rid = in().netmap_tags.get(0).rid;
- dvtag.vTag = in().netmap_tags.get(0).tag;
- modelMeta.dependentVtags.add(dvtag);
-
- modelMeta.costType.costMetric = in().costType.metric;
- modelMeta.costType.costMode = in().costType.mode;
- modelMeta.costType.description = in().costType.description;
-
- return modelMeta;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import java.util.List;
-import java.util.LinkedList;
-
-import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
-import org.opendaylight.alto.commons.types.model150404.ModelEndpointAddressGroup;
-
-public class RFC2ModelEndpointAddressGroupConverter
- extends Converter<RFC7285Endpoint.AddressGroup, List<ModelEndpointAddressGroup>> {
-
- public RFC2ModelEndpointAddressGroupConverter() {
- }
-
- public RFC2ModelEndpointAddressGroupConverter(RFC7285Endpoint.AddressGroup _in) {
- super(_in);
- }
-
- @Override
- protected Object _convert() {
- List<ModelEndpointAddressGroup> out = new LinkedList<ModelEndpointAddressGroup>();
- if ((in().ipv4 != null) && (!in().ipv4.isEmpty())) {
- ModelEndpointAddressGroup v4 = new ModelEndpointAddressGroup();
- v4.type = ModelEndpointAddressGroup.IPV4;
- v4.prefixes = in().ipv4;
- out.add(v4);
- }
- if ((in().ipv6 != null) && (!in().ipv6.isEmpty())) {
- ModelEndpointAddressGroup v6 = new ModelEndpointAddressGroup();
- v6.type = ModelEndpointAddressGroup.IPV6;
- v6.prefixes = in().ipv6;
- out.add(v6);
- }
- return out;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.model150404.ModelDependentVtag;
-import org.opendaylight.alto.commons.types.model150404.ModelEndpointProperties;
-import org.opendaylight.alto.commons.types.model150404.ModelEndpointPropertyMap;
-import org.opendaylight.alto.commons.types.model150404.ModelEndpointPropertyMeta;
-import org.opendaylight.alto.commons.types.model150404.ModelProperties;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285EndpointPropertyMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-
-public class RFC2ModelEndpointPropMapConverter
- extends Converter<RFC7285EndpointPropertyMap, ModelEndpointPropertyMap> {
-
- @Override
- protected Object _convert() {
- ModelEndpointPropertyMap out = new ModelEndpointPropertyMap();
- out.endpointPropertyMeta = convertMeta(in().meta);
- out.properties = new LinkedList<ModelEndpointProperties>();
- for (String endpoint : in().map.keySet()) {
- out.properties.add(convertEndpointProperty(endpoint, in().map.get(endpoint)));
- }
- return out;
- }
-
- protected static String readFromFile(String path) throws IOException {
- return new String(Files.readAllBytes(Paths.get(path)),
- StandardCharsets.UTF_8);
- }
-
- private ModelEndpointPropertyMeta convertMeta(RFC7285EndpointPropertyMap.Meta meta) {
- ModelEndpointPropertyMeta endpointPropertyMeta = new ModelEndpointPropertyMeta();
-
- endpointPropertyMeta.dependentVtags = new LinkedList<ModelDependentVtag>();
- for (RFC7285VersionTag vtag : meta.netmap_tags) {
- ModelDependentVtag dependentVtag = new ModelDependentVtag();
- dependentVtag.rid = vtag.rid;
- dependentVtag.vTag = vtag.tag;
- endpointPropertyMeta.dependentVtags.add(dependentVtag);
- }
-
- return endpointPropertyMeta;
- }
-
- private ModelEndpointProperties
- convertEndpointProperty(String endpoint, Map<String, String> property) {
- ModelEndpointProperties endpointProperty = new ModelEndpointProperties();
- endpointProperty.endpoint = endpoint;
- endpointProperty.properties = new LinkedList<ModelProperties>();
- for (String propertyType : property.keySet()) {
- endpointProperty.properties.add(convertProperty(propertyType, property.get(propertyType)));
- }
- return endpointProperty;
- }
-
- private ModelProperties convertProperty(String propertyType, String propertyValue) {
- ModelProperties property = new ModelProperties();
- property.propertyType = propertyType;
- property.propertyValue = propertyValue;
- return property;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
-
-public class RFC2ModelNetworkMapConverter
- extends Converter<RFC7285NetworkMap, ModelNetworkMap> {
-
- protected RFC2ModelNetworkMapDataConverter conv = new RFC2ModelNetworkMapDataConverter();
-
- public RFC2ModelNetworkMapConverter() {
- }
-
- public RFC2ModelNetworkMapConverter(RFC7285NetworkMap _in) {
- super(_in);
- }
-
- @Override
- public Object _convert() {
- ModelNetworkMap out = new ModelNetworkMap();
- out.rid = in().meta.vtag.rid;
- out.tag = in().meta.vtag.tag;
- out.map = conv.convert(in().map);
- return out;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import java.util.Map;
-import java.util.List;
-import java.util.LinkedList;
-
-import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
-import org.opendaylight.alto.commons.types.model150404.ModelEndpoint;
-
-public class RFC2ModelNetworkMapDataConverter
- extends Converter<Map<String, RFC7285Endpoint.AddressGroup>, List<ModelEndpoint>> {
-
- protected RFC2ModelEndpointAddressGroupConverter conv = new RFC2ModelEndpointAddressGroupConverter();
-
- public RFC2ModelNetworkMapDataConverter() {
- }
-
- public RFC2ModelNetworkMapDataConverter(Map<String, RFC7285Endpoint.AddressGroup> _in) {
- super(_in);
- }
-
- @Override
- public Object _convert() {
- List<ModelEndpoint> out = new LinkedList<ModelEndpoint>();
-
- for (Map.Entry<String, RFC7285Endpoint.AddressGroup> rep: in().entrySet()) {
- ModelEndpoint mep = new ModelEndpoint();
- mep.pid = rep.getKey();
- mep.addressGroup = conv.convert(rep.getValue());
- out.add(mep);
- }
- return out;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import org.opendaylight.alto.commons.helper.Converter;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class YANGJSON2RFCAddressGroupConverter extends Converter<JsonNode, RFC7285Endpoint.AddressGroup> {
- public YANGJSON2RFCAddressGroupConverter() {
- }
-
- public YANGJSON2RFCAddressGroupConverter(JsonNode _in) {
- super(_in);
- }
-
- @Override
- protected Object _convert() {
- JsonNode node = this.in();
- RFC7285Endpoint.AddressGroup ag = new RFC7285Endpoint.AddressGroup();
-
- for (JsonNode address: node) {
- JsonNode prefixes = address.get("endpointPrefix");
- assert prefixes.isArray();
- for (JsonNode prefix: prefixes) {
- JsonNode ipv4 = prefix.get("ipv4Prefix");
- JsonNode ipv6 = prefix.get("ipv6Prefix");
- if ((ipv4 != null) && (!ipv4.isNull())) {
- ag.ipv4.add(ipv4.get("value").asText());
- }
- if ((ipv6 != null) && (!ipv6.isNull())) {
- ag.ipv6.add(ipv6.get("value").asText());
- }
- }
- }
- return ag;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import org.opendaylight.alto.commons.helper.Converter;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
-
-import java.util.Map;
-import java.util.LinkedHashMap;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class YANGJSON2RFCCostMapConverter extends Converter<JsonNode, RFC7285CostMap> {
- private static final String NUMERICAL_MODE = "numerical";
- private static final String ORDINAL_MODE = "ordinal";
- private static final String ROUTING_COST_METRIC = "routingcost";
- private static final String HOP_COUNT_METRIC = "hopcount";
-
- public YANGJSON2RFCCostMapConverter() {
- }
-
- public YANGJSON2RFCCostMapConverter(JsonNode _in) {
- super(_in);
- }
-
- @Override
- protected Object _convert() {
- JsonNode node = this.in();
- RFC7285CostMap cm = new RFC7285CostMap();
-
- JsonNode meta = node.get("meta");
- for (JsonNode vtag: meta.get("dependentVtags")) {
- String resource_id = vtag.get("resourceId").get("value").asText();
- String tag = vtag.get("tag").get("value").asText();
- cm.meta.netmap_tags.add(new RFC7285VersionTag(resource_id, tag));
- }
-
- JsonNode cost_type = meta.get("costType");
- String mode = cost_type.get("costMode").asText().toLowerCase();
- String metric = cost_type.get("costMetric").get("value").asText().toLowerCase();
- cm.meta.costType = new RFC7285CostType(mode, metric);
-
- JsonNode map = node.get("map");
- assert map.isArray();
- for (JsonNode cost_map: map) {
- String src_pid = cost_map.get("src").get("value").asText();
- Map<String, Object> data = new LinkedHashMap<String, Object>();
-
- for (JsonNode dst: cost_map.get("dstCosts")) {
- String dst_pid = dst.get("dst").get("value").asText();
-
- JsonNode cost_node = dst.get("cost");
- if ((cost_node != null) && (!cost_node.isNull())) {
- Object cost = cost(mode, metric, cost_node.asText());
- data.put(dst_pid, cost);
- }
- }
-
- cm.map.put(src_pid, data);
- }
- return cm;
- }
-
- private Object cost(String mode, String metric, String cost) {
- if (ORDINAL_MODE.equals(mode.toLowerCase())) {
- return Integer.parseInt(cost);
- }
-
- if (NUMERICAL_MODE.equals(mode.toLowerCase())) {
- if (HOP_COUNT_METRIC.equals(metric.toLowerCase())) {
- return Integer.parseInt(cost);
- } else if (ROUTING_COST_METRIC.equals(metric.toLowerCase())) {
- return Double.parseDouble(cost);
- }
- }
- return cost;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285EndpointPropertyMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285EndpointPropertyMap.Meta;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class YANGJSON2RFCEndpointPropMapConverter
- extends Converter<JsonNode, RFC7285EndpointPropertyMap> {
- public YANGJSON2RFCEndpointPropMapConverter() {
- }
-
- public YANGJSON2RFCEndpointPropMapConverter(JsonNode _in) {
- super(_in);
- }
-
- @Override
- public Object _convert() {
- JsonNode node = this.in();
- RFC7285EndpointPropertyMap out = new RFC7285EndpointPropertyMap();
- out.meta = convertMeta(in().get("meta"));
- out.map = new LinkedHashMap<String, Map<String, String>>();
- JsonNode endpointProperties = node.get("endpointProperties");
- assert !endpointProperties.isArray();
- for (JsonNode endpoint : endpointProperties) {
- String addr = extract_addr(endpoint);
- JsonNode properties = endpoint.get("properties");
- assert properties.isNull();
- Map<String, String> ps = convertProperties(properties);
- out.map.put(addr, ps);
- }
- return out;
- }
-
- private Map<String, String> convertProperties(JsonNode properties) {
- // TODO Auto-generated method stub
- Map<String, String> ps = new LinkedHashMap<String, String>();
- for (JsonNode propertyType : properties) {
- String type = propertyType.get("propertyType").get("value").asText();
- String property = propertyType.get("property").get("value").asText();
- ps.put(type, property);
- }
- return ps;
- }
-
- private String extract_addr(JsonNode endpoint) {
- // TODO Auto-generated method stub
- return endpoint.get("endpoint").get("value").asText();
- }
-
- private Meta convertMeta(JsonNode jsonNode) {
- // TODO Auto-generated method stub
- Meta meta = new Meta();
- meta.netmap_tags = new LinkedList<RFC7285VersionTag>();
-
- for (JsonNode vtag : jsonNode.get("dependentVtags")) {
- String resource_id = vtag.get("resourceId").get("value").asText();
- String tag = vtag.get("tag").get("value").asText();
- meta.netmap_tags.add(new RFC7285VersionTag(resource_id, tag));
- }
- return meta;
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import java.util.LinkedList;
-
-import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285IRD;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class YANGJSON2RFCIRDConverter extends Converter<JsonNode, RFC7285IRD> {
-
- public YANGJSON2RFCIRDConverter() {
- }
-
- public YANGJSON2RFCIRDConverter(JsonNode _in) {
- super(_in);
- }
-
- @Override
- protected Object _convert() {
- JsonNode node = this.in();
- RFC7285IRD ird = new RFC7285IRD();
-
- JsonNode meta = node.get("meta");
- for (JsonNode costType : meta.get("costTypes")) {
- String costTypeName = costType.get("costTypeName").get("value").asText();
- String costMode = costType.get("costMode").asText().toLowerCase();
- String costMatric = costType.get("costMetric").get("value").asText();
- if (!costType.get("description").isNull()) {
- ird.meta.costTypes.put(costTypeName,
- new RFC7285CostType(costMode, costMatric, costType.get("description").asText()));
- } else {
- ird.meta.costTypes.put(costTypeName, new RFC7285CostType(costMode, costMatric));
- }
-
- }
- ird.meta.defaultAltoNetworkMap = meta.get("defaultAltoNetworkMap").get("resourceId").get("value").asText();
-
- JsonNode resources = node.get("resources");
- for (JsonNode res : resources) {
- String rid = res.get("resourceId").get("value").asText();
-
- RFC7285IRD.Entry ent = ird.new Entry();
- ent.uri = res.get("uri").get("value").asText();
- ent.mediaType = res.get("mediaType").get("value").asText();
- if (!res.get("uses").isNull()) {
- ent.uses = new LinkedList<String>();
- for (JsonNode use : res.get("uses")) {
- ent.uses.add(use.get("value").asText());
- }
- }
-
- if (!res.get("capabilities").isNull()) {
- ent.capabilities = ird.new Capability();
- if (!res.get("capabilities").get("costConstraints").isNull()) {
- ent.capabilities.costConstraints = res.get("capabilities").get("costConstraints").asBoolean();
-
- }
- if (!res.get("capabilities").get("costTypeNames").isNull()) {
- ent.capabilities.costTypeNames = new LinkedList<String>();
- for (JsonNode name : res.get("capabilities").get("costTypeNames")) {
- ent.capabilities.costTypeNames.add(name.get("value").asText());
- }
- }
- if (!res.get("capabilities").get("propTypes").isNull()) {
- ent.capabilities.propTypes = new LinkedList<String>();
- for (JsonNode prop : res.get("capabilities").get("propTypes")) {
- ent.capabilities.propTypes.add(prop.get("value").asText());
- }
- }
- }
-
- if (!res.get("accepts").isNull()) {
- for (JsonNode act : res.get("accepts")) {
- ent.accepts = act.get("value").asText();
- }
- }
-
- ird.resources.put(rid, ent);
- }
- return ird;
- }
-
- private RFC7285CostType RFC7285CostType() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import org.opendaylight.alto.commons.helper.Converter;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class YANGJSON2RFCNetworkMapConverter extends Converter<JsonNode, RFC7285NetworkMap> {
- public YANGJSON2RFCNetworkMapConverter() {
- }
-
- public YANGJSON2RFCNetworkMapConverter(JsonNode _in) {
- super(_in);
- }
-
- protected YANGJSON2RFCAddressGroupConverter group_converter
- = new YANGJSON2RFCAddressGroupConverter();
-
- @Override
- protected Object _convert() {
- JsonNode node = this.in();
- RFC7285NetworkMap nm = new RFC7285NetworkMap();
-
- String resource_id = node.get("resourceId").get("value").asText();
- String tag = node.get("tag").get("value").asText();
-
- nm.meta.vtag = new RFC7285VersionTag(resource_id, tag);
-
- JsonNode map = node.get("map");
- assert map.isArray();
- for (JsonNode egroup: map) {
- String pid = extract_pid(egroup);
- JsonNode addr_group = egroup.get("endpointAddressGroup");
- assert !addr_group.isNull();
- RFC7285Endpoint.AddressGroup ag = group_converter.convert(addr_group);
-
- nm.map.put(pid, ag);
- }
- return nm;
- }
-
- protected String extract_pid(JsonNode node) {
- return node.get("pid").get("value").asText();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-class MediaType {
-
- /** The media types generated by alto-model
- * */
-
- public static final String ALTO_DIRECTORY
- = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType.Enumeration.AltoDirectory
- ).toString();
-
- public static final String ALTO_NETWORKMAP
- = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType.Enumeration.AltoNetworkmap
- ).toString();
-
- public static final String ALTO_NETWORKMAP_FILTER
- = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType.Enumeration.AltoNetworkmapfilter
- ).toString();
-
- public static final String ALTO_COSTMAP
- = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType.Enumeration.AltoCostmap
- ).toString();
-
- public static final String ALTO_COSTMAP_FILTER
- = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType.Enumeration.AltoCostmapfilter
- ).toString();
-
- public static final String ALTO_ENDPOINT_PROP
- = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType.Enumeration.AltoEndpointprop
- ).toString();
-
- public static final String ALTO_ENDPOINT_PROPPARAMS
- = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType.Enumeration.AltoEndpointpropparams
- ).toString();
-
- public static final String ALTO_ENDPOINT_COST
- = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType.Enumeration.AltoEndpointcost
- ).toString();
-
- public static final String ALTO_ENDPOST_COSTPARAMS
- = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType.Enumeration.AltoEndpointcostparams
- ).toString();
-
- public static final String ALTO_ERROR
- = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType.Enumeration.AltoError
- ).toString();
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.CostMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Map;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Meta;
-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.yangtools.yang.binding.DataContainer;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ModelCostMap implements CostMap {
-
- @JsonProperty("alto-service:resource-id")
- public String rid = null;
-
- @JsonProperty("alto-service:tag")
- public String tag = null;
-
- @JsonProperty("alto-service:meta")
- public ModelCostMapMeta meta = null;
-
- @JsonProperty("alto-service:map")
- public List<ModelCostMapData> map = new LinkedList<ModelCostMapData>();
-
- @JsonIgnore
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return CostMap.class;
- }
-
- @JsonIgnore
- @Override
- public ResourceId getResourceId() {
- return new ResourceId(rid);
- }
-
- @JsonIgnore
- @Override
- public TagString getTag() {
- return new TagString(tag);
- }
-
- @JsonIgnore
- @Override
- public Meta getMeta() {
- return meta;
- }
-
- @JsonIgnore
- @Override
- public List<Map> getMap() {
- return new LinkedList<Map>(map);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Map;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.MapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.map.DstCosts;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ModelCostMapData implements Map {
-
- @JsonProperty("alto-service:src")
- public String src = null;
-
- @JsonProperty("alto-service:dst-costs")
- public List<ModelDstCosts> dstCosts = new LinkedList<ModelDstCosts>();
-
- @JsonIgnore
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return Map.class;
- }
-
- @JsonIgnore
- @Override
- public <E extends Augmentation<Map>> E getAugmentation(Class<E> arg0) {
- return null;
- }
-
- @JsonIgnore
- @Override
- public PidName getSrc() {
- return new PidName(src);
- }
-
- @JsonIgnore
- @Override
- public List<DstCosts> getDstCosts() {
- return new LinkedList<DstCosts>(dstCosts);
- }
-
- @JsonIgnore
- @Override
- public MapKey getKey() {
- return new MapKey(getSrc());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Meta;
-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.dependent.vtags.DependentVtags;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ModelCostMapMeta implements Meta {
-
- @JsonProperty("alto-service:dependent-vtags")
- public List<ModelDependentVtag> dependentVtags = new LinkedList<ModelDependentVtag>();
-
- @JsonProperty("alto-service:cost-type")
- public ModelCostType costType = new ModelCostType();
-
- @JsonIgnore
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return Meta.class;
- }
-
- @JsonIgnore
- @Override
- public List<DependentVtags> getDependentVtags() {
- return new LinkedList<DependentVtags>(dependentVtags);
- }
-
- @JsonIgnore
- @Override
- public CostType getCostType() {
- return costType;
- }
-
- @JsonIgnore
- @Override
- public <E extends Augmentation<Meta>> E getAugmentation(Class<E> arg0) {
- return null;
- }
-
- @JsonIgnore
- public static String getCostMapResourceId(String networkMapRID,
- String costMetric, String costMode) {
- return networkMapRID + "-" + costMetric + "-" + costMode;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.CostMetric;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.CostMetricBuilder;
-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.cost.map.meta.CostType;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ModelCostType implements CostType {
-
- @JsonIgnore
- public static final String NUMERICAL = "Numerical";
-
- @JsonIgnore
- public static final String ORDINAL = "Ordinal";
-
- @JsonProperty("alto-service:cost-mode")
- public String costMode = null;
-
- @JsonProperty("alto-service:cost-metric")
- public String costMetric = null;
-
- @JsonProperty("alto-service:description")
- public String description = null;
-
- @JsonIgnore
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return CostType.class;
- }
-
- @JsonIgnore
- @Override
- public <E extends Augmentation<CostType>> E getAugmentation(Class<E> arg0) {
- return null;
- }
-
- @JsonIgnore
- @Override
- public CostMode getCostMode() {
- switch(costMode) {
- case NUMERICAL:
- return CostMode.Numerical;
- case ORDINAL:
- return CostMode.Ordinal;
- default:
- throw new RuntimeException("Non-Supported cost mode.");
- }
- }
-
- @JsonIgnore
- @Override
- public CostMetric getCostMetric() {
- return CostMetricBuilder.getDefaultInstance(costMetric);
- }
-
- @JsonIgnore
- @Override
- public String getDescription() {
- return description;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-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.dependent.vtags.DependentVtags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.dependent.vtags.DependentVtagsKey;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ModelDependentVtag implements DependentVtags {
-
- @JsonProperty("alto-service:resource-id")
- public String rid = "";
-
- @JsonProperty("alto-service:tag")
- public String vTag = "";
-
- @JsonIgnore
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return DependentVtags.class;
- }
-
- @JsonIgnore
- @Override
- public <E extends Augmentation<DependentVtags>> E getAugmentation(
- Class<E> arg0) {
- return null;
- }
-
- @JsonIgnore
- @Override
- public ResourceId getResourceId() {
- return new ResourceId(rid);
- }
-
- @JsonIgnore
- @Override
- public TagString getTag() {
- return new TagString(vTag);
- }
-
- @JsonIgnore
- @Override
- public DependentVtagsKey getKey() {
- return new DependentVtagsKey(getResourceId());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.costdefault.rev150507.DstCosts2;
-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.DstCostsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ModelDstCosts implements DstCosts, DstCosts2 {
-
- @JsonProperty("alto-service:dst")
- public String dst = null;
-
- @JsonProperty("alto-cost-default:cost-default")
- public String costDefault;
-
- @JsonIgnore
- @Override
- public String getCostDefault() {
- return costDefault;
- }
-
- @JsonIgnore
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return DstCosts.class;
- }
-
- @JsonIgnore
- @Override
- public <E extends Augmentation<DstCosts>> E getAugmentation(Class<E> arg0) {
- return (E) this;
- }
-
- @JsonIgnore
- @Override
- public PidName getDst() {
- return new PidName(dst);
- }
-
- @JsonIgnore
- @Override
- public DstCostsKey getKey() {
- return new DstCostsKey(getDst());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey;
-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.endpoint.address.group.EndpointAddressGroup;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-
-import java.util.List;
-import java.util.LinkedList;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-public class ModelEndpoint implements Map {
-
- @JsonProperty("alto-service:pid")
- public String pid = null;
-
- @JsonProperty("alto-service:endpoint-address-group")
- public List<ModelEndpointAddressGroup> addressGroup = new LinkedList<ModelEndpointAddressGroup>();
-
- @JsonIgnore
- @Override
- public Class<Map> getImplementedInterface() {
- return Map.class;
- }
-
- @JsonIgnore
- @Override
- public <E extends Augmentation<Map>> E getAugmentation(Class<E> augmentationType) {
- return null;
- }
-
- @JsonIgnore
- @Override
- public MapKey getKey() {
- return new MapKey(getPid());
- }
-
- @JsonIgnore
- @Override
- public PidName getPid() {
- return new PidName(pid);
- }
-
- @JsonIgnore
- @Override
- public List<EndpointAddressGroup> getEndpointAddressGroup() {
- return new LinkedList<EndpointAddressGroup>(addressGroup);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import java.util.LinkedList;
-import java.util.List;
-
-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.IpPrefixBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
-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.EndpointAddressGroupKey;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ModelEndpointAddressGroup implements EndpointAddressGroup {
-
- @JsonIgnore
- public static final String IPV4 = "ipv4";
-
- @JsonIgnore
- public static final String IPV6 = "ipv6";
-
- @JsonProperty("alto-service:address-type")
- public String type;
-
- @JsonProperty("alto-service:endpoint-prefix")
- public List<String> prefixes = new LinkedList<String>();
-
- @JsonIgnore
- @Override
- public Class<EndpointAddressGroup> getImplementedInterface() {
- return EndpointAddressGroup.class;
- }
-
- @JsonIgnore
- @Override
- public EndpointAddressType getAddressType() {
- if (IPV4.equals(type))
- return new EndpointAddressType(EndpointAddressType.Enumeration.Ipv4);
- if (IPV6.equals(type))
- return new EndpointAddressType(EndpointAddressType.Enumeration.Ipv6);
- throw new java.lang.UnsupportedOperationException("Unsupported AddressType");
- }
-
- @JsonIgnore
- @Override
- public <E extends Augmentation<EndpointAddressGroup>> E getAugmentation(Class<E> augmentationType) {
- return null;
- }
-
- @JsonIgnore
- @Override
- public List<IpPrefix> getEndpointPrefix() {
- List<IpPrefix> ipPrefixes = new LinkedList<IpPrefix>();
- for (String prefix : prefixes) {
- ipPrefixes.add(IpPrefixBuilder.getDefaultInstance(prefix));
- }
- return ipPrefixes;
- }
-
- @JsonIgnore
- @Override
- public EndpointAddressGroupKey getKey() {
- return new EndpointAddressGroupKey(getAddressType());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import java.util.LinkedList;
-import java.util.List;
-
-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.TypedEndpointAddressBuilder;
-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.EndpointPropertiesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.data.endpoint.properties.Properties;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ModelEndpointProperties implements EndpointProperties {
-
- @JsonProperty("alto-service:endpoint")
- public String endpoint = null;
-
- @JsonProperty("alto-service:properties")
- public List<ModelProperties> properties = new LinkedList<ModelProperties>();
-
- @JsonIgnore
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return EndpointProperties.class;
- }
-
- @JsonIgnore
- @Override
- public <E extends Augmentation<EndpointProperties>> E getAugmentation(
- Class<E> arg0) {
- return null;
- }
-
- @JsonIgnore
- @Override
- public TypedEndpointAddress getEndpoint() {
- return TypedEndpointAddressBuilder.getDefaultInstance(endpoint);
- }
-
- @JsonIgnore
- @Override
- public List<Properties> getProperties() {
- return new LinkedList<Properties>(properties);
- }
-
- @JsonIgnore
- @Override
- public EndpointPropertiesKey getKey() {
- return new EndpointPropertiesKey(getEndpoint());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointPropertyMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.Meta;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.data.EndpointProperties;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ModelEndpointPropertyMap implements EndpointPropertyMap {
-
- @JsonProperty("alto-service:meta")
- public ModelEndpointPropertyMeta endpointPropertyMeta = new ModelEndpointPropertyMeta();
-
- @JsonProperty("alto-service:endpoint-properties")
- public List<ModelEndpointProperties> properties = new LinkedList<ModelEndpointProperties>();
-
- @JsonIgnore
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return EndpointPropertyMap.class;
- }
-
- @JsonIgnore
- @Override
- public List<EndpointProperties> getEndpointProperties() {
- return new LinkedList<EndpointProperties>(properties);
- }
-
- @JsonIgnore
- @Override
- public Meta getMeta() {
- return endpointPropertyMeta;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.Meta;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.dependent.vtags.DependentVtags;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ModelEndpointPropertyMeta implements Meta {
-
- @JsonProperty("alto-service:dependent-vtags")
- public List<ModelDependentVtag> dependentVtags = new LinkedList<ModelDependentVtag>();
-
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return Meta.class;
- }
-
- @Override
- public List<DependentVtags> getDependentVtags() {
- return new LinkedList<DependentVtags>(dependentVtags);
- }
-
- @Override
- public <E extends Augmentation<Meta>> E getAugmentation(Class<E> arg0) {
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class ModelJSONMapper {
-
- private ObjectMapper mapper = new ObjectMapper()
- .setSerializationInclusion(Include.NON_DEFAULT)
- .disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
-
-
- public ModelNetworkMap asNetworkMap(String json) throws Exception {
- return mapper.readValue(json, ModelNetworkMap.class);
- }
-
- public List<ModelNetworkMap> asNetworkMapList(String json) throws Exception {
- return Arrays.asList(mapper.readValue(json, ModelNetworkMap[].class));
- }
-
- public ModelCostMap asCostMap(String json) throws Exception {
- return mapper.readValue(json, ModelCostMap.class);
- }
-
- public List<ModelCostMap> asCostMapList(String json) throws Exception {
- return Arrays.asList(mapper.readValue(json, ModelCostMap[].class));
- }
-
- public ModelEndpointPropertyMap asEndpointPropMap(String json) throws Exception {
- return mapper.readValue(json, ModelEndpointPropertyMap.class);
- }
-
- public ModelEndpoint asModelEndpoint(String json) throws IOException {
- return mapper.readValue(json, ModelEndpoint.class);
- }
-
- public String asJSON(Object obj) throws Exception {
- return mapper.writeValueAsString(obj);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.NetworkMap;
-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.rev150404.network.map.Map;
-
-import java.util.List;
-import java.util.LinkedList;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-public class ModelNetworkMap implements NetworkMap {
-
- @JsonProperty("alto-service:resource-id")
- public String rid = null;
-
- @JsonProperty("alto-service:tag")
- public String tag = null;
-
- @JsonProperty("alto-service:map")
- public List<ModelEndpoint> map = new LinkedList<ModelEndpoint>();
-
- @JsonIgnore
- @Override
- public Class<NetworkMap> getImplementedInterface() {
- return NetworkMap.class;
- }
-
- @JsonIgnore
- @Override
- public ResourceId getResourceId() {
- return new ResourceId(rid);
- }
-
- @JsonIgnore
- @Override
- public TagString getTag() {
- return new TagString(tag);
- }
-
- @JsonIgnore
- @Override
- public List<Map> getMap() {
- return new LinkedList<Map>(map);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.model150404;
-
-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.endpoint.properties.Properties;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.property.map.data.endpoint.properties.PropertiesKey;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ModelProperties implements Properties {
-
- @JsonProperty("alto-service:property-type")
- public String propertyType = null;
-
- @JsonProperty("alto-service:property")
- public String propertyValue = null;
-
- @JsonIgnore
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return Properties.class;
- }
-
- @JsonIgnore
- @Override
- public <E extends Augmentation<Properties>> E getAugmentation(Class<E> arg0) {
- return null;
- }
-
- @JsonIgnore
- @Override
- public EndpointPropertyType getPropertyType() {
- return new EndpointPropertyType(propertyType.toCharArray());
- }
-
- @JsonIgnore
- @Override
- public EndpointPropertyValue getProperty() {
- return new EndpointPropertyValue(propertyValue);
- }
-
- @JsonIgnore
- @Override
- public PropertiesKey getKey() {
- return new PropertiesKey(getPropertyType());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import java.util.Map;
-import java.util.LinkedHashMap;
-
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-public class Extensible {
-
- @JsonIgnore
- private Map<String, Object> extra = new LinkedHashMap<String, Object>();
-
- @JsonAnyGetter
- public Map<String, Object> any() {
- return extra;
- }
-
- @JsonAnySetter
- public void set(String name, Object value) {
- extra.put(name, value);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import java.util.regex.Pattern;
-
-public class FormatValidator {
-
- /**
- * RFC 7285 section 10.1
- * */
- private static final String VALID_CHARSET = "a-zA-Z_0-9\\-:@";
- private static final Pattern VALID_ID_PATTERN
- = Pattern.compile("^["+VALID_CHARSET+"]{1,64}$");
- private static final String VALID_CHARSET_WITH_DOT = VALID_CHARSET + "\\.";
- private static final Pattern VALID_ID_PATTERN_WITH_DOT
- = Pattern.compile("^["+VALID_CHARSET_WITH_DOT+"]{1,64}$");
- private static final String VALID_TAG_CHARSET = "!-~";
- private static final Pattern VALID_TAG_PATTERN
- = Pattern.compile("^["+VALID_TAG_CHARSET+"]{1,64}$");
- private static final String VALID_ADDR_IPV4 = "^ipv4:(([0-9]|[1-9][0-9]|1[0-9][0-9]|"
- + "2[0-4][0-9]|25[0-5])\\.){3}"
- + "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"
- + "(%[\\p{N}\\p{L}]+)?$";
- private static final Pattern VALID_ADDR_IPV4_PATTERN
- = Pattern.compile(VALID_ADDR_IPV4);
- private static final String VALID_ADDR_IPV6_1 = "^ipv6:((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}"
- + "((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|"
- + "(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}"
- + "(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))"
- + "(%[\\p{N}\\p{L}]+)?$";
- private static final Pattern VALID_ADDR_IPV6_1_PATTERN
- = Pattern.compile(VALID_ADDR_IPV6_1);
- private static final String VALID_ADDR_IPV6_2 = "^ipv6:((([^:]+:){6}(([^:]+:[^:]+)|(.*\\..*)))|"
- + "((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)"
- + "(%.+)?)$";
- private static final Pattern VALID_ADDR_IPV6_2_PATTERN
- = Pattern.compile(VALID_ADDR_IPV6_2);
- private static final String VALID_OPERATORS = "(gt|lt|ge|le|eq)";
- private static final Pattern VALID_CONSTRAINTS_PATTERN
- = Pattern.compile("^"+VALID_OPERATORS+" [0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$");
-
-
- public static boolean validId(String id) {
- return VALID_ID_PATTERN.matcher(id).matches();
- }
-
- public static boolean validIdWithDots(String id) {
- return VALID_ID_PATTERN_WITH_DOT.matcher(id).matches();
- }
-
- /**
- * RFC 7285 section 10.1
- * */
- public static boolean validPid(String id) {
- return validId(id);
- }
-
- public static boolean validPidWithDots(String id) {
- return validIdWithDots(id);
- }
-
- /**
- * RFC 7285 section 10.2
- * */
- public static boolean validResourceId(String id) {
- return validId(id);
- }
-
- public static boolean validResourceIdWithDots(String id) {
- return validIdWithDots(id);
- }
-
- /**
- * RFC 7285 section 10.3
- * */
- public static boolean validTag(String tag) {
- return VALID_TAG_PATTERN.matcher(tag).matches();
- }
- /**
- * RFC 7285 section 10.8.1
- * */
- public static boolean validSpecificEndpointProperty(String prop) {
- /* TODO maybe enhance the performance? */
- return validId(prop) && (prop.indexOf('@') == -1);
- }
-
- public static boolean validSpecificEndpointPropertyWithDots(String prop) {
- /* TODO maybe enhance the performance? */
- return validIdWithDots(prop) && (prop.indexOf('@') == -1);
- }
-
- /**
- * RFC 7285 seciton 10.8.2
- * */
- public static boolean validGlobalEndpointProperty(String prop) {
- return (prop.length() <= 32) && validId(prop);
- }
-
- /**
- * RFC 7285 section 11.3.2
- * */
- public static boolean validFilterConstraint(String constrant) {
- return VALID_CONSTRAINTS_PATTERN.matcher(constrant).matches();
- }
-
- public static boolean validAddressIpv4(String address) {
- return VALID_ADDR_IPV4_PATTERN.matcher(address).matches();
- }
-
- public static boolean validAddressIpv6(String address) {
- return VALID_ADDR_IPV6_1_PATTERN.matcher(address).matches() &&
- VALID_ADDR_IPV6_2_PATTERN.matcher(address).matches();
- }
-
- public static boolean validEndpointAddress(String address) {
- return validAddressIpv4(address) || validAddressIpv6(address);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-public class MediaType {
-
- /** The media types defined in [RFC7285]
- *
- * The media types defined here should be identical to those
- * generated by alto-model, the main reason we need this is
- * the ones defined here are *STRING LITERALS*.
- * */
-
- public static final String ALTO_DIRECTORY
- = "application/alto-directory+json";
- public static final String ALTO_NETWORKMAP
- = "application/alto-networkmap+json";
- public static final String ALTO_NETWORKMAP_FILTER
- = "application/alto-networkmapfilter+json";
- public static final String ALTO_COSTMAP
- = "application/alto-costmap+json";
- public static final String ALTO_COSTMAP_FILTER
- = "application/alto-costmapfilter+json";
- public static final String ALTO_ENDPOINT_PROP
- = "application/alto-endpointprop+json";
- public static final String ALTO_ENDPOINT_PROPPARAMS
- = "application/alto-endpointpropparams+json";
- public static final String ALTO_ENDPOINT_COST
- = "application/alto-endpointcost+json";
- public static final String ALTO_ENDPOINT_COSTPARAMS
- = "application/alto-endpointcostparams+json";
- public static final String ALTO_ERROR
- = "application/alto-error+json";
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import java.util.List;
-import java.util.Map;
-import java.util.LinkedList;
-import java.util.LinkedHashMap;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * Cost Map: defined in RFC7285 secion 11.2.3
- * */
-public class RFC7285CostMap {
-
- public static class Meta extends Extensible {
-
- @JsonProperty("dependent-vtags")
- public List<RFC7285VersionTag> netmap_tags = new LinkedList<RFC7285VersionTag>();
-
- @JsonProperty("cost-type")
- public RFC7285CostType costType;
- }
-
- /**
- * for filtered-cost-map service, RFC7285 secion 11.3.2
- * */
- public static class Filter {
-
- @JsonProperty("cost-type")
- public RFC7285CostType costType;
-
- @JsonProperty("pids")
- public RFC7285QueryPairs pids;
-
- @JsonProperty("constraints")
- public List<String> constraints;
- }
-
- @JsonProperty("meta")
- public Meta meta = new Meta();
-
- @JsonProperty("cost-map")
- public Map<String, Map<String, Object>> map
- = new LinkedHashMap<String, Map<String, Object>>();
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Arrays;
-
-public class RFC7285CostType {
-
- @JsonProperty("cost-mode")
- public String mode = null;
-
- @JsonProperty("cost-metric")
- public String metric = null;
-
- @JsonProperty("description")
- public String description = null;
-
- public RFC7285CostType() {
- }
-
- public RFC7285CostType(String mode, String metric) {
- this.mode = mode;
- this.metric = metric;
- }
-
- public RFC7285CostType(String mode, String metric, String description) {
- this.mode = mode;
- this.metric = metric;
- this.description = description;
- }
-
- @Override
- public int hashCode() {
- String[] members = { metric, mode };
- return Arrays.hashCode(members);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!(obj != null ? (obj instanceof RFC7285CostType) : false))
- return false;
-
- RFC7285CostType other = (RFC7285CostType)obj;
- String[] lhs = { metric, mode };
- String[] rhs = { other.metric, other.mode };
- return Arrays.equals(lhs, rhs);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.LinkedHashMap;
-
-
-public class RFC7285Endpoint {
-
- public static class AddressGroup extends Extensible {
-
- @JsonIgnore
- public static final String IPV4_LABEL = "ipv4";
-
- @JsonIgnore
- public static final String IPV6_LABEL = "ipv6";
-
- @JsonProperty(IPV4_LABEL)
- public List<String> ipv4 = new ArrayList<String>();
-
- @JsonProperty(IPV6_LABEL)
- public List<String> ipv6 = new ArrayList<String>();
-
- }
-
- public static class PropertyRequest {
-
- @JsonProperty(value="properties")
- public List<String> properties;
-
- @JsonProperty(value="endpoints")
- public List<String> endpoints;
- }
-
- public static class PropertyResponse {
-
- public static class Meta extends Extensible {
-
- @JsonProperty("dependent-vtags")
- public List<RFC7285VersionTag> netmap_tags = new ArrayList<RFC7285VersionTag>();
-
- }
-
- @JsonProperty("meta")
- public Meta meta = new Meta();
-
- @JsonProperty("endpoint-properties")
- public Map<String, Map<String, Object>> answer
- = new LinkedHashMap<String, Map<String, Object>>();
- }
-
- public static class CostRequest {
-
- @JsonProperty("cost-type")
- public RFC7285CostType costType;
-
- @JsonProperty("constraints")
- public List<String> constraints = new ArrayList<String>();
-
- @JsonProperty("endpoints")
- public RFC7285QueryPairs endpoints;
- }
-
- public static class CostResponse {
-
- public static class Meta extends Extensible {
-
- @JsonProperty("cost-type")
- public RFC7285CostType costType = new RFC7285CostType();
-
- }
-
- @JsonProperty("meta")
- public Meta meta = new Meta();
-
- @JsonProperty("endpoint-cost-map")
- public Map<String, Map<String, Object>> answer = null;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class RFC7285EndpointPropertyMap {
-
- public static class Meta extends Extensible {
- @JsonProperty("dependent-vtags")
- public List<RFC7285VersionTag> netmap_tags;
- }
-
- @JsonProperty("meta")
- public Meta meta;
-
- @JsonProperty("endpoint-properties")
- public Map<String, Map<String, String>> map
- = new LinkedHashMap<String, Map<String, String>>();
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import java.util.List;
-import java.util.Map;
-import java.util.LinkedHashMap;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class RFC7285IRD {
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- public class Meta {
- @JsonProperty("default-alto-network-map")
- public String defaultAltoNetworkMap;
-
- @JsonProperty("cost-types")
- public Map<String, RFC7285CostType> costTypes = new LinkedHashMap<String, RFC7285CostType>();
-
- }
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- public class Capability {
- @JsonProperty("cost-constraints")
- public Boolean costConstraints;
-
- @JsonProperty("cost-type-names")
- public List<String> costTypeNames;
-
- @JsonProperty("prop-types")
- public List<String> propTypes;
- }
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- public class Entry {
- @JsonProperty("uri")
- public String uri;
-
- @JsonProperty("media-type")
- public String mediaType;
-
- @JsonProperty("accepts")
- public String accepts;
-
- @JsonProperty("capabilities")
- public Capability capabilities;
-
- @JsonProperty("uses")
- public List<String> uses;
- }
-
- @JsonProperty("meta")
- public Meta meta = new Meta();
-
- @JsonProperty("resources")
- public Map<String, Entry> resources = new LinkedHashMap<String, Entry>();
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import java.util.Arrays;
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.JsonMappingException;
-
-public class RFC7285JSONMapper {
-
- private ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(Include.NON_DEFAULT)
- .disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
-
- public RFC7285Endpoint.AddressGroup asAddressGroup(String json) throws Exception {
- return mapper.readValue(json, RFC7285Endpoint.AddressGroup.class);
- }
-
- public RFC7285Endpoint.PropertyRequest asPropertyRequest(String json) throws Exception {
- RFC7285Endpoint.PropertyRequest ret = mapper.readValue(json, RFC7285Endpoint.PropertyRequest.class);
-
- if (ret.properties == null) {
- throw new JsonMappingException("Missing field:properties");
- }
- if (ret.endpoints == null) {
- throw new JsonMappingException("Missing field:endpoints");
- }
- return ret;
- }
-
- public RFC7285Endpoint.PropertyResponse asPropertyResponse(String json) throws Exception {
- return mapper.readValue(json, RFC7285Endpoint.PropertyResponse.class);
- }
-
- public RFC7285Endpoint.CostRequest asCostRequest(String json) throws Exception {
- RFC7285Endpoint.CostRequest ret = mapper.readValue(json, RFC7285Endpoint.CostRequest.class);
- if (ret.costType == null) {
- throw new JsonMappingException("Missing field:cost-type");
- }
- if (ret.endpoints == null) {
- throw new JsonMappingException("Missing field:endpoints");
- }
- return ret;
- }
-
- public RFC7285Endpoint.CostResponse asCostResponse(String json) throws Exception {
- return mapper.readValue(json, RFC7285Endpoint.CostResponse.class);
- }
-
- public RFC7285CostMap asCostMap(String json) throws Exception {
- return mapper.readValue(json, RFC7285CostMap.class);
- }
-
- public List<RFC7285CostMap> asCostMapList(String json) throws Exception {
- return Arrays.asList(mapper.readValue(json, RFC7285CostMap[].class));
- }
-
- public RFC7285CostType asCostType(String json) throws Exception {
- return mapper.readValue(json, RFC7285CostType.class);
- }
-
- public RFC7285Endpoint asEndpoint(String json) throws Exception {
- return mapper.readValue(json, RFC7285Endpoint.class);
- }
-
- public Extensible asExtensible(String json) throws Exception {
- return mapper.readValue(json, Extensible.class);
- }
-
- public RFC7285IRD asIRD(String json) throws Exception {
- return mapper.readValue(json, RFC7285IRD.class);
- }
-
- public RFC7285NetworkMap asNetworkMap(String json) throws Exception {
- return mapper.readValue(json, RFC7285NetworkMap.class);
- }
-
- public List<RFC7285NetworkMap> asNetworkMapList(String json) throws Exception {
- return Arrays.asList(mapper.readValue(json, RFC7285NetworkMap[].class));
- }
-
- public RFC7285NetworkMap.Filter asNetworkMapFilter(String json) throws Exception {
- RFC7285NetworkMap.Filter ret = mapper.readValue(json, RFC7285NetworkMap.Filter.class);
- if (ret.pids == null) {
- throw new JsonMappingException("Missing field:pids");
- }
- return ret;
- }
-
- public RFC7285CostMap.Filter asCostMapFilter(String json) throws Exception {
- RFC7285CostMap.Filter ret = mapper.readValue(json, RFC7285CostMap.Filter.class);
- if (ret.costType == null) {
- throw new JsonMappingException("Missing field:cost-type");
- }
- if (ret.pids == null) {
- throw new JsonMappingException("Missing field:pids");
- }
- return ret;
- }
-
- public RFC7285VersionTag asVersionTag(String json) throws Exception {
- return mapper.readValue(json, RFC7285VersionTag.class);
- }
-
- public RFC7285EndpointPropertyMap asEndpointPropMap(String json) throws Exception {
- return mapper.readValue(json, RFC7285EndpointPropertyMap.class);
- }
-
- public String asJSON(Object obj) throws Exception {
- return mapper.writeValueAsString(obj);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * Network Map: defined in RFC 7285 section 11.2.1
- * */
-public class RFC7285NetworkMap {
-
- public static class Meta extends Extensible {
-
- @JsonProperty("vtag")
- public RFC7285VersionTag vtag = new RFC7285VersionTag();
-
- }
-
- /**
- * used for filtered-network-map, RFC7285 secion 11.3.1
- * */
- public static class Filter {
-
- @JsonProperty("pids")
- public List<String> pids;
- @JsonProperty("address-types")
- public List<String> addressTypes;
- }
-
- @JsonProperty("meta")
- public Meta meta = new Meta();
-
- @JsonProperty("network-map")
- public Map<String, RFC7285Endpoint.AddressGroup> map
- = new LinkedHashMap<String, RFC7285Endpoint.AddressGroup>();
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import java.util.List;
-import java.util.LinkedList;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class RFC7285QueryPairs {
-
- @JsonProperty("srcs")
- public List<String> src = new LinkedList<String>();
-
- @JsonProperty("dsts")
- public List<String> dst = new LinkedList<String>();
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class RFC7285VersionTag {
-
- @JsonProperty("resource-id")
- public String rid;
-
- @JsonProperty("tag")
- public String tag;
-
- public RFC7285VersionTag() {
- rid = "";
- tag = "";
- }
-
- public RFC7285VersionTag(String rid, String tag) {
- this.rid = (rid != null ? rid : "");
- this.tag = (tag != null ? tag : "");
- }
-
- public boolean incomplete() {
- return (rid == null) || (tag == null) || (rid == "") || (tag == "");
- }
-
- private static char ILLEGAL = '$';
-
- @Override
- public int hashCode() {
- return (rid + ILLEGAL + tag).hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
-
- RFC7285VersionTag other = (RFC7285VersionTag)obj;
- boolean _rid = (rid == null ? (other.rid == null) : rid.equals(other.rid));
- boolean _tag = (tag == null ? (other.tag == null) : tag.equals(other.tag));
- return (_rid && _tag);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import org.opendaylight.alto.commons.types.model150404.ModelCostMap;
-import org.opendaylight.alto.commons.types.model150404.ModelJSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class RFC2ModelCostMapConverterTest {
- String costMapJson;
- RFC2ModelCostMapConverter converter;
- ObjectMapper mapper;
- ModelJSONMapper model2Json;
- String yangModelString;
-
- @Before
- public void init() {
- costMapJson = "{\"meta\":{\"dependent-vtags\":[{\"resource-id\":\"my-default-network-map\",\"tag\":\"3ee2cb7e8d63d9fab71b9b34cbf764436315542e\"}],\"cost-type\":{\"cost-mode\":\"numerical\",\"cost-metric\":\"routingcost\"}},\"cost-map\":{\"PID1\":{\"PID1\":1,\"PID2\":5,\"PID3\":10},\"PID2\":{\"PID1\":5,\"PID2\":1,\"PID3\":15},\"PID3\":{\"PID1\":20,\"PID2\":15}}}";
- converter = new RFC2ModelCostMapConverter();
- mapper = new ObjectMapper();
- model2Json = new ModelJSONMapper();
- yangModelString = "{\"alto-service:resource-id\":\"my-default-network-map-routingcost-numerical\",\"alto-service:tag\":\"da65eca2eb7a10ce8b059740b0b2e3f8eb1d4786\",\"alto-service:meta\":{\"alto-service:dependent-vtags\":[{\"alto-service:resource-id\":\"my-default-network-map\",\"alto-service:tag\":\"3ee2cb7e8d63d9fab71b9b34cbf764436315542e\"}],\"alto-service:cost-type\":{\"alto-service:cost-mode\":\"numerical\",\"alto-service:cost-metric\":\"routingcost\"}},\"alto-service:map\":[{\"alto-service:src\":\"PID1\",\"alto-service:dst-costs\":[{\"alto-service:dst\":\"PID1\",\"alto-cost-default:cost-default\":\"1\"},{\"alto-service:dst\":\"PID2\",\"alto-cost-default:cost-default\":\"5\"},{\"alto-service:dst\":\"PID3\",\"alto-cost-default:cost-default\":\"10\"}]},{\"alto-service:src\":\"PID2\",\"alto-service:dst-costs\":[{\"alto-service:dst\":\"PID1\",\"alto-cost-default:cost-default\":\"5\"},{\"alto-service:dst\":\"PID2\",\"alto-cost-default:cost-default\":\"1\"},{\"alto-service:dst\":\"PID3\",\"alto-cost-default:cost-default\":\"15\"}]},{\"alto-service:src\":\"PID3\",\"alto-service:dst-costs\":[{\"alto-service:dst\":\"PID1\",\"alto-cost-default:cost-default\":\"20\"},{\"alto-service:dst\":\"PID2\",\"alto-cost-default:cost-default\":\"15\"}]}]}";
- }
-
- @Test
- public void onRFC2Model() throws Exception {
- RFC7285CostMap costMap = mapper.readValue(costMapJson,RFC7285CostMap.class);
- ModelCostMap model = converter.convert(costMap);
- String resultJson = model2Json.asJSON(model);
- Assert.assertEquals(resultJson, this.yangModelString);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.alto.commons.types.model150404.ModelEndpointPropertyMap;
-import org.opendaylight.alto.commons.types.model150404.ModelJSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285EndpointPropertyMap;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class RFC2ModelEndpointPropMapConverterTest {
- String endpointPropMapJson;
- RFC2ModelEndpointPropMapConverter converter;
- ObjectMapper mapper;
- ModelJSONMapper model2Json;
- String yangModelString;
-
- @Before
- public void init(){
- endpointPropMapJson = "{\"meta\":{\"dependent-vtags\":[{\"resource-id\":\"my-default-network-map\",\"tag\":\"7915dc0290c2705481c491a2b4ffbec482b3cf62\"}]},\"endpoint-properties\":{\"ipv4:192.0.2.34\":{\"my-default-network-map.pid\":\"PID1\",\"priv:ietf-example-prop\":\"1\"},\"ipv4:203.0.113.129\":{\"my-default-network-map.pid\":\"PID3\"}}}";
- converter = new RFC2ModelEndpointPropMapConverter();
- mapper = new ObjectMapper();
- model2Json = new ModelJSONMapper();
- yangModelString = "{\"alto-service:meta\":{\"alto-service:dependent-vtags\":[{\"alto-service:resource-id\":\"my-default-network-map\",\"alto-service:tag\":\"7915dc0290c2705481c491a2b4ffbec482b3cf62\"}]},\"alto-service:endpoint-properties\":[{\"alto-service:endpoint\":\"ipv4:192.0.2.34\",\"alto-service:properties\":[{\"alto-service:property-type\":\"my-default-network-map.pid\",\"alto-service:property\":\"PID1\"},{\"alto-service:property-type\":\"priv:ietf-example-prop\",\"alto-service:property\":\"1\"}]},{\"alto-service:endpoint\":\"ipv4:203.0.113.129\",\"alto-service:properties\":[{\"alto-service:property-type\":\"my-default-network-map.pid\",\"alto-service:property\":\"PID3\"}]}]}";
- }
-
- @Test
- public void onRFC2Model() throws Exception{
- RFC7285EndpointPropertyMap endpointPropertyMap = mapper.readValue(this.endpointPropMapJson, RFC7285EndpointPropertyMap.class);
- ModelEndpointPropertyMap model = converter.convert(endpointPropertyMap);
- String resultJson = model2Json.asJSON(model);
- Assert.assertEquals(resultJson, this.yangModelString);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
-import org.opendaylight.alto.commons.types.model150404.ModelJSONMapper;
-import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class RFC2ModelNetworkMapConverterTest {
-
- private RFC2ModelNetworkMapConverter nmconv;
- private RFC7285JSONMapper rfcMapper;
- private ModelJSONMapper modelMapper;
-
- @Before
- public void init() {
- nmconv = new RFC2ModelNetworkMapConverter();
- rfcMapper = new RFC7285JSONMapper();
- modelMapper = new ModelJSONMapper();
- }
-
- @Test
- public void onRFC2ModelNetworkMap() throws Exception {
- String testInput = "{\"network-map\": {\"PID1\": {\"ipv4\": [\"192.0.2.0/24\", \"198.51.100.0/25\"]}, \"PID2\": {\"ipv4\": [\"198.51.100.128/25\"]}, \"PID3\": {\"ipv6\": [\"::/0\"], \"ipv4\": [\"0.0.0.0/0\"]}}, \"meta\": {\"vtag\": {\"tag\": \"da65eca2eb7a10ce8b059740b0b2e3f8eb1d4785\", \"resource-id\": \"my-default-network-map\"}}}";
- RFC7285NetworkMap rfcMap = rfcMapper.asNetworkMap(testInput);
- ModelNetworkMap modelMap = nmconv.convert(rfcMap);
- String result = modelMapper.asJSON(modelMap);
- String testOutput = "{\"alto-service:resource-id\":\"my-default-network-map\",\"alto-service:tag\":\"da65eca2eb7a10ce8b059740b0b2e3f8eb1d4785\",\"alto-service:map\":[{\"alto-service:pid\":\"PID1\",\"alto-service:endpoint-address-group\":[{\"alto-service:address-type\":\"ipv4\",\"alto-service:endpoint-prefix\":[\"192.0.2.0/24\",\"198.51.100.0/25\"]}]},{\"alto-service:pid\":\"PID2\",\"alto-service:endpoint-address-group\":[{\"alto-service:address-type\":\"ipv4\",\"alto-service:endpoint-prefix\":[\"198.51.100.128/25\"]}]},{\"alto-service:pid\":\"PID3\",\"alto-service:endpoint-address-group\":[{\"alto-service:address-type\":\"ipv4\",\"alto-service:endpoint-prefix\":[\"0.0.0.0/0\"]},{\"alto-service:address-type\":\"ipv6\",\"alto-service:endpoint-prefix\":[\"::/0\"]}]}]}";
- Assert.assertEquals(testOutput, result);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-
-import org.opendaylight.alto.commons.types.model150404.ModelJSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class YANGJSON2RFCCostMapConverterTest {
- String costMapJson;
- YANGJSON2RFCCostMapConverter converter;
- ObjectMapper mapper;
- ModelJSONMapper model2Json;
- String yangModelString;
-
- @Before
- public void init() {
- yangModelString = "{\"key\":{\"resourceId\":{\"value\":\"my-default-network-map-routingcost-numerical\"}},\"map\":[{\"key\":{\"src\":{\"value\":\"PID3\"}},\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Map\",\"dstCosts\":[{\"dst\":{\"value\":\"PID2\"},\"cost\":\"15\"},{\"dst\":{\"value\":\"PID1\"},\"cost\":\"20\"}],\"src\":{\"value\":\"PID3\"}},{\"key\":{\"src\":{\"value\":\"PID2\"}},\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Map\",\"dstCosts\":[{\"dst\":{\"value\":\"PID2\"},\"cost\":\"1\"},{\"dst\":{\"value\":\"PID1\"},\"cost\":\"5\"},{\"dst\":{\"value\":\"PID3\"},\"cost\":\"15\"}],\"src\":{\"value\":\"PID2\"}},{\"key\":{\"src\":{\"value\":\"PID1\"}},\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Map\",\"dstCosts\":[{\"dst\":{\"value\":\"PID2\"},\"cost\":\"5\"},{\"dst\":{\"value\":\"PID1\"},\"cost\":\"1\"},{\"dst\":{\"value\":\"PID3\"},\"cost\":\"10\"}],\"src\":{\"value\":\"PID1\"}}],\"tag\":{\"value\":\"da65eca2eb7a10ce8b059740b0b2e3f8eb1d4786\"},\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.cost.maps.CostMap\",\"resourceId\":{\"value\":\"my-default-network-map-routingcost-numerical\"},\"meta\":{\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Meta\",\"costType\":{\"description\":null,\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.cost.map.meta.CostType\",\"costMetric\":{\"value\":\"routingcost\",\"enumeration\":null,\"string\":\"routingcost\"},\"costMode\":\"Numerical\"},\"dependentVtags\":[{\"key\":{\"resourceId\":{\"value\":\"my-default-network-map\"}},\"tag\":{\"value\":\"3ee2cb7e8d63d9fab71b9b34cbf764436315542e\"},\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.dependent.vtags.DependentVtags\",\"resourceId\":{\"value\":\"my-default-network-map\"}}]}}";
- converter = new YANGJSON2RFCCostMapConverter();
- mapper = new ObjectMapper();
- model2Json = new ModelJSONMapper();
- costMapJson = "{\"meta\":{\"dependent-vtags\":[{\"resource-id\":\"my-default-network-map\",\"tag\":\"3ee2cb7e8d63d9fab71b9b34cbf764436315542e\"}],\"cost-type\":{\"cost-mode\":\"numerical\",\"cost-metric\":\"routingcost\"}},\"cost-map\":{\"PID3\":{\"PID2\":15.0,\"PID1\":20.0},\"PID2\":{\"PID2\":1.0,\"PID1\":5.0,\"PID3\":15.0},\"PID1\":{\"PID2\":5.0,\"PID1\":1.0,\"PID3\":10.0}}}";
- }
-
- @Test
- public void onYANGJSON2RFC() throws Exception {
- JsonNode node = mapper.readTree(yangModelString);
- RFC7285CostMap costMap = converter.convert(node);
- String resultJson = model2Json.asJSON(costMap);
- Assert.assertEquals(resultJson, this.costMapJson);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.converter;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-//import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class YANGJSON2RFCNetworkMapConverterTest {
- private RFC7285JSONMapper rfcMapper;
- private YANGJSON2RFCNetworkMapConverter ynmc;
- private ObjectMapper objectMapper;
- private RFC2ModelNetworkMapConverter nmconv;
- @Before
- public void init() {
- rfcMapper = new RFC7285JSONMapper();
- objectMapper = new ObjectMapper();
- ynmc = new YANGJSON2RFCNetworkMapConverter();
- }
-
- @Test
- public void onModel2RFCNetworkMap() throws Exception {
- String testInput = "{\"resourceId\":{\"value\":\"my-default-network-map\"},\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap\",\"tag\":{\"value\":\"da65eca2eb7a10ce8b059740b0b2e3f8eb1d4785\"},\"key\":{\"resourceId\":{\"value\":\"my-default-network-map\"}},\"map\":[{\"endpointAddressGroup\":[{\"endpointPrefix\":[{\"ipv4Prefix\":null,\"ipv6Prefix\":{\"value\":\"::/0\"},\"value\":\"::/0\"}],\"addressType\":{\"value\":\"ipv6\",\"enumeration\":\"Ipv6\"},\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup\",\"key\":{\"addressType\":{\"value\":\"ipv6\",\"enumeration\":\"Ipv6\"}}},{\"endpointPrefix\":[{\"ipv4Prefix\":{\"value\":\"0.0.0.0/0\"},\"ipv6Prefix\":null,\"value\":\"0.0.0.0/0\"}],\"addressType\":{\"value\":\"ipv4\",\"enumeration\":\"Ipv4\"},\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup\",\"key\":{\"addressType\":{\"value\":\"ipv4\",\"enumeration\":\"Ipv4\"}}}],\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map\",\"key\":{\"pid\":{\"value\":\"PID3\"}},\"pid\":{\"value\":\"PID3\"}},{\"endpointAddressGroup\":[{\"endpointPrefix\":[{\"ipv4Prefix\":{\"value\":\"198.51.100.128/25\"},\"ipv6Prefix\":null,\"value\":\"198.51.100.128/25\"}],\"addressType\":{\"value\":\"ipv4\",\"enumeration\":\"Ipv4\"},\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup\",\"key\":{\"addressType\":{\"value\":\"ipv4\",\"enumeration\":\"Ipv4\"}}}],\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map\",\"key\":{\"pid\":{\"value\":\"PID2\"}},\"pid\":{\"value\":\"PID2\"}},{\"endpointAddressGroup\":[{\"endpointPrefix\":[{\"ipv4Prefix\":{\"value\":\"192.0.2.0/24\"},\"ipv6Prefix\":null,\"value\":\"192.0.2.0/24\"},{\"ipv4Prefix\":{\"value\":\"198.51.100.0/25\"},\"ipv6Prefix\":null,\"value\":\"198.51.100.0/25\"}],\"addressType\":{\"value\":\"ipv4\",\"enumeration\":\"Ipv4\"},\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup\",\"key\":{\"addressType\":{\"value\":\"ipv4\",\"enumeration\":\"Ipv4\"}}}],\"implementedInterface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map\",\"key\":{\"pid\":{\"value\":\"PID1\"}},\"pid\":{\"value\":\"PID1\"}}]}";
- ObjectNode node = (ObjectNode) objectMapper.readTree(testInput);
- RFC7285NetworkMap rnm = ynmc.convert(node);
- String result = rfcMapper.asJSON(rnm);
- String testOutput = "{\"meta\":{\"vtag\":{\"resource-id\":\"my-default-network-map\",\"tag\":\"da65eca2eb7a10ce8b059740b0b2e3f8eb1d4785\"}},\"network-map\":{\"PID3\":{\"ipv4\":[\"0.0.0.0/0\"],\"ipv6\":[\"::/0\"]},\"PID2\":{\"ipv4\":[\"198.51.100.128/25\"]},\"PID1\":{\"ipv4\":[\"192.0.2.0/24\",\"198.51.100.0/25\"]}}}";
- Assert.assertEquals(testOutput, result);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.ArrayList;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestRFC7285Types {
-
- public RFC7285NetworkMap makeNetworkMap() {
- /*
- *
- * {
- * "meta" : {
- * "vtag": {
- * "resource-id": "my-default-network-map",
- * "tag": "da65eca2eb7a10ce8b059740b0b2e3f8eb1d4785"
- * }
- * },
- * "network-map": {
- * "PID1" : {
- * "ipv4" : [
- * "192.0.2.0/24",
- * "198.51.100.0/25"
- * ]
- * },
- * "PID2" : {
- * "ipv4" : [
- * "198.51.100.128/25"
- * ]
- * },
- * "PID3" : {
- * "ipv4" : [
- * "0.0.0.0/0"
- * ],
- * "ipv6" : [
- * "::/0"
- * ]
- * }
- * }
- * }
- *
- * */
- RFC7285NetworkMap nm = new RFC7285NetworkMap();
- nm.meta.vtag = new RFC7285VersionTag("my-default-network-map",
- "da65eca2eb7a10ce8b059740b0b2e3f8eb1d4785");
-
- nm.map.put("PID1", new RFC7285Endpoint.AddressGroup());
- nm.map.get("PID1").ipv4.add("192.0.2.0/24");
- nm.map.get("PID1").ipv4.add("198.51.100.0/25");
-
- nm.map.put("PID2", new RFC7285Endpoint.AddressGroup());
- nm.map.get("PID2").ipv4.add("198.51.100.128/25");
-
- nm.map.put("PID3", new RFC7285Endpoint.AddressGroup());
- nm.map.get("PID3").ipv4.add("0.0.0.0/0");
- nm.map.get("PID3").ipv6.add("::/0");
-
- return nm;
- }
-
- @Test
- public void test() {
- }
-
- public <T> void assertCollectionEquals(Collection<T> lhs, Collection<T> rhs) {
- Set<T> _lhs = new HashSet<T>(lhs);
- Set<T> _rhs = new HashSet<T>(rhs);
- assertEquals(lhs.size(), rhs.size());
-
- for (T obj: lhs) {
- assertTrue(_rhs.contains(obj));
- }
- }
-
- @Test
- public void testNetworkMap() throws Exception {
- RFC7285JSONMapper mapper = new RFC7285JSONMapper();
-
- RFC7285NetworkMap nm = makeNetworkMap();
- String nmText = mapper.asJSON(nm);
- RFC7285NetworkMap _nm = mapper.asNetworkMap(nmText);
-
- assertEquals(nm.meta.vtag, _nm.meta.vtag);
- assertEquals(nm.map.size(), _nm.map.size());
- assertCollectionEquals(nm.map.get("PID1").ipv4, _nm.map.get("PID1").ipv4);
- assertCollectionEquals(nm.map.get("PID2").ipv4, _nm.map.get("PID2").ipv4);
- assertCollectionEquals(nm.map.get("PID3").ipv4, _nm.map.get("PID3").ipv4);
- assertCollectionEquals(nm.map.get("PID3").ipv6, _nm.map.get("PID3").ipv6);
-
- String addrGroupString = mapper.asJSON(nm.map.get("PID3"));
- RFC7285Endpoint.AddressGroup _ag = mapper.asAddressGroup(addrGroupString);
- assertCollectionEquals(nm.map.get("PID3").ipv4, _ag.ipv4);
- assertCollectionEquals(nm.map.get("PID3").ipv6, _ag.ipv6);
- }
-
- @Test
- public void testNetworkMapFilter() throws Exception {
- /*
- *
- * {
- * "pids": [ "PID1", "PID2" ]
- * }
- * */
-
- RFC7285JSONMapper mapper = new RFC7285JSONMapper();
-
- RFC7285NetworkMap.Filter filter = new RFC7285NetworkMap.Filter();
- filter.pids = new ArrayList<String>();
- filter.pids.add("PID1");
- filter.pids.add("PID2");
-
- String nmfString = mapper.asJSON(filter);
- RFC7285NetworkMap.Filter _filter = mapper.asNetworkMapFilter(nmfString);
- assertCollectionEquals(filter.pids, _filter.pids);
- }
-
- public RFC7285CostMap makeCostMap() {
- /*
- * {
- * "meta": {
- * "dependent-vtags" : [
- * {
- * "resource-id": "my-default-network-map",
- * "tag": "3ee2cb7e8d63d9fab71b9b34cbf764436315542e"
- * }
- * ],
- * "cost-type" : {
- * "cost-mode": "numerical",
- * "cost-metric": "routingcost"
- * }
- * },
- * "cost-map" : {
- * "PID1": { "PID1": 1, "PID2": 5, "PID3": 10 },
- * "PID2": { "PID1": 5, "PID2": 1, "PID3": 15 },
- * "PID3": { "PID1": 20, "PID2": 15 }
- * }
- * }
- * */
-
- RFC7285CostMap cm = new RFC7285CostMap();
- cm.meta.costType = new RFC7285CostType("numerical", "routingcost");
- cm.meta.netmap_tags.add(new RFC7285VersionTag("my-default-network-map",
- "3ee2cb7e8d63d9fab71b9b34cbf764436315542e"));
- cm.map.put("PID1", new LinkedHashMap<String, Object>());
- cm.map.get("PID1").put("PID1", new Integer(1));
- cm.map.get("PID1").put("PID2", new Integer(5));
- cm.map.get("PID1").put("PID3", new Integer(10));
- cm.map.put("PID2", new LinkedHashMap<String, Object>());
- cm.map.get("PID2").put("PID1", new Integer(5));
- cm.map.get("PID2").put("PID2", new Integer(1));
- cm.map.get("PID2").put("PID3", new Integer(15));
- cm.map.put("PID3", new LinkedHashMap<String, Object>());
- cm.map.get("PID3").put("PID1", new Integer(20));
- cm.map.get("PID3").put("PID2", new Integer(15));
-
- return cm;
- }
-
- @Test
- public void testCostMap() throws Exception {
- RFC7285JSONMapper mapper = new RFC7285JSONMapper();
-
- RFC7285CostMap cm = makeCostMap();
-
- String cmString = mapper.asJSON(cm);
- RFC7285CostMap _cm = mapper.asCostMap(cmString);
-
- assertCollectionEquals(cm.meta.netmap_tags, _cm.meta.netmap_tags);
- assertEquals(cm.meta.costType, _cm.meta.costType);
-
- String pids[] = { "PID1", "PID2", "PID3" };
- for (String pid: pids) {
- assertCollectionEquals(cm.map.get(pid).entrySet(), _cm.map.get(pid).entrySet());
- }
- }
-
- @Test
- public void testCostMapFilter() throws Exception {
- /*
- * {
- * "cost-type" : {
- * "cost-mode": "numerical",
- * "cost-metric": "routingcost"
- * },
- * "pids" : {
- * "srcs" : [ "PID1" ],
- * "dsts" : [ "PID1", "PID2", "PID3" ]
- * }
- * }
- * */
-
- RFC7285JSONMapper mapper = new RFC7285JSONMapper();
-
- RFC7285CostMap.Filter filter = new RFC7285CostMap.Filter();
- filter.costType = new RFC7285CostType("numerical", "routingcost", "test");
- filter.pids = new RFC7285QueryPairs();
- filter.pids.src.add("PID1");
- filter.pids.dst.add("PID1");
- filter.pids.dst.add("PID2");
- filter.pids.dst.add("PID3");
-
- String cmfString = mapper.asJSON(filter);
- RFC7285CostMap.Filter _filter = mapper.asCostMapFilter(cmfString);
-
- assertEquals(filter.costType, _filter.costType);
- assertCollectionEquals(filter.pids.src, _filter.pids.src);
- assertCollectionEquals(filter.pids.dst, _filter.pids.dst);
- }
-
- @Test
- public void testECSRequest() throws Exception {
- /*
- * {
- * "cost-type" : {
- * "cost-mode": "ordinal",
- * "cost-metric": "routingcost"
- * },
- * "endpoints": {
- * "srcs": [ "ipv4:192.0.2.2" ],
- * "dsts": [
- * "ipv4:192.0.2.89",
- * "ipv4:198.51.100.34",
- * "ipv4:203.0.113.45"
- * ]
- * }
- * }
- * */
-
- RFC7285JSONMapper mapper = new RFC7285JSONMapper();
-
- RFC7285Endpoint.CostRequest req = new RFC7285Endpoint.CostRequest();
- req.costType = new RFC7285CostType("ordinal", "routingcost", "test");
- req.endpoints = new RFC7285QueryPairs();
- req.endpoints.src.add("ipv4:192.0.2.2");
- req.endpoints.dst.add("ipv4:192.0.2.89");
- req.endpoints.dst.add("ipv4:198.51.100.34");
- req.endpoints.dst.add("ipv4:203.0.113.45");
-
- String ecsrString = mapper.asJSON(req);
- RFC7285Endpoint.CostRequest _req = mapper.asCostRequest(ecsrString);
-
- assertEquals(req.costType, _req.costType);
- assertCollectionEquals(req.endpoints.src, _req.endpoints.src);
- assertCollectionEquals(req.endpoints.dst, _req.endpoints.dst);
- }
-
- public RFC7285Endpoint.CostResponse makeECSResponse() {
- /*
- * {
- * "meta": {
- * "cost-type" : {
- * "cost-mode": "ordinal",
- * "cost-metric": "routingcost"
- * }
- * },
- * "endpoint-cost-map" : {
- * "ipv4:192.0.2.2": {
- * "ipv4:192.0.2.89": 1,
- * "ipv4:198.51.100.34": 2,
- * "ipv4:203.0.113.45": 3
- * },
- * }
- * }
- * */
-
- String src[] = { "ipv4:192.0.2.2" };
- String dst[] = { "ipv4:192.0.2.89", "ipv4:198.51.100.34", "ipv4:203.0.113.45" };
-
- RFC7285Endpoint.CostResponse ecsr = new RFC7285Endpoint.CostResponse();
- ecsr.meta.costType = new RFC7285CostType("ordinal", "routingcost");
- ecsr.answer = new LinkedHashMap<String, Map<String, Object>>();
- ecsr.answer.put(src[0], new LinkedHashMap<String, Object>());
- ecsr.answer.get(src[0]).put(dst[0], new Integer(1));
- ecsr.answer.get(src[0]).put(dst[1], new Integer(2));
- ecsr.answer.get(src[0]).put(dst[2], new Integer(3));
-
- return ecsr;
- }
-
- @Test
- public void testECSAnswer() throws Exception {
- RFC7285JSONMapper mapper = new RFC7285JSONMapper();
-
- RFC7285Endpoint.CostResponse ecsr = makeECSResponse();
-
- String ecsrString = mapper.asJSON(ecsr);
- RFC7285Endpoint.CostResponse _ecsr = mapper.asCostResponse(ecsrString);
-
- assertEquals(ecsr.meta.costType, _ecsr.meta.costType);
-
- String endpoints[] = { "ipv4:192.0.2.2" };
- for (String endpoint: endpoints) {
- assertCollectionEquals(ecsr.answer.get(endpoint).entrySet(),
- _ecsr.answer.get(endpoint).entrySet());
- }
- }
-
- @Test
- public void testEPSRequest() throws Exception {
- /*
- * {
- * "properties" : [
- * "my-default-networkmap.pid",
- * "priv:ietf-example-prop"
- * ],
- * "endpoints" : [
- * "ipv4:192.0.2.34",
- * "ipv4:203.0.113.129"
- * ]
- * }
- */
- RFC7285JSONMapper mapper = new RFC7285JSONMapper();
-
- RFC7285Endpoint.PropertyRequest req = new RFC7285Endpoint.PropertyRequest();
- if (req.properties == null)
- req.properties = new ArrayList<String>();
- req.properties.add("my-default-networkmap.pid");
- req.properties.add("priv:ietf-example-prop");
-
- if (req.endpoints == null)
- req.endpoints = new ArrayList<String>();
-
- req.endpoints.add("ipv4:192.0.2.34");
- req.endpoints.add("ipv4:203.0.113.129");
-
- String epsrString = mapper.asJSON(req);
- RFC7285Endpoint.PropertyRequest _req = mapper.asPropertyRequest(epsrString);
-
- assertCollectionEquals(req.properties, _req.properties);
- assertCollectionEquals(req.endpoints, _req.endpoints);
- }
-
- @Test
- public void testEPSResponse() throws Exception {
- /*
- * {
- * "meta" : {
- * "dependent-vtags" : [
- * {
- * "resource-id": "my-default-network-map",
- * "tag": "7915dc0290c2705481c491a2b4ffbec482b3cf62"
- * }
- * ]
- * },
- * "endpoint-properties": {
- * "ipv4:192.0.2.34": {
- * "my-default-network-map.pid": "PID1",
- * "priv:ietf-example-prop": "1"
- * },
- * "ipv4:203.0.113.129": {
- * "my-default-network-map.pid": "PID3"
- * }
- * }
- * }
- * */
- RFC7285JSONMapper mapper = new RFC7285JSONMapper();
-
- RFC7285Endpoint.PropertyResponse res = new RFC7285Endpoint.PropertyResponse();
- RFC7285VersionTag vtag = new RFC7285VersionTag("my-default-network-map",
- "7915dc0290c2705481c491a2b4ffbec482b3cf62");
- res.meta.netmap_tags.add(vtag);
-
- String endpoints[] = { "ipv4:192.0.2.34", "ipv4:203.0.113.129" };
- String properties[] = { "my-default-network-map", "priv:itef-example-prop" };
- for (String endpoint: endpoints) {
- res.answer.put(endpoint, new LinkedHashMap<String, Object>());
- }
- res.answer.get(endpoints[0]).put(properties[0], "PID1");
- res.answer.get(endpoints[0]).put(properties[1], new Integer(1));
- res.answer.get(endpoints[1]).put(properties[0], "PID3");
-
- String epsrString = mapper.asJSON(res);
- RFC7285Endpoint.PropertyResponse _res = mapper.asPropertyResponse(epsrString);
-
- assertCollectionEquals(res.meta.netmap_tags, _res.meta.netmap_tags);
- for (String endpoint: endpoints) {
- assertCollectionEquals(res.answer.get(endpoint).entrySet(),
- _res.answer.get(endpoint).entrySet());
- }
- }
-}
+++ /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</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
-
- <artifactId>alto-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/03-alto.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"?>
-<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:alto="urn:opendaylight:params:xml:ns:yang:controller:config:alto-provider:impl">
- alto:alto-provider-impl
- </type>
- <name>alto-provider-impl</name>
-
- <rpc-registry>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
- <name>binding-rpc-broker</name>
- </rpc-registry>
-
- <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:params:xml:ns:yang:controller:config:alto-provider:impl?module=alto-provider-impl&revision=2014-11-19</capability>
- </required-capabilities>
-
-</snapshot>
-
+++ /dev/null
-<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/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>alto-extensions</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../../</relativePath>
- </parent>
-
- <artifactId>file-converter</artifactId>
- <packaging>bundle</packaging>
- <name>${project.artifactId}</name>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-model</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- <version>2.2.11</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-commons</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>${bundle.plugin.version}</version>
- <configuration>
- <instructions>
- <Import-Package>
- org.apache.felix.service.command,
- org.apache.felix.gogo.commands,
- org.apache.karaf.shell.console,
- org.opendaylight.alto.commons.types.*,
- *
- </Import-Package>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.ext.cli.fileconverter;
-
-public class ConvertType {
-
- //TODO add more types
-
- public static final String NETWORK_MAP = "networkmap";
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.ext.cli.fileconverter;
-
-import java.io.File;
-import java.nio.charset.StandardCharsets;
-
-import com.google.common.io.Files;
-
-class FileConverterHelper {
-
- public String load(String path) throws Exception {
- File file = new File(path);
- return Files.toString(file, StandardCharsets.US_ASCII);
- }
-
- public void save(String path, String content) throws Exception {
- File file = new File(path);
- Files.write(content, file, StandardCharsets.US_ASCII);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.ext.cli.fileconverter;
-
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-import org.opendaylight.alto.commons.types.converter.RFC2ModelNetworkMapConverter;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
-import org.opendaylight.alto.commons.types.model150404.ModelJSONMapper;
-import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Command(scope = "alto", name = "file-rfc2yang", description = "Convert file from RFC 7285 format to Yang Data format")
-public class RFC2Yang extends OsgiCommandSupport {
-
- private static final Logger logger = LoggerFactory.getLogger(RFC2Yang.class);
-
- @Argument(index = 0, name = "type", description = "The type of the source file", required = true, multiValued = false)
- String type = null;
-
- @Argument(index = 1, name = "source", description = "The source file", required = true, multiValued = false)
- String source = null;
-
- @Argument(index = 2, name = "target", description = "The target file", required = false, multiValued = false)
- String target = null;
-
- protected RFC7285JSONMapper rfcMapper = new RFC7285JSONMapper();
- protected ModelJSONMapper modelMapper = new ModelJSONMapper();
- protected FileConverterHelper helper = new FileConverterHelper();
-
- @Override
- protected Object doExecute() throws Exception {
- logger.info("command: alto:rfc2yang {} {} {}",
- type, source, target);
- if (ConvertType.NETWORK_MAP.equals(type)) {
- String input = helper.load(source);
- RFC7285NetworkMap rfcMap = rfcMapper.asNetworkMap(input);
-
- RFC2ModelNetworkMapConverter conv = new RFC2ModelNetworkMapConverter();
-
- ModelNetworkMap modelMap = conv.convert(rfcMap);
- String output = modelMapper.asJSON(modelMap);
- helper.save(target, output);
- }
- throw new UnsupportedOperationException("Not implemented yet");
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.ext.cli.fileconverter;
-
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Command(scope = "alto", name = "file-yang2rfc", description = "The converter between RFC 7285 and Yang Model files")
-public class Yang2RFC extends OsgiCommandSupport {
-
- private static final Logger logger = LoggerFactory.getLogger(Yang2RFC.class);
-
- @Argument(index = 0, name = "type", description = "The type of the source file", required = true, multiValued = false)
- String type = null;
-
- @Argument(index = 1, name = "source", description = "The source file", required = true, multiValued = false)
- String source = null;
-
- @Argument(index = 2, name = "target", description = "The target file", required = false, multiValued = false)
- String target = null;
-
- @Override
- protected Object doExecute() throws Exception {
- logger.info("command: alto:rfc2yang {} {} {}",
- type, source, target);
-
- throw new UnsupportedOperationException("Not implemented yet");
- }
-}
-
+++ /dev/null
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
- <command name="alto/file-yang2rfc">
- <action class="org.opendaylight.alto.ext.cli.fileconvertor.Yang2RFC"/>
- </command>
-
- <command name="alto/file-rfc2yang">
- <action class="org.opendaylight.alto.ext.cli.fileconvertor.RFC2Yang"/>
- </command>
- </command-bundle>
-</blueprint>
+++ /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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
-
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>alto-cli-extension</artifactId>
- <packaging>pom</packaging>
-
- <modules>
- <module>file-converter</module>
- </modules>
-
-</project>
-
+++ /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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>alto-extensions</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>alto-fake-extension</artifactId>
- <packaging>bundle</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <executions>
- <execution>
- <phase>process-sources</phase>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
-
- <configuration>
- <failsOnError>true</failsOnError>
- <configLocation>controller/checkstyle.xml</configLocation>
- <consoleOutput>true</consoleOutput>
- <includeTestSourceDirectory>true</includeTestSourceDirectory>
- <sourceDirectory>${project.basedir}</sourceDirectory>
- <excludes>**\/target\/,**\/bin\/,**\/third-party,**\/yang-gen-sal</excludes>
- </configuration>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>checkstyle</artifactId>
- <version>${controller.checkstyle.version}</version>
- </dependency>
- </dependencies>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>*</Import-Package>
- <Export-Package>
- org.opendaylight.alto.ext.fake;
- </Export-Package>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-model</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-commons</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>service-api-rfc7285</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.ext.fake;
-
-import org.opendaylight.alto.services.api.rfc7285.AltoService;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostRequest;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostResponse;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.PropertyRequest;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.PropertyResponse;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285IRD;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
-
-public class FakeAltoService implements AltoService {
-
- private RFC7285JSONMapper mapper = new RFC7285JSONMapper();
-
- private static final String NETWORKMAP_JSON =
- "{"
- + "\"meta\" : {"
- + "\"vtag\": {"
- + "\"resource-id\": \"default-networkmap\","
- + "\"tag\": \"3ee2cb7e8d63d9fab71b9b34cbf764436315542e\""
- + "}"
- + "},"
- + "\"network-map\" : {"
- + "\"PID1\" : {"
- + "\"ipv4\" : ["
- + "\"192.0.2.0/24\","
- + "\"198.51.100.0/25\""
- + "]"
- + "},"
- + "\"PID2\" : {"
- + "\"ipv4\" : ["
- + "\"198.51.100.128/25\""
- + "]"
- + "},"
- + "\"PID3\" : {"
- + "\"ipv4\" : ["
- + "\"0.0.0.0/0\""
- + "],"
- + "\"ipv6\" : ["
- + "\"::/0\""
- + "]"
- + "}"
- + "}"
- + "}";
-
- private static final String DEFAULT_NETWORKMAP_ID = "default-networkmap";
- private static final String DEFAULT_NETWORKMAP_TAG = "3ee2cb7e8d63d9fab71b9b34cbf764436315542e";
- private RFC7285NetworkMap networkMap = null;
-
- private static final String COSTMAP_JSON =
- "{"
- + "\"meta\" : {"
- + "\"dependent-vtags\" : ["
- + "{"
- + "\"resource-id\": \"default-networkmap\","
- + "\"tag\": \"3ee2cb7e8d63d9fab71b9b34cbf764436315542e\""
- + "}"
- + "],"
- + "\"cost-type\" : {"
- + "\"cost-mode\" : \"numerical\","
- + "\"cost-metric\": \"routingcost\""
- + "}"
- + "},"
- + "\"cost-map\" : {"
- + "\"PID1\": { \"PID1\": 1, \"PID2\": 5, \"PID3\": 10 },"
- + "\"PID2\": { \"PID1\": 5, \"PID2\": 1, \"PID3\": 15 },"
- + "\"PID3\": { \"PID1\": 20, \"PID2\": 15 }"
- + "}"
- + "}";
-
- private static final String DEFAULT_COSTMAP_ID = "default-costmap";
-
- private RFC7285CostMap costMap = null;
-
- public FakeAltoService() {
- try {
- networkMap = mapper.asNetworkMap(NETWORKMAP_JSON);
- costMap = mapper.asCostMap(COSTMAP_JSON);
- } catch (Exception e) {
- networkMap = null;
- costMap = null;
- }
- }
-
- public RFC7285CostMap getCostMap(String id) {
- if (!DEFAULT_COSTMAP_ID.equals(id))
- return null;
- return costMap;
- }
-
- public RFC7285CostMap getCostMap(RFC7285VersionTag vtag) {
- return getCostMap(vtag.rid);
- }
-
- public RFC7285CostMap getCostMap(String id, RFC7285CostType type) {
- if (!DEFAULT_COSTMAP_ID.equals(id))
- return null;
- if (!(costMap.meta.costType.equals(type)))
- return null;
- return costMap;
- }
-
- public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostType type) {
- return getCostMap(vtag.rid, type);
- }
-
- public RFC7285CostMap getCostMap(String id, RFC7285CostMap.Filter filter) {
- return null;
- }
-
- public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
- return null;
- }
-
- public Boolean supportCostType(String id, RFC7285CostType type) {
- return null;
- }
-
- public Boolean supportCostType(RFC7285VersionTag vtag, RFC7285CostType type) {
- if (!DEFAULT_COSTMAP_ID.equals(vtag.rid))
- return new Boolean(false);
- if (!costMap.meta.costType.equals(type))
- return new Boolean(false);
- return new Boolean(true);
- }
-
- public Boolean validateCostMapFilter(String id, RFC7285CostMap.Filter filter) {
- return false;
- }
-
- public Boolean validateCostMapFilter(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
- return false;
- }
-
-
- public RFC7285NetworkMap getDefaultNetworkMap() {
- return networkMap;
- }
-
- public RFC7285NetworkMap getNetworkMap(String id) {
- if (!DEFAULT_NETWORKMAP_ID.equals(id))
- return null;
- return networkMap;
- }
-
- public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag) {
- if (!DEFAULT_NETWORKMAP_ID.equals(vtag.rid))
- return null;
- if (!DEFAULT_NETWORKMAP_TAG.equals(vtag.tag))
- return null;
- return networkMap;
- }
-
- public RFC7285NetworkMap getNetworkMap(String id, RFC7285NetworkMap.Filter filter) {
- return null;
- }
-
- public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter) {
- return null;
- }
-
- public Boolean validateNetworkMapFilter(String id, RFC7285NetworkMap.Filter filter) {
- return new Boolean(false);
- }
-
- public Boolean validateNetworkMapFilter(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter) {
- return new Boolean(false);
- }
-
- public RFC7285IRD getDefaultIRD() {
- return null;
- }
-
- public RFC7285IRD getIRD(String id) {
- return null;
- }
-
- public RFC7285Endpoint.CostResponse getEndpointCost(String id, RFC7285Endpoint.CostRequest request) {
- return null;
- }
-
- public RFC7285Endpoint.CostResponse getEndpointCost(RFC7285VersionTag vtag, RFC7285Endpoint.CostRequest request) {
- return null;
- }
-
- public RFC7285Endpoint.PropertyResponse getEndpointProperty(String id, RFC7285Endpoint.PropertyRequest request) {
- return null;
- }
-
- public RFC7285Endpoint.PropertyResponse getEndpointProperty(RFC7285VersionTag vtag, RFC7285Endpoint.PropertyRequest request) {
- return null;
- }
-
- @Override
- public PropertyResponse getEndpointProperty(PropertyRequest request) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public CostResponse getEndpointCost(CostRequest request) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
+++ /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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>alto-extensions</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>fs-map-generator</artifactId>
- <packaging>bundle</packaging>
-
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.opendaylight.alto.commons.types.rfc7285,
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
- org.slf4j,
- </Import-Package>
- <Export-Package>
- org.opendaylight.alto.ext.fsmap;
- </Export-Package>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-model</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-commons</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.ext.fsmap;
-
-import java.net.URI;
-import java.nio.file.FileSystem;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.FileVisitResult;
-import java.nio.file.PathMatcher;
-import java.nio.file.WatchService;
-import java.nio.file.WatchKey;
-import java.nio.file.WatchEvent;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardWatchEventKinds;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.ClosedWatchServiceException;
-import java.nio.file.attribute.BasicFileAttributes;
-
-import java.io.IOException;
-
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.HashMap;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FileSystemNetworkMapGenerator implements Runnable, AutoCloseable {
-
- private static final Logger logger = LoggerFactory.getLogger(FileSystemNetworkMapGenerator.class);
-
- private ReentrantLock lock = new ReentrantLock();
- private Path source = null;
- private WatchService watcher = null;
- private HashMap<Path, WatchKey> keys = new HashMap<Path, WatchKey>();
- private HashMap<WatchKey, Path> paths = new HashMap<WatchKey, Path>();
- private MapFileLoader loader = null;
- private AtomicBoolean cancelled = new AtomicBoolean(false);
- private HashMap<Path, RFC7285VersionTag> path_to_id = new HashMap<Path, RFC7285VersionTag>();
- private HashMap<RFC7285VersionTag, RFC7285NetworkMap> id_to_map = new HashMap<RFC7285VersionTag, RFC7285NetworkMap>();
- private RFC7285JSONMapper mapper = new RFC7285JSONMapper();
-
- public FileSystemNetworkMapGenerator(URI uri) throws Exception {
- source = Paths.get(uri);
-
- FileSystem fs = source.getFileSystem();
- watcher = fs.newWatchService();
- if (watcher == null) {
- throw new IOException("Unable to create watcher on given uri: " + uri);
- }
-
- onCreateDir(source);
-
- loader = new MapFileLoader(fs);
- Files.walkFileTree(source, loader);
- }
-
- class MapFileLoader extends SimpleFileVisitor<Path> {
- private PathMatcher matcher = null;
-
- MapFileLoader(FileSystem fs) {
- matcher = fs.getPathMatcher("glob:**/*.{networkmap}");
- }
-
- @Override
- public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
- lock.lock();
- onCreateDir(dir);
- lock.unlock();
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
- logger.info("visiting file: " + file.toString());
- if (file.toFile().isFile()) {
- if (matcher.matches(file)) {
- lock.lock();
- onCreate(file);
- lock.unlock();
- }
- }
- return FileVisitResult.CONTINUE;
- }
- }
-
- public void run() {
- while (!cancelled.get()) {
- WatchKey key;
- try {
- key = watcher.take();
- } catch (ClosedWatchServiceException e) {
- System.out.println(e);
- break;
- } catch (Exception e) {
- System.out.println(e);
- continue;
- }
-
- for (WatchEvent<?> event: key.pollEvents()) {
- WatchEvent.Kind<?> kind = event.kind();
-
- if (kind == StandardWatchEventKinds.OVERFLOW)
- continue;
-
- lock.lock();
- Path dir = paths.get(key);
- Path file = dir.resolve((Path)event.context());
-
- if (kind == StandardWatchEventKinds.ENTRY_CREATE) {
- if (file.toFile().isFile())
- onCreate(file);
- else if (file.toFile().isDirectory())
- onCreateDir(file);
- } else if (kind == StandardWatchEventKinds.ENTRY_DELETE) {
- if (file.toFile().isFile())
- onDelete(file);
- else if (file.toFile().isDirectory())
- onDeleteDir(file);
- } else if (kind == StandardWatchEventKinds.ENTRY_MODIFY) {
- if (file.toFile().isFile())
- onModify(file);
- else if (file.toFile().isDirectory())
- onModifyDir(file);
- }
- lock.unlock();
- }
-
- boolean valid = key.reset();
- if (!valid) {
- Path dir = paths.get(key);
- keys.remove(dir);
- paths.remove(key);
-
- if (keys.isEmpty())
- break;
- }
- }
- cleanup();
- }
-
- public void cleanup() {
- lock.lock();
- for (WatchKey key: keys.values()) {
- try {
- if (key != null) {
- key.cancel();
- }
- } catch (Exception e) {
- }
- }
- keys.clear();
- paths.clear();
- try {
- if (watcher != null) {
- watcher.close();
- watcher = null;
- }
- } catch (Exception e) {
- }
-
- for (RFC7285VersionTag vtag: path_to_id.values()) {
- // TODO remove network map
- if (vtag.incomplete())
- continue;
- }
- path_to_id.clear();
- id_to_map.clear();
- lock.unlock();
- }
-
- public void close() {
- cancelled.set(true);
- cleanup();
- }
-
- public void onCreate(Path file) {
- //TODO
- try {
- String content = new String(Files.readAllBytes(file), StandardCharsets.US_ASCII);
- RFC7285NetworkMap map = mapper.asNetworkMap(content);
-
- RFC7285VersionTag vtag = map.meta.vtag;
- logger.info("vtag: <" + vtag.rid + ", " + vtag.tag + ">");
- if (id_to_map.get(map.meta.vtag) != null) {
- logger.warn("Version tag already registered: ("
- + vtag.rid + ", " + vtag.tag + ")");
- return;
- }
- path_to_id.put(file, map.meta.vtag);
- id_to_map.put(map.meta.vtag, map);
- logger.info("create successfully: " + file.toString());
- logger.info("current maps: " + id_to_map.size());
- } catch (Exception e) {
- logger.warn("Error while creating " + file.toString());
- logger.warn(e.toString());
- }
- }
-
- public void onCreateDir(Path dir) {
- try {
- WatchKey key = dir.register(watcher,
- StandardWatchEventKinds.ENTRY_CREATE,
- StandardWatchEventKinds.ENTRY_DELETE,
- StandardWatchEventKinds.ENTRY_MODIFY);
- keys.put(dir, key);
- paths.put(key, dir);
- logger.info("create dir successfully: " + dir.toString());
- } catch (Exception e) {
- logger.warn(e.toString());
- }
- }
-
- public void onDelete(Path file) {
- //TODO
- try {
- RFC7285VersionTag vtag = path_to_id.get(file);
- if (vtag == null)
- return;
-
- id_to_map.remove(vtag);
- logger.info("delete: " + file.toString());
- } catch (Exception e) {
- logger.warn("Error while deleting " + file.toString());
- logger.warn(e.toString());
- }
- }
-
- public void onDeleteDir(Path dir) {
- // TODO
- try {
- WatchKey key = keys.get(dir);
- if (key != null) {
- key.cancel();
-
- keys.remove(dir);
- paths.remove(key);
- }
- logger.warn("delete dir successfully: " + dir.toString());
- } catch (Exception e) {
- logger.warn(e.toString());
- }
- }
-
- public void onModify(Path file) {
- //TODO
- try {
- String content = new String(Files.readAllBytes(file), StandardCharsets.US_ASCII);
- RFC7285NetworkMap map = mapper.asNetworkMap(content);
- RFC7285VersionTag vtag = map.meta.vtag;
- RFC7285VersionTag old = path_to_id.get(file);
-
- if (old != null) {
- if (vtag.rid != old.rid) {
- throw new Exception("defining another map in one file is not allowed");
- }
- id_to_map.remove(old);
- }
- path_to_id.put(file, vtag);
- id_to_map.put(vtag, map);
- logger.info("modify successfully: " + file.toString());
- } catch (Exception e) {
- logger.warn("Error while modifying " + file.toString());
- logger.warn(e.toString());
- }
- }
-
- public void onModifyDir(Path dir) {
- //TODO
- onDeleteDir(dir);
- onModifyDir(dir);
- }
-}
<?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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+<!--
+Copyright © 2015 Copyright (c) Yale University and others. All rights reserved.
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
+--><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">
<parent>
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>..</relativePath>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>odlparent</artifactId>
+ <version>1.7.0-SNAPSHOT</version>
+ <relativePath/>
</parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-extensions</artifactId>
+
+ <version>0.3.0-SNAPSHOT</version>
+ <name>alto-extensions</name>
<packaging>pom</packaging>
+ <modelVersion>4.0.0</modelVersion>
+ <prerequisites>
+ <maven>3.1.1</maven>
+ </prerequisites>
<modules>
<module>simple-pce</module>
</modules>
+ <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
-
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
<version>1.7.0-SNAPSHOT</version>
+ <relativePath/>
</parent>
<groupId>org.opendaylight.alto.spce.network</groupId>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
<version>1.7.0-SNAPSHOT</version>
+ <relativePath/>
</parent>
<groupId>org.opendaylight.alto.ext</groupId>
+++ /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.3.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.3.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.5.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>${mdsal.model.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.mdsal</groupId>
- <artifactId>yang-binding</artifactId>
- <version>${mdsal.model.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.mdsal.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
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.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.hosttracker.rev150416.DstCosts1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.hosttracker.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;
-
- private String networkTag=null;
- // 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 nm_rid = new ResourceId(new ValidIdString(NMRESOURCEID));
- 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);
-
- TagString dtag = new TagString(this.networkTag);
- DependentVtags dv = new DependentVtagsBuilder().setResourceId(nm_rid)
- .setTag(dtag).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));
- this.networkTag = TagGenerator.getTag(32);
- TagString tag = new TagString(this.networkTag);
- ValidIdString vis = new ValidIdString("pid0");
- PidName pid = new PidName(vis);
- IpPrefix ep = new IpPrefix(new Ipv4Prefix("0.0.0.0/0"));
-
- 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 = 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
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.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
-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) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.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.3.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.mdsal</groupId>
- <artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>${mdsal.model.version}</version>
- <type>jar</type>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-module alto-hosttracker-cost-service {
- namespace "urn:opendaylight:alto:hosttracker";
- 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.3.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>
+++ /dev/null
-#Alto-Manager
-
-======
-
-Alto-manager provides extends karaf shell interface for you to create and delete maps and set properties for odl datastore. All functions are implemented by restconf in the backend.
-
-Alto-Manager supports three different commands.
-
-##alto:create
-Load maps from file and put them into odl datastore
-
-#####Command:
-
-```
-alto:create <map-type> <file-path>
-```
-alto:create command supports three different map types, `network-map, cost-map and endpoint-property-map`.
-
-#####File Format:
-* **network-map**: JSON Array of RFC formatted network maps.
-* **cost-map**: JSON Array of RFC formatted cost maps.
-* **endpoint-property-map**: Single RFC formatted endpoint property map
-
-File examples can be found at ./alto-manager/examples/.
-
-#####Note:
-Exceptions will be thrown if you try to:
-
-* Sepecify wrong map-type
-
-#####Example:
-```
-alto:create network-map ./examples/network-map-rfc
-alto:create cost-map ./examples/cost-map-rfc
-alto:create endpoint-property-map ./examples/cost-map-rfc
-```
-
-
-##alto:delete
-Delete map from odl datastore.
-
-#####Command:
-
-```
-alto:delete <map-type> <resource-id or null>
-```
-alto:delete command supports three different map types, `network-map, cost-map and endpoint-property-map`.
-
-If you are going to delete a network map or cost map, the second option should be set to resource id of the map. If you are going to delete endpoint-property-map, the second option should not be set.
-
-#####Note:
-Exceptions will be thrown if you try to:
-
-* Sepecify unsupported map type
-* Delete a map which does not exist
-* Delete the default network map
-* Delete a cost map or network map without specifying the resource id
-* Delete the endpoint propery map with a resource id
-
-#####Example:
-```
-alto:delete network-map my-default-network-map
-alto:create cost-map new-network-map-routingcost-numerical
-alto:create endpoint-property-map
-```
-
-##alto:set
-Set specific field for old datastore. **Currently only "default-network-map" field for IRD resource is supported.**
-
-#####Command:
-
-```
-alto:set <propety-name> <property-value>
-```
-
-#####Note:
-Exceptions will be thrown if you try to:
-
-* Sepecify unsupported map type
-* Network map specified by resource id does not exist
-
-#####Example:
-```
-alto:set default-network-map <network-map-resource-id>
-```
-
-##TODO
-* Support URI for alto:create
+++ /dev/null
-[
- {
- "meta": {
- "dependent-vtags": [
- {
- "resource-id": "my-default-network-map",
- "tag": "3ee2cb7e8d63d9fab71b9b34cbf764436315542e"
- }
- ],
- "cost-type": {
- "cost-mode": "numerical",
- "cost-metric": "routingcost"
- }
- },
- "cost-map": {
- "PID1": {
- "PID1": 1,
- "PID2": 5,
- "PID3": 10
- },
- "PID2": {
- "PID1": 5,
- "PID2": 1,
- "PID3": 15
- },
- "PID3": {
- "PID1": 20,
- "PID2": 15
- }
- }
- },
- {
- "meta": {
- "dependent-vtags": [
- {
- "resource-id": "new-network-map",
- "tag": "3ee2cb7e8d63d9fab71b9b34cbf764436315542F"
- }
- ],
- "cost-type": {
- "cost-mode": "numerical",
- "cost-metric": "routingcost"
- }
- },
- "cost-map": {
- "PID1": {
- "PID1": 1,
- "PID2": 5,
- "PID3": 10
- },
- "PID2": {
- "PID1": 5,
- "PID2": 1,
- "PID3": 15
- },
- "PID3": {
- "PID1": 20,
- "PID2": 15
- }
- }
- }
-]
+++ /dev/null
-{
- "meta" : {
- "dependent-vtags" : [
- {"resource-id": "my-default-network-map",
- "tag": "7915dc0290c2705481c491a2b4ffbec482b3cf62"
- }
- ]
- },
- "endpoint-properties": {
- "ipv4:192.0.2.34" : { "my-default-network-map.pid": "PID1",
- "priv:ietf-example-prop": "1" },
- "ipv4:203.0.113.129" : { "my-default-network-map.pid": "PID3" }
- }
-}
+++ /dev/null
-[
- {
- "meta": {
- "vtag": {
- "resource-id": "my-default-network-map",
- "tag": "da65eca2eb7a10ce8b059740b0b2e3f8eb1d4785"
- }
- },
- "network-map": {
- "PID1": {
- "ipv4": [
- "192.0.2.0/24",
- "198.51.100.0/25"
- ]
- },
- "PID2": {
- "ipv4": [
- "198.51.100.128/25"
- ]
- },
- "PID3": {
- "ipv4": [
- "0.0.0.0/0"
- ],
- "ipv6": [
- "::/0"
- ]
- }
- }
- },
- {
- "meta": {
- "vtag": {
- "resource-id": "new-network-map",
- "tag": "da65eca2eb7a10ce8b059740b0b2e3f8eb1d4786"
- }
- },
- "network-map": {
- "PID1": {
- "ipv4": [
- "192.0.2.0/24",
- "198.51.100.0/25"
- ]
- },
- "PID2": {
- "ipv4": [
- "198.51.100.128/25"
- ]
- },
- "PID3": {
- "ipv4": [
- "0.0.0.0/0"
- ],
- "ipv6": [
- "::/0"
- ]
- }
- }
- }
-]
+++ /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</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
-
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>alto-manager</artifactId>
- <packaging>bundle</packaging>
- <name>${project.artifactId}</name>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-commons</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- <version>${karaf.shell.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient-osgi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore-osgi</artifactId>
- </dependency>
- <!-- Testing Dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Import-Package>
- org.apache.felix.service.command,
- org.apache.karaf.shell.commands,
- org.apache.karaf.shell.console,
- org.apache.http.*,
- org.opendaylight.alto.commons.*,
- org.osgi.framework.*,
- org.slf4j
- </Import-Package>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <target>1.7</target>
- <source>1.7</source>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.manager;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.opendaylight.alto.commons.types.converter.RFC2ModelCostMapConverter;
-import org.opendaylight.alto.commons.types.converter.RFC2ModelEndpointPropMapConverter;
-import org.opendaylight.alto.commons.types.converter.RFC2ModelNetworkMapConverter;
-import org.opendaylight.alto.commons.types.model150404.ModelCostMap;
-import org.opendaylight.alto.commons.types.model150404.ModelEndpointPropertyMap;
-import org.opendaylight.alto.commons.types.model150404.ModelJSONMapper;
-import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
-import org.opendaylight.alto.manager.AltoManagerConstants.MAP_FORMAT_TYPE;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Command(scope = "alto", name = "create", description = "Create resource by resource type and resource file")
-public class AltoCreate extends AltoManager {
- private static final Logger log = LoggerFactory.getLogger(AltoCreate.class);
- private RFC7285JSONMapper rfcMapper = new RFC7285JSONMapper();
- private ModelJSONMapper modelMapper = new ModelJSONMapper();
- private RFC2ModelNetworkMapConverter networkMapConverter = new RFC2ModelNetworkMapConverter();
- private RFC2ModelCostMapConverter costMapConverter = new RFC2ModelCostMapConverter();
- private RFC2ModelEndpointPropMapConverter endpointPropConverter = new RFC2ModelEndpointPropMapConverter();
- private MAP_FORMAT_TYPE format = MAP_FORMAT_TYPE.RFC;
-
- @Argument(index = 0, name = "resource-type", description = "Resource Type", required = true, multiValued = false)
- String resourceType = null;
-
- @Argument(index = 1, name = "resource-file", description = "Resource File", required = true, multiValued = false)
- String resourceFile = null;
-
- public AltoCreate() {
- super();
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (networkMapType().equals(resourceType)) {
- putNetworkMaps();
- } else if (costMapType().equals(resourceType)) {
- putCostMaps();
- } else if (endpointPropertyMapType().equals(resourceType)) {
- putEndpointPropertyMap();
- } else {
- throw new UnsupportedOperationException("Unsupported resource type \"" + resourceType + "\".");
- }
- return null;
- }
-
- private void putNetworkMaps() throws Exception {
- log.info("Loading network maps from " + this.resourceFile);
- List<ModelNetworkMap> networkMaps = getYangNetworkMaps(readFromFile(resourceFile));
- for (ModelNetworkMap map : networkMaps) {
- log.info("Putting network map \"" + map.rid + "\"...");
- String data = modelMapper.asJSON(map);
- putMap(AltoManagerConstants.NETWORK_MAP_URL, map.rid, data);
- }
- }
-
- private List<ModelNetworkMap> getYangNetworkMaps(String data) throws Exception {
- if (MAP_FORMAT_TYPE.RFC.equals(format)) {
- List<ModelNetworkMap> modelNetworkMaps = new ArrayList<ModelNetworkMap>();
- for (RFC7285NetworkMap networkMap : rfcMapper.asNetworkMapList(data)) {
- modelNetworkMaps.add(networkMapConverter.convert(networkMap));
- }
- return modelNetworkMaps;
- }
- return modelMapper.asNetworkMapList(data);
- }
-
- private void putCostMaps() throws Exception {
- log.info("Loading cost map from " + this.resourceFile);
- List<ModelCostMap> costMaps = getYangCostMaps(readFromFile(resourceFile));
- for (ModelCostMap map : costMaps) {
- log.info("Putting cost map " + map.rid + "...");
- String data = modelMapper.asJSON(map);
- putMap(AltoManagerConstants.COST_MAP_URL, map.rid, data);
- }
- }
-
- private List<ModelCostMap> getYangCostMaps(String data) throws Exception {
- if (MAP_FORMAT_TYPE.RFC.equals(format)) {
- List<ModelCostMap> modelCostMaps = new ArrayList<ModelCostMap>();
- for (RFC7285CostMap costMap : rfcMapper.asCostMapList(data)) {
- modelCostMaps.add(costMapConverter.convert(costMap));
- }
- return modelCostMaps;
- }
- return modelMapper.asCostMapList(data);
- }
-
- private void putEndpointPropertyMap() throws Exception {
- log.info("Loading endpoint property map from " + this.resourceFile);
- ModelEndpointPropertyMap endpointPropMap = getYangEndpointPropMap(readFromFile(resourceFile));
- String data = modelMapper.asJSON(endpointPropMap);
- httpPut(AltoManagerConstants.ENDPOINT_PROP_MAP_URL, wrapdata(data));
- }
-
- private ModelEndpointPropertyMap getYangEndpointPropMap(String data) throws Exception {
- if (MAP_FORMAT_TYPE.RFC.equals(format)) {
- return endpointPropConverter.convert(rfcMapper.asEndpointPropMap(data));
- }
- return modelMapper.asEndpointPropMap(data);
- }
-
- private void putMap(String baseUrl, String resourceId, String data) throws Exception {
- if (resourceId == null) {
- throw new RuntimeException("No ResourceId Specified.");
- }
- httpPut(baseUrl + resourceId, wrapdata(data));
- }
-
- private String wrapdata(String data) throws Exception {
- if (endpointPropertyMapType().equals(resourceType)) {
- return "{\"alto-service:" + resourceType + "\":" + data + "}";
- } else {
- return "{\"alto-service:" + resourceType + "\":[" + data + "]}";
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.manager;
-
-import java.io.IOException;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Command(scope = "alto", name = "delete", description = "Destroy a map by resourceId")
-public class AltoDelete extends AltoManager {
- private static final Logger log = LoggerFactory.getLogger(AltoDelete.class);
-
- @Argument(index = 0, name = "resource-type", description = "Resource Type", required = true, multiValued = false)
- String resourceType = null;
-
- @Argument(index = 1, name = "resource-id", description = "Resource Id", required = false, multiValued = false)
- String resourceId = null;
-
- public AltoDelete() {
- super();
- }
-
- @Override
- protected Object doExecute() throws Exception {
- checkResourceID();
- if (networkMapType().equals(resourceType)) {
- deleteNetworkMap();
- } else if (costMapType().equals(resourceType)) {
- deleteCostMap();
- } else if (endpointPropertyMapType().equals(resourceType)) {
- deleteEndpointPropertyMap();
- } else {
- throw new UnsupportedOperationException("Unsupported resource type \"" + resourceType + "\".");
- }
- return null;
- }
-
- private void checkResourceID() throws IOException {
- if (networkMapType().equals(resourceType) && isDefaultNetworkMap(resourceId)) {
- throw new RuntimeException("Cannot destroy default network map.");
- }
-
- if (resourceId == null && !endpointPropertyMapType().equals(resourceType)) {
- throw new RuntimeException("Please specify resource id for " + resourceType + ".");
- }
-
- if (resourceId != null && endpointPropertyMapType().equals(resourceType)) {
- throw new RuntimeException("Please do not specify resource id for " + resourceType + ".");
- }
- }
-
- private boolean deleteEndpointPropertyMap() throws IOException {
- log.info("Deleting endpoint property map " + this.resourceId);
- return httpDelete(AltoManagerConstants.RESOURCES_URL + AltoManagerConstants.ENDPOINT_PROPERTY_MAP_NODE);
- }
-
- private boolean deleteCostMap() throws IOException {
- log.info("Deleting endpoint property map " + this.resourceId);
- return httpDelete(AltoManagerConstants.COST_MAP_URL + resourceId);
- }
-
- private boolean deleteNetworkMap() throws IOException {
- log.info("Deleting endpoint property map " + this.resourceId);
- return httpDelete(AltoManagerConstants.NETWORK_MAP_URL + resourceId);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.manager;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.ParseException;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AltoManager extends OsgiCommandSupport {
- private static final Logger log = LoggerFactory.getLogger(AltoManager.class);
-
- protected HttpClient httpClient;
-
- public AltoManager () {
- httpClient = initiateHttpClient();
- log.info(this.getClass().getName() + " Initiated");
- }
-
- protected HttpClient initiateHttpClient() {
- CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
- credentialsProvider.setCredentials(AuthScope.ANY,
- new UsernamePasswordCredentials("admin:admin"));
- return HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build();
- }
-
- @Override
- protected Object doExecute() throws Exception {
- return null;
- }
-
- protected String readFromFile(String path) throws IOException {
- return new String(Files.readAllBytes(Paths.get(path)),
- StandardCharsets.UTF_8);
- }
-
- protected boolean isDefaultNetworkMap(String resourceId) throws IOException {
- String defaultNetworkResourceId = getDefaultNetworMapResourceId();
- return (defaultNetworkResourceId != null) && defaultNetworkResourceId.equals(resourceId);
- }
-
- protected String getDefaultNetworMapResourceId() throws IOException {
- HttpResponse response = httpGet(AltoManagerConstants.IRD_DEFAULT_NETWORK_MAP_URL);
- Pattern pattern = Pattern.compile(AltoManagerConstants.DEFAULT_NETWORK_MAP_REGEX);
- Matcher matcher = pattern.matcher(EntityUtils.toString(response.getEntity()));
- return matcher.find() ? matcher.group(1) : null;
- }
-
- protected HttpResponse httpGet(String url) throws IOException {
- HttpGet httpGet = new HttpGet(url);
- logHttpRequest("HTTP GET:", url, "");
- httpGet.setHeader(HTTP.CONTENT_TYPE, AltoManagerConstants.JSON_CONTENT_TYPE);
- return httpClient.execute(httpGet);
- }
-
- protected boolean httpPut(String url, String data) throws IOException {
- HttpPut httpPut = new HttpPut(url);
- httpPut.setHeader(HTTP.CONTENT_TYPE, AltoManagerConstants.JSON_CONTENT_TYPE);
- httpPut.setEntity(new StringEntity(data));
- logHttpRequest("HTTP PUT:", url, data);
- HttpResponse response = httpClient.execute(httpPut);
- return handleResponse(response);
- }
-
- protected boolean httpDelete(String url) throws IOException {
- HttpDelete httpDelete = new HttpDelete(url);
- httpDelete.setHeader(HTTP.CONTENT_TYPE, AltoManagerConstants.JSON_CONTENT_TYPE);
- logHttpRequest("HTTP DELETE:", url, "");
- HttpResponse response = httpClient.execute(httpDelete);
- return handleResponse(response);
- }
-
- private void logHttpRequest(String prefix, String url, String data) {
- log.debug(prefix +
- "\nUrl: " + url +
- "\nHeader: " + HTTP.CONTENT_TYPE + ": " + AltoManagerConstants.JSON_CONTENT_TYPE +
- "\nData: " + data);
- }
-
- protected boolean handleResponse(HttpResponse response) throws ParseException, IOException {
- int statusCode = response.getStatusLine().getStatusCode();
- logResponse(response);
- if (statusCode == 200) {
- log.info("Operation Succesfully");
- return true;
- } else {
- log.error("Operation Failed");
- return false;
- }
- }
-
- protected void logResponse(HttpResponse response) throws IOException {
- HttpEntity entity = response.getEntity();
- int statusCode = response.getStatusLine().getStatusCode();
- String body = entity != null ? EntityUtils.toString(entity) : "";
- log.info("Response: "
- + "\nStatus Code: " + statusCode
- + "\nBody: " + body);
- }
-
- protected String networkMapType() {
- return AltoManagerConstants.SERVICE_TYPE.NETWORK_MAP.toString()
- .toLowerCase().replace("_", "-");
- }
-
- protected String costMapType() {
- return AltoManagerConstants.SERVICE_TYPE.COST_MAP.toString()
- .toLowerCase().replace("_", "-");
- }
-
- protected String endpointPropertyMapType() {
- return AltoManagerConstants.SERVICE_TYPE.ENDPOINT_PROPERTY_MAP.toString()
- .toLowerCase().replace("_", "-");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.manager;
-
-public class AltoManagerConstants {
- public static final String HOST = "http://127.0.0.1:8181/restconf/config/";
- public static final String MODULE = "alto-service";
- public static final String JSON_CONTENT_TYPE = "application/yang.data+json";
-
- public static final String RESOURCES_NODE = MODULE + ":resources";
- public static final String IRD_NODE = MODULE + ":IRD";
- public static final String META_NODE = MODULE + ":meta";
- public static final String DEFAULT_NETWORK_MAP_NODE = MODULE + ":default-alto-network-map";
-
- public static final String NETWORK_MAPS_NODE = MODULE + ":network-maps";
- public static final String NETWORK_MAP_NODE = MODULE + ":network-map";
- public static final String COST_MAPS_NODE = MODULE + ":cost-maps";
- public static final String COST_MAP_NODE = MODULE + ":cost-map";
- public static final String ENDPOINT_PROPERTY_MAP_NODE = MODULE + ":endpoint-property-map";
- public static final String RESOURCE_ID_NODE = MODULE + ":resource-id";
-
- public static final String RESOURCES_URL = HOST + RESOURCES_NODE + "/";
- public static final String NETWORK_MAP_URL = RESOURCES_URL + NETWORK_MAPS_NODE + "/" + NETWORK_MAP_NODE + "/";
- public static final String COST_MAP_URL = RESOURCES_URL + COST_MAPS_NODE + "/" + COST_MAP_NODE + "/";
- public static final String ENDPOINT_PROP_MAP_URL = RESOURCES_URL + ENDPOINT_PROPERTY_MAP_NODE;
- public static final String IRD_DEFAULT_NETWORK_MAP_URL = RESOURCES_URL + IRD_NODE + "/" + META_NODE + "/" + DEFAULT_NETWORK_MAP_NODE + "/";
-
- public static final String DEFAULT_NETWORK_MAP_PROPERTY = "default-network-map";
- public static final String DELIMETER = "-";
-
- public static final String DEFAULT_NETWORK_MAP_REGEX = "^\\{\"default-alto-network-map\":\\{\"resource-id\":\"(.*)\"\\}}$";
-
- public enum COST_MODE {
- Numerical, Ordinal
- }
-
- public enum SERVICE_TYPE{
- NETWORK_MAP, COST_MAP, ENDPOINT_PROPERTY_MAP
- }
-
- public enum MAP_FORMAT_TYPE {
- YANG, RFC
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.manager;
-
-import java.io.IOException;
-
-import org.apache.http.HttpResponse;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Command(scope = "alto", name = "set", description = "Set property")
-public class AltoSet extends AltoManager {
- private static final Logger log = LoggerFactory.getLogger(AltoSet.class);
-
- @Argument(index = 0, name = "property-name", description = "Property Name", required = true, multiValued = false)
- String property = null;
-
- @Argument(index = 1, name = "property-value", description = "Property Value", required = true, multiValued = false)
- String value = null;
-
- public AltoSet() {
- super();
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (AltoManagerConstants.DEFAULT_NETWORK_MAP_PROPERTY.equals(property)) {
- if (!ifNetworkMapExist(value)) {
- throw new RuntimeException("Network map \"" + value + "\" does not exist.");
- }
- setDefaultNetworkMap();
- } else {
- throw new UnsupportedOperationException("Unsupported property \"" + property + "\".");
- }
- return null;
- }
-
- private boolean ifNetworkMapExist(String resourceId) throws IOException {
- HttpResponse response = httpGet(AltoManagerConstants.NETWORK_MAP_URL + resourceId);
- logResponse(response);
- int statusCode = response.getStatusLine().getStatusCode();
- return (statusCode == 200);
- }
-
- private void setDefaultNetworkMap() throws IOException {
- log.info("Setting default network map");
- httpPut(AltoManagerConstants.IRD_DEFAULT_NETWORK_MAP_URL, queryData(value));
- }
-
- private String queryData(String resourceId) {
- return "{\"alto-service:default-alto-network-map\":{\"alto-service:resource-id\":\"" + resourceId + "\"}}";
- }
-}
+++ /dev/null
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
- <command name="alto/create">
- <action class="org.opendaylight.alto.manager.AltoCreate"/>
- </command>
-
- <command name="alto/delete">
- <action class="org.opendaylight.alto.manager.AltoDelete"/>
- </command>
-
- <command name="alto/set">
- <action class="org.opendaylight.alto.manager.AltoSet"/>
- </command>
- </command-bundle>
-</blueprint>
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Unit test for simple App.
- */
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
- /**
- * Rigourous Test :-)
- */
- public void testApp()
- {
- assertTrue( true );
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.manager;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Matchers.any;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.StatusLine;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPut;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-
-public class AltoCreateTest {
- @Mock(name = "httpClient")
- private HttpClient httpClient;
-
- @InjectMocks
- @Spy
- private AltoCreate altoCreate = new AltoCreate();
-
- private final String NETWORK_MAP = "[{\"meta\":{\"vtag\":{\"resource-id\":\"my-alternate-network-map\",\"tag\":\"88e5d857507ed921f157a7c3413af0c4\"}},\"network-map\":{\"dc1\":{\"ipv4\":[\"101.0.0.0/16\"]},\"dc2\":{\"ipv4\":[\"102.0.0.0/16\"]},\"dc3\":{\"ipv4\":[\"103.0.0.0/16\"]},\"dc4\":{\"ipv4\":[\"104.0.0.0/16\"]},\"default\":{\"ipv4\":[\"0.0.0.0/0\"],\"ipv6\":[\"::/0\"]},\"linklocal\":{\"ipv4\":[\"169.254.0.0/16\"],\"ipv6\":[\"FF80::/10\"]},\"loopback\":{\"ipv4\":[\"127.0.0.0/8\"],\"ipv6\":[\"::1/128\"]},\"private\":{\"ipv4\":[\"10.0.0.0/8\",\"172.16.0.0/12\",\"192.168.0.0/16\"],\"ipv6\":[\"FC00::/7\"]},\"user1\":{\"ipv4\":[\"201.0.0.0/16\"]},\"user2\":{\"ipv4\":[\"202.0.0.0/16\"]},\"user3\":{\"ipv4\":[\"203.0.0.0/16\"]},\"user4\":{\"ipv4\":[\"204.0.0.0/16\"]}}},{\"meta\":{\"vtag\":{\"resource-id\":\"my-default-network-map\",\"tag\":\"200dc84a734fb99516eceffcb2c8458a\"}},\"network-map\":{\"default\":{\"ipv4\":[\"0.0.0.0/0\"],\"ipv6\":[\"::/0\"]},\"linklocal\":{\"ipv4\":[\"169.254.0.0/16\"],\"ipv6\":[\"FF80::/10\"]},\"loopback\":{\"ipv4\":[\"127.0.0.0/8\"],\"ipv6\":[\"::1/128\"]},\"mine\":{\"ipv4\":[\"100.0.0.0/8\"]},\"mine1\":{\"ipv4\":[\"100.0.0.0/10\"]},\"mine1a\":{\"ipv4\":[\"100.0.64.0/24\",\"100.0.192.0/24\",\"100.0.1.0/24\"]},\"mine2\":{\"ipv4\":[\"100.64.0.0/10\"]},\"mine3\":{\"ipv4\":[\"100.128.0.0/10\"]},\"peer1\":{\"ipv4\":[\"130.0.0.0/16\",\"128.0.0.0/16\"],\"ipv6\":[\"2001:DB8::/33\"]},\"peer2\":{\"ipv4\":[\"131.0.0.0/16\",\"129.0.0.0/16\"],\"ipv6\":[\"2001:DB8:8000::/33\"]},\"private\":{\"ipv4\":[\"10.0.0.0/8\",\"172.16.0.0/12\",\"192.168.0.0/16\"],\"ipv6\":[\"FC00::/7\"]},\"tran1\":{\"ipv4\":[\"132.0.0.0/16\"]},\"tran2\":{\"ipv4\":[\"135.0.0.0/16\"]}}}]";
- private final String COST_MAP = "[{\"meta\":{\"dependent-vtags\":[{\"resource-id\":\"my-default-network-map\",\"tag\":\"200dc84a734fb99516eceffcb2c8458a\"}],\"cost-type\":{\"cost-mode\":\"numerical\",\"cost-metric\":\"routingcost\"}},\"cost-map\":{\"default\":{\"default\":1.0,\"mine\":75.0,\"mine1\":75.0,\"mine1a\":75.0,\"mine2\":75.0,\"mine3\":75.0,\"private\":75.0},\"linklocal\":{\"linklocal\":1.0},\"loopback\":{\"loopback\":0.0},\"mine\":{\"default\":75.0,\"mine\":1.0,\"mine1\":15.0,\"mine1a\":15.0,\"mine2\":15.0,\"mine3\":15.0,\"peer1\":30.0,\"peer2\":30.0,\"tran1\":50.0,\"tran2\":50.0},\"mine1\":{\"default\":75.0,\"mine\":15.0,\"mine1\":1.0,\"mine1a\":2.5,\"mine2\":5.0,\"mine3\":7.0,\"peer1\":20.0,\"peer2\":25.0,\"tran1\":40.0,\"tran2\":45.0},\"mine1a\":{\"default\":75.0,\"mine\":15.0,\"mine1\":2.0,\"mine1a\":1.0,\"mine2\":7.0,\"mine3\":9.0,\"peer1\":22.0,\"peer2\":24.0,\"tran1\":42.0,\"tran2\":48.0},\"mine2\":{\"default\":75.0,\"mine\":15.0,\"mine1\":5.5,\"mine1a\":7.0,\"mine2\":1.0,\"mine3\":6.0,\"peer1\":23.0,\"peer2\":25.0,\"tran1\":43.0,\"tran2\":46.0},\"mine3\":{\"default\":75.0,\"mine\":15.0,\"mine1\":7.0,\"mine1a\":9.0,\"mine2\":6.0,\"mine3\":1.0,\"peer1\":25.0,\"peer2\":28.0,\"tran1\":45.0,\"tran2\":49.0},\"peer1\":{\"mine\":30.0,\"mine1\":20.0,\"mine1a\":22.0,\"mine2\":23.0,\"mine3\":25.0,\"peer1\":1.0},\"peer2\":{\"mine\":30.0,\"mine1\":25.0,\"mine1a\":24.0,\"mine2\":25.0,\"mine3\":28.0,\"peer2\":1.0},\"private\":{\"default\":75.0,\"private\":1.0},\"tran1\":{\"mine\":50.0,\"mine1\":40.0,\"mine1a\":42.0,\"mine2\":43.0,\"mine3\":45.0,\"tran1\":1.0},\"tran2\":{\"mine\":50.0,\"mine1\":45.0,\"mine1a\":48.0,\"mine2\":46.0,\"mine3\":49.0,\"tran2\":1.0}}},{\"meta\":{\"dependent-vtags\":[{\"resource-id\":\"my-default-network-map\",\"tag\":\"200dc84a734fb99516eceffcb2c8458a\"}],\"cost-type\":{\"cost-mode\":\"numerical\",\"cost-metric\":\"hopcount\"}},\"cost-map\":{\"default\":{\"default\":1,\"mine\":10,\"mine1\":10,\"mine1a\":10,\"mine2\":10,\"mine3\":10,\"private\":10},\"linklocal\":{\"linklocal\":1},\"loopback\":{\"loopback\":0},\"mine\":{\"default\":10,\"mine\":1,\"mine1\":3,\"mine1a\":3,\"mine2\":3,\"mine3\":3,\"peer1\":5,\"peer2\":6,\"tran1\":8,\"tran2\":8},\"mine1\":{\"default\":10,\"mine\":3,\"mine1\":1,\"mine1a\":2,\"mine2\":2,\"mine3\":2,\"peer1\":4,\"peer2\":5,\"tran1\":6,\"tran2\":7},\"mine1a\":{\"default\":10,\"mine\":3,\"mine1\":2,\"mine1a\":1,\"mine2\":2,\"mine3\":3,\"peer1\":5,\"peer2\":6,\"tran1\":7,\"tran2\":8},\"mine2\":{\"default\":10,\"mine\":3,\"mine1\":2,\"mine1a\":2,\"mine2\":1,\"mine3\":2,\"peer1\":4,\"peer2\":5,\"tran1\":6,\"tran2\":7},\"mine3\":{\"default\":10,\"mine\":3,\"mine1\":2,\"mine1a\":3,\"mine2\":2,\"mine3\":1,\"peer1\":4,\"peer2\":5,\"tran1\":6,\"tran2\":7},\"peer1\":{\"mine\":5,\"mine1\":4,\"mine1a\":5,\"mine2\":4,\"mine3\":4,\"peer1\":1},\"peer2\":{\"mine\":6,\"mine1\":5,\"mine1a\":6,\"mine2\":5,\"mine3\":5,\"peer2\":1},\"private\":{\"default\":10,\"private\":1},\"tran1\":{\"mine\":8,\"mine1\":6,\"mine1a\":7,\"mine2\":6,\"mine3\":6,\"tran1\":1},\"tran2\":{\"mine\":8,\"mine1\":7,\"mine1a\":8,\"mine2\":7,\"mine3\":7,\"tran2\":1}}},{\"meta\":{\"dependent-vtags\":[{\"resource-id\":\"my-alternate-network-map\",\"tag\":\"88e5d857507ed921f157a7c3413af0c4\"}],\"cost-type\":{\"cost-mode\":\"numerical\",\"cost-metric\":\"routingcost\"}},\"cost-map\":{\"dc1\":{\"dc1\":0.0,\"dc2\":5.0,\"dc3\":5.0,\"dc4\":5.0,\"default\":50.0,\"user1\":10.0,\"user2\":20.0,\"user3\":30.0,\"user4\":40.0},\"dc2\":{\"dc1\":5.0,\"dc2\":0.0,\"dc3\":5.0,\"dc4\":5.0,\"default\":50.0,\"user1\":20.0,\"user2\":10.0,\"user3\":20.0,\"user4\":30.0},\"dc3\":{\"dc1\":5.0,\"dc2\":5.0,\"dc3\":0.0,\"dc4\":5.0,\"default\":50.0,\"user1\":30.0,\"user2\":20.0,\"user3\":10.0,\"user4\":20.0},\"dc4\":{\"dc1\":5.0,\"dc2\":5.0,\"dc3\":5.0,\"dc4\":0.0,\"default\":50.0,\"user1\":40.0,\"user2\":30.0,\"user3\":20.0,\"user4\":10.0},\"default\":{\"dc1\":50.0,\"dc2\":50.0,\"dc3\":50.0,\"dc4\":50.0,\"default\":0.0},\"user1\":{\"dc1\":10.0,\"dc2\":20.0,\"dc3\":30.0,\"dc4\":40.0,\"user1\":0.0},\"user2\":{\"dc1\":20.0,\"dc2\":10.0,\"dc3\":20.0,\"dc4\":30.0,\"user2\":0.0},\"user3\":{\"dc1\":30.0,\"dc2\":20.0,\"dc3\":10.0,\"dc4\":20.0,\"user3\":0.0},\"user4\":{\"dc1\":40.0,\"dc2\":30.0,\"dc3\":20.0,\"dc4\":10.0,\"user4\":0.0}}},{\"meta\":{\"dependent-vtags\":[{\"resource-id\":\"my-alternate-network-map\",\"tag\":\"88e5d857507ed921f157a7c3413af0c4\"}],\"cost-type\":{\"cost-mode\":\"numerical\",\"cost-metric\":\"hopcount\"}},\"cost-map\":{\"dc1\":{\"dc1\":0,\"dc2\":1,\"dc3\":1,\"dc4\":1,\"default\":8,\"user1\":3,\"user2\":4,\"user3\":5,\"user4\":6},\"dc2\":{\"dc1\":1,\"dc2\":0,\"dc3\":1,\"dc4\":1,\"default\":8,\"user1\":4,\"user2\":3,\"user3\":4,\"user4\":5},\"dc3\":{\"dc1\":1,\"dc2\":1,\"dc3\":0,\"dc4\":1,\"default\":8,\"user1\":5,\"user2\":4,\"user3\":3,\"user4\":4},\"dc4\":{\"dc1\":1,\"dc2\":1,\"dc3\":1,\"dc4\":0,\"default\":8,\"user1\":6,\"user2\":5,\"user3\":4,\"user4\":3},\"default\":{\"dc1\":8,\"dc2\":8,\"dc3\":8,\"dc4\":8,\"default\":0},\"user1\":{\"dc1\":3,\"dc2\":4,\"dc3\":5,\"dc4\":6,\"user1\":0},\"user2\":{\"dc1\":4,\"dc2\":3,\"dc3\":4,\"dc4\":5,\"user2\":0},\"user3\":{\"dc1\":5,\"dc2\":4,\"dc3\":3,\"dc4\":4,\"user3\":0},\"user4\":{\"dc1\":6,\"dc2\":5,\"dc3\":4,\"dc4\":3,\"user4\":0}}}]";
- private final String ENDPOINT_PROPERTY_MAP = "{\"endpoint-properties\":{\"ipv6:ff80:1:2::\":{\"my-alternate-network-map.pid\":\"linklocal\",\"my-default-network-map.pid\":\"linklocal\"},\"ipv6:fc00:1::\":{\"my-alternate-network-map.pid\":\"private\",\"my-default-network-map.pid\":\"private\"},\"ipv6:2001:db8:8000::1\":{\"priv:ietf-type\":\"peer\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"peer2\"},\"ipv4:127.255.255.255\":{\"my-alternate-network-map.pid\":\"loopback\",\"my-default-network-map.pid\":\"loopback\"},\"ipv4:127.0.0.1\":{\"my-alternate-network-map.pid\":\"loopback\",\"my-default-network-map.pid\":\"loopback\"},\"ipv4:104.0.0.1\":{\"my-alternate-network-map.pid\":\"dc4\",\"my-default-network-map.pid\":\"default\"},\"ipv4:103.0.0.1\":{\"my-alternate-network-map.pid\":\"dc3\",\"my-default-network-map.pid\":\"default\"},\"ipv4:102.0.0.1\":{\"my-alternate-network-map.pid\":\"dc2\",\"my-default-network-map.pid\":\"default\"},\"ipv4:101.1.0.1\":{\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"default\"},\"ipv4:101.0.0.1\":{\"my-alternate-network-map.pid\":\"dc1\",\"my-default-network-map.pid\":\"default\"},\"ipv4:100.75.0.1\":{\"priv:ietf-type\":\"mine\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"mine2\"},\"ipv4:0.0.0.1\":{\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"default\"},\"ipv4:10.1.2.3\":{\"my-alternate-network-map.pid\":\"private\",\"my-default-network-map.pid\":\"private\"},\"ipv4:100.0.0.1\":{\"priv:ietf-type\":\"mine\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"mine1\"},\"ipv4:100.0.1.1\":{\"priv:ietf-type\":\"mine\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"mine1a\"},\"ipv4:100.0.192.1\":{\"priv:ietf-type\":\"mine\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"mine1a\"},\"ipv4:100.0.64.1\":{\"priv:ietf-type\":\"mine\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"mine1a\"},\"ipv4:100.130.0.1\":{\"priv:ietf-type\":\"mine\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"mine3\"},\"ipv4:100.200.0.1\":{\"priv:ietf-type\":\"mine\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"mine\"},\"ipv4:128.0.0.1\":{\"priv:ietf-type\":\"peer\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"peer1\"},\"ipv4:129.0.0.1\":{\"priv:ietf-type\":\"peer\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"peer2\"},\"ipv4:130.0.0.1\":{\"priv:ietf-type\":\"peer\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"peer1\"},\"ipv4:131.0.0.1\":{\"priv:ietf-type\":\"peer\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"peer2\"},\"ipv4:132.0.0.1\":{\"priv:ietf-type\":\"transit\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"tran1\"},\"ipv4:135.0.0.1\":{\"priv:ietf-type\":\"transit\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"tran2\"},\"ipv4:169.254.1.2\":{\"my-alternate-network-map.pid\":\"linklocal\",\"my-default-network-map.pid\":\"linklocal\"},\"ipv4:201.0.0.1\":{\"my-alternate-network-map.pid\":\"user1\",\"my-default-network-map.pid\":\"default\"},\"ipv4:201.1.2.3\":{\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"default\"},\"ipv4:202.0.0.1\":{\"my-alternate-network-map.pid\":\"user2\",\"my-default-network-map.pid\":\"default\"},\"ipv4:203.0.0.1\":{\"my-alternate-network-map.pid\":\"user3\",\"my-default-network-map.pid\":\"default\"},\"ipv4:204.0.0.1\":{\"my-alternate-network-map.pid\":\"user4\",\"my-default-network-map.pid\":\"default\"},\"ipv4:99.0.0.1\":{\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"default\"},\"ipv6:::1\":{\"my-alternate-network-map.pid\":\"loopback\",\"my-default-network-map.pid\":\"loopback\"},\"ipv6:::2\":{\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"default\"},\"ipv6:2001:db8::\":{\"priv:ietf-type\":\"peer\",\"my-alternate-network-map.pid\":\"default\",\"my-default-network-map.pid\":\"peer1\"}},\"meta\":{\"dependent-vtags\":[{\"tag\":\"200dc84a734fb99516eceffcb2c8458a\",\"resource-id\":\"my-default-network-map\"},{\"tag\":\"88e5d857507ed921f157a7c3413af0c4\",\"resource-id\":\"my-alternate-network-map\"}]}}";
-
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testDoExecute() throws Exception {
- HttpResponse response = mock(HttpResponse.class);
- StatusLine statusLine = mock(StatusLine.class);
- doReturn(NETWORK_MAP).when(altoCreate).readFromFile("network-maps");
- doReturn(COST_MAP).when(altoCreate).readFromFile("cost-maps");
- doReturn(ENDPOINT_PROPERTY_MAP).when(altoCreate).readFromFile("endpoint-property-map");
- doReturn(response).when(httpClient).execute(any(HttpPut.class));
- doReturn(statusLine).when(response).getStatusLine();
- doReturn(200).when(statusLine).getStatusCode();
-
- altoCreate.resourceType = "network-map";
- altoCreate.resourceFile = "network-maps";
- altoCreate.doExecute();
- verify(httpClient, atLeastOnce()).execute(any(HttpPut.class));
- altoCreate.resourceType = "cost-map";
- altoCreate.resourceFile = "cost-maps";
- altoCreate.doExecute();
- verify(httpClient, atLeastOnce()).execute(any(HttpPut.class));
- altoCreate.resourceType = "endpoint-property-map";
- altoCreate.resourceFile = "endpoint-property-map";
- altoCreate.doExecute();
- verify(httpClient, atLeastOnce()).execute(any(HttpPut.class));
- altoCreate.resourceType = "otherwise";
- try {
- altoCreate.doExecute();
- } catch (Exception e) {
- Assert.assertEquals(e.getClass(), UnsupportedOperationException.class);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.manager;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Matchers.any;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.StatusLine;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.entity.EntityBuilder;
-import org.apache.http.client.methods.HttpDelete;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-
-public class AltoDeleteTest {
- @Mock(name = "httpClient")
- private HttpClient httpClient;
-
- @InjectMocks
- @Spy
- private AltoDelete altoDelete = new AltoDelete();
-
- private final String DEFAULT_NETWORK_MAP = "{\"default-alto-network-map\":{\"resource-id\":\"default-network-map\"}}";
-
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testDoExecute() throws Exception {
- HttpResponse response = mock(HttpResponse.class);
- HttpEntity entity = EntityBuilder.create().setText(DEFAULT_NETWORK_MAP).build();
- StatusLine statusLine = mock(StatusLine.class);
- doReturn(response).when(httpClient).execute(any(HttpDelete.class));
- doReturn(statusLine).when(response).getStatusLine();
- doReturn(200).when(statusLine).getStatusCode();
- doReturn(response).when(altoDelete).httpGet(AltoManagerConstants.IRD_DEFAULT_NETWORK_MAP_URL);
- doReturn(entity).when(response).getEntity();
-
- altoDelete.resourceType = "network-map";
- altoDelete.resourceId = "my-default-network-map";
- altoDelete.doExecute();
- verify(httpClient, atLeastOnce()).execute(any(HttpDelete.class));
- altoDelete.resourceType = "cost-map";
- altoDelete.resourceId = "my-default-network-map-routingcost-numerical";
- altoDelete.doExecute();
- verify(httpClient, atLeastOnce()).execute(any(HttpDelete.class));
- altoDelete.resourceType = "endpoint-property-map";
- altoDelete.resourceId = null;
- altoDelete.doExecute();
- verify(httpClient, atLeastOnce()).execute(any(HttpDelete.class));
- altoDelete.resourceType = "otherwise";
- altoDelete.resourceId = "";
- try {
- altoDelete.doExecute();
- } catch (Exception e) {
- Assert.assertEquals(e.getClass(), UnsupportedOperationException.class);
- }
- }
-}
+++ /dev/null
-Manifest-Version: 1.0\r
-Bnd-LastModified: 1427734698968\r
-Build-Jdk: 1.7.0_51\r
-Built-By: richardyang\r
-Bundle-ManifestVersion: 2\r
-Bundle-Name: org.opendaylight.alto.alto-model\r
-Bundle-SymbolicName: org.opendaylight.alto.model\r
-Bundle-Version: 1.0.0.SNAPSHOT\r
-Created-By: Apache Maven Bundle Plugin\r
-Export-Package: org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev14\r
- 1119;uses:="org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev14111\r
- 9.endpoint.cost.service.input,org.opendaylight.yang.gen.v1.urn.opendayl\r
- ight.alto.rev141119.endpoint.cost.service.output,org.opendaylight.yang.\r
- gen.v1.urn.opendaylight.alto.rev141119.endpoint.property.service.output\r
- ,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev141119.filtered.\r
- cost.map.service.input,org.opendaylight.yang.gen.v1.urn.opendaylight.al\r
- to.rev141119.filtered.cost.map.service.output,org.opendaylight.yang.gen\r
- .v1.urn.opendaylight.alto.rev141119.filtered.network.map.service.output\r
- ,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev141119.resources\r
- ,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev14\r
- 1101,org.opendaylight.yangtools.concepts,org.opendaylight.yangtools.yan\r
- g.binding,org.opendaylight.yangtools.yang.common";version="1.0.0.SNAPSH\r
- OT",org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev141119.endpoi\r
- nt.cost.service.input;uses:="org.opendaylight.yang.gen.v1.urn.opendayli\r
- ght.alto.rev141119,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.s\r
- ervice.types.rev141101,org.opendaylight.yangtools.concepts,org.opendayl\r
- ight.yangtools.yang.binding,org.opendaylight.yangtools.yang.common";ver\r
- sion="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn.opendaylight.alt\r
- o.rev141119.endpoint.cost.service.output.endpoint.cost.service.endpoint\r
- .cost.map;uses:="org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev\r
- 141119.endpoint.cost.service.output.endpoint.cost.service,org.opendayli\r
- ght.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101,org.opend\r
- aylight.yangtools.concepts,org.opendaylight.yangtools.yang.binding,org.\r
- opendaylight.yangtools.yang.common";version="1.0.0.SNAPSHOT",org.openda\r
- ylight.yang.gen.v1.urn.opendaylight.alto.rev141119.endpoint.cost.servic\r
- e.output.endpoint.cost.service;uses:="org.opendaylight.yang.gen.v1.urn.\r
- opendaylight.alto.rev141119.endpoint.cost.service.output,org.opendaylig\r
- ht.yang.gen.v1.urn.opendaylight.alto.rev141119.endpoint.cost.service.ou\r
- tput.endpoint.cost.service.endpoint.cost.map,org.opendaylight.yang.gen.\r
- v1.urn.opendaylight.alto.rev141119.endpoint.cost.service.output.endpoin\r
- t.cost.service.meta,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.\r
- service.types.rev141101,org.opendaylight.yangtools.concepts,org.openday\r
- light.yangtools.yang.binding,org.opendaylight.yangtools.yang.common";ve\r
- rsion="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn.opendaylight.al\r
- to.rev141119.endpoint.cost.service.output.endpoint.cost.service.meta;us\r
- es:="org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev141119.endpo\r
- int.cost.service.output.endpoint.cost.service,org.opendaylight.yang.gen\r
- .v1.urn.opendaylight.alto.service.types.rev141101,org.opendaylight.yang\r
- tools.concepts,org.opendaylight.yangtools.yang.binding,org.opendaylight\r
- .yangtools.yang.common";version="1.0.0.SNAPSHOT",org.opendaylight.yang.\r
- gen.v1.urn.opendaylight.alto.rev141119.endpoint.cost.service.output;use\r
- s:="org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev141119,org.op\r
- endaylight.yang.gen.v1.urn.opendaylight.alto.rev141119.endpoint.cost.se\r
- rvice.output.endpoint.cost.service,org.opendaylight.yangtools.concepts,\r
- org.opendaylight.yangtools.yang.binding,org.opendaylight.yangtools.yang\r
- .common";version="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn.open\r
- daylight.alto.rev141119.endpoint.property.service.output;uses:="org.ope\r
- ndaylight.yang.gen.v1.urn.opendaylight.alto.rev141119,org.opendaylight.\r
- yang.gen.v1.urn.opendaylight.alto.service.types.rev141101,org.opendayli\r
- ght.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101.endpoint.\r
- property.map,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service\r
- .types.rev141101.endpoint.property.map.data,org.opendaylight.yangtools.\r
- concepts,org.opendaylight.yangtools.yang.binding,org.opendaylight.yangt\r
- ools.yang.common";version="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1\r
- .urn.opendaylight.alto.rev141119.filtered.cost.map.service.input;uses:=\r
- "org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev141119,org.opend\r
- aylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101,org.o\r
- pendaylight.yangtools.concepts,org.opendaylight.yangtools.yang.binding,\r
- org.opendaylight.yangtools.yang.common";version="1.0.0.SNAPSHOT",org.op\r
- endaylight.yang.gen.v1.urn.opendaylight.alto.rev141119.filtered.cost.ma\r
- p.service.output;uses:="com.google.common.collect,org.opendaylight.yang\r
- .gen.v1.urn.opendaylight.alto.rev141119,org.opendaylight.yang.gen.v1.ur\r
- n.opendaylight.alto.service.did.rev141101,org.opendaylight.yang.gen.v1.\r
- urn.opendaylight.alto.service.did.rev141101.cost.map,org.opendaylight.y\r
- ang.gen.v1.urn.opendaylight.alto.service.did.rev141101.cost.map.data,or\r
- g.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev14110\r
- 1,org.opendaylight.yangtools.concepts,org.opendaylight.yangtools.yang.b\r
- inding,org.opendaylight.yangtools.yang.common";version="1.0.0.SNAPSHOT"\r
- ,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev141119.filtered.\r
- network.map.service.output;uses:="com.google.common.collect,org.openday\r
- light.yang.gen.v1.urn.opendaylight.alto.rev141119,org.opendaylight.yang\r
- .gen.v1.urn.opendaylight.alto.service.did.rev141101,org.opendaylight.ya\r
- ng.gen.v1.urn.opendaylight.alto.service.did.rev141101.network.map.data,\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141\r
- 101,org.opendaylight.yangtools.concepts,org.opendaylight.yangtools.yang\r
- .binding,org.opendaylight.yangtools.yang.common";version="1.0.0.SNAPSHO\r
- T",org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev141119.resourc\r
- es.network.maps;uses:="com.google.common.collect,org.opendaylight.yang.\r
- gen.v1.urn.opendaylight.alto.rev141119.resources,org.opendaylight.yang.\r
- gen.v1.urn.opendaylight.alto.service.did.rev141101,org.opendaylight.yan\r
- g.gen.v1.urn.opendaylight.alto.service.did.rev141101.network.map.data,o\r
- rg.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev1411\r
- 01,org.opendaylight.yangtools.concepts,org.opendaylight.yangtools.yang.\r
- binding,org.opendaylight.yangtools.yang.common";version="1.0.0.SNAPSHOT\r
- ",org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev141119.resource\r
- s;uses:="org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev141119,o\r
- rg.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev141119.resources.n\r
- etwork.maps,org.opendaylight.yangtools.concepts,org.opendaylight.yangto\r
- ols.yang.binding,org.opendaylight.yangtools.yang.common";version="1.0.0\r
- .SNAPSHOT",org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.d\r
- id.rev141101;uses:="org.opendaylight.yang.gen.v1.urn.opendaylight.alto.\r
- service.did.rev141101.alto.resources,org.opendaylight.yang.gen.v1.urn.o\r
- pendaylight.alto.service.did.rev141101.cost.map,org.opendaylight.yang.g\r
- en.v1.urn.opendaylight.alto.service.did.rev141101.cost.map.data,org.ope\r
- ndaylight.yang.gen.v1.urn.opendaylight.alto.service.did.rev141101.netwo\r
- rk.map.data,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.\r
- types.rev141101,org.opendaylight.yangtools.yang.binding,org.opendayligh\r
- t.yangtools.yang.common";version="1.0.0.SNAPSHOT",org.opendaylight.yang\r
- .gen.v1.urn.opendaylight.alto.service.did.rev141101.alto.resources.cost\r
- .maps;uses:="com.google.common.collect,org.opendaylight.yang.gen.v1.urn\r
- .opendaylight.alto.service.did.rev141101,org.opendaylight.yang.gen.v1.u\r
- rn.opendaylight.alto.service.did.rev141101.alto.resources,org.opendayli\r
- ght.yang.gen.v1.urn.opendaylight.alto.service.did.rev141101.cost.map,or\r
- g.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.did.rev141101.\r
- cost.map.data,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.servic\r
- e.types.rev141101,org.opendaylight.yangtools.concepts,org.opendaylight.\r
- yangtools.yang.binding,org.opendaylight.yangtools.yang.common";version=\r
- "1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn.opendaylight.alto.ser\r
- vice.did.rev141101.alto.resources;uses:="org.opendaylight.yang.gen.v1.u\r
- rn.opendaylight.alto.service.did.rev141101,org.opendaylight.yang.gen.v1\r
- .urn.opendaylight.alto.service.did.rev141101.alto.resources.cost.maps,o\r
- rg.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.did.rev141101\r
- .alto.resources.network.maps,org.opendaylight.yang.gen.v1.urn.opendayli\r
- ght.alto.service.types.rev141101,org.opendaylight.yang.gen.v1.urn.opend\r
- aylight.alto.service.types.rev141101.endpoint.property.map,org.opendayl\r
- ight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101.endpoint\r
- .property.map.data,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.s\r
- ervice.types.rev141101.ird,org.opendaylight.yang.gen.v1.urn.opendayligh\r
- t.alto.service.types.rev141101.ird.data,org.opendaylight.yangtools.conc\r
- epts,org.opendaylight.yangtools.yang.binding,org.opendaylight.yangtools\r
- .yang.common";version="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn\r
- .opendaylight.alto.service.did.rev141101.alto.resources.network.maps;us\r
- es:="com.google.common.collect,org.opendaylight.yang.gen.v1.urn.openday\r
- light.alto.service.did.rev141101,org.opendaylight.yang.gen.v1.urn.opend\r
- aylight.alto.service.did.rev141101.alto.resources,org.opendaylight.yang\r
- .gen.v1.urn.opendaylight.alto.service.did.rev141101.network.map.data,or\r
- g.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev14110\r
- 1,org.opendaylight.yangtools.concepts,org.opendaylight.yangtools.yang.b\r
- inding,org.opendaylight.yangtools.yang.common";version="1.0.0.SNAPSHOT"\r
- ,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.did.rev1411\r
- 01.cost.map.data.map;uses:="org.opendaylight.yang.gen.v1.urn.opendaylig\r
- ht.alto.service.did.rev141101.cost.map.data,org.opendaylight.yang.gen.v\r
- 1.urn.opendaylight.alto.service.types.rev141101,org.opendaylight.yangto\r
- ols.concepts,org.opendaylight.yangtools.yang.binding,org.opendaylight.y\r
- angtools.yang.common";version="1.0.0.SNAPSHOT",org.opendaylight.yang.ge\r
- n.v1.urn.opendaylight.alto.service.did.rev141101.cost.map.data;uses:="o\r
- rg.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.did.rev141101\r
- ,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.did.rev1411\r
- 01.cost.map.data.map,org.opendaylight.yang.gen.v1.urn.opendaylight.alto\r
- .service.types.rev141101,org.opendaylight.yangtools.concepts,org.openda\r
- ylight.yangtools.yang.binding,org.opendaylight.yangtools.yang.common";v\r
- ersion="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn.opendaylight.a\r
- lto.service.did.rev141101.cost.map;uses:="org.opendaylight.yang.gen.v1.\r
- urn.opendaylight.alto.service.did.rev141101,org.opendaylight.yang.gen.v\r
- 1.urn.opendaylight.alto.service.types.rev141101,org.opendaylight.yang.g\r
- en.v1.urn.opendaylight.alto.service.types.rev141101.cost.map.meta,org.o\r
- pendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101.d\r
- ependent.vtags,org.opendaylight.yangtools.concepts,org.opendaylight.yan\r
- gtools.yang.binding,org.opendaylight.yangtools.yang.common";version="1.\r
- 0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn.opendaylight.alto.servic\r
- e.did.rev141101.network.map.data;uses:="org.opendaylight.yang.gen.v1.ur\r
- n.opendaylight.alto.service.did.rev141101,org.opendaylight.yang.gen.v1.\r
- urn.opendaylight.alto.service.types.rev141101,org.opendaylight.yang.gen\r
- .v1.urn.opendaylight.alto.service.types.rev141101.endpoint.address.grou\r
- p,org.opendaylight.yangtools.concepts,org.opendaylight.yangtools.yang.b\r
- inding,org.opendaylight.yangtools.yang.common";version="1.0.0.SNAPSHOT"\r
- ,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev14\r
- 1101;uses:="com.google.common.collect,org.opendaylight.yang.gen.v1.urn.\r
- opendaylight.alto.service.types.rev141101.cost.map,org.opendaylight.yan\r
- g.gen.v1.urn.opendaylight.alto.service.types.rev141101.cost.map.data,or\r
- g.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev14110\r
- 1.cost.map.meta,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.serv\r
- ice.types.rev141101.cost.types,org.opendaylight.yang.gen.v1.urn.openday\r
- light.alto.service.types.rev141101.dependent.vtags,org.opendaylight.yan\r
- g.gen.v1.urn.opendaylight.alto.service.types.rev141101.endpoint.address\r
- .group,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types\r
- .rev141101.endpoint.property.map,org.opendaylight.yang.gen.v1.urn.opend\r
- aylight.alto.service.types.rev141101.endpoint.property.map.data,org.ope\r
- ndaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101.ird\r
- ,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev14\r
- 1101.ird.capabilities,org.opendaylight.yang.gen.v1.urn.opendaylight.alt\r
- o.service.types.rev141101.ird.data,org.opendaylight.yang.gen.v1.urn.ope\r
- ndaylight.alto.service.types.rev141101.network.map,org.opendaylight.yan\r
- g.gen.v1.urn.opendaylight.alto.service.types.rev141101.network.map.data\r
- ,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev14\r
- 1101.network.map.meta,org.opendaylight.yangtools.yang.binding,org.opend\r
- aylight.yangtools.yang.common";version="1.0.0.SNAPSHOT",org.opendayligh\r
- t.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101.cost.map.da\r
- ta.cost.map;uses:="org.opendaylight.yang.gen.v1.urn.opendaylight.alto.s\r
- ervice.types.rev141101,org.opendaylight.yang.gen.v1.urn.opendaylight.al\r
- to.service.types.rev141101.cost.map.data,org.opendaylight.yangtools.con\r
- cepts,org.opendaylight.yangtools.yang.binding,org.opendaylight.yangtool\r
- s.yang.common";version="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.ur\r
- n.opendaylight.alto.service.types.rev141101.cost.map.data;uses:="org.op\r
- endaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101,or\r
- g.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev14110\r
- 1.cost.map.data.cost.map,org.opendaylight.yangtools.concepts,org.openda\r
- ylight.yangtools.yang.binding,org.opendaylight.yangtools.yang.common";v\r
- ersion="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn.opendaylight.a\r
- lto.service.types.rev141101.cost.map.meta;uses:="org.opendaylight.yang.\r
- gen.v1.urn.opendaylight.alto.service.types.rev141101,org.opendaylight.y\r
- angtools.concepts,org.opendaylight.yangtools.yang.binding,org.opendayli\r
- ght.yangtools.yang.common";version="1.0.0.SNAPSHOT",org.opendaylight.ya\r
- ng.gen.v1.urn.opendaylight.alto.service.types.rev141101.cost.map;uses:=\r
- "org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev14\r
- 1101,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.r\r
- ev141101.cost.map.meta,org.opendaylight.yang.gen.v1.urn.opendaylight.al\r
- to.service.types.rev141101.dependent.vtags,org.opendaylight.yangtools.c\r
- oncepts,org.opendaylight.yangtools.yang.binding,org.opendaylight.yangto\r
- ols.yang.common";version="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.\r
- urn.opendaylight.alto.service.types.rev141101.cost.types;uses:="org.ope\r
- ndaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101,org\r
- .opendaylight.yangtools.concepts,org.opendaylight.yangtools.yang.bindin\r
- g,org.opendaylight.yangtools.yang.common";version="1.0.0.SNAPSHOT",org.\r
- opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101.\r
- dependent.vtags;uses:="com.google.common.collect,org.opendaylight.yang.\r
- gen.v1.urn.opendaylight.alto.service.types.rev141101,org.opendaylight.y\r
- angtools.concepts,org.opendaylight.yangtools.yang.binding,org.opendayli\r
- ght.yangtools.yang.common";version="1.0.0.SNAPSHOT",org.opendaylight.ya\r
- ng.gen.v1.urn.opendaylight.alto.service.types.rev141101.endpoint.addres\r
- s.group;uses:="org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang\r
- .ietf.inet.types.rev100924,org.opendaylight.yang.gen.v1.urn.opendayligh\r
- t.alto.service.types.rev141101,org.opendaylight.yangtools.concepts,org.\r
- opendaylight.yangtools.yang.binding,org.opendaylight.yangtools.yang.com\r
- mon";version="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn.opendayl\r
- ight.alto.service.types.rev141101.endpoint.property.map.data.endpoint.p\r
- roperties;uses:="org.opendaylight.yang.gen.v1.urn.opendaylight.alto.ser\r
- vice.types.rev141101,org.opendaylight.yang.gen.v1.urn.opendaylight.alto\r
- .service.types.rev141101.endpoint.property.map.data,org.opendaylight.ya\r
- ngtools.concepts,org.opendaylight.yangtools.yang.binding,org.opendaylig\r
- ht.yangtools.yang.common";version="1.0.0.SNAPSHOT",org.opendaylight.yan\r
- g.gen.v1.urn.opendaylight.alto.service.types.rev141101.endpoint.propert\r
- y.map.data;uses:="org.opendaylight.yang.gen.v1.urn.opendaylight.alto.se\r
- rvice.types.rev141101,org.opendaylight.yang.gen.v1.urn.opendaylight.alt\r
- o.service.types.rev141101.endpoint.property.map.data.endpoint.propertie\r
- s,org.opendaylight.yangtools.concepts,org.opendaylight.yangtools.yang.b\r
- inding,org.opendaylight.yangtools.yang.common";version="1.0.0.SNAPSHOT"\r
- ,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev14\r
- 1101.endpoint.property.map;uses:="org.opendaylight.yang.gen.v1.urn.open\r
- daylight.alto.service.types.rev141101,org.opendaylight.yang.gen.v1.urn.\r
- opendaylight.alto.service.types.rev141101.dependent.vtags,org.opendayli\r
- ght.yangtools.concepts,org.opendaylight.yangtools.yang.binding,org.open\r
- daylight.yangtools.yang.common";version="1.0.0.SNAPSHOT",org.opendaylig\r
- ht.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101.ird.capabi\r
- lities;uses:="org.opendaylight.yang.gen.v1.urn.opendaylight.alto.servic\r
- e.types.rev141101,org.opendaylight.yangtools.concepts,org.opendaylight.\r
- yangtools.yang.binding,org.opendaylight.yangtools.yang.common";version=\r
- "1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn.opendaylight.alto.ser\r
- vice.types.rev141101.ird.data;uses:="org.opendaylight.yang.gen.v1.urn.i\r
- etf.params.xml.ns.yang.ietf.inet.types.rev100924,org.opendaylight.yang.\r
- gen.v1.urn.opendaylight.alto.service.types.rev141101,org.opendaylight.y\r
- ang.gen.v1.urn.opendaylight.alto.service.types.rev141101.ird.capabiliti\r
- es,org.opendaylight.yangtools.concepts,org.opendaylight.yangtools.yang.\r
- binding,org.opendaylight.yangtools.yang.common";version="1.0.0.SNAPSHOT\r
- ",org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev1\r
- 41101.ird;uses:="org.opendaylight.yang.gen.v1.urn.opendaylight.alto.ser\r
- vice.types.rev141101,org.opendaylight.yang.gen.v1.urn.opendaylight.alto\r
- .service.types.rev141101.cost.types,org.opendaylight.yangtools.concepts\r
- ,org.opendaylight.yangtools.yang.binding,org.opendaylight.yangtools.yan\r
- g.common";version="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn.ope\r
- ndaylight.alto.service.types.rev141101.network.map.data;uses:="org.open\r
- daylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101,org.\r
- opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101.\r
- endpoint.address.group,org.opendaylight.yangtools.concepts,org.opendayl\r
- ight.yangtools.yang.binding,org.opendaylight.yangtools.yang.common";ver\r
- sion="1.0.0.SNAPSHOT",org.opendaylight.yang.gen.v1.urn.opendaylight.alt\r
- o.service.types.rev141101.network.map.meta;uses:="com.google.common.col\r
- lect,org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.r\r
- ev141101,org.opendaylight.yangtools.concepts,org.opendaylight.yangtools\r
- .yang.binding,org.opendaylight.yangtools.yang.common";version="1.0.0.SN\r
- APSHOT",org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.type\r
- s.rev141101.network.map;uses:="org.opendaylight.yang.gen.v1.urn.openday\r
- light.alto.service.types.rev141101,org.opendaylight.yang.gen.v1.urn.ope\r
- ndaylight.alto.service.types.rev141101.network.map.meta,org.opendayligh\r
- t.yangtools.concepts,org.opendaylight.yangtools.yang.binding,org.openda\r
- ylight.yangtools.yang.common";version="1.0.0.SNAPSHOT"\r
-Import-Package: com.google.common.base;version="[18.0,19)",com.google.co\r
- mmon.collect;version="[18.0,19)",org.opendaylight.yang.gen.v1.urn.ietf.\r
- params.xml.ns.yang.ietf.inet.types.rev100924;version="[2010.9,2011)",or\r
- g.opendaylight.yangtools.concepts;version="[0.7,1)",org.opendaylight.ya\r
- ngtools.yang.binding;version="[0.7,1)",org.opendaylight.yangtools.yang.\r
- common;version="[0.7,1)",org.opendaylight.yangtools.yang.binding.annota\r
- tions;version="[0.7,1)"\r
-Tool: Bnd-2.1.0.20130426-122213\r
+++ /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</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
-
- <artifactId>alto-model</artifactId>
- <packaging>bundle</packaging>
-
- <build>
- <plugins>
- <plugin> <!-- OSGi plugin -->
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.*;
- </Export-Package>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-jmx-generator-plugin</artifactId>
- <version>${config.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>${mdsal.model.version}</version>
- <type>jar</type>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- </codeGeneratorClass>
- <outputBaseDir>${jmxGeneratorPath}</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>${salGeneratorPath}</outputBaseDir>
- </generator>
- -->
- </codeGenerators>
- <inspectDependencies>true</inspectDependencies>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency> <!-- yang generated -->
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-yang-types-20130715</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404;
-
-
-/**
- * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
- * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
- *
- * The reason behind putting it under src/main/java is:
- * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
- * loss of user code.
- *
- */
-public class CostMetricBuilder {
-
- public static CostMetric getDefaultInstance(java.lang.String defaultValue) {
- return new CostMetric(defaultValue);
- }
-
-}
+++ /dev/null
-package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404;
-
-
-/**
- * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
- * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
- *
- * The reason behind putting it under src/main/java is:
- * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
- * loss of user code.
- *
- */
-public class EndpointAddressTypeBuilder {
-
- public static EndpointAddressType getDefaultInstance(java.lang.String defaultValue) {
- if ("ipv4".equals(defaultValue)) {
- return new EndpointAddressType(EndpointAddressType.Enumeration.Ipv4);
- } else if ("ipv6".equals(defaultValue)) {
- return new EndpointAddressType(EndpointAddressType.Enumeration.Ipv6);
- }
-
- throw new java.lang.UnsupportedOperationException("Wrong EndpointAddressType");
- }
-
-}
+++ /dev/null
-package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404;
-
-
-/**
- * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
- * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
- *
- * The reason behind putting it under src/main/java is:
- * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
- * loss of user code.
- *
- */
-public class EndpointPropertyTypeBuilder {
-
- public static EndpointPropertyType getDefaultInstance(java.lang.String defaultValue) {
- if (defaultValue.contains(".")) {
- return new EndpointPropertyType(new ResourceSpecificEndpointProperty(defaultValue));
- } else {
- return new EndpointPropertyType(new GlobalEndpointProperty(defaultValue.toCharArray()));
- }
- }
-
-}
+++ /dev/null
-package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.GlobalEndpointProperty.Enumeration;
-
-
-/**
- * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
- * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
- *
- * The reason behind putting it under src/main/java is:
- * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
- * loss of user code.
- *
- */
-public class GlobalEndpointPropertyBuilder {
-
- public static GlobalEndpointProperty getDefaultInstance(java.lang.String defaultValue) {
- if ("Pid".equals(defaultValue)) {
- return new GlobalEndpointProperty(Enumeration.Pid);
- } else {
- return new GlobalEndpointProperty(defaultValue);
- }
- }
-
-}
+++ /dev/null
-package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404;
-
-
-/**
- * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
- * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
- *
- * The reason behind putting it under src/main/java is:
- * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
- * loss of user code.
- *
- */
-public class MediaTypeBuilder {
-
- public static MediaType getDefaultInstance(java.lang.String defaultValue) {
- if ("application/alto-directory+json".equals(defaultValue)) {
- return new MediaType(MediaType.Enumeration.AltoDirectory);
- } else if ("application/alto-networkmap+json".equals(defaultValue)) {
- return new MediaType(MediaType.Enumeration.AltoNetworkmap);
- } else if ("application/alto-networkmapfilter+json".equals(defaultValue)) {
- return new MediaType(MediaType.Enumeration.AltoNetworkmapfilter);
- } else if ("application/alto-costmap+json".equals(defaultValue)) {
- return new MediaType(MediaType.Enumeration.AltoCostmap);
- } else if ("application/alto-costmapfilter+json".equals(defaultValue)) {
- return new MediaType(MediaType.Enumeration.AltoCostmapfilter);
- } else if ("application/alto-endpointprop+json".equals(defaultValue)) {
- return new MediaType(MediaType.Enumeration.AltoEndpointprop);
- } else if ("application/alto-endpointpropparams+json".equals(defaultValue)) {
- return new MediaType(MediaType.Enumeration.AltoEndpointpropparams);
- } else if ("application/alto-endpointcost+json".equals(defaultValue)) {
- return new MediaType(MediaType.Enumeration.AltoEndpointcost);
- } else if ("application/alto-endpointcostparams+json".equals(defaultValue)) {
- return new MediaType(MediaType.Enumeration.AltoEndpointcostparams);
- } else if ("application/alto-error+json".equals(defaultValue)) {
- return new MediaType(MediaType.Enumeration.AltoError);
- }
-
- throw new java.lang.UnsupportedOperationException("Wrong MediaType: "+defaultValue);
- }
-
-}
+++ /dev/null
-package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404;
-
-
-/**
- * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
- * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
- *
- * The reason behind putting it under src/main/java is:
- * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
- * loss of user code.
- *
- */
-public class TypedEndpointAddressBuilder {
-
- public static TypedEndpointAddress getDefaultInstance(java.lang.String defaultValue) {
- if (defaultValue.startsWith("ipv4")) {
- return new TypedEndpointAddress(new TypedIpv4Address(defaultValue));
- } else if (defaultValue.startsWith("ipv6")) {
- return new TypedEndpointAddress(new TypedIpv6Address(defaultValue));
- }
- throw new java.lang.UnsupportedOperationException("Wrong TypedEndpointAddress type");
- }
-
-}
+++ /dev/null
-module alto-cost-default {
- namespace "urn:opendaylight:alto:costdefault";
- prefix "alto-cost-default";
-
- import alto-service {prefix alto-restconf;}
-
- revision 2015-05-07 {
- description
- "augment default cost in alto-service-types";
- }
-
- augment "/alto-restconf:endpoint-cost-service/alto-restconf:output/alto-restconf:endpoint-cost-service/alto-restconf:endpoint-cost-map/alto-restconf:dst-costs" {
- leaf cost-default {
- type string;
- }
- }
-
- augment "/alto-restconf:resources/alto-restconf:cost-maps/alto-restconf:cost-map/alto-restconf:map/alto-restconf:dst-costs" {
- leaf cost-default {
- type string;
- }
- }
-
-}
+++ /dev/null
-module alto-service-types {
- yang-version 1;
-
- namespace "urn:opendaylight:alto-service-types";
- // TODO: replace with IANA namespace when assigned
-
- prefix "alto";
-
- import ietf-inet-types {
- prefix inet;
- }
-
- organization "ALTO WG";
- contact "alto@ietf.org";
-
- description
- "This module defines the data types and groupings for a semantically
- equivalent data model for the ALTO services defined in RFC7285.";
-
- revision 2015-04-04 {
- description "Interop with RFC7285";
- }
-
- revision 2014-11-01 {
- description "Separate types module";
- }
-
- revision 2014-10-24 {
- description "Initial version.";
- }
-
- /********************
- * TYPE DEFINITIONS *
- ********************/
-
- /***********************************************************
- Definitions for addresses
-
- ALTO RFC7285 uses the following addresses, as shown in the
- examples below:
-
- - Endpoint property service (Sec. 11.4.1.7):
- "endpoints" : [ "ipv4:192.0.2.34",
- "ipv4:203.0.113.129" ]
- - Endpoint cost service (Sec. 11.5.1.7):
- "endpoints" : {
- "srcs": [ "ipv4:192.0.2.2" ],
- "dsts": [
- "ipv4:192.0.2.89",
- "ipv4:198.51.100.34",
- "ipv4:203.0.113.45"
- - Network map (Sec. 11.2.1.7.):
- "ipv4": [
- "192.0.2.0/24",
- "198.51.100.0/25"
- ],
- "ipv6": [
- "2001:db8:0:1::/64",
- "2001:db8:0:2::/64"
- ]
-
- To handle the proceeding, we need the following definitions:
- ipv4-address (e.g., 192.0.2.0, already defined in rfc6991),
- ipv6-address (already defined in rfc6991),
- ipv4-prefix (e.g., 192.0.2.0/24, already defined in rfc6991),
- ipv6-prefix (defined in rfc6991),
- typed-ipv4-address (e.g., ipv4:192.0.2.1, to be defined below)
- typed-ipv6-address
- typed-ipv4-prefix-list (e.g., "ipv4": [
- "192.0.2.0/24",
- "198.51.100.0/25"
- ],
-
- *******************************************************************/
-
- /*
- First define typed-ipv4-address and typed-ipv6-address, as used
- by endpoint services.
-
- The ideal case is to define it as "ipv4:"+ipv4-address, but there
- is not such a type constructor (YANG EXTENSION). Hence, the
- current definition cuts-and-pastes (i.e., repeats verbatim) the
- definition of ipv4-address and prepend "ipv4:". The downside is
- that if someone redefines ipv4-address, there could be
- inconsistency.
- */
-
- typedef typed-ipv4-address {
- type string {
- pattern
- 'ipv4:(([0-9]|[1-9][0-9]|1[0-9][0-9]|'
- + '2[0-4][0-9]|25[0-5])\.){3}'
- + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
- + '(%[\p{N}\p{L}]+)?';
- }
- }
-
-
- typedef typed-ipv6-address {
- type string {
- pattern 'ipv6:((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
- + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
- + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
- + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
- + '(%[\p{N}\p{L}]+)?';
- pattern 'ipv6:((([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
- + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
- + '(%.+)?)';
- }
- }
-
- typedef typed-endpoint-address {
- type union {
- type typed-ipv4-address;
- type typed-ipv6-address;
- // EXTENSION: ADD NEW TYPE HERE.
- }
- description
- "Ref: RFC7285 Sec. 10.4.1 Typed Endpoint Addresses" +
- "= AddressType:EndpointAddr";
- }
-
- /* Next, we define endpoint address group, as used in the definition
- of ALTO network maps. Specifically, an endpoint address group in
- ALTO is defined as a key-value store, with address type as key,
- and an array of prefix as the value of each key:
-
- EndpointAddrGroup. RFC7285 Sec. 10.4.5." +
- object-map {
- AddressType -> endpoint-prefix<0..*>;
- } EndpointAddrGroup;
-
- There are two challenges:
-
- 1) To specify that AddressType is key, we must use the list type,
- which is the only type that one can specify key. However, the
- current JSON-YANG encoding generates an array, instead of a
- key-value map;
-
- 2) Ideally, we want to enforce address type and prefix
- consistency; for example, an ipv6 prefix in an ipv4 type should
- not be allowed. However, we encounter problems. We leave this as
- an OPEN ISSUE.
- */
-
- typedef endpoint-address-type {
- type union {
- type enumeration {
- enum ipv4;
- enum ipv6;
- // EXTENSION: ADD NEW TYPE HERE
- }
- }
- description
- "Ref: RFC7285 Sec 2.2.";
- }
- /*
- typedef endpoint-prefix {
- type inet:ip-prefix;
- description
- "endpoint prefix, identical to ip-prefix defined in RFC6991.";
- }
- */
-
- grouping endpoint-address-group {
- list endpoint-address-group {
- key address-type;
- leaf address-type {
- type endpoint-address-type;
- mandatory true;
- }
- leaf-list endpoint-prefix {
- type inet:ip-prefix;
- }
- }
- description
- "EndpointAddrGroup. RFC7285 Sec. 10.4.5." +
- " object-map {
- AddressType -> endpoint-prefix<0..*>;
- } EndpointAddrGroup;";
- }
-
- /**************************************************************
- * Definitions for IDs and names
- *
- * ALTO defines the following concepts that are names and IDs:
- *
- * pid name (used in network map, cost map),
- * resource IDs (used to identify alto network/cost maps),
- * version tag (used to indicate uniqueness of resource),
- * cost-type-name (used in IRD),
- * cost-metric,
- * cost-mode
- *
- * We group their definitions together below.
- **************************************************************/
-
- typedef valid-id-string {
- type string {
- length "1..64";
- pattern "[0-9a-zA-Z_\-:@\.]+";
- }
- description
- "Type for valid ID strings.";
- }
-
- typedef tag-string {
- type string {
- length "1..64";
- pattern "[!-~]+";
- }
- description
- "Tag. RFC7285 Sec. 10.3. U+0021-U+007E";
- }
-
- typedef pid-name {
- type valid-id-string;
- description
- "Name for the PID." +
- "RFC7285, Section 10.1. Note: the '.' separator MUST NOT be" +
- "used unless specifically indicated in RFC7285 or an" +
- " extension document.";
- }
-
- typedef resource-id {
- type valid-id-string;
- description
- "Resource-ID.";
- }
-
- grouping vtag {
- leaf resource-id {
- type resource-id;
- mandatory true;
- }
- leaf tag {
- type tag-string;
- mandatory true;
- }
- description
- "Version tag. Both resource-id and tag must be equal
- byte-for-byte. RFC7285 Sec. 10.3." +
- " object {
- ResourceID resource-id;
- JSONString tag;
- } VersionTag;";
- }
-
- grouping dependent-vtags {
- list dependent-vtags {
- key resource-id;
- uses vtag;
- min-elements 1;
- }
- }
-
- /*************************************
- Definitions for cost type and cost types
-
- In ALTO, a cost type consists of two required components:
-
- cost-metric,
- cost-mode
- and an optional description component.
-
- In the IRD, one can name each cost type. Such info is collected
- in a hash map called cost types.
- *************************************/
-
- typedef cost-metric {
- type union {
- type enumeration {
- enum routingcost {
- description
- "Default metric. MUST support. RFC7285 Sec. 6.1.1.1.";
- }
- enum hopcount {
- description
- "Hopcount metric.";
- }
- // EXTENSION: Additional cost-metric will be defined here.
- }
- type string {
- length 1..32;
- pattern "priv:[0-9a-zA-Z_\-:\.]+";
- }
- }
- description
- "Cost metric. for type string,
- 'priv:' reserved for Private Use.";
- }
-
- typedef cost-mode {
- type enumeration {
- enum numerical {
- description
- "Numerical cost mode.";
- }
- enum ordinal {
- description
- "Ordinal cost mode.";
- }
- // EXTENSION: Additional cost-mode will be defined here.
- }
- description
- "Cost mode. MUST support at least one of numerical and ordinal";
- }
-
- grouping cost-type {
- leaf cost-mode {
- type cost-mode;
- mandatory true;
- description
- "Cost mode.";
- }
- leaf cost-metric {
- type cost-metric;
- mandatory true;
- description
- "Cost metric.";
- }
- leaf description {
- type string;
- description
- "Optional description field.";
- }
- description
- "Cost type. RFC7285 Sec. 10.7." +
- " object {
- CostMetric cost-metric;
- CostMode cost-mode;
- [JSONString description;]
- } CostType;";
- }
-
- typedef cost-type-name {
- type valid-id-string;
- // NOTE: not fully specified in RFC7285, default as valid id
- }
-
- grouping cost-types {
- list cost-types {
- key cost-type-name;
- leaf cost-type-name {
- type cost-type-name;
- }
- uses cost-type;
- }
- description
- "RFC 7285 Sec. 9.2.2." +
- "object-map {
- JSONString -> CostType;
- } IRDMetaCostTypes;";
- }
-
-
- /**************************************
- * Definitions for endpoint properties *
- **************************************/
- typedef global-endpoint-property {
- type union {
- type enumeration {
- enum pid {
- description "PID property.";
- }
- // EXTENSION: other options here
- }
- type string {
- pattern "priv:[\w\-:@]+";
- }
- }
- description
- "Global endpoint property. RFC7285 Sec. 10.8.2." +
- "'priv:' for Private Use " +
- " length 1..32; ‘.’ is not allowed";
- }
-
- /*
- * Ideally we would want to extend the typedef of resource-id and
- * global endpoint properties, however, YANG 1.0 does not allow
- * that, hence we simply copied the regex for resource-id over
- * verbatim.
- */
-
- typedef resource-specific-endpoint-property {
- type string {
- length "3..97"; //len(resource-id) + 1 + len(global-property)
- pattern "(priv:)?[\w\-:@\.]+\.[\w\-:_]+"; // resource-id.property
- }
- description
- "Resource-specific endpoint property.";
- }
-
- typedef endpoint-property-type {
- type union {
- type resource-specific-endpoint-property;
- type global-endpoint-property;
- }
- description
- "Endpoint property type. RFC7285 Sec. 10.8.";
- }
-
- typedef endpoint-property-value {
- type string;
- description
- "Endpoint property (value).";
- }
-
- /*************************************
- * Definitions for response header
- *************************************/
-
- typedef media-type {
- type union {
- type string {
- pattern "application/alto\-.*";
- }
- type enumeration {
- enum alto-directory; //+json
- enum alto-networkmap; //+json
- enum alto-networkmapfilter; //+json
- enum alto-costmap; //+json
- enum alto-costmapfilter; //+json
- enum alto-endpointprop; //+json
- enum alto-endpointpropparams; //+json
- enum alto-endpointcost; //+json
- enum alto-endpointcostparams; //+json
- enum alto-error; //+json
- }
- }
- }
-
- grouping alto-cost {
- anyxml cost {
- mandatory true;
- description
- "ALTO cost is a JSONValue, which could be
- an object, array, string, etc. (Ref: RFC 7159 Sec.3.)";
- }
- }
-
- typedef constraint {
- type string {
- pattern "(gt|ge|lt|le|eq) [0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?";
- }
- description
- "RFC7285 Sec. 11.3.2.3. The second part must be in the" +
- "same unit as cost-metric, IEEE 754 2008 floating point.";
- }
-
- /******************************************
- Groupings for ALTO information resource
- *******************************************/
-
- /* meta */
- grouping IRD-meta {
- uses cost-types;
- container default-alto-network-map {
- leaf resource-id {
- type resource-id;
- mandatory true;
- }
- }
- }
-
- grouping network-map-meta {
- container vtag {
- uses vtag;
- }
- }
-
- grouping cost-map-meta {
- uses dependent-vtags {
- refine dependent-vtags {
- max-elements 1;
- }
- }
- container cost-type {
- uses cost-type;
- }
- }
-
- grouping endpoint-property-meta {
- uses dependent-vtags;
- }
-
- /* accepts (optional) */
- grouping accepts {
- leaf-list accepts {
- type media-type;
- min-elements 1;
- }
- }
-
- /* capabilities (capabilities) */
- grouping IRD-capabilities {
- container capabilities {
- leaf cost-constraints {
- type boolean;
- }
- leaf-list cost-type-names {
- type cost-type-name;
- }
- leaf-list prop-types {
- type endpoint-property-type;
- }
- }
- }
-
- /* uses (optional) */
- grouping uses {
- leaf-list uses {
- type resource-id;
- min-elements 1;
- }
- }
-
- /* Information Resource Directory Grouping */
- grouping IRD {
- container meta {
- uses IRD-meta;
- }
- uses IRD-data;
- }
-
- grouping IRD-data {
- list resources {
- key resource-id;
- leaf resource-id {
- type resource-id;
- mandatory true;
- }
- leaf uri {
- type inet:uri;
- mandatory true;
- }
- leaf media-type {
- type media-type;
- mandatory true;
- }
- uses accepts {
- when "current()";
- }
- uses IRD-capabilities {
- when "current()";
- }
- uses uses {
- when "current()";
- }
- description
- "IRDResourceEntry. RFC7285 9.2.2." +
- " object {
- JSONString uri;
- JSONString media-type;
- [JSONString accepts;]
- [Capabilities capabilities;]
- [ResourceID uses<0..*>;]
- } IRDResourceEntry;" +
- "IRDResourceEntries. RFC7285 9.2.2." +
- " object-map {
- ResourceID -> IRDResourceEntry;
- } IRDResourceEntries;" +
- "InformationResourceDirectory. RFC7285 9.2.2." +
- " object {
- IRDResourceEntries resources;
- } InfoResourceDirectory : ResponseEntityBase;";
- }
- }
-
- /* Network Map Grouping */
- grouping network-map {
- container meta {
- uses network-map-meta;
- }
- uses network-map-data;
- }
-
- grouping network-map-data {
- list network-map {
- key "pid";
- leaf pid {
- type pid-name;
- }
- uses endpoint-address-group;
- description
- "RFC7285 Sec. 11.2.1.6." +
- " object-map {
- PIDName -> EndpointAddrGroup;
- } NetworkMapData;";
- }
- description
- "Network map. RFC7285 Sec. 11.2.1.6." +
- "object {
- NetworkMapData network-map;
- } InfoResourceNetworkMap : ResponseEntityBase;";
- }
-
- /* Cost Map Grouping */
- grouping cost-map {
- container meta {
- uses cost-map-meta;
- }
- uses cost-map-data;
- }
-
- grouping cost-map-data {
- list cost-map {
- leaf src {
- type pid-name;
- description
- "Source PID.";
- }
- key "src";
- list dst-costs {
- leaf dst {
- type pid-name;
- description
- "Destination PID.";
- }
- key "dst";
- uses alto-cost {
- description
- "Cost from source to destination.";
- }
- description
- "The list represents the inner part of the cost matrix." +
- "DstCosts. RFC7285 Sec. 11.2.3.6." +
- " object-map {
- PIDName -> JSONValue;
- } DstCosts;";
- }
- description
- "The list represents the outer part of the cost matrix." +
- "CostMapData. RFC7285 Sec. 11.2.3.6." +
- " object-map {
- PIDName -> DstCosts;
- } CostMapData;";
- }
- description
- "Cost map. RFC7285 Sec. 11.2.3.6." +
- " object {
- CostMapData cost-map;
- } InfoResourceCostMap : ResponseEntityBase;";
- }
-
- /* Endpoint Property Map Grouping */
- grouping endpoint-property-map {
- container meta {
- uses endpoint-property-meta;
- }
- uses endpoint-property-map-data;
- }
-
- grouping endpoint-property-map-data {
- list endpoint-properties {
- key endpoint;
- leaf endpoint {
- type typed-endpoint-address;
- mandatory true;
- }
- list properties {
- key property-type;
- leaf property-type {
- type endpoint-property-type;
- mandatory true;
- }
- leaf property {
- type endpoint-property-value;
- mandatory true;
- }
- description
- "EndpointProps. RFC7285 Sec. 11.4.1.6." +
- " object {
- EndpointPropertyType -> JSONValue;
- } EndpointProps;";
- }
- description
- "EndpointPropertyMapData. Sec. 11.4.1.6." +
- " object-map {
- TypedEndpointAddr -> EndpointProps;
- } EndpointPropertyMapData;";
- }
- description
- "InfoResourceEndpointProperties. Sec. 11.4.1.6." +
- " object {
- EndpointPropertyMapData endpoint-properties;
- } InfoResourceEndpointProperties : ResponseEntityBase;";
- }
-}
+++ /dev/null
-module alto-service {
- //alto-service-restconf
-
- yang-version 1;
-
- namespace "urn:opendaylight:alto";
- // TODO: replace with IANA namespace when assigned
-
- prefix "alto-restconf";
-
- import alto-service-types {
- prefix alto;
- }
-
- organization "ALTO WG";
- contact "alto@ietf.org";
-
- description
- "This module defines a data model for the ALTO services
- using restconf. Note this is not interop with RFC7285.";
-
- revision 2015-04-04 {
- description "Fix IRD";
- }
-
- revision 2014-11-19 {
- description "Initial version for ODL.";
- }
-
- grouping network-map {
- leaf resource-id {
- type alto:resource-id;
- mandatory true;
- }
- leaf tag {
- type alto:tag-string;
- mandatory true;
- }
- list map {
- key "pid";
- leaf pid {
- type alto:pid-name;
- }
- uses alto:endpoint-address-group;
- }
- }
-
- grouping cost-map {
- leaf resource-id {
- type alto:resource-id;
- mandatory true;
- }
- leaf tag {
- type alto:tag-string;
- mandatory true;
- }
- container meta {
- must "current()";
- uses alto:cost-map-meta;
- }
- list map {
- leaf src {
- type alto:pid-name;
- }
- key "src";
- list dst-costs {
- leaf dst {
- type alto:pid-name;
- }
- key "dst";
- //uses alto:alto-cost;
- }
- }
- }
-
- /************************************
- * Data Instances *
- ************************************/
-
- container resources {
- //presence "Indicates that the alto service is available.";
-
- container IRD {
- uses alto:IRD;
- }
-
- container network-maps {
- list network-map {
- key "resource-id";
- uses network-map;
- }
- }
-
- container cost-maps {
- list cost-map {
- key "resource-id";
- uses cost-map;
- }
- }
-
- container endpoint-property-map {
- uses alto:endpoint-property-map;
- }
- }
-
- /************************************
- * RPCs *
- ************************************/
-
- rpc filtered-network-map-service {
- input {
- leaf resource-id {
- mandatory true;
- type alto:resource-id;
- }
- leaf-list pids {
- must "current()";
- type alto:pid-name;
- }
- leaf-list address-types {
- type alto:endpoint-address-type;
- }
- }
- output {
- container filtered-network-map-service {
- uses network-map;
- }
- }
- }
-
- rpc filtered-cost-map-service {
- input {
- leaf resource-id {
- mandatory true;
- type alto:resource-id;
- }
- container cost-type {
- must "current()";
- uses alto:cost-type;
- }
- leaf-list constraints {
- type alto:constraint;
- }
- container pids {
- leaf-list srcs {
- type alto:pid-name;
- }
- leaf-list dsts {
- type alto:pid-name;
- }
- }
- }
- output {
- container filtered-cost-map-service {
- uses cost-map;
- }
- }
- }
-
- rpc endpoint-cost-service {
- input {
- container cost-type {
- must "current()";
- uses alto:cost-type;
- }
- leaf-list constraints {
- type alto:constraint;
- }
- container endpoints {
- must "current()";
- leaf-list srcs {
- type alto:typed-endpoint-address;
- }
- leaf-list dsts {
- type alto:typed-endpoint-address;
- }
- }
- }
- output {
- container endpoint-cost-service {
- container meta {
- container cost-type {
- uses alto:cost-type;
- }
- }
- list endpoint-cost-map {
- leaf src {
- type alto:typed-endpoint-address;
- }
- key "src";
- list dst-costs {
- leaf dst {
- type alto:typed-endpoint-address;
- }
- key "dst";
- //uses alto:alto-cost;
- }
- }
- }
- }
- }
-
-}
+++ /dev/null
-<?xml version="1.0"?>
-<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
- <services>
- <rest defaultRestSubcontext="/controller/nb/v2/alto"/>
- </services>
-
- <modules>
- <docs docsDir="rest" title="Alto REST API" includeExampleXml="true" includeExampleJson="true"/>
- </modules>
-</enunciate>
+++ /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</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
-
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>alto-northbound</artifactId>
- <packaging>bundle</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.enunciate</groupId>
- <artifactId>maven-enunciate-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
- <version>${sal.version}</version>
- </dependency>
- </dependencies>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.*,
- org.opendaylight.alto.services.api.rfc7285,
- org.opendaylight.alto.commons.*,
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
- org.apache.commons.logging,
- com.sun.jersey.spi.container.servlet,
- javax.ws.rs,
- javax.ws.rs.core,
- javax.ws.rs.ext,
- javax.xml.bind.annotation,
- javax.xml.bind,
- javax.xml.ws.http,
- javax.servlet.http,
- org.slf4j,
- org.apache.catalina.filters,
- !org.codehaus.enunciate.jaxrs
- </Import-Package>
- <Web-ContextPath>/controller/nb/v2/alto</Web-ContextPath>
- </instructions>
- <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller.thirdparty</groupId>
- <artifactId>com.sun.jersey.jersey-servlet</artifactId>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>${servlet.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.enunciate</groupId>
- <artifactId>enunciate-core-annotations</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-model</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-commons</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>service-api-rfc7285</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.northbound;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-
-import org.opendaylight.alto.commons.helper.ServiceHelper;
-import org.opendaylight.alto.commons.types.rfc7285.FormatValidator;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285QueryPairs;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285IRD;
-import org.opendaylight.alto.commons.types.rfc7285.MediaType;
-import org.opendaylight.alto.services.api.rfc7285.AltoService;
-import org.opendaylight.alto.services.api.rfc7285.IRDService;
-import org.opendaylight.alto.services.api.rfc7285.NetworkMapService;
-import org.opendaylight.alto.services.api.rfc7285.CostMapService;
-import org.opendaylight.alto.services.api.rfc7285.EndpointCostService;
-import org.opendaylight.alto.services.api.rfc7285.EndpointPropertyService;
-import org.opendaylight.alto.northbound.exception.AltoBasicException;
-import org.opendaylight.alto.northbound.exception.AltoBadFormatException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.List;
-
-@Path("/")
-public class AltoNorthbound {
-
- private static final Logger logger = LoggerFactory.getLogger(AltoNorthbound.class);
-
- private RFC7285JSONMapper mapper = new RFC7285JSONMapper();
-
- private static final List<String> definedProperties = Arrays.asList(
- "my-alternate-network-map.pid",
- "my-default-network-map.pid",
- "priv:ietf-type");
-
- private static final List<String> definedCostMetrics = Arrays.asList(
- "routingcost",
- "hopcount");
-
- private static final List<String> definedCostModes = Arrays.asList(
- "ordinal",
- "numerical");
-
- @SuppressWarnings("unchecked")
- private <E> E getService(Class<E> clazz) {
- E service = (E)ServiceHelper.getGlobalInstance(clazz, this);
- if (service == null) {
- service = (E)ServiceHelper.getGlobalInstance(AltoService.class, this);
- }
- return service;
- }
-
- private void checkService(Object service) throws Exception {
- if (service == null)
- throw new AltoBasicException(Status.SERVICE_UNAVAILABLE, null);
- }
-
- private void checkResourceId(String rid) throws AltoBadFormatException {
- if (!FormatValidator.validResourceId(rid))
- throw new AltoBadFormatException("resource-id", rid);
- }
-
- private void checkTag(String tag) throws AltoBadFormatException {
- if (!FormatValidator.validTag(tag))
- throw new AltoBadFormatException("tag", tag);
- }
-
- private void checkPropertyName(List<String> properties) throws AltoBadFormatException {
- for (String name : properties) {
- if (!definedProperties.contains(name))
- throw new AltoBadFormatException("E_INVALID_FIELD_VALUE", "properties", name);
- }
- }
-
- private void checkEndpointAddress(List<String> endpoints) throws AltoBadFormatException {
- for (String address : endpoints) {
- if (!FormatValidator.validEndpointAddress(address))
- throw new AltoBadFormatException("E_INVALID_FIELD_VALUE", "endpoints", address);
- }
- }
-
- private void checkPropertyRequest(RFC7285Endpoint.PropertyRequest request) throws AltoBadFormatException {
- checkPropertyName(request.properties);
- checkEndpointAddress(request.endpoints);
- }
-
- private void checkCostMetric(String metric) throws AltoBadFormatException {
- if (!definedCostMetrics.contains(metric))
- throw new AltoBadFormatException("E_INVALID_FIELD_VALUE", "cost-type/cost-metric", metric);
- }
-
- private void checkCostMode(String mode) throws AltoBadFormatException {
- if (!definedCostModes.contains(mode))
- throw new AltoBadFormatException("E_INVALID_FIELD_VALUE", "cost-type/cost-mode", mode);
- }
-
- private void checkCostType(RFC7285CostType costType) throws AltoBadFormatException {
- checkCostMetric(costType.metric);
- checkCostMode(costType.mode);
- }
-
- private void checkConstraints(List<String> constraints) throws AltoBadFormatException {
- for (String constraint : constraints)
- if (!FormatValidator.validFilterConstraint(constraint))
- throw new AltoBadFormatException("E_INVALID_FIELD_VALUE", "constraints", constraint);
- }
-
- private void checkCostRequest(HttpServletRequest httpRequest, RFC7285Endpoint.CostRequest request) throws AltoBadFormatException {
- checkCostType(request.costType);
- checkEndpoints(httpRequest, request.endpoints);
- }
-
- private void checkCostMapFilter(RFC7285CostMap.Filter filter) throws AltoBadFormatException {
- checkCostType(filter.costType);
- if (filter.constraints != null)
- checkConstraints(filter.constraints);
- }
-
- private void checkEndpoints(HttpServletRequest httpRequest, RFC7285QueryPairs endpoints) {
- /*
- * See https://tools.ietf.org/html/rfc7285#section-11.5.1.3
- * */
- String ipAddress = getClientIpAddress(httpRequest);
- if ((endpoints.src.size() == 0) && (endpoints.dst.size() == 0)) {
- throw new AltoBadFormatException("E_INVALID_FIELD_VALUE", "endpoints", "");
- }
-
- if (endpoints.src.size() == 0) {
- endpoints.src.add(ipAddress);
- }
-
- if (endpoints.dst.size() == 0) {
- endpoints.dst.add(ipAddress);
- }
- }
-
- private String getClientIpAddress(HttpServletRequest httpRequest) {
- String remoteAddress = httpRequest.getRemoteAddr();
- if (FormatValidator.validAddressIpv4("ipv4:" + remoteAddress)) {
- return "ipv4:" + remoteAddress;
- }
-
- if (FormatValidator.validAddressIpv6("ipv6:" + remoteAddress)) {
- return "ipv6:" + remoteAddress;
- }
-
- throw new AltoBadFormatException("E_INVALID_CLIENT_IP");
- }
-
- private Response fail(Response.Status status, Object data) {
- try {
- String output = (data == null ? "" : mapper.asJSON(data));
- return Response.status(status)
- .entity(output)
- .type(MediaType.ALTO_ERROR).build();
- } catch (Exception e) {
- logger.error("Failed to parse object to json: {}", data.toString());
- return Response.status(status)
- .type(MediaType.ALTO_ERROR).build();
- }
- }
-
- private Response success(Object data, String mediaType) {
- try {
- String output = mapper.asJSON(data);
- return Response.ok(output, mediaType).build();
- } catch (Exception e) {
- logger.error("Failed to parse object to json: {}", data.toString());
- logger.error(e.getMessage());
- return fail(Status.INTERNAL_SERVER_ERROR, null);
- }
- }
-
- @Path("/directory")
- @GET
- @Produces({ MediaType.ALTO_DIRECTORY, MediaType.ALTO_ERROR })
- public Response retrieveIRD() throws Exception {
- IRDService service = getService(IRDService.class);
- checkService(service);
-
- RFC7285IRD ird = service.getDefaultIRD();
- if (ird == null)
- return fail(Status.NOT_FOUND, null);
- return success(ird, MediaType.ALTO_DIRECTORY);
- }
-
- @Path("/networkmap")
- @GET
- @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR })
- public Response retrieveDefaultNetworkMap() throws Exception {
- NetworkMapService service = getService(NetworkMapService.class);
- checkService(service);
-
- RFC7285NetworkMap map = service.getDefaultNetworkMap();
- if (map == null)
- return fail(Status.NOT_FOUND, null);
- return success(map, MediaType.ALTO_NETWORKMAP);
- }
-
- @Path("/networkmap/{id}")
- @GET
- @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR })
- public Response retrieveNetworkMap(
- @PathParam("id") String id) throws Exception {
- NetworkMapService service = getService(NetworkMapService.class);
- checkService(service);
- checkResourceId(id);
-
- RFC7285NetworkMap map = service.getNetworkMap(id);
- if (map == null)
- return fail(Status.NOT_FOUND, id);
- return success(map, MediaType.ALTO_NETWORKMAP);
- }
-
- @Path("/networkmap/{id}/{tag}")
- @GET
- @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR })
- public Response retrieveNetworkMap(
- @PathParam("id") String id,
- @PathParam("tag") String tag) throws Exception {
- NetworkMapService service = getService(NetworkMapService.class);
- checkService(service);
- checkResourceId(id);
- checkTag(tag);
-
- RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
- RFC7285NetworkMap map = service.getNetworkMap(vtag);
- if (map == null)
- return fail(Status.NOT_FOUND, vtag);
- return success(map, MediaType.ALTO_NETWORKMAP);
- }
-
- @Path("/costmap/{id}")
- @GET
- @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
- public Response retrieveCostMap(@PathParam("id") String id) throws Exception {
- CostMapService service = getService(CostMapService.class);
- checkService(service);
- checkResourceId(id);
-
- RFC7285CostMap map = service.getCostMap(id);
- if (map == null)
- return fail(Status.NOT_FOUND, id);
- return success(map, MediaType.ALTO_COSTMAP);
- }
-
- @Path("/costmap/{id}/{tag}")
- @GET
- @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
- public Response retrieveCostMap(
- @PathParam("id") String id,
- @PathParam("tag") String tag) throws Exception {
- CostMapService service = getService(CostMapService.class);
- checkService(service);
- checkResourceId(id);
- checkTag(tag);
-
- RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
- RFC7285CostMap map = service.getCostMap(vtag);
- if (map == null)
- return fail(Status.NOT_FOUND, vtag);
- return success(map, MediaType.ALTO_COSTMAP);
- }
-
- @Path("/costmap/{id}/{mode}/{metric}")
- @GET
- @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
- public Response retrieveCostMap(
- @PathParam("id") String id,
- @PathParam("mode") String mode,
- @PathParam("metric") String metric) throws Exception {
- CostMapService service = getService(CostMapService.class);
- checkService(service);
- checkResourceId(id);
-
- RFC7285CostType costType = new RFC7285CostType(mode, metric);
- if (!service.supportCostType(id, costType))
- return fail(Status.NOT_FOUND, costType);
- RFC7285CostMap map = service.getCostMap(id, costType);
- if (map == null)
- return fail(Status.NOT_FOUND, id);
- return success(map, MediaType.ALTO_COSTMAP);
- }
-
- @Path("/costmap/{id}/{tag}/{mode}/{metric}")
- @GET
- @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
- public Response retrieveCostMap(
- @PathParam("id") String id,
- @PathParam("tag") String tag,
- @PathParam("mode") String mode,
- @PathParam("metric") String metric) throws Exception {
- CostMapService service = getService(CostMapService.class);
- checkService(service);
- checkResourceId(id);
- checkTag(tag);
-
- RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
- RFC7285CostType costType = new RFC7285CostType(mode, metric);
- if (!service.supportCostType(vtag, costType))
- return fail(Status.NOT_FOUND, costType);
- RFC7285CostMap map = service.getCostMap(vtag, costType);
- if (map == null)
- return fail(Status.NOT_FOUND, vtag);
- return success(map, MediaType.ALTO_COSTMAP);
- }
-
- @Path("/filtered/networkmap/{id}")
- @POST
- @Consumes({ MediaType.ALTO_NETWORKMAP_FILTER})
- @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR})
- public Response retrieveFilteredNetworkMap(
- @PathParam("id") String id, String filterJSON) throws Exception {
- NetworkMapService service = getService(NetworkMapService.class);
- checkService(service);
- checkResourceId(id);
-
- RFC7285NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
-
- if (!service.validateNetworkMapFilter(id, filter))
- return fail(Status.BAD_REQUEST, filter);
- RFC7285NetworkMap map = service.getNetworkMap(id, filter);
- if (map == null)
- return fail(Status.NOT_FOUND, id);
- return success(map, MediaType.ALTO_NETWORKMAP);
- }
-
- @Path("/filtered/networkmap/{id}/{tag}")
- @POST
- @Consumes({ MediaType.ALTO_NETWORKMAP_FILTER})
- @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR})
- public Response retrieveFilteredNetworkMap(
- @PathParam("id") String id,
- @PathParam("tag") String tag,
- String filterJSON) throws Exception {
- NetworkMapService service = getService(NetworkMapService.class);
- checkService(service);
- checkResourceId(id);
- checkTag(tag);
-
- RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
- RFC7285NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
- if (!service.validateNetworkMapFilter(vtag, filter))
- return fail(Status.BAD_REQUEST, filter);
-
- RFC7285NetworkMap map = service.getNetworkMap(vtag, filter);
- if (map == null)
- return fail(Status.NOT_FOUND, vtag);
- return success(map, MediaType.ALTO_NETWORKMAP);
- }
-
- @Path("/filtered/costmap/{id}")
- @POST
- @Consumes({ MediaType.ALTO_COSTMAP_FILTER })
- @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
- public Response retrieveFilteredCostMap(
- @PathParam("id") String id, String filterJSON) throws Exception {
- CostMapService service = getService(CostMapService.class);
- checkService(service);
- checkResourceId(id);
-
- RFC7285CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
- checkCostMapFilter(filter);
- if (!service.validateCostMapFilter(id, filter))
- return fail(Status.BAD_REQUEST, filter);
-
- RFC7285CostMap map = service.getCostMap(id, filter);
- if (map == null)
- return fail(Status.NOT_FOUND, id);
- return success(map, MediaType.ALTO_COSTMAP);
- }
-
- @Path("/filtered/costmap/{id}/{tag}")
- @POST
- @Consumes({ MediaType.ALTO_COSTMAP_FILTER })
- @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
- public Response retrieveFilteredCostMap(
- @PathParam("id") String id,
- @PathParam("tag") String tag, String filterJSON) throws Exception {
- CostMapService service = getService(CostMapService.class);
- checkService(service);
- checkResourceId(id);
- checkTag(tag);
-
- RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
- RFC7285CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
- checkCostMapFilter(filter);
- if (!service.validateCostMapFilter(vtag, filter))
- return fail(Status.BAD_REQUEST, filter);
-
- RFC7285CostMap map = service.getCostMap(vtag, filter);
- if (map == null)
- return fail(Status.NOT_FOUND, vtag);
- return success(map, MediaType.ALTO_COSTMAP);
- }
-
- @Path("/endpointprop/lookup")
- @POST
- @Consumes({ MediaType.ALTO_ENDPOINT_PROPPARAMS })
- @Produces({ MediaType.ALTO_ENDPOINT_PROP, MediaType.ALTO_ERROR })
- public Response retrieveEndpointPropMap(
- String params) throws Exception {
- EndpointPropertyService service = getService(EndpointPropertyService.class);
- checkService(service);
-
- RFC7285Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
- checkPropertyRequest(request);
- RFC7285Endpoint.PropertyResponse response = service.getEndpointProperty(request);
- if (response == null)
- return fail(Status.NOT_FOUND, request);
- return success(response, MediaType.ALTO_ENDPOINT_PROP);
- }
-
- @Path("/endpointprop/lookup/{id}/{tag}")
- @POST
- @Consumes({ MediaType.ALTO_ENDPOINT_PROPPARAMS })
- @Produces({ MediaType.ALTO_ENDPOINT_PROP, MediaType.ALTO_ERROR })
- public Response retrieveEndpointPropMap(
- @PathParam("id") String id,
- @PathParam("tag") String tag,
- String params) throws Exception {
- EndpointPropertyService service = getService(EndpointPropertyService.class);
- checkService(service);
- checkResourceId(id);
- checkTag(tag);
-
- RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
- RFC7285Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
- RFC7285Endpoint.PropertyResponse response = service.getEndpointProperty(vtag, request);
- if (response == null)
- return fail(Status.NOT_FOUND, request);
- return success(response, MediaType.ALTO_ENDPOINT_PROP);
- }
-
- @Path("/endpointcost/lookup")
- @POST
- @Consumes({ MediaType.ALTO_ENDPOINT_COSTPARAMS })
- @Produces({ MediaType.ALTO_ENDPOINT_COST, MediaType.ALTO_ERROR })
- public Response retrieveEndpointCostMap(@Context HttpServletRequest httpRequest,
- String params) throws Exception {
- EndpointCostService service = getService(EndpointCostService.class);
- checkService(service);
-
- RFC7285Endpoint.CostRequest request = mapper.asCostRequest(params);
- checkCostRequest(httpRequest, request);
- RFC7285Endpoint.CostResponse response = service.getEndpointCost(request);
- if (response == null)
- return fail(Status.NOT_FOUND, request);
- return success(response, MediaType.ALTO_ENDPOINT_COST);
- }
-
- @Path("/endpointcost/lookup/{id}/{tag}")
- @POST
- @Consumes({ MediaType.ALTO_ENDPOINT_COSTPARAMS })
- @Produces({ MediaType.ALTO_ENDPOINT_COST, MediaType.ALTO_ERROR })
- public Response retrieveEndpointCostMap(
- @PathParam("id") String id,
- @PathParam("tag") String tag,
- String params) throws Exception {
- EndpointCostService service = getService(EndpointCostService.class);
- checkService(service);
- checkResourceId(id);
- checkTag(tag);
-
- RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
- RFC7285Endpoint.CostRequest request = mapper.asCostRequest(params);
- RFC7285Endpoint.CostResponse response = service.getEndpointCost(vtag, request);
- if (response == null)
- return fail(Status.NOT_FOUND, request);
- return success(response, MediaType.ALTO_ENDPOINT_COST);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.northbound;
-
-import javax.ws.rs.core.Application;
-import java.util.HashSet;
-import java.util.Set;
-import org.opendaylight.alto.northbound.exception.AltoNorthboundExceptionHandler;
-
-public class AltoNorthboundRSApplication extends Application {
- @Override
- public Set<Class<?>> getClasses() {
- Set<Class<?>> classes = new HashSet<Class<?>>();
- classes.add(AltoNorthbound.class);
- classes.add(AltoNorthboundExceptionHandler.class);
- return classes;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.northbound;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Response;
-
-import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
-import org.opendaylight.alto.commons.types.model150404.ModelJSONMapper;
-
-@Path("/echo")
-class Echo {
-
- protected ModelJSONMapper modelMapper = new ModelJSONMapper();
-
- @Path("/model/networkmap")
- @POST
- Response echoModelNetworkMap(String content) throws Exception {
- ModelNetworkMap nmap = modelMapper.asNetworkMap(content);
- String output = modelMapper.asJSON(nmap);
- return Response.ok(output).build();
- }
-
- @Path("/model/networkmap")
- @GET
- Response echoModelNetworkMap() throws Exception {
- return Response.ok("not implemented").build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.northbound.exception;
-
-import javax.ws.rs.core.Response.Status;
-
-public class AltoBadFormatException extends AltoErrorTestException {
-
- public AltoBadFormatException() {
- super(Status.BAD_REQUEST);
- }
-
- public AltoBadFormatException(String code) {
- super(Status.BAD_REQUEST, code);
- }
-
- public AltoBadFormatException(String code, String field) {
- super(Status.BAD_REQUEST, code, field);
- }
-
- public AltoBadFormatException(String code, String field, String value) {
- super(Status.BAD_REQUEST, code, field, value);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.northbound.exception;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-
-import org.opendaylight.alto.commons.types.rfc7285.MediaType;
-
-public class AltoBasicException extends WebApplicationException {
-
- public static final String MEDIA_TYPE = MediaType.ALTO_ERROR;
-
- public AltoBasicException(int status, Object cause) {
- super(Response.status(status).entity(cause).type(MEDIA_TYPE).build());
- }
-
- public AltoBasicException(Response.Status status, Object cause) {
- super(Response.status(status).entity(cause).type(MEDIA_TYPE).build());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.northbound.exception;
-
-import javax.ws.rs.core.Response;
-
-public class AltoErrorTestException extends AltoBasicException {
- public static final String TEMPLATE_EMPTY = "{}";
- public static final String TEMPLATE_CODE =
- "{\"meta\":{\"code\":\"%s\"}}";
- public static final String TEMPLATE_CODE_FIELD =
- "{\"meta\":{\"code\":\"%s\",\"field\":\"%s\"}}";
- public static final String TEMPLATE_CODE_FIELD_VALUE =
- "{\"meta\":{\"code\":\"%s\",\"field\":\"%s\",\"value\":\"%s\"}}";
-
- public enum ERROR_CODES {
- E_MISSING_FIELD, E_SYNTAX, E_INVALID_FIELD_TYPE, E_INVALID_FIELD_VALUE, E_INVALID_CLIENT_IP
- }
-
- public AltoErrorTestException(Response.Status status) {
- super(status, "{}");
- }
-
- public AltoErrorTestException(Response.Status status, String code) {
- super(status, String.format(TEMPLATE_CODE, code));
- }
-
- public AltoErrorTestException(Response.Status status, String code, String field) {
- super(status, String.format(TEMPLATE_CODE_FIELD, code, field));
- }
-
- public AltoErrorTestException(Response.Status status, String code, String field, String value) {
- super(status, String.format(TEMPLATE_CODE_FIELD_VALUE, code, field, value));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.northbound.exception;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.ext.ExceptionMapper;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import org.opendaylight.alto.commons.types.rfc7285.MediaType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class AltoNorthboundExceptionHandler implements ExceptionMapper<Exception> {
-
- private static final Logger logger = LoggerFactory.getLogger(AltoNorthboundExceptionHandler.class);
-
- @Override
- public Response toResponse(Exception e) {
- logger.info("begin exception handle: " + e.toString());
- logger.info("exception type: " + e.getClass().toString());
- if (e instanceof AltoBasicException) {
- return ((AltoBasicException) e).getResponse();
- }
-
- if (e instanceof JsonParseException) {
- logger.info("JsonParseException: " + e.toString());
- AltoBasicException ept = new AltoErrorTestException(Status.BAD_REQUEST,
- AltoErrorTestException.ERROR_CODES.E_SYNTAX.name());
- return ept.getResponse();
- }
-
- if (e instanceof JsonMappingException) {
- logger.info("JsonMappingException: " + e.toString());
- if (e.getMessage().split(":")[0].equals("Missing field")) {
- AltoBasicException ept = new AltoErrorTestException(Status.BAD_REQUEST,
- AltoErrorTestException.ERROR_CODES.E_MISSING_FIELD.name(), e.getMessage().split(":")[1]);
- return ept.getResponse();
- } else {
- String fieldName = ((JsonMappingException) e).getPath().get(0).getFieldName();
- AltoBasicException ept = new AltoErrorTestException(Status.BAD_REQUEST,
- AltoErrorTestException.ERROR_CODES.E_INVALID_FIELD_TYPE.name(), fieldName);
- return ept.getResponse();
- }
- }
-
- if (e instanceof WebApplicationException) {
- return ((WebApplicationException) e).getResponse();
- }
- return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).type(MediaType.ALTO_ERROR).build();
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
- <servlet>
- <servlet-name>JAXRSAlto</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>javax.ws.rs.Application</param-name>
- <param-value>org.opendaylight.alto.northbound.AltoNorthboundRSApplication</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>JAXRSAlto</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-
- <filter>
- <filter-name>CorsFilter</filter-name>
- <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
- <init-param>
- <param-name>cors.allowed.origins</param-name>
- <param-value>*</param-value>
- </init-param>
- <init-param>
- <param-name>cors.allowed.methods</param-name>
- <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
- </init-param>
- <init-param>
- <param-name>cors.allowed.headers</param-name>
- <param-value>Content-Type,X-Requested-With,accept,authorization, origin,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
- </init-param>
- <init-param>
- <param-name>cors.exposed.headers</param-name>
- <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
- </init-param>
- <init-param>
- <param-name>cors.support.credentials</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>cors.preflight.maxage</param-name>
- <param-value>10</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>CorsFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- <http-method>POST</http-method>
- <http-method>GET</http-method>
- <http-method>PUT</http-method>
- <http-method>PATCH</http-method>
- <http-method>DELETE</http-method>
- <http-method>HEAD</http-method>
- </web-resource-collection>
- </security-constraint>
-</web-app>
-
+++ /dev/null
-Manifest-Version: 1.0\r
-Bnd-LastModified: 1427728619623\r
-Build-Jdk: 1.7.0_51\r
-Built-By: richardyang\r
-Bundle-ManifestVersion: 2\r
-Bundle-Name: org.opendaylight.controller.samples.alto-provider\r
-Bundle-SymbolicName: org.opendaylight.controller.samples.alto-provider\r
-Bundle-Version: 1.0.0.SNAPSHOT\r
-Created-By: Apache Maven Bundle Plugin\r
-Export-Package: org.opendaylight.controller.config.yang.alto_provider;ve\r
- rsion="1.0.0"\r
-Import-Package: com.google.common.base;version="[18.0,19)",com.google.co\r
- mmon.collect;version="[18.0,19)",com.google.common.util.concurrent;vers\r
- ion="[18.0,19)",javax.management,org.opendaylight.controller.config.api\r
- ;version="[0.3,1)",org.opendaylight.controller.config.api.annotations;v\r
- ersion="[0.3,1)",org.opendaylight.controller.config.api.runtime;version\r
- ="[0.3,1)",org.opendaylight.controller.config.spi;version="[0.3,1)",org\r
- .opendaylight.controller.config.yang.md.sal.binding;version="[1.2,2)",o\r
- rg.opendaylight.controller.md.sal.binding.api;version="[1.2,2)",org.ope\r
- ndaylight.controller.md.sal.common.api.data;version="[1.2,2)",org.opend\r
- aylight.controller.sal.binding.api;version="[1.2,2)",org.opendaylight.y\r
- ang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924;versio\r
- n="[2010.9,2011)",org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.y\r
- ang.rpc.context.rev130617;version="[0.3,1)",org.opendaylight.yang.gen.v\r
- 1.urn.opendaylight.alto.rev141119;version="[1.2,2)",org.opendaylight.ya\r
- ng.gen.v1.urn.opendaylight.alto.rev141119.filtered.network.map.service.\r
- output;version="[1.2,2)",org.opendaylight.yang.gen.v1.urn.opendaylight.\r
- alto.rev141119.resources;version="[1.2,2)",org.opendaylight.yang.gen.v1\r
- .urn.opendaylight.alto.rev141119.resources.network.maps;version="[1.2,2\r
- )",org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.did.rev14\r
- 1101.network.map.data;version="[1.2,2)",org.opendaylight.yang.gen.v1.ur\r
- n.opendaylight.alto.service.types.rev141101;version="[1.2,2)",org.opend\r
- aylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101.endpo\r
- int.address.group;version="[1.2,2)",org.opendaylight.yang.gen.v1.urn.op\r
- endaylight.params.xml.ns.yang.controller.config.rev130405;version="[0.3\r
- ,1)",org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.c\r
- ontroller.config.rev130405.modules;version="[0.3,1)",org.opendaylight.y\r
- ang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130\r
- 405.modules.module;version="[0.3,1)",org.opendaylight.yang.gen.v1.urn.o\r
- pendaylight.params.xml.ns.yang.controller.md.sal.binding.rev131028;vers\r
- ion="[1.2,2)",org.opendaylight.yangtools.concepts;version="[0.7,1)",org\r
- .opendaylight.yangtools.yang.binding;version="[0.7,1)",org.opendaylight\r
- .yangtools.yang.binding.annotations;version="[0.7,1)",org.opendaylight.\r
- yangtools.yang.common;version="[0.7,1)",org.osgi.framework;version="[1.\r
- 7,2)",org.slf4j;version="[1.7,2)"\r
-Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))"\r
-Tool: Bnd-2.3.0.201405100607\r
+++ /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</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
-
- <artifactId>alto-provider</artifactId>
- <packaging>bundle</packaging>
-
- <properties>
- <configfile>default.networkmap</configfile>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-model</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-commons</artifactId>
- <version>${project.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-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-config</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
-
- <!-- dependencies to use AbstractDataBrokerTest -->
- <dependency>
- <artifactId>junit</artifactId>
- <groupId>junit</groupId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <type>test-jar</type>
- <version>${mdsal.version}</version>
- <scope>test</scope>
- </dependency>
- <!-- used to mock up classes -->
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </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.l2switch.hosttracker</groupId>
- <artifactId>hosttracker-model</artifactId>
- <version>${l2switch.version}</version>
- <type>jar</type>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-topology</artifactId>
- <version>${ietf.topology.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.thirdparty</groupId>
- <artifactId>net.sf.jung2</artifactId>
- <version>2.0.1</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- </plugin>
-
-
- <plugin> <!-- OSGi plugin -->
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>org.opendaylight.alto.provider.*;</Export-Package>
- <Import-Package>*</Import-Package>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-jmx-generator-plugin</artifactId>
- <version>${config.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>${mdsal.model.version}</version>
- <type>jar</type>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- </codeGeneratorClass>
- <outputBaseDir>${jmxGeneratorPath}</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>${salGeneratorPath}</outputBaseDir>
- </generator>
- </codeGenerators>
- <inspectDependencies>true</inspectDependencies>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.provider;
-
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.logging.Level;
-
-import org.opendaylight.alto.commons.helper.NetworkMapIpPrefixHelper;
-import org.opendaylight.alto.commons.types.model150404.ModelCostMapMeta;
-import org.opendaylight.controller.config.yang.config.alto_provider.impl.AltoProviderRuntimeMXBean;
-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.alto.costdefault.rev150507.DstCosts1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.costdefault.rev150507.DstCosts1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.costdefault.rev150507.DstCosts2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.AltoServiceService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.EndpointCostServiceInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.EndpointCostServiceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.EndpointCostServiceOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.FilteredCostMapServiceInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.FilteredCostMapServiceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.FilteredNetworkMapServiceInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.FilteredNetworkMapServiceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.Resources;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.input.CostType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.input.Endpoints;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.EndpointCostService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.EndpointCostServiceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.EndpointCostMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.EndpointCostMapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.EndpointCostMapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.Meta;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.MetaBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.endpoint.cost.map.DstCosts;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.endpoint.cost.map.DstCostsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.CostMaps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.IRD;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.NetworkMaps;
-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.CostMapKey;
-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.NetworkMapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.CostMetric;
-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.PidName;
-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.TypedEndpointAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ird.meta.DefaultAltoNetworkMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.host.tracker.rev140624.HostNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.host.tracker.rev140624.host.AttachmentPoints;
-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.NodeId;
-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.TpId;
-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.Link;
-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.opendaylight.yangtools.yang.common.RpcError.ErrorType;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-
-import edu.uci.ics.jung.algorithms.shortestpath.DijkstraShortestPath;
-import edu.uci.ics.jung.graph.Graph;
-import edu.uci.ics.jung.graph.SparseMultigraph;
-import edu.uci.ics.jung.graph.util.EdgeType;
-
-public class AltoProvider implements AltoServiceService, DataChangeListener,
- AltoProviderRuntimeMXBean, AutoCloseable {
-
- private static final Logger log = LoggerFactory
- .getLogger(AltoProvider.class);
-
- private ListenerRegistration<DataChangeListener> hostNodeListerRegistration;
-
- private ListenerRegistration<DataChangeListener> linkListerRegistration;
-
- private ListenerRegistration<DataChangeListener> topologyListerRegistration;
- private ListenerRegistration<DataChangeListener> defaultNetworkMapperRegistration;
- private NetworkMapIpPrefixHelper ipHelper = new NetworkMapIpPrefixHelper();
-
- private Map<String, String> ipSwitchIdMap = null;
- Graph<NodeId, Link> networkGraph = null;
- Set<String> linkAdded = null;
- DijkstraShortestPath<NodeId, Link> shortestPath = null;
- private AtomicBoolean networkGraphFlag;
- public static final InstanceIdentifier<Resources> ALTO_IID = InstanceIdentifier
- .builder(Resources.class).build();
-
- private DataBroker dataProvider;
- private final ExecutorService executor;
-
- private InstanceIdentifier<DefaultAltoNetworkMap> DEFAULT_NETWORK_MAP_IID = InstanceIdentifier
- .builder(Resources.class)
- .child(IRD.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ird.Meta.class)
- .child(DefaultAltoNetworkMap.class).build();
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public AltoProvider() {
- this.networkGraph = new SparseMultigraph<>();
- this.shortestPath = new DijkstraShortestPath(this.networkGraph);
- this.ipSwitchIdMap = new HashMap<String, String>();
- this.linkAdded = new HashSet<>();
- this.networkGraphFlag = new AtomicBoolean(false);
- this.executor = Executors.newFixedThreadPool(1);
- }
-
- public void setDataProvider(final DataBroker salDataProvider) {
- this.dataProvider = salDataProvider;
- log.info(this.getClass().getName() + " data provider initiated");
- }
-
- private NetworkMap readNetworkMap(ResourceId rid)
- throws InterruptedException, ExecutionException {
- NetworkMapKey key = new NetworkMapKey(rid);
- InstanceIdentifier<NetworkMap> iid = InstanceIdentifier
- .builder(Resources.class).child(NetworkMaps.class)
- .child(NetworkMap.class, key).build();
- return readDataFromConfiguration(iid);
- }
-
- public void registerAsDataChangeListener() {
- this.defaultNetworkMapperRegistration = dataProvider
- .registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
- this.DEFAULT_NETWORK_MAP_IID, this,
- DataChangeScope.BASE);
-
- InstanceIdentifier<HostNode> hostNodes = InstanceIdentifier
- .builder(NetworkTopology.class)//
- .child(Topology.class,
- new TopologyKey(new TopologyId("flow:1")))//
- .child(Node.class).augmentation(HostNode.class).build();
- this.hostNodeListerRegistration = dataProvider
- .registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
- hostNodes, this, DataChangeScope.BASE);
-
- InstanceIdentifier<Link> links = InstanceIdentifier
- .builder(NetworkTopology.class)//
- .child(Topology.class,
- new TopologyKey(new TopologyId("flow:1")))//
- .child(Link.class).build();
- this.linkListerRegistration = dataProvider.registerDataChangeListener(
- LogicalDatastoreType.OPERATIONAL, links, this,
- DataChangeScope.BASE);
-
- InstanceIdentifier<Topology> topology = InstanceIdentifier
- .builder(NetworkTopology.class)
- //
- .child(Topology.class,
- new TopologyKey(new TopologyId("flow:1"))).build();
- this.topologyListerRegistration = dataProvider
- .registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
- topology, this, DataChangeScope.BASE);
-
- ReadOnlyTransaction newReadOnlyTransaction = dataProvider
- .newReadOnlyTransaction();
-
- ListenableFuture<Optional<Topology>> dataFuture = newReadOnlyTransaction
- .read(LogicalDatastoreType.OPERATIONAL, topology);
- try {
- dataFuture.get().get();
- } catch (InterruptedException | ExecutionException ex) {
- java.util.logging.Logger.getLogger(AltoProvider.class.getName())
- .log(Level.SEVERE, null, ex);
- }
- Futures.addCallback(dataFuture,
- new FutureCallback<Optional<Topology>>() {
- @Override
- public void onSuccess(final Optional<Topology> result) {
- if (result.isPresent()) {
- log.trace("Processing NEW NODE? " + result.get());
- processTopology(result.get());
- }
- }
-
- @Override
- public void onFailure(Throwable arg0) {
- }
- });
- }
-
- public synchronized void addLinks(List<Link> links) {
- if (links == null || links.isEmpty()) {
- log.info("In addLinks: No link added as links is null or empty.");
- return;
- }
-
- if (this.networkGraph == null) {
- this.networkGraph = new SparseMultigraph<>();
- networkGraphFlag.set(true);
- }
-
- for (Link link : links) {
- if (linkAlreadyAdded(link)) {
- continue;
- }
- NodeId sourceNodeId = link.getSource().getSourceNode();
- NodeId destinationNodeId = link.getDestination().getDestNode();
- this.networkGraph.addVertex(sourceNodeId);
- this.networkGraph.addVertex(destinationNodeId);
- this.networkGraph.addEdge(link, sourceNodeId, destinationNodeId,
- EdgeType.UNDIRECTED);
- networkGraphFlag.set(true);
- }
-
- }
-
- private boolean linkAlreadyAdded(Link link) {
- String linkAddedKey = null;
- if (link.getDestination().getDestTp().hashCode() > link.getSource()
- .getSourceTp().hashCode()) {
- linkAddedKey = link.getSource().getSourceTp().getValue()
- + link.getDestination().getDestTp().getValue();
- } else {
- linkAddedKey = link.getDestination().getDestTp().getValue()
- + link.getSource().getSourceTp().getValue();
- }
- if (linkAdded.contains(linkAddedKey)) {
- return true;
- } else {
- linkAdded.add(linkAddedKey);
- return false;
- }
- }
-
- public void processTopology(Topology topology) {
- List<Node> nodeList = null;
- if ((nodeList = topology.getNode()) != null) {
- for (int i = 0; i < nodeList.size(); ++i) {
- Node node = nodeList.get(i);
- HostNode hostNode = node.getAugmentation(HostNode.class);
- log.info("process node " + i + hostNode);
- processNode(hostNode);
- }
- List<Link> linkList = topology.getLink();
- addLinks(linkList);
- }
- }
-
- private void deleteHostNode(HostNode hostNode) {
- String ipv4String = hostNode.getAddresses().get(0).getIp()
- .getIpv4Address().getValue();
- this.ipSwitchIdMap.remove(ipv4String);
- }
-
- private void processNode(HostNode hostNode) {
- if (this.networkGraph == null) {
- this.networkGraph = new SparseMultigraph<>();
- }
- if (hostNode == null)
- return;
- List<AttachmentPoints> attachmentPoints = hostNode
- .getAttachmentPoints();
-
- TpId tpId = attachmentPoints.get(0).getTpId();
- String tpIdString = tpId.getValue();
-
- String ipv4String = hostNode.getAddresses().get(0).getIp()
- .getIpv4Address().getValue();
-
- this.ipSwitchIdMap.put(ipv4String, tpIdString);
- }
-
-
- @Override
- public void onDataChanged(
- final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
- log.info("in Data Changed");
- 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("delete Data");
- if (iid.getTargetType().equals(HostNode.class)) {
- log.info("delete hostnode");
- HostNode node = ((HostNode) originalData.get(iid));
- deleteHostNode(node);
- } else if (iid.getTargetType().equals(Link.class)) {
- log.info("delete edge");
- String linkAddedKey = null;
- Link link = (Link) originalData.get(iid);
- if (link.getDestination().getDestTp().hashCode() > link
- .getSource().getSourceTp().hashCode()) {
- linkAddedKey = link.getSource().getSourceTp().getValue()
- + link.getDestination().getDestTp().getValue();
- } else {
- linkAddedKey = link.getDestination().getDestTp().getValue()
- + link.getSource().getSourceTp().getValue();
- }
- if (linkAdded.contains(linkAddedKey)) {
- linkAdded.remove(linkAddedKey);
- }
- this.networkGraph.removeEdge((Link) originalData.get(iid));
- networkGraphFlag.set(true);
-
- } else if (iid.getTargetType().equals(DefaultAltoNetworkMap.class)) {
- ipHelper.clear();
- }
- }
-
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entrySet : updatedData
- .entrySet()) {
- final DataObject dataObject = entrySet.getValue();
- if (dataObject instanceof HostNode) {
- log.info("update hostnode data");
- processNode((HostNode) dataObject);
- } else if (dataObject instanceof DefaultAltoNetworkMap) {
- try {
- DefaultAltoNetworkMap defaultMap = (DefaultAltoNetworkMap) dataObject;
- NetworkMap networkMap = readNetworkMap(defaultMap
- .getResourceId());
- ipHelper.update(networkMap);
- } catch (InterruptedException | ExecutionException
- | UnknownHostException e) {
- e.printStackTrace();
- }
- }
- }
-
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entrySet : createdData
- .entrySet()) {
- final DataObject dataObject = entrySet.getValue();
- if (dataObject instanceof HostNode) {
- log.info("update HostNode");
- processNode((HostNode) dataObject);
- } else if (dataObject instanceof Link) {
- log.info("update link");
- Link link = (Link) dataObject;
- if (!linkAlreadyAdded(link)) {
- NodeId sourceNodeId = link.getSource().getSourceNode();
- NodeId destinationNodeId = link.getDestination()
- .getDestNode();
- this.networkGraph.addVertex(sourceNodeId);
- this.networkGraph.addVertex(destinationNodeId);
- this.networkGraph.addEdge(link, sourceNodeId,
- destinationNodeId, EdgeType.UNDIRECTED);
- log.info("update link in networkGraph");
- networkGraphFlag.set(true);
- }
- } else if (dataObject instanceof DefaultAltoNetworkMap) {
- try {
- DefaultAltoNetworkMap defaultMap = (DefaultAltoNetworkMap) dataObject;
- NetworkMap networkMap = readNetworkMap(defaultMap
- .getResourceId());
- ipHelper.update(networkMap);
- } catch (InterruptedException | ExecutionException
- | UnknownHostException e) {
- e.printStackTrace();
- ipHelper.clear();
- }
- }
- }
-
-
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public List<EndpointCostMap> hopcountNumerical(
- List<TypedEndpointAddress> srcs, List<TypedEndpointAddress> dsts) {
- if (networkGraphFlag.get()) {
- shortestPath = new DijkstraShortestPath(this.networkGraph);
- networkGraphFlag.set(false);
- }
- List<EndpointCostMap> result = new ArrayList<EndpointCostMap>();
- for (int i = 0; i < srcs.size(); ++i) {
- TypedEndpointAddress teaSrc = srcs.get(i);
- String ipv4SrcString = teaSrc.getTypedIpv4Address().getValue()
- .substring(5);
- String tpIdSrc = this.ipSwitchIdMap.get(ipv4SrcString);
- String[] tempi = tpIdSrc.split(":");
- String swSrcId = tempi[0] + ":" + tempi[1];
- List<DstCosts> dstCostsList = new ArrayList<DstCosts>();
-
- for (int j = 0; j < dsts.size(); ++j) {
- TypedEndpointAddress teaDst = dsts.get(j);
- String ipv4DstString = teaDst.getTypedIpv4Address().getValue()
- .substring(5);
- String tpIdDst = this.ipSwitchIdMap.get(ipv4DstString);
- String[] tempj = tpIdDst.split(":");
- String swDstId = tempj[0] + ":" + tempj[1];
-
- NodeId srcNodeId = new NodeId(swSrcId);
- NodeId dstNodeId = new NodeId(swDstId);
- Number number = shortestPath.getDistance(srcNodeId, dstNodeId);
- if (number == null) {
- number = Integer.MAX_VALUE;
- }
- DstCosts1 dst1 = new DstCosts1Builder()
- .setCostDefault(new Integer(number.intValue()).toString()).build();
- DstCosts dstCost = new DstCostsBuilder()
- .addAugmentation(DstCosts1.class, dst1).setDst(teaDst)
- .build();
- dstCostsList.add(dstCost);
- }
- EndpointCostMap ecp = new EndpointCostMapBuilder().setSrc(teaSrc)
- .setDstCosts(dstCostsList)
- .setKey(new EndpointCostMapKey(teaSrc)).build();
- result.add(ecp);
- }
- return result;
- }
-
- @Override
- public Future<RpcResult<EndpointCostServiceOutput>> endpointCostService(
- EndpointCostServiceInput input) {
- RpcResultBuilder<EndpointCostServiceOutput> endpointCostServiceBuilder = null;
- if (input.getCostType() == null) {
- endpointCostServiceBuilder = RpcResultBuilder
- .<EndpointCostServiceOutput> failed().withError(
- ErrorType.APPLICATION, "Invalid cost-type value ",
- "Argument can not be null.");
- }
-
- if (input.getEndpoints() == null) {
- endpointCostServiceBuilder = RpcResultBuilder
- .<EndpointCostServiceOutput> failed().withError(
- ErrorType.APPLICATION, "Invalid endpoints value ",
- "Argument can not be null.");
- }
-
- return hosttrackerNumericalHopCountImplementation(input, endpointCostServiceBuilder);
- }
-
- public ListenableFuture<RpcResult<EndpointCostServiceOutput>> interopECSImplementation(
- EndpointCostServiceInput input,
- RpcResultBuilder<EndpointCostServiceOutput> endpointCostServiceBuilder) {
- if (!ipHelper.initiated()) {
- return Futures.immediateFuture(RpcResultBuilder
- .<EndpointCostServiceOutput> failed()
- .withError(ErrorType.APPLICATION, "Default Map Error",
- "Failed to parse default network map.").build());
- }
-
- Endpoints endpoints = input.getEndpoints();
- CostMap costMap = getDefaultCostMap(input.getCostType());
- if (costMap == null) {
- return Futures.immediateFuture(RpcResultBuilder
- .<EndpointCostServiceOutput> failed()
- .withError(ErrorType.APPLICATION, "Cost Map Error",
- "Failed to read data from cost map.").build());
- }
-
- EndpointCostServiceOutput output = null;
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.meta.CostType eCostType = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.meta.CostTypeBuilder()
- .setCostMetric(input.getCostType().getCostMetric())
- .setCostMode(input.getCostType().getCostMode()).build();
-
- Meta meta = new MetaBuilder().setCostType(eCostType).build();
- List<TypedEndpointAddress> srcs = endpoints.getSrcs();
- List<TypedEndpointAddress> dsts = endpoints.getDsts();
- List<EndpointCostMap> ecmList = getEndpointCostListFromCostMap(
- ipHelper, costMap, srcs, dsts);
- EndpointCostService ecs = new EndpointCostServiceBuilder()
- .setMeta(meta).setEndpointCostMap(ecmList).build();
-
- if ((output = new EndpointCostServiceOutputBuilder()
- .setEndpointCostService(ecs).build()) != null) {
- endpointCostServiceBuilder = RpcResultBuilder.success(output);
- } else {
- endpointCostServiceBuilder = RpcResultBuilder
- .<EndpointCostServiceOutput> failed().withError(
- ErrorType.APPLICATION, "Invalid output value",
- "Output is null.");
- }
-
- return Futures.immediateFuture(endpointCostServiceBuilder.build());
- }
-
- private CostMap getDefaultCostMap(CostType costType) {
- CostMap costMap = null;
- try {
- String costMapRid = ModelCostMapMeta.getCostMapResourceId(
- readDefaultNetworkMapId().getValue(), costType
- .getCostMetric().getString(), costType
- .getCostMode().name().toLowerCase());
- InstanceIdentifier<CostMap> costMapNode = costMapIID(new ResourceId(
- costMapRid));
- costMap = readDataFromConfiguration(costMapNode);
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
- return costMap;
- }
-
- private ResourceId readDefaultNetworkMapId() throws InterruptedException,
- ExecutionException {
- return readDataFromConfiguration(this.DEFAULT_NETWORK_MAP_IID)
- .getResourceId();
- }
-
- private InstanceIdentifier<CostMap> costMapIID(ResourceId rid) {
- return InstanceIdentifier.builder(Resources.class)
- .child(CostMaps.class)
- .child(CostMap.class, new CostMapKey(rid)).build();
- }
-
- public List<EndpointCostMap> getEndpointCostListFromCostMap(
- NetworkMapIpPrefixHelper ipHelper, CostMap costMap,
- List<TypedEndpointAddress> srcs, List<TypedEndpointAddress> dsts) {
- Map<TypedEndpointAddress, PidName> srcPids = ipHelper
- .getPIDsByEndpointAddresses(srcs);
- Map<TypedEndpointAddress, PidName> dstPids = ipHelper
- .getPIDsByEndpointAddresses(dsts);
- Map<PidName, Map<PidName, DstCosts2>> costMaps = costMapListToMap(costMap
- .getMap());
-
- List<EndpointCostMap> ecmList = new ArrayList<EndpointCostMap>();
- for (TypedEndpointAddress src : srcs) {
- List<DstCosts> dstList = new ArrayList<DstCosts>();
- for (TypedEndpointAddress dst : dsts) {
- PidName srcPid = srcPids.get(src);
- PidName dstPid = dstPids.get(dst);
- String cost = getCostDefault(srcPid, dstPid, costMaps);
- if (cost != null) {
- DstCosts1 dstCost1 = new DstCosts1Builder()
- .setCostDefault(cost).build();
- DstCosts dstCosts = new DstCostsBuilder()
- .setDst(dst)
- .setKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.endpoint.cost.map.DstCostsKey(
- dst))
- .addAugmentation(DstCosts1.class, dstCost1).build();
- dstList.add(dstCosts);
- }
- }
- if (dstList.size() > 0) {
- ecmList.add(new EndpointCostMapBuilder().setDstCosts(dstList)
- .setKey(new EndpointCostMapKey(src)).setSrc(src).build());
- }
- }
- return ecmList;
- }
-
- private String getCostDefault(PidName srcPid, PidName dstPid,
- Map<PidName, Map<PidName, DstCosts2>> costMaps) {
- if (srcPid != null && dstPid != null) {
- Map<PidName, DstCosts2> dstMap = costMaps.get(srcPid);
- if (dstMap != null) {
- DstCosts2 dstCost2 = dstMap.get(dstPid);
- if (dstCost2 != null) {
- return dstCost2.getCostDefault();
- }
- }
- }
- return null;
- }
-
- private Map<PidName, Map<PidName, DstCosts2>> costMapListToMap(
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Map> costMaps) {
- Map<PidName, Map<PidName, DstCosts2>> resultCostMaps = new HashMap<PidName, Map<PidName, DstCosts2>>();
- for (org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.Map costMap : costMaps) {
- Map<PidName, DstCosts2> resultCostMap = new HashMap<PidName, DstCosts2>();
- for (org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.map.DstCosts dstCosts : costMap
- .getDstCosts()) {
- DstCosts2 cost = dstCosts.getAugmentation(DstCosts2.class);
- if (cost != null) {
- resultCostMap.put(dstCosts.getDst(), cost);
- }
- }
- resultCostMaps.put(costMap.getSrc(), resultCostMap);
- }
- return resultCostMaps;
- }
-
- @SuppressWarnings("unused")
- private ListenableFuture<RpcResult<EndpointCostServiceOutput>> hosttrackerNumericalHopCountImplementation(
- EndpointCostServiceInput input,
- RpcResultBuilder<EndpointCostServiceOutput> endpointCostServiceBuilder) {
- Endpoints endpoints = input.getEndpoints();
- List<TypedEndpointAddress> srcs = endpoints.getSrcs();
- List<TypedEndpointAddress> dsts = endpoints.getDsts();
- CostType costTypeInput = input.getCostType();
- EndpointCostServiceOutput output = null;
-
- boolean srcDstFoundFlag = true;
- for (int i = 0; i < srcs.size(); ++i) {
- TypedEndpointAddress teaSrc = srcs.get(i);
- String ipv4SrcString = teaSrc.getTypedIpv4Address().getValue()
- .substring(5);
- if (this.ipSwitchIdMap.get(ipv4SrcString) == null) {
- endpointCostServiceBuilder = RpcResultBuilder
- .<EndpointCostServiceOutput> failed()
- .withError(
- ErrorType.APPLICATION,
- "Invalid endpoints value ",
- "src IP:"
- + ipv4SrcString
- + " can not be found. Or Topology has not been built.");
- srcDstFoundFlag = false;
- return Futures.immediateFuture(endpointCostServiceBuilder
- .build());
- }
- }
-
- for (int j = 0; j < dsts.size(); ++j) {
- TypedEndpointAddress teaDst = dsts.get(j);
- String ipv4DstString = teaDst.getTypedIpv4Address().getValue()
- .substring(5);
- if (this.ipSwitchIdMap.get(ipv4DstString) == null) {
- endpointCostServiceBuilder = RpcResultBuilder
- .<EndpointCostServiceOutput> failed()
- .withError(
- ErrorType.APPLICATION,
- "Invalid endpoints value ",
- "dst IP:"
- + ipv4DstString
- + " can not be found. Or Topology has not been built.");
- srcDstFoundFlag = false;
- return Futures.immediateFuture(endpointCostServiceBuilder
- .build());
- }
- }
-
- CostMetric costMetric = costTypeInput.getCostMetric();
- CostMode costMode = costTypeInput.getCostMode();
- if (srcDstFoundFlag
- && costMode.equals(CostMode.Numerical)
- && (costMetric.getEnumeration() == CostMetric.Enumeration.Hopcount || costMetric
- .getString().equals("hopcount"))) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.meta.CostType costType = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.meta.CostTypeBuilder()
- .setCostMetric(costMetric).setCostMode(costMode).build();
- Meta meta = new MetaBuilder().setCostType(costType).build();
- List<EndpointCostMap> ecmList = hopcountNumerical(srcs, dsts);
- EndpointCostService ecs = new EndpointCostServiceBuilder()
- .setMeta(meta).setEndpointCostMap(ecmList).build();
-
- if ((output = new EndpointCostServiceOutputBuilder()
- .setEndpointCostService(ecs).build()) != null) {
- endpointCostServiceBuilder = RpcResultBuilder.success(output);
- } else {
- endpointCostServiceBuilder = RpcResultBuilder
- .<EndpointCostServiceOutput> failed().withError(
- ErrorType.APPLICATION, "Invalid output value",
- "Output is null.");
- }
- return Futures.immediateFuture(endpointCostServiceBuilder.build());
- }
-
- return Futures.immediateFuture(RpcResultBuilder
- .<EndpointCostServiceOutput> failed()
- .withError(ErrorType.APPLICATION, "Invalid output value",
- "Output is null.").build());
- }
-
- @Override
- public Future<RpcResult<FilteredCostMapServiceOutput>> filteredCostMapService(
- FilteredCostMapServiceInput input) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Future<RpcResult<FilteredNetworkMapServiceOutput>> filteredNetworkMapService(
- final FilteredNetworkMapServiceInput input) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void close() throws ExecutionException, InterruptedException {
- this.hostNodeListerRegistration.close();
- this.linkListerRegistration.close();
- this.ipSwitchIdMap.clear();
- this.defaultNetworkMapperRegistration.close();
- this.topologyListerRegistration.close();
- executor.shutdown();
- if (dataProvider != null) {
- WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
- tx.delete(LogicalDatastoreType.CONFIGURATION, ALTO_IID);
- Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
- @Override
- public void onSuccess(final Void result) {
- log.debug("Delete ALTO commit result: " + result);
- }
-
- @Override
- public void onFailure(final Throwable t) {
- log.error("Delete of ALTO failed", t);
- }
- });
- }
- }
-
- private <T extends DataObject> T readDataFromConfiguration(
- InstanceIdentifier<T> iid) throws InterruptedException,
- ExecutionException {
- ReadOnlyTransaction tx = this.dataProvider.newReadOnlyTransaction();
- Optional<T> optional = tx.read(LogicalDatastoreType.CONFIGURATION, iid)
- .get();
- if (optional.isPresent()) {
- return optional.get();
- }
- return null;
- }
-}
+++ /dev/null
-package org.opendaylight.controller.config.yang.config.alto_provider.impl;
-
-import org.opendaylight.alto.provider.AltoProvider;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.AltoServiceService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AltoProviderModule extends AbstractAltoProviderModule {
- private static final Logger log = LoggerFactory.getLogger(AltoProviderModule.class);
-
- public AltoProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public AltoProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.alto_provider.impl.AltoProviderModule 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() {
- final AltoProvider altoProvider = new AltoProvider();
-
- DataBroker dataBrokerService = getDataBrokerDependency();
- altoProvider.setDataProvider(dataBrokerService);
-
- final BindingAwareBroker.RpcRegistration<AltoServiceService> rpcRegistration = getRpcRegistryDependency()
- .addRpcImplementation(AltoServiceService.class, altoProvider);
-
- final ListenerRegistration<DataChangeListener> altoDataChangeListenerRegistration =
- dataBrokerService.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, AltoProvider.ALTO_IID, altoProvider, DataChangeScope.SUBTREE);
- final AltoProviderRuntimeRegistration runtimeReg = getRootRuntimeBeanRegistratorWrapper().register(altoProvider);
-
- altoProvider.registerAsDataChangeListener();
- log.info("provider success");
-
- final class AutoCloseableAlto implements AutoCloseable {
- @Override
- public void close() throws Exception {
- rpcRegistration.close();
- altoDataChangeListenerRegistration.close();
- runtimeReg.close();
- altoProvider.close();
- }
- }
-
- return new AutoCloseableAlto();
- }
-
-}
+++ /dev/null
-/*
-* Generated file
-*
-* Generated from: yang module name: alto-provider-impl yang module local name: alto-provider-impl
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Thu Nov 20 06:13:29 EST 2014
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.config.alto_provider.impl;
-public class AltoProviderModuleFactory extends org.opendaylight.controller.config.yang.config.alto_provider.impl.AbstractAltoProviderModuleFactory {
-
-}
+++ /dev/null
-module alto-provider-impl {
-
- yang-version 1;
-
- namespace "urn:opendaylight:params:xml:ns:yang:controller:config:alto-provider:impl";
- // TODO: replace with IANA namespace when assigned
-
- prefix "alto-provider-impl";
-
- import config {
- prefix config;
- revision-date 2013-04-05;
- }
-
- import opendaylight-md-sal-binding {
- prefix mdsal;
- revision-date 2013-10-28;
- }
-
- import rpc-context { prefix rpcx; revision-date 2013-06-17; }
-
- organization "ALTO WG";
- contact "alto@ietf.org";
-
- description
- "This module defines the implementation model for the ALTO services
- using restconf. Note this is not interop with RFC7285.";
-
- revision 2014-11-19 {
- description "Initial version for ODL.";
- }
-
- // This is the definition of the service implementation as a module identity
- identity alto-provider-impl {
- base config:module-type;
-
- // Specifies the prefix for generated java classes.
- config:java-name-prefix AltoProvider;
- }
-
- // Augments the 'configuration' choice node under modules/module.
- augment "/config:modules/config:module/config:configuration" {
- case alto-provider-impl {
- when "/config:modules/config:module/config:type = 'alto-provider-impl'";
-
- container rpc-registry {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity mdsal:binding-rpc-registry;
- }
- }
- }
-
- //wires in the data-broker service
- container data-broker {
- uses config:service-ref {
- refine type {
- mandatory false;
- config:required-identity mdsal:binding-async-data-broker;
- }
- }
- }
- }
- }
-
- /*dummy*/
- augment "/config:modules/config:module/config:state" {
- case alto-provider-impl {
- when "/config:modules/config:module/config:type = 'alto-provider-impl'";
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.provider;
-
-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.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.EndpointCostMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.EndpointCostMapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.endpoint.cost.map.DstCosts;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.endpoint.cost.service.output.endpoint.cost.service.endpoint.cost.map.DstCostsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.costdefault.rev150507.DstCosts1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.costdefault.rev150507.DstCosts1Builder;
-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.TypedIpv4Address;
-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.opendaylight.host.tracker.rev140624.host.AttachmentPoints;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.host.tracker.rev140624.host.AttachmentPointsBuilder;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.LinkId;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
-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.TpId;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.Destination;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.DestinationBuilder;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.Source;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.SourceBuilder;
-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.topology.Link;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkBuilder;
-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.NodeBuilder;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-
-public class AltoProviderTest {
-
- private AltoProvider altoProvider;
- private Addresses addrs;
- private DataBroker dataBroker;
- private IpAddress ipAddress;
- private MacAddress mac;
-
-
- @Before
- public void init(){
- dataBroker = mock(DataBroker.class);
- altoProvider = new AltoProvider();
- }
-
- @Test
- public void onProcessTopology() throws Exception {
- IpAddress ipAddress1 = new IpAddress(new Ipv4Address("10.0.0.1"));
- MacAddress mac1 = new MacAddress("00:00:00:00:00:01");
- Addresses addrs1 = new AddressesBuilder().setIp(ipAddress1).setMac(mac1).build();
- List<Addresses> addrsList1 = new ArrayList<Addresses>();
- addrsList1.add(addrs1);
-
- AttachmentPoints ap1 = new AttachmentPointsBuilder().setTpId(new TpId("openflow:1:1")).build();
- List<AttachmentPoints> apList1 = new ArrayList<AttachmentPoints>();
- apList1.add(ap1);
- HostNode hostNode1 = new HostNodeBuilder().setAddresses(addrsList1).setAttachmentPoints(apList1).build();
-
- IpAddress ipAddress2 = new IpAddress(new Ipv4Address("10.0.0.2"));
- MacAddress mac2 = new MacAddress("00:00:00:00:00:02");
- Addresses addrs2 = new AddressesBuilder().setIp(ipAddress2).setMac(mac2).build();
- List<Addresses> addrsList2 = new ArrayList<Addresses>();
- addrsList2.add(addrs2);
-
- AttachmentPoints ap2 = new AttachmentPointsBuilder().setTpId(new TpId("openflow:2:1")).build();
- List<AttachmentPoints> apList2 = new ArrayList<AttachmentPoints>();
- apList2.add(ap2);
- HostNode hostNode2 = new HostNodeBuilder().setAddresses(addrsList2).setAttachmentPoints(apList2).build();
-
-
- Node node1 = new NodeBuilder().addAugmentation(HostNode.class, hostNode1).build();
- Node node2 = new NodeBuilder().addAugmentation(HostNode.class, hostNode2).build();
-
- Node sw1 = new NodeBuilder().setNodeId(new NodeId("openflow:1")).build();
- Node sw2 = new NodeBuilder().setNodeId(new NodeId("openflow:2")).build();
- Node sw3 = new NodeBuilder().setNodeId(new NodeId("openflow:3")).build();
-
- Destination SW1_2 = new DestinationBuilder().setDestNode(new NodeId("openflow:1"))
- .setDestTp(new TpId("openflow:1:2")).build();
- Source SW3_1 = new SourceBuilder().setSourceNode(new NodeId("openflow:3"))
- .setSourceTp(new TpId("openflow:3:1")).build();
- Link l1 = new LinkBuilder().setLinkId(new LinkId("link1"))
- .setDestination(SW1_2)
- .setSource(SW3_1).build();
-
- Destination SW1_3 = new DestinationBuilder().setDestNode(new NodeId("openflow:1"))
- .setDestTp(new TpId("openflow:1:3")).build();
- Source SW2_2 = new SourceBuilder().setSourceNode(new NodeId("openflow:2"))
- .setSourceTp(new TpId("openflow:2:2")).build();
- Link l2 = new LinkBuilder().setLinkId(new LinkId("link2"))
- .setDestination(SW1_3)
- .setSource(SW2_2).build();
-
- Destination SW3_2 = new DestinationBuilder().setDestNode(new NodeId("openflow:3"))
- .setDestTp(new TpId("openflow:3:2")).build();
- Source SW2_3 = new SourceBuilder().setSourceNode(new NodeId("openflow:2"))
- .setSourceTp(new TpId("openflow:2:3")).build();
- Link l3 = new LinkBuilder().setLinkId(new LinkId("link3"))
- .setDestination(SW3_2)
- .setSource(SW2_3).build();
-
- List<Node> nodeList = new ArrayList<Node>();
- nodeList.add(node1);
- nodeList.add(node2);
- nodeList.add(sw1);
- nodeList.add(sw2);
- nodeList.add(sw3);
-
- List<Link> linkList = new ArrayList<Link>();
- linkList.add(l1);
- linkList.add(l2);
- linkList.add(l3);
-
- Topology topology = new TopologyBuilder().setTopologyId(new TopologyId("flow:1"))
- .setLink(linkList)
- .setNode(nodeList).build();
-
- altoProvider.processTopology(topology);
-
- TypedIpv4Address ipv4_1 = new TypedIpv4Address("ipv4:10.0.0.1");
- TypedEndpointAddress tea1 = new TypedEndpointAddress(ipv4_1);
-
- List<TypedEndpointAddress> teaList1 = new ArrayList<TypedEndpointAddress>();
- teaList1.add(tea1);
-
- TypedIpv4Address ipv4_2 = new TypedIpv4Address("ipv4:10.0.0.2");
- TypedEndpointAddress tea2 = new TypedEndpointAddress(ipv4_2);
-
- List<TypedEndpointAddress> teaList2 = new ArrayList<TypedEndpointAddress>();
- teaList2.add(tea2);
-
- DstCosts1 dc1 = new DstCosts1Builder().setCostDefault("1").build();
- DstCosts dc = new DstCostsBuilder().setDst(tea2).addAugmentation(DstCosts1.class, dc1).build();
-
- List<DstCosts> dcList = new ArrayList<DstCosts>();
- dcList.add(dc);
-
- EndpointCostMap ecp = new EndpointCostMapBuilder().setSrc(tea1).setDstCosts(dcList).build();
- List<EndpointCostMap> ecpList = new ArrayList<EndpointCostMap>();
- ecpList.add(ecp);
-
- Assert.assertEquals(altoProvider.hopcountNumerical(teaList1, teaList2), ecpList);
- }
-
-}
<type>xml</type>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.l2switch.addresstracker</groupId>
- <artifactId>addresstracker-model</artifactId>
- <version>${l2switch.version}</version>
- <type>jar</type>
- </dependency>
<dependency>
<groupId>org.opendaylight.l2switch.packethandler</groupId>
<artifactId>packethandler-model</artifactId>
+++ /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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
-
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>services.api</artifactId>
- <packaging>pom</packaging>
-
- <modules>
- <module>rfc7285</module>
- </modules>
-</project>
-
+++ /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</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../../../</relativePath>
- </parent>
-
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>service-api-rfc7285</artifactId>
- <packaging>bundle</packaging>
-
- <build>
- <plugins>
- <plugin> <!-- OSGi plugin -->
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.opendaylight.alto.commons.types.rfc7285,
- </Import-Package>
- <Export-Package>
- org.opendaylight.alto.services.api.rfc7285;
- </Export-Package>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-model</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-commons</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.services.api.rfc7285;
-
-//TODO EndpointPropertyService and EndpointCostService not defined yet
-public interface AltoService
- extends IRDService, NetworkMapService, CostMapService,
- EndpointPropertyService, EndpointCostService {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.services.api.rfc7285;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
-
-public interface CostMapService {
-
- RFC7285CostMap getCostMap(String id);
-
- RFC7285CostMap getCostMap(RFC7285VersionTag vtag);
-
- RFC7285CostMap getCostMap(String id, RFC7285CostType type);
-
- RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostType type);
-
- RFC7285CostMap getCostMap(String id, RFC7285CostMap.Filter filter);
-
- RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter);
-
- Boolean supportCostType(String id, RFC7285CostType type);
-
- Boolean supportCostType(RFC7285VersionTag vtag, RFC7285CostType type);
-
- Boolean validateCostMapFilter(String id, RFC7285CostMap.Filter filter);
-
- Boolean validateCostMapFilter(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.services.api.rfc7285;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostRequest;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostResponse;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-
-public interface EndpointCostService {
-
- CostResponse getEndpointCost(CostRequest request);
-
- CostResponse getEndpointCost(RFC7285VersionTag vtag, CostRequest request);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.services.api.rfc7285;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.PropertyRequest;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.PropertyResponse;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-
-public interface EndpointPropertyService {
-
- PropertyResponse getEndpointProperty(PropertyRequest request);
-
- PropertyResponse getEndpointProperty(RFC7285VersionTag vtag, PropertyRequest request);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.services.api.rfc7285;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285IRD;
-
-public interface IRDService {
-
- RFC7285IRD getDefaultIRD();
-
- RFC7285IRD getIRD(String id);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.services.api.rfc7285;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-
-public interface NetworkMapService {
-
- RFC7285NetworkMap getDefaultNetworkMap();
-
- RFC7285NetworkMap getNetworkMap(String id);
-
- RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag);
-
- RFC7285NetworkMap getNetworkMap(String id, RFC7285NetworkMap.Filter filter);
-
- RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter);
-
- Boolean validateNetworkMapFilter(String id, RFC7285NetworkMap.Filter filter);
-
- Boolean validateNetworkMapFilter(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter);
-
-}
+++ /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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
-
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>services.provider</artifactId>
- <packaging>pom</packaging>
-
- <modules>
- <module>simple-alto</module>
- </modules>
-
-</project>
-
+++ /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">
-
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-parent</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.opendaylight.alto</groupId>
- <artifactId>simple-impl</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>mdsal-model-artifacts</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-model</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-commons</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>service-api-rfc7285</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
-
- <!-- Testing Dependencies -->
- <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.controller</groupId>
- <artifactId>config-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-config</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-<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:alto-simple="urn:opendaylight:alto:simple-impl">
- alto-simple:simple-alto-adsal-impl
- </type>
- <name>simple-alto-adsal-impl</name>
-
- <rpc-registry>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
- <name>binding-rpc-broker</name>
- </rpc-registry>
-
- <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:simple-impl?module=simple-alto-adsal-impl&revision=2015-05-12</capability>
- </required-capabilities>
-</snapshot>
+++ /dev/null
-/*
- * Copyright (c) 2015 Yale University and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.alto.services.provider.simple;
-
-import org.opendaylight.alto.commons.helper.NetworkMapIpPrefixHelper;
-import org.opendaylight.alto.commons.types.converter.CostRequest2EndpointCostServiceInputConverter;
-import org.opendaylight.alto.commons.types.converter.EndpointCostServiceOutput2CostResponseConverter;
-import org.opendaylight.alto.commons.types.converter.YANGJSON2RFCCostMapConverter;
-import org.opendaylight.alto.commons.types.converter.YANGJSON2RFCEndpointPropMapConverter;
-import org.opendaylight.alto.commons.types.converter.YANGJSON2RFCIRDConverter;
-import org.opendaylight.alto.commons.types.converter.YANGJSON2RFCNetworkMapConverter;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.AddressGroup;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostRequest;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostResponse;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.PropertyRequest;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.PropertyResponse;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285EndpointPropertyMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285IRD;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-import org.opendaylight.alto.services.api.rfc7285.AltoService;
-import org.opendaylight.alto.services.api.rfc7285.NetworkMapService;
-import org.opendaylight.alto.services.api.rfc7285.CostMapService;
-import org.opendaylight.alto.services.api.rfc7285.EndpointCostService;
-import org.opendaylight.alto.services.api.rfc7285.EndpointPropertyService;
-import org.opendaylight.alto.services.api.rfc7285.IRDService;
-import org.opendaylight.alto.commons.helper.ServiceHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.cost.map.map.DstCosts;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.AltoServiceService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.EndpointCostServiceInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.EndpointCostServiceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.Resources;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.CostMaps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.EndpointPropertyMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.IRD;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.NetworkMaps;
-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.CostMapKey;
-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.NetworkMapKey;
-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.ResourceId;
-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.TypedEndpointAddressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ird.Meta;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ird.meta.DefaultAltoNetworkMap;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.osgi.framework.ServiceRegistration;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.module.SimpleModule;
-
-@SuppressWarnings("rawtypes")
-public class SimpleAltoService implements AltoService, AutoCloseable {
-
- private final Logger m_logger = LoggerFactory.getLogger(SimpleAltoService.class);
- private DataBroker m_db = null;
- private AltoServiceService m_service = null;
-
- private ObjectMapper m_mapper = new ObjectMapper();
- private RFC7285JSONMapper j_mapper = new RFC7285JSONMapper();
- private List<ServiceRegistration> m_reg = new LinkedList<ServiceRegistration>();
- private YANGJSON2RFCNetworkMapConverter m_nmconverter = null;
- private YANGJSON2RFCCostMapConverter m_cmconverter = null;
- private YANGJSON2RFCEndpointPropMapConverter m_epmconverter = null;
- private YANGJSON2RFCIRDConverter m_irdconverter = null;
- private EndpointCostServiceOutput2CostResponseConverter ecsOutputConverter = null;
- private CostRequest2EndpointCostServiceInputConverter ecsInputConverter = null;
- private NetworkMapIpPrefixHelper iHelper = new NetworkMapIpPrefixHelper();
- private final String PRIV_NETWORK_MAP = "private-network-map";
- private final String PRIV_ENDPOINT_PROPERTY_NAME = "priv:ietf-type";
-
- protected class DstCostSerializer extends JsonSerializer<DstCosts> {
- @Override
- public void serialize(DstCosts value, JsonGenerator jgen, SerializerProvider provider) {
- try {
- jgen.writeStartObject();
-
- jgen.writeObjectFieldStart("dst");
- jgen.writeStringField("value", value.getDst().getValue());
- jgen.writeEndObject();
-
- Map<Class<? extends Augmentation<?>>, Augmentation<?>> augmentations
- = BindingReflections.getAugmentations(value);
- String cost = null;
- for (Augmentation<?> aug : augmentations.values()) {
- try {
- ObjectNode node = m_mapper.valueToTree(aug);
- for (Iterator<String> itr = node.fieldNames(); itr.hasNext();) {
- String field = itr.next();
- if (field.toLowerCase().indexOf("cost") >= 0) {
- cost = node.get(field).asText();
- break;
- }
- }
- } catch (Exception e) {
- m_logger.warn("Failed to write data from {}", cost);
- }
- }
- if (cost != null) {
- jgen.writeStringField("cost", cost);
- }
-
- jgen.writeEndObject();
- } catch (Exception e) {
- m_logger.info("Failed to parse DstCosts");
- }
- }
- }
-
- public SimpleAltoService(DataBroker db, AltoServiceService service) {
- this.m_db = db;
- this.m_service = service;
- this.m_nmconverter = new YANGJSON2RFCNetworkMapConverter();
- this.m_cmconverter = new YANGJSON2RFCCostMapConverter();
- this.m_epmconverter = new YANGJSON2RFCEndpointPropMapConverter();
- this.m_irdconverter = new YANGJSON2RFCIRDConverter();
- this.ecsOutputConverter = new EndpointCostServiceOutput2CostResponseConverter();
- this.ecsInputConverter = new CostRequest2EndpointCostServiceInputConverter();
-
- this.register(IRDService.class);
- this.register(NetworkMapService.class);
- this.register(CostMapService.class);
- this.register(EndpointPropertyService.class);
- this.register(EndpointCostService.class);
-
- try {
- SimpleModule module = new SimpleModule();
- module.addSerializer(DstCosts.class, new DstCostSerializer());
- m_mapper.registerModule(module);
- } catch (Exception e) {
- m_logger.info("failed to load customized serializer");
- }
- }
-
- protected <E> void register(Class<E> clazz) {
- ServiceRegistration reg = ServiceHelper.registerGlobalServiceWReg(clazz, this, null);
- if (reg != null)
- this.m_reg.add(reg);
-
- assert ServiceHelper.getGlobalInstance(clazz, this) != this;
- }
-
- @Override
- public void close() {
- for (ServiceRegistration reg : this.m_reg) {
- reg.unregister();
- }
- this.m_reg.clear();
- }
-
- @Override
- public RFC7285NetworkMap getDefaultNetworkMap() {
- //TODO
- return null;
- }
-
- @Override
- public RFC7285NetworkMap getNetworkMap(String id) {
- m_logger.info("Handling resource-id: {}", id);
- InstanceIdentifier<NetworkMap> niid = getNetworkMapIID(id);
- m_logger.info("IID: {}", niid);
-
- try {
- ReadOnlyTransaction tx = m_db.newReadOnlyTransaction();
- ListenableFuture<Optional<NetworkMap>> result
- = tx.read(LogicalDatastoreType.CONFIGURATION, niid);
- if (result.get().isPresent()) {
- NetworkMap nm = result.get().get();
- ObjectNode node = m_mapper.valueToTree(nm);
- m_logger.info(m_mapper.writeValueAsString(nm));
-
- RFC7285NetworkMap ret = m_nmconverter.convert(node);
- return ret;
- } else {
- m_logger.info("Failed to read with niid: {}", niid);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- @Override
- public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag) {
- RFC7285NetworkMap nm = getNetworkMap(vtag.rid);
-
- if ((nm != null) && (vtag.equals(nm.meta.vtag))) {
- return nm;
- }
- return null;
- }
-
- @Override
- public RFC7285NetworkMap getNetworkMap(String id, RFC7285NetworkMap.Filter filter) {
- RFC7285NetworkMap nm = getNetworkMap(id);
-
- if (nm == null)
- return null;
-
- LinkedHashMap<String, RFC7285Endpoint.AddressGroup> map = new LinkedHashMap<String, RFC7285Endpoint.AddressGroup>();
- for (String pid : filter.pids) {
- if (nm.map.get(pid) != null)
- map.put(pid, nm.map.get(pid));
- }
- if (filter.pids.isEmpty()) {
- map = new LinkedHashMap<String, RFC7285Endpoint.AddressGroup>(nm.map);
- }
- LinkedHashMap<String, RFC7285Endpoint.AddressGroup> ret = new LinkedHashMap<String, RFC7285Endpoint.AddressGroup>();
- for (Map.Entry<String, RFC7285Endpoint.AddressGroup> entry : map.entrySet()) {
- String pid = entry.getKey();
- if (filter.addressTypes != null && (!filter.addressTypes.isEmpty())) {
- AddressGroup ag = new AddressGroup();
- if (filter.addressTypes.contains("ipv4")) {
- ag.ipv4 = nm.map.get(pid).ipv4;
- }
- if (filter.addressTypes.contains("ipv6")) {
- ag.ipv6 = nm.map.get(pid).ipv6;
- }
- if (!ag.ipv4.isEmpty() || !ag.ipv6.isEmpty())
- ret.put(pid, ag);
- } else {
- ret.put(pid, entry.getValue());
- }
- }
- nm.map = ret;
- return nm;
- }
-
- @Override
- public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter) {
- RFC7285NetworkMap nm = getNetworkMap(vtag.rid, filter);
- if ((nm != null) && (vtag.equals(nm.meta.vtag))) {
- return nm;
- }
- return null;
- }
-
- @Override
- public Boolean validateNetworkMapFilter(String id, RFC7285NetworkMap.Filter filter) {
- return (filter != null) && (filter.pids != null);
- }
-
- @Override
- public Boolean validateNetworkMapFilter(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter) {
- return validateNetworkMapFilter(vtag.rid, filter);
- }
-
- @Override
- public RFC7285CostMap getCostMap(String id) {
- m_logger.info("Handling cost-map resource: {}", id);
- InstanceIdentifier<CostMap> ciid = getCostMapIID(id);
- m_logger.info("CostMap IID: {}", ciid);
-
- try {
- ReadOnlyTransaction tx = m_db.newReadOnlyTransaction();
- ListenableFuture<Optional<CostMap>> result
- = tx.read(LogicalDatastoreType.CONFIGURATION, ciid);
- if (result.get().isPresent()) {
- CostMap cm = result.get().get();
- m_logger.info(cm.toString());
- m_logger.info(m_mapper.writeValueAsString(cm));
- ObjectNode node = m_mapper.valueToTree(cm);
-
- RFC7285CostMap ret = m_cmconverter.convert(node);
- return ret;
- } else {
- m_logger.info("Failed to read with ciid: {}", ciid);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- @Override
- public RFC7285CostMap getCostMap(RFC7285VersionTag vtag) {
- //TODO
- return null;
- }
-
- @Override
- public RFC7285CostMap getCostMap(String id, RFC7285CostType type) {
- RFC7285CostMap cm = getCostMap(id);
- if (cm == null)
- return null;
- if (!type.equals(cm.meta.costType))
- return null;
- return cm;
- }
-
- @Override
- public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostType type) {
- //TODO
- return null;
- }
-
- @Override
- public RFC7285CostMap getCostMap(String id, RFC7285CostMap.Filter filter) {
- RFC7285CostMap cm = getCostMap(id + "-" + filter.costType.metric + "-" + filter.costType.mode);
-
- if (cm == null)
- return null;
-
- if (filter.pids != null) {
- if (filter.pids.src.isEmpty())
- filter.pids.src = new LinkedList<String>(cm.map.keySet());
- if (filter.pids.dst.isEmpty())
- filter.pids.dst = new LinkedList<String>(cm.map.keySet());
-
- Map<String, Map<String, Object>> data = new LinkedHashMap<String, Map<String, Object>>();
- for (String src : filter.pids.src) {
- if (!cm.map.containsKey(src))
- continue;
- Map<String, Object> old_data = cm.map.get(src);
- if (old_data == null)
- continue;
-
- Map<String, Object> new_data = new LinkedHashMap<String, Object>();
- for (String dst : filter.pids.dst) {
- if (!old_data.containsKey(dst))
- continue;
- if (filter.constraints == null || filter.constraints.isEmpty()
- || meetConstraints(filter.constraints, old_data.get(dst)))
- new_data.put(dst, old_data.get(dst));
- }
- data.put(src, new_data);
- }
- cm.map = data;
- }
- return cm;
- }
-
- private boolean meetConstraints(List<String> constraints, Object object) {
- // We'd better simplify the constraints before using it.
- for (String constraint : constraints)
- if (!meetConstraint(constraint, object))
- return false;
- return true;
- }
-
- private boolean meetConstraint(String constraint, Object object) {
- String operator = constraint.substring(0, 2);
- double target = Double.parseDouble(object.toString());
- double value = Double.parseDouble(constraint.substring(3));
- switch (operator) {
- case "gt":
- return target > value;
- case "lt":
- return target < value;
- case "ge":
- return target >= value;
- case "le":
- return target <= value;
- case "eq":
- return target == value;
- }
- return false;
- }
-
- @Override
- public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
- //TODO
- return null;
- }
-
- @Override
- public Boolean supportCostType(String id, RFC7285CostType type) {
- //TODO
- return true;
- }
-
- @Override
- public Boolean supportCostType(RFC7285VersionTag vtag, RFC7285CostType type) {
- //TODO
- return true;
- }
-
- @Override
- public Boolean validateCostMapFilter(String id, RFC7285CostMap.Filter filter) {
- //TODO
- return true;
- }
-
- @Override
- public Boolean validateCostMapFilter(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
- //TODO
- return true;
- }
-
- protected InstanceIdentifier<DefaultAltoNetworkMap> getDefaultNetworkMapIID() {
- InstanceIdentifier<DefaultAltoNetworkMap> iid = InstanceIdentifier.builder(Resources.class)
- .child(IRD.class)
- .child(Meta.class)
- .child(DefaultAltoNetworkMap.class).build();
- return iid;
- }
-
- protected InstanceIdentifier<NetworkMap> getNetworkMapIID(String resource_id) {
- NetworkMapKey key = new NetworkMapKey(ResourceId.getDefaultInstance(resource_id));
- InstanceIdentifier<NetworkMap> iid = InstanceIdentifier.builder(Resources.class)
- .child(NetworkMaps.class)
- .child(NetworkMap.class, key)
- .build();
- return iid;
- }
-
- protected InstanceIdentifier<CostMap> getCostMapIID(String resource_id) {
- CostMapKey key = new CostMapKey(ResourceId.getDefaultInstance(resource_id));
- InstanceIdentifier<CostMap> iid = InstanceIdentifier.builder(Resources.class)
- .child(CostMaps.class)
- .child(CostMap.class, key)
- .build();
- return iid;
- }
-
- protected InstanceIdentifier<EndpointPropertyMap> getEndpointPropertyMapIID() {
- InstanceIdentifier<EndpointPropertyMap> iid = InstanceIdentifier.builder(Resources.class)
- .child(EndpointPropertyMap.class).build();
- return iid;
- }
-
- @Override
- public PropertyResponse getEndpointProperty(PropertyRequest request) {
- InstanceIdentifier<EndpointPropertyMap> eiid = getEndpointPropertyMapIID();
- m_logger.info("EndpointPropertyMap IID: {}", eiid);
- updatePrivateNetworkMap();
-
- try {
- ReadOnlyTransaction tx = m_db.newReadOnlyTransaction();
- ListenableFuture<Optional<EndpointPropertyMap>> result = tx.read(LogicalDatastoreType.CONFIGURATION, eiid);
- if (result.get().isPresent()) {
- EndpointPropertyMap epm = result.get().get();
- ObjectNode node = m_mapper.valueToTree(epm);
- m_logger.info(m_mapper.writeValueAsString(epm));
-
- RFC7285EndpointPropertyMap endpointPropMap = m_epmconverter.convert(node);
- RFC7285EndpointPropertyMap ret = new RFC7285EndpointPropertyMap();
- ret.meta = endpointPropMap.meta;
- ret.meta.netmap_tags = getDependentTags(endpointPropMap.meta, request.properties);
- for (String addr : request.endpoints) {
- Map<String, String> newProps = new LinkedHashMap<String, String>();
- if (endpointPropMap.map.containsKey(addr.toLowerCase())) {
- Map<String, String> props = endpointPropMap.map.get(addr);
- for (String type : request.properties) {
- if (props.containsKey(type)) {
- newProps.put(type, props.get(type));
- }
- }
- } else if (request.properties.contains(PRIV_ENDPOINT_PROPERTY_NAME)) {
- newProps = getPrivateEndpointProperty(addr);
- }
- if (!newProps.isEmpty())
- ret.map.put(addr, newProps);
- }
- return j_mapper.asPropertyResponse(j_mapper.asJSON(ret));
- } else {
- m_logger.info("Failed to read with eiid: {}", eiid);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- private void updatePrivateNetworkMap() {
- InstanceIdentifier<NetworkMap> niid = getNetworkMapIID(PRIV_NETWORK_MAP);
- try {
- ReadOnlyTransaction tx = m_db.newReadOnlyTransaction();
- ListenableFuture<Optional<NetworkMap>> result
- = tx.read(LogicalDatastoreType.CONFIGURATION, niid);
- if (result.get().isPresent()) {
- NetworkMap privateNetworkMap = result.get().get();
- iHelper.update(privateNetworkMap);
- } else {
- m_logger.info("Failed to read with niid: {}", niid);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private List<RFC7285VersionTag> getDependentTags(RFC7285EndpointPropertyMap.Meta meta, List<String> properties) {
- List<RFC7285VersionTag> dependentTags = new LinkedList<RFC7285VersionTag>();
- for (RFC7285VersionTag vtag : meta.netmap_tags) {
- if (properties.contains(vtag.rid + ".pid"))
- dependentTags.add(vtag);
- }
- return dependentTags;
- }
-
- private Map<String, String> getPrivateEndpointProperty(String addr) {
- Map<String, String> property = new LinkedHashMap<String, String>();
- try {
- TypedEndpointAddress address = TypedEndpointAddressBuilder.getDefaultInstance(addr);
- PidName pid = iHelper.getPIDByEndpointAddress(address);
- if (pid != null)
- property.put(PRIV_ENDPOINT_PROPERTY_NAME, pid.getValue());
- } catch (Exception e) {
- e.printStackTrace();
- }
- return property;
- }
-
- @Override
- public RFC7285IRD getDefaultIRD() {
- InstanceIdentifier<IRD> iid = getIRDIID();
-
- try {
- ReadOnlyTransaction tx = m_db.newReadOnlyTransaction();
- ListenableFuture<Optional<IRD>> result = tx.read(LogicalDatastoreType.CONFIGURATION, iid);
- if (result.get().isPresent()) {
- IRD iIRD = result.get().get();
- m_logger.info(iIRD.toString());
- m_logger.info(m_mapper.writeValueAsString(iIRD));
- ObjectNode node = m_mapper.valueToTree(iIRD);
-
- RFC7285IRD ret = m_irdconverter.convert(node);
- m_logger.info("IRD convert compelete.");
- return ret;
- } else {
- m_logger.info("Failed to read with ciid: {}", iid);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- @Override
- public PropertyResponse getEndpointProperty(RFC7285VersionTag vtag, PropertyRequest request) {
- return null;
- }
-
- @Override
- public CostResponse getEndpointCost(CostRequest request) {
- CostResponse response = null;
- EndpointCostServiceInput input = this.ecsInputConverter.convert(request);
- Future<RpcResult<EndpointCostServiceOutput>> result = this.m_service.endpointCostService(input);
- try {
- EndpointCostServiceOutput output = result.get().getResult();
- response = this.ecsOutputConverter.convert(output);
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
- return response;
- }
-
- @Override
- public CostResponse getEndpointCost(RFC7285VersionTag vtag, CostRequest request) {
- return null;
- }
-
- public RFC7285IRD getIRD(String id) {
- return this.getDefaultIRD();
- }
-
- protected InstanceIdentifier<IRD> getIRDIID() {
- InstanceIdentifier<IRD> iid = InstanceIdentifier.builder(Resources.class).child(IRD.class).build();
- return iid;
- }
-}
+++ /dev/null
-package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.simple.impl.rev150512;
-
-import org.opendaylight.alto.services.provider.simple.SimpleAltoService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.AltoServiceService;
-
-public class SimpleAltoImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.simple.impl.rev150512.AbstractSimpleAltoImplModule {
- public SimpleAltoImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public SimpleAltoImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.alto.simple.impl.rev150512.SimpleAltoImplModule 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() {
- SimpleAltoService service = new SimpleAltoService(this.getDataBrokerDependency(),
- this.getRpcRegistryDependency().getRpcService(AltoServiceService.class));
- return service;
- }
-
-}
+++ /dev/null
-/*
-* Generated file
-*
-* Generated from: yang module name: simple-alto-adsal-impl yang module local name: simple-alto-adsal-impl
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Tue May 12 16:43:21 CST 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.simple.impl.rev150512;
-public class SimpleAltoImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.simple.impl.rev150512.AbstractSimpleAltoImplModuleFactory {
-
-}
+++ /dev/null
-module simple-alto-adsal-impl {
- yang-version 1;
- namespace "urn:opendaylight:alto:simple-impl";
-
- prefix alto-simple;
-
- 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 definition for adsal-based northbound services";
-
- revision "2015-05-12" {
- description "Initial revision";
- }
-
- identity simple-alto-adsal-impl {
- base config:module-type;
-
- config:java-name-prefix SimpleAltoImpl;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case simple-alto-adsal-impl {
- when "/config:modules/config:module/config:type = 'simple-alto-adsal-impl'";
-
- container rpc-registry {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity mdsal:binding-rpc-registry;
- }
- }
- }
-
- container data-broker {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity mdsal:binding-async-data-broker;
- }
- }
- }
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2015 Yale University and others. All rights reserved.
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
--->
-<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</groupId>
- <artifactId>alto-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
-
- <artifactId>features-alto</artifactId>
- <name>${project.artifactId}</name>
-
- <properties>
- <features.file>features.xml</features.file>
- <configfile.directory>etc/opendaylight/karaf</configfile.directory>
- </properties>
-
- <dependencyManagement>
- <dependencies>
- <!-- project specific dependencies -->
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>${mdsal.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>features-yangtools</artifactId>
- <classifier>features</classifier>
- <version>${yangtools.version}</version>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>features-mdsal-model</artifactId>
- <version>${mdsal.model.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.karaf.features</groupId>
- <artifactId>standard</artifactId>
- <version>${karaf.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>features-mdsal</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>features-restconf</artifactId>
- <classifier>features</classifier>
- <version>${restconf.version}</version>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-model</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-commons</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-config</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>config</classifier>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>simple-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>simple-impl</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>config</classifier>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-northbound</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>alto-manager</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}.alto-hosttracker</groupId>
- <artifactId>alto-hosttracker-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}.alto-hosttracker</groupId>
- <artifactId>alto-hosttracker-model</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}.alto-hosttracker</groupId>
- <artifactId>alto-hosttracker-config</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>config</classifier>
- </dependency>
-
-
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient-osgi</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore-osgi</artifactId>
- </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</groupId>
- <artifactId>features-l2switch</artifactId>
- <classifier>features</classifier>
- <version>${l2switch.version}</version>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.l2switch.addresstracker</groupId>
- <artifactId>addresstracker-model</artifactId>
- <version>${l2switch.version}</version>
- <type>jar</type>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.l2switch.hosttracker</groupId>
- <artifactId>hosttracker-model</artifactId>
- <version>${l2switch.version}</version>
- <type>jar</type>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-topology</artifactId>
- <version>${ietf.topology.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller.thirdparty</groupId>
- <artifactId>net.sf.jung2</artifactId>
- <version>2.0.1</version>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>filter</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>resources</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <phase>package</phase>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <configuration>
- <artifacts>
- <artifact>
- <file>${project.build.directory}/classes/${features.file}</file>
- <type>xml</type>
- <classifier>features</classifier>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2015 Yale University
-
-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
--->
-<features name="odl-alto-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
- <repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/${mdsal.model.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.netconf/features-restconf/${restconf.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.l2switch/features-l2switch/${l2switch.version}/xml/features</repository>
-
- <feature name='odl-alto-all' version='${project.version}' description='OpenDaylight :: alto :: All '>
- <feature>odl-restconf-all</feature>
- <feature version='${project.version}'>odl-alto-provider</feature>
- <feature version='${project.version}'>odl-alto-manager</feature>
- <feature version='${project.version}'>odl-alto-hosttracker</feature>
- <feature version='${project.version}'>odl-alto-northbound</feature>
- </feature>
-
- <feature name='odl-alto-model' version='${project.version}' description='OpenDaylight :: alto :: Model '>
- <feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
- <feature version='${yangtools.version}'>odl-mdsal-binding-base</feature>
- <bundle>mvn:org.opendaylight.alto/alto-model/${project.version}</bundle>
- </feature>
-
- <feature name='odl-alto-commons' version='${project.version}' description='OpenDaylight :: alto :: utils'>
- <feature version='${project.version}'>odl-alto-model</feature>
- <bundle start="true">mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
- <bundle start="true">mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
- <bundle start="true">mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
- <bundle>mvn:org.osgi/org.osgi.core/${osgi.core.version}</bundle>
- <bundle>mvn:org.opendaylight.alto/alto-commons/${project.version}</bundle>
- </feature>
-
- <feature name='odl-alto-provider' version='${project.version}' description='OpenDaylight :: alto :: Provider'>
- <feature version='${project.version}'>odl-alto-model</feature>
- <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
- <feature version='${l2switch.version}'>odl-l2switch-hosttracker</feature>
- <feature version='${l2switch.version}'>odl-l2switch-addresstracker</feature>
- <configfile finalname="${configfile.directory}/03-alto.xml">mvn:org.opendaylight.alto/alto-config/${project.version}/xml/config</configfile>
- <bundle>mvn:org.opendaylight.alto/alto-provider/${project.version}</bundle>
- </feature>
-
- <feature name='odl-alto-hosttracker' version='${project.version}' description='OpenDaylight :: alto :: Hosttracker'>
- <feature version='${project.version}'>odl-alto-model</feature>
- <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
- <feature version='${l2switch.version}'>odl-l2switch-hosttracker</feature>
- <feature version='${l2switch.version}'>odl-l2switch-addresstracker</feature>
- <configfile finalname="etc/opendaylight/karaf/59-altohosttracker.xml">mvn:org.opendaylight.alto.alto-hosttracker/alto-hosttracker-config/${project.version}/xml/config</configfile>
- <bundle>mvn:org.opendaylight.alto.alto-hosttracker/alto-hosttracker-impl/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.alto.alto-hosttracker/alto-hosttracker-model/${project.version}</bundle>
- </feature>
-
- <feature name='odl-alto-manager' version='${project.version}' description='OpenDaylight :: alto :: Provider'>
- <feature version='${project.version}'>odl-alto-commons</feature>
- <bundle>mvn:org.apache.httpcomponents/httpclient-osgi/${httpclient.version}</bundle>
- <bundle>mvn:org.apache.httpcomponents/httpcore-osgi/${httpclient.version}</bundle>
- <bundle>mvn:org.opendaylight.alto/alto-manager/${project.version}</bundle>
- </feature>
-
- <feature name='odl-alto-simple' version='${project.version}' description='OpenDaylight :: alto :: Simple'>
- <feature version='${mdsal.version}'>odl-mdsal-common</feature>
- <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
- <feature version='${project.version}'>odl-alto-commons</feature>
- <configfile finalname='${configfile.directory}/alto-simple.xml'>mvn:org.opendaylight.alto/simple-impl/${project.version}/xml/config</configfile>
- <bundle>mvn:org.opendaylight.alto/service-api-rfc7285/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.alto/simple-impl/${project.version}</bundle>
- </feature>
-
- <feature name='odl-alto-tomcat' version='${project.version}' description='Opendaylight :: alto :: Tomcat'>
- <bundle start="true">mvn:orbit/javax.ejb/3.1.1.v201204261316</bundle>
- <bundle start="true">mvn:orbit/javax.xml.rpc/1.1.0.v201005080400</bundle>
- <bundle start="true">mvn:eclipselink/javax.persistence/2.0.4.v201112161009</bundle>
- <bundle start="true">mvn:orbit/org.apache.catalina/${commons.catalina.version}</bundle>
- <bundle start="true">mvn:orbit/org.apache.coyote/${commons.coyote.version}</bundle>
- <bundle start="true">mvn:orbit/org.apache.juli.extras/${commons.juli.version}</bundle>
- <bundle start="true">mvn:orbit/org.apache.tomcat.api/${commons.tomcat.api.version}</bundle>
- <bundle start="true">mvn:orbit/org.apache.tomcat.util/${commons.tomcat.util.version}</bundle>
- </feature>
-
- <feature name='odl-alto-northbound' version='${project.version}' description='Opendaylight :: alto :: Northbound'>
- <feature>war</feature>
- <bundle>mvn:com.sun.jersey/jersey-servlet/${jersey.version}</bundle>
- <feature version='${project.version}'>odl-alto-tomcat</feature>
- <feature version='${project.version}'>odl-alto-simple</feature>
- <bundle>mvn:org.opendaylight.alto/alto-northbound/${project.version}</bundle>
- </feature>
-
- <feature name='odl-alto-integration-test' version='${project.version}' description='Opendaylight :: alto :: IntegrationTest'>
- <feature version='${project.version}'>odl-alto-all</feature>
- </feature>
-</features>
<tag>HEAD</tag>
</scm>
- <properties>
- <mdsal.model.version>0.9.0-SNAPSHOT</mdsal.model.version>
- </properties>
+ <profiles>
+ <profile>
+ <id>minimal</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>alto-core</module>
+ <module>alto-basic</module>
+ <module>alto-extensions</module>
+ <module>alto-release-features</module>
+ </modules>
+ </profile>
- <modules>
- <module>alto-core</module>
- <module>alto-basic</module>
- <module>alto-extensions</module>
- <module>alto-release-features</module>
- </modules>
+ <profile>
+ <id>alto-test</id>
+ <modules>
+ <module>alto-core</module>
+ <module>alto-basic</module>
+ <module>alto-extensions</module>
+ <module>alto-release-features</module>
+ <module>alto-karaf</module>
+ </modules>
+ </profile>
+ </profiles>
<build>
<pluginManagement>