blob: 639e68be27d51fcade3c68d1212898f6251b308f [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070019package org.onlab.onos.net.intent;
20
tom95329eb2014-10-06 08:40:06 -070021import com.google.common.base.MoreObjects;
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070022import org.onlab.onos.core.ApplicationId;
Brian O'Connorb876bf12014-10-02 14:59:37 -070023import org.onlab.onos.net.Path;
24import org.onlab.onos.net.flow.TrafficSelector;
25import org.onlab.onos.net.flow.TrafficTreatment;
26
Brian O'Connorb876bf12014-10-02 14:59:37 -070027/**
28 * Abstraction of explicitly path specified connectivity intent.
29 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070030public class PathIntent extends ConnectivityIntent {
Brian O'Connorb876bf12014-10-02 14:59:37 -070031
32 private final Path path;
33
34 /**
35 * Creates a new point-to-point intent with the supplied ingress/egress
36 * ports and using the specified explicit path.
37 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070038 * @param appId application identifier
39 * @param selector traffic selector
40 * @param treatment treatment
41 * @param path traversed links
Brian O'Connorb876bf12014-10-02 14:59:37 -070042 * @throws NullPointerException {@code path} is null
43 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070044 public PathIntent(ApplicationId appId, TrafficSelector selector,
45 TrafficTreatment treatment, Path path) {
46 super(id(PathIntent.class, selector, treatment, path), appId,
47 resources(path.links()), selector, treatment);
Brian O'Connorb876bf12014-10-02 14:59:37 -070048 this.path = path;
49 }
50
Thomas Vachuskac96058a2014-10-20 23:00:16 -070051 /**
52 * Constructor for serializer.
53 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070054 protected PathIntent() {
55 super();
56 this.path = null;
57 }
58
59 /**
60 * Returns the links which the traffic goes along.
61 *
62 * @return traversed links
63 */
tom85258ee2014-10-07 00:10:02 -070064 public Path path() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070065 return path;
66 }
67
68 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -070069 public boolean isInstallable() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070070 return true;
71 }
72
73 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -070074 public String toString() {
75 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -070076 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -070077 .add("appId", appId())
78 .add("selector", selector())
79 .add("treatment", treatment())
Brian O'Connorb876bf12014-10-02 14:59:37 -070080 .add("path", path)
81 .toString();
82 }
tom95329eb2014-10-06 08:40:06 -070083
Brian O'Connorb876bf12014-10-02 14:59:37 -070084}