<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
import org.opendaylight.alto.commons.types.model150404.ModelDependentVtag;
import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
-public class RFC2ModelCostMapMetaConverter
+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;
}
import org.opendaylight.alto.commons.types.model150404.ModelProperties;
import org.opendaylight.alto.commons.types.rfc7285.RFC7285EndpointPropertyMap;
-public class RFC2ModelEndpointPropMapConverter
+public class RFC2ModelEndpointPropMapConverter
extends Converter<RFC7285EndpointPropertyMap, ModelEndpointPropertyMap> {
-
+
@Override
protected Object _convert() {
ModelEndpointPropertyMap out = new ModelEndpointPropertyMap();
}
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>();
ModelDependentVtag dependentVtag = new ModelDependentVtag();
dependentVtag.rid = meta.netmap_tags.get(0).rid;
dependentVtag.vTag = meta.netmap_tags.get(0).tag;
-
+
endpointPropertyMeta.dependentVtags.add(dependentVtag);
return endpointPropertyMeta;
}
-
- private ModelEndpointProperties
+
+ private ModelEndpointProperties
convertEndpointProperty(String endpoint, Map<String, String> property) {
ModelEndpointProperties endpointProperty = new ModelEndpointProperties();
endpointProperty.endpoint = endpoint;
}
return endpointProperty;
}
-
+
private ModelProperties convertProperty(String propertyType, String propertyValue) {
ModelProperties property = new ModelProperties();
property.propertyType = propertyType;
public RFC2ModelNetworkMapConverter(RFC7285NetworkMap _in) {
super(_in);
}
-
+
@Override
public Object _convert() {
ModelNetworkMap out = new ModelNetworkMap();
import org.opendaylight.alto.commons.helper.Converter;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.JsonNode;
public class YANGJSON2RFCAddressGroupConverter extends Converter<JsonNode, RFC7285Endpoint.AddressGroup> {
import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
-import java.util.Iterator;
import java.util.Map;
import java.util.LinkedHashMap;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.JsonNode;
public class YANGJSON2RFCCostMapConverter extends Converter<JsonNode, RFC7285CostMap> {
import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.JsonNode;
public class YANGJSON2RFCNetworkMapConverter extends Converter<JsonNode, RFC7285NetworkMap> {
@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() {
public List<DstCosts> getDstCosts() {
return new LinkedList<DstCosts>(dstCosts);
}
-
+
@JsonIgnore
@Override
public MapKey getKey() {
@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() {
@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() {
case ORDINAL:
return CostMode.Ordinal;
default:
- throw new RuntimeException("Non-Supported cost mode.");
+ throw new RuntimeException("Non-Supported cost mode.");
}
}
@JsonProperty("alto-service:resource-id")
public String rid = "";
-
+
@JsonProperty("alto-service:tag")
public String vTag = "";
-
+
@JsonIgnore
@Override
public Class<? extends DataContainer> getImplementedInterface() {
@JsonProperty("alto-service:endpoint-address-group")
public List<ModelEndpointAddressGroup> addressGroup = new LinkedList<ModelEndpointAddressGroup>();
-
+
@JsonIgnore
@Override
public Class<Map> getImplementedInterface() {
@JsonIgnore
public static final String IPV4 = "ipv4";
-
+
@JsonIgnore
public static final String IPV6 = "ipv6";
@JsonProperty("alto-service:endpoint")
public String endpoint = null;
-
+
@JsonProperty("alto-service:properties")
public List<ModelProperties> properties = new LinkedList<ModelProperties>();
@JsonIgnore
@Override
- public TypedEndpointAddress getEndpoint() {
- return new TypedEndpointAddress(endpoint.toCharArray());
+ public TypedEndpointAddress getEndpoint() {
+ return new TypedEndpointAddress(endpoint.toCharArray());
}
@JsonIgnore
@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() {
@JsonProperty("alto-service:dependent-vtags")
public List<ModelDependentVtag> dependentVtags = new LinkedList<ModelDependentVtag>();
-
+
@Override
public Class<? extends DataContainer> getImplementedInterface() {
return Meta.class;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class ModelNetworkMap implements NetworkMap {
-
+
@JsonProperty("alto-service:resource-id")
public String rid = null;
@JsonProperty("alto-service:property-type")
public String propertyType = null;
-
+
@JsonProperty("alto-service:property")
public String propertyValue = null;
-
+
@JsonIgnore
@Override
public Class<? extends DataContainer> getImplementedInterface() {
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>>();
+ = new LinkedHashMap<String, Map<String, String>>();
}
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-extensions</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-extensions</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-extensions</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.alto.alto-hosttracker</groupId>
<artifactId>alto-hosttracker.aggregator</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<groupId>org.opendaylight.alto.alto-hosttracker</groupId>
<parent>
<groupId>org.opendaylight.alto.alto-hosttracker</groupId>
<artifactId>alto-hosttracker.aggregator</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<name>alto-hosttracker-impl</name>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-jmx-generator-plugin</artifactId>
- <version>0.3.0-SNAPSHOT</version>
+ <version>0.4.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<parent>
<groupId>org.opendaylight.alto.alto-hosttracker</groupId>
<artifactId>alto-hosttracker.aggregator</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<groupId>org.opendaylight.alto.alto-hosttracker</groupId>
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>alto-hosttracker.aggregator</artifactId>
<modelVersion>4.0.0</modelVersion>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-karaf</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<prerequisites>
<maven>3.1.1</maven>
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
@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();
}
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);
@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)) {
}
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 + "\"}}";
}
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
private static final Logger log = LoggerFactory.getLogger(AltoProvider.class);
private ListenerRegistration<DataChangeListener> hostNodeListerRegistration;
-
+
private ListenerRegistration<DataChangeListener> linkListerRegistration;
private ListenerRegistration<DataChangeListener> topologyListerRegistration;
public AltoProvider() {
this.networkGraph = new SparseMultigraph<>();
this.shortestPath = new DijkstraShortestPath(this.networkGraph);
- this.ipSwitchIdMap = new HashMap<String, String>();
+ this.ipSwitchIdMap = new HashMap<String, String>();
this.linkAdded = new HashSet<>();
this.networkGraphFlag = new AtomicBoolean(false);
this.executor = Executors.newFixedThreadPool(1);
}
public void registerAsDataChangeListener() {
- 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();
+ 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 {
- Topology get = 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) {
- }
- });
- }
-
+ LogicalDatastoreType.OPERATIONAL, topology, this,
+ DataChangeScope.BASE);
+
+ ReadOnlyTransaction newReadOnlyTransaction = dataProvider
+ .newReadOnlyTransaction();
+
+ ListenableFuture<Optional<Topology>> dataFuture = newReadOnlyTransaction
+ .read(LogicalDatastoreType.OPERATIONAL, topology);
+ try {
+ Topology get = 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 (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<>();
+ 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);
+ }
+
+ 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;
+ }
+
+ }
+
+ 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);
+ 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) {
- List<AttachmentPoints> attachmentPoints = hostNode
- .getAttachmentPoints();
+ private void deleteHostNode(HostNode hostNode) {
+ List<AttachmentPoints> attachmentPoints = hostNode
+ .getAttachmentPoints();
- TpId tpId = attachmentPoints.get(0).getTpId();
- String tpIdString = tpId.getValue();
+ TpId tpId = attachmentPoints.get(0).getTpId();
+ String tpIdString = tpId.getValue();
- String ipv4String = hostNode.getAddresses().get(0).getIp()
- .getIpv4Address().getValue();
+ String ipv4String = hostNode.getAddresses().get(0).getIp()
+ .getIpv4Address().getValue();
- this.ipSwitchIdMap.remove(ipv4String);
- }
+ this.ipSwitchIdMap.remove(ipv4String);
+ }
- private void processNode(HostNode hostNode) {
+ private void processNode(HostNode hostNode) {
if (this.networkGraph==null) {
- this.networkGraph = new SparseMultigraph<>();
+ this.networkGraph = new SparseMultigraph<>();
}
- if(hostNode==null)return;
- List<AttachmentPoints> attachmentPoints = hostNode
- .getAttachmentPoints();
+ if(hostNode==null)return;
+ List<AttachmentPoints> attachmentPoints = hostNode
+ .getAttachmentPoints();
+
+ TpId tpId = attachmentPoints.get(0).getTpId();
+ String tpIdString = tpId.getValue();
- TpId tpId = attachmentPoints.get(0).getTpId();
- String tpIdString = tpId.getValue();
+ String ipv4String = hostNode.getAddresses().get(0).getIp()
+ .getIpv4Address().getValue();
- String ipv4String = hostNode.getAddresses().get(0).getIp()
- .getIpv4Address().getValue();
+ this.ipSwitchIdMap.put(ipv4String, tpIdString);
+ }
- 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) {
+ 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)) {
+ 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)) {
+ HostNode node = ((HostNode) originalData.get(iid));
+ deleteHostNode(node);
+ } else if (iid.getTargetType().equals(Link.class)) {
log.info("delete edge");
- String linkAddedKey = null;
+ 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));
+ 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);
-
- }
- }
-
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entrySet : updatedData
- .entrySet()) {
-
- InstanceIdentifier<?> iiD = entrySet.getKey();
- final DataObject dataObject = entrySet.getValue();
- if (dataObject instanceof HostNode) {
+
+ }
+ }
+
+ for (Map.Entry<InstanceIdentifier<?>, DataObject> entrySet : updatedData
+ .entrySet()) {
+
+ InstanceIdentifier<?> iiD = entrySet.getKey();
+ final DataObject dataObject = entrySet.getValue();
+ if (dataObject instanceof HostNode) {
log.info("update hostnode data");
- processNode((HostNode) dataObject);
- }
- }
-
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entrySet : createdData
- .entrySet()) {
- InstanceIdentifier<?> iiD = entrySet.getKey();
- final DataObject dataObject = entrySet.getValue();
- if (dataObject instanceof HostNode) {
+ processNode((HostNode) dataObject);
+ }
+ }
+
+ for (Map.Entry<InstanceIdentifier<?>, DataObject> entrySet : createdData
+ .entrySet()) {
+ InstanceIdentifier<?> iiD = entrySet.getKey();
+ final DataObject dataObject = entrySet.getValue();
+ if (dataObject instanceof HostNode) {
log.info("update HostNode");
- processNode((HostNode) dataObject);
- } else if (dataObject instanceof Link) {
+ 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);
+ 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);
- }
- }
- }
-
-
+ }
+ }
+ }
+
+
}
public List<EndpointCostMap> hopcountNumerical(List<TypedEndpointAddress> srcs, List<TypedEndpointAddress> dsts) {
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);
+ 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);
DstCosts1 dst1 = null;
if (number!=null) {
- dst1 = new DstCosts1Builder().setCostDefault(number.intValue()).build();
+ dst1 = new DstCosts1Builder().setCostDefault(number.intValue()).build();
}
else {
dst1 = new DstCosts1Builder().setCostDefault(Integer.MAX_VALUE).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;
- }
-
+ 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) {
-
+
CostType costTypeInput = null;
List<Constraint> constraintsInput = null;
Endpoints endpointsInput = null;
-
+
RpcResultBuilder<EndpointCostServiceOutput> endpointCostServiceBuilder = null;
EndpointCostServiceOutput output = null;
-
+
if ((costTypeInput = input.getCostType()) == null) {
endpointCostServiceBuilder = RpcResultBuilder.<EndpointCostServiceOutput>failed().withError(ErrorType.APPLICATION, "Invalid cost-type value ", "Argument can not be null.");
}
endpointCostServiceBuilder = RpcResultBuilder.<EndpointCostServiceOutput>failed().withError(ErrorType.APPLICATION, "Invalid endpoints value ", "Argument can not be null.");
}
else {
- Endpoints endpoints = input.getEndpoints();
- List<TypedEndpointAddress> srcs = endpoints.getSrcs();
- List<TypedEndpointAddress> dsts = endpoints.getDsts();
+ Endpoints endpoints = input.getEndpoints();
+ List<TypedEndpointAddress> srcs = endpoints.getSrcs();
+ List<TypedEndpointAddress> dsts = endpoints.getDsts();
boolean srcDstFoundFlag = true;
- for (int i = 0; i < srcs.size(); ++i) {
- TypedEndpointAddress teaSrc = srcs.get(i);
- String ipv4SrcString = teaSrc.getTypedIpv4Address().getValue()
- .substring(5);
+ 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.");
+ 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.");
+ }
+ }
+ 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();
-
+ 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);
}
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
@Override
public void close() throws ExecutionException, InterruptedException {
- this.hostNodeListerRegistration.close();
- this.linkListerRegistration.close();
- this.ipSwitchIdMap.clear();
- executor.shutdown();
+ this.hostNodeListerRegistration.close();
+ this.linkListerRegistration.close();
+ this.ipSwitchIdMap.clear();
+ executor.shutdown();
if (dataProvider != null) {
WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
tx.delete(LogicalDatastoreType.CONFIGURATION, ALTO_IID);
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.TypedEndpointAddressBuilder;
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.junit.Before;
import org.junit.Test;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.mock;
public class AltoProviderTest {
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);
+ 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);
}
}
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../../../</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
+ <version>0.4.0-SNAPSHOT</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.opendaylight.alto</groupId>
<artifactId>simple-impl</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal</artifactId>
- <version>0.9.0-SNAPSHOT</version>
+ <version>0.10.0-SNAPSHOT</version>
</dependency>
<dependency>
import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
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 org.opendaylight.alto.commons.types.converter.YANGJSON2RFCNetworkMapConverter;
import org.opendaylight.alto.commons.types.converter.YANGJSON2RFCCostMapConverter;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Augmentable;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.Resources;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.osgi.framework.ServiceRegistration;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.AsyncFunction;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Iterator;
@Override
- public RFC7285CostMap getCostMap(String id) {
+ public RFC7285CostMap getCostMap(String id) {
m_logger.info("Handling cost-map resource: {}", id);
InstanceIdentifier<CostMap> ciid = getCostMapIID(id);
m_logger.info("CostMap IID: {}", ciid);
}
@Override
- public RFC7285CostMap getCostMap(RFC7285VersionTag vtag) {
+ public RFC7285CostMap getCostMap(RFC7285VersionTag vtag) {
//TODO
return null;
}
@Override
- public RFC7285CostMap getCostMap(String id, RFC7285CostType type) {
+ public RFC7285CostMap getCostMap(String id, RFC7285CostType type) {
RFC7285CostMap cm = getCostMap(id);
if (cm == null)
return null;
}
@Override
- public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostType type) {
+ public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostType type) {
//TODO
return null;
}
@Override
- public RFC7285CostMap getCostMap(String id, RFC7285CostMap.Filter filter) {
+ public RFC7285CostMap getCostMap(String id, RFC7285CostMap.Filter filter) {
RFC7285CostMap cm = null;
if (filter.costType != null) {
cm = getCostMap(id, filter.costType);
}
@Override
- public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
+ public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
//TODO
return null;
}
@Override
- public Boolean supportCostType(String id, RFC7285CostType type) {
+ public Boolean supportCostType(String id, RFC7285CostType type) {
//TODO
return true;
}
@Override
- public Boolean supportCostType(RFC7285VersionTag vtag, RFC7285CostType type) {
+ public Boolean supportCostType(RFC7285VersionTag vtag, RFC7285CostType type) {
//TODO
return true;
}
@Override
- public Boolean validateCostMapFilter(String id, RFC7285CostMap.Filter filter) {
+ public Boolean validateCostMapFilter(String id, RFC7285CostMap.Filter filter) {
//TODO
return true;
}
@Override
- public Boolean validateCostMapFilter(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
+ public Boolean validateCostMapFilter(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
//TODO
return true;
}
<parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>1.5.0-SNAPSHOT</version>
+ <version>1.6.0-SNAPSHOT</version>
<relativePath/>
</parent>
<groupId>org.opendaylight.alto</groupId>
<artifactId>alto-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
<name>alto</name> <!-- Used by Sonar to set project name -->
<packaging>pom</packaging>
</modules>
<properties>
- <odl.version>1.5.0-SNAPSHOT</odl.version>
+ <odl.version>1.6.0-SNAPSHOT</odl.version>
<karaf.shell.version>2.2.11</karaf.shell.version>
- <checkstyle.skip>true</checkstyle.skip>
<!-- required by alto command line -->
<httpclient.version>4.4.1</httpclient.version>
<!-- used by yangtools, but the name is strange.
TODO: need more investigation -->
- <config.version>0.3.0-SNAPSHOT</config.version>
+ <config.version>0.4.0-SNAPSHOT</config.version>
- <sal.version>0.9.0-SNAPSHOT</sal.version>
+ <sal.version>0.10.0-SNAPSHOT</sal.version>
<war.version>${karaf.version}</war.version>
- <mdsal.version>1.2.0-SNAPSHOT</mdsal.version>
+ <mdsal.version>1.3.0-SNAPSHOT</mdsal.version>
<jmxGeneratorPath>src/main/yang-gen-config</jmxGeneratorPath>
<salGeneratorPath>src/main/yang-gen-sal</salGeneratorPath>
- <yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
+ <yangtools.version>0.8.0-SNAPSHOT</yangtools.version>
<controller.checkstyle.version> <!-- checkstyle artifact of controller -->
- 0.1.0-SNAPSHOT
+ 0.2.0-SNAPSHOT
</controller.checkstyle.version>
<controller.commons.northbound.version> <!-- required by alto-northbound -->
- 0.5.0-SNAPSHOT
+ 0.6.0-SNAPSHOT
</controller.commons.northbound.version>
- <l2switch.version>0.2.0-SNAPSHOT</l2switch.version>
+ <l2switch.version>0.3.0-SNAPSHOT</l2switch.version>
<ietf.topology.version>2013.10.21.7-SNAPSHOT</ietf.topology.version>
<commons.catalina.version>7.0.53.v201406061610</commons.catalina.version>
</properties>