blob: 9a04fff874494e9edaa6b4f5e30c14b4b59b922d [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.topology.impl;
tom4774c8f2014-09-16 11:17:08 -070017
tom4774c8f2014-09-16 11:17:08 -070018import org.apache.felix.scr.annotations.Activate;
19import org.apache.felix.scr.annotations.Component;
20import org.apache.felix.scr.annotations.Deactivate;
tom4774c8f2014-09-16 11:17:08 -070021import org.apache.felix.scr.annotations.Service;
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070022import org.onosproject.net.DisjointPath;
Brian O'Connorabafb502014-12-02 22:26:20 -080023import org.onosproject.net.ElementId;
Brian O'Connorabafb502014-12-02 22:26:20 -080024import org.onosproject.net.Link;
25import org.onosproject.net.Path;
Brian O'Connorabafb502014-12-02 22:26:20 -080026import org.onosproject.net.topology.LinkWeight;
27import org.onosproject.net.topology.PathService;
Claudine Chiu45920dd2016-07-28 19:19:46 +000028import org.onosproject.net.topology.AbstractPathService;
tom4774c8f2014-09-16 11:17:08 -070029import org.slf4j.Logger;
30
tom4774c8f2014-09-16 11:17:08 -070031import java.util.Set;
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070032import java.util.Map;
33
tom4774c8f2014-09-16 11:17:08 -070034
tom4774c8f2014-09-16 11:17:08 -070035import static org.slf4j.LoggerFactory.getLogger;
Changhoon Yoon541ef712015-05-23 17:18:34 +090036import static org.onosproject.security.AppGuard.checkPermission;
Changhoon Yoonb856b812015-08-10 03:47:19 +090037import static org.onosproject.security.AppPermission.Type.*;
Changhoon Yoon541ef712015-05-23 17:18:34 +090038
tom4774c8f2014-09-16 11:17:08 -070039
40/**
41 * Provides implementation of a path selection service atop the current
42 * topology and host services.
43 */
44@Component(immediate = true)
45@Service
Claudine Chiu45920dd2016-07-28 19:19:46 +000046public class PathManager extends AbstractPathService implements PathService {
tom4774c8f2014-09-16 11:17:08 -070047
tomcbefa232014-09-16 14:17:20 -070048
tom4774c8f2014-09-16 11:17:08 -070049 private final Logger log = getLogger(getClass());
50
tom4774c8f2014-09-16 11:17:08 -070051 @Activate
tomca90c462014-09-22 11:40:58 -070052 public void activate() {
tom4774c8f2014-09-16 11:17:08 -070053 log.info("Started");
54 }
55
56 @Deactivate
tomca90c462014-09-22 11:40:58 -070057 public void deactivate() {
tom4774c8f2014-09-16 11:17:08 -070058 log.info("Stopped");
59 }
60
61 @Override
tomcbefa232014-09-16 14:17:20 -070062 public Set<Path> getPaths(ElementId src, ElementId dst) {
Changhoon Yoonb856b812015-08-10 03:47:19 +090063 checkPermission(TOPOLOGY_READ);
Changhoon Yoon541ef712015-05-23 17:18:34 +090064
tom4774c8f2014-09-16 11:17:08 -070065 return getPaths(src, dst, null);
66 }
67
68 @Override
tomcbefa232014-09-16 14:17:20 -070069 public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
Changhoon Yoonb856b812015-08-10 03:47:19 +090070 checkPermission(TOPOLOGY_READ);
Claudine Chiu45920dd2016-07-28 19:19:46 +000071 return super.getPaths(src, dst, weight);
tom4774c8f2014-09-16 11:17:08 -070072 }
73
Claudine Chiu45920dd2016-07-28 19:19:46 +000074
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070075 @Override
76 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
Heedo Kang4a47a302016-02-29 17:40:23 +090077 checkPermission(TOPOLOGY_READ);
Thomas Vachuska48e64e42015-09-22 15:32:55 -070078 return getDisjointPaths(src, dst, (LinkWeight) null);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070079 }
80
81 @Override
82 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
Heedo Kang4a47a302016-02-29 17:40:23 +090083 checkPermission(TOPOLOGY_READ);
Claudine Chiu45920dd2016-07-28 19:19:46 +000084 return super.getDisjointPaths(src, dst, weight);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070085 }
86
87 @Override
Thomas Vachuska48e64e42015-09-22 15:32:55 -070088 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
89 Map<Link, Object> riskProfile) {
Heedo Kang4a47a302016-02-29 17:40:23 +090090 checkPermission(TOPOLOGY_READ);
Thomas Vachuska48e64e42015-09-22 15:32:55 -070091 return getDisjointPaths(src, dst, null, riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070092 }
93
94 @Override
Thomas Vachuska48e64e42015-09-22 15:32:55 -070095 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
96 Map<Link, Object> riskProfile) {
Heedo Kang4a47a302016-02-29 17:40:23 +090097 checkPermission(TOPOLOGY_READ);
Claudine Chiu45920dd2016-07-28 19:19:46 +000098 return super.getDisjointPaths(src, dst, weight, riskProfile);
Nikhil Cheerla2ec191f2015-07-09 12:34:54 -070099 }
100
tom4774c8f2014-09-16 11:17:08 -0700101}