blob: ad81141fd3f81212e43432b03650da074c6e3c31 [file] [log] [blame]
Claudine Chiu45920dd2016-07-28 19:19:46 +00001/*
Brian O'Connord03d7dd2016-08-02 23:33:25 -07002 * Copyright 2016-present Open Networking Laboratory
Claudine Chiu45920dd2016-07-28 19:19:46 +00003 *
Brian O'Connord03d7dd2016-08-02 23:33:25 -07004 * 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
Claudine Chiu45920dd2016-07-28 19:19:46 +00007 *
Brian O'Connord03d7dd2016-08-02 23:33:25 -07008 * 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.
Claudine Chiu45920dd2016-07-28 19:19:46 +000015 */
Claudine Chiu45920dd2016-07-28 19:19:46 +000016package org.onosproject.incubator.net.virtual.impl;
17
18import org.onosproject.incubator.net.virtual.VirtualNetwork;
19import org.onosproject.incubator.net.virtual.VirtualNetworkService;
yoonseon214963b2016-11-21 15:41:07 -080020import org.onosproject.incubator.net.virtual.VnetService;
Claudine Chiu45920dd2016-07-28 19:19:46 +000021import org.onosproject.net.DisjointPath;
22import org.onosproject.net.ElementId;
23import org.onosproject.net.Link;
24import org.onosproject.net.Path;
25import org.onosproject.net.host.HostService;
26import org.onosproject.net.topology.LinkWeight;
27import org.onosproject.net.topology.PathService;
28import org.onosproject.net.topology.AbstractPathService;
29import org.onosproject.net.topology.TopologyService;
30
31import java.util.Map;
32import java.util.Set;
33
34import static com.google.common.base.Preconditions.checkNotNull;
35
36/**
37 * Path service implementation built on the virtual network service.
38 */
yoonseon214963b2016-11-21 15:41:07 -080039public class VirtualNetworkPathManager
40 extends AbstractPathService
Claudine Chiu45920dd2016-07-28 19:19:46 +000041 implements PathService, VnetService {
42
43 private static final String NETWORK_NULL = "Network ID cannot be null";
44
45 private final VirtualNetwork network;
46
47 /**
48 * Creates a new virtual network path service object.
49 *
50 * @param virtualNetworkManager virtual network manager service
51 * @param network virtual network
52 */
53
yoonseon214963b2016-11-21 15:41:07 -080054 public VirtualNetworkPathManager(VirtualNetworkService virtualNetworkManager,
55 VirtualNetwork network) {
Claudine Chiu45920dd2016-07-28 19:19:46 +000056 checkNotNull(network, NETWORK_NULL);
57 this.network = network;
58 topologyService = virtualNetworkManager.get(network.id(), TopologyService.class);
59 hostService = virtualNetworkManager.get(network.id(), HostService.class);
60 }
61
62 @Override
63 public Set<Path> getPaths(ElementId src, ElementId dst) {
64 return getPaths(src, dst, null);
65 }
66
67 @Override
68 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
69 return getDisjointPaths(src, dst, (LinkWeight) null);
70 }
71
72 @Override
yoonseon214963b2016-11-21 15:41:07 -080073 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
74 Map<Link, Object> riskProfile) {
Claudine Chiu45920dd2016-07-28 19:19:46 +000075 return getDisjointPaths(src, dst, null, riskProfile);
76 }
77
78 @Override
79 public VirtualNetwork network() {
80 return network;
81 }
82}