blob: 62f3bdf6c9974938312c7d20a04cc09d22c0dcf7 [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;
20import org.onosproject.net.DisjointPath;
21import org.onosproject.net.ElementId;
22import org.onosproject.net.Link;
23import org.onosproject.net.Path;
24import org.onosproject.net.host.HostService;
25import org.onosproject.net.topology.LinkWeight;
26import org.onosproject.net.topology.PathService;
27import org.onosproject.net.topology.AbstractPathService;
28import org.onosproject.net.topology.TopologyService;
29
30import java.util.Map;
31import java.util.Set;
32
33import static com.google.common.base.Preconditions.checkNotNull;
34
35/**
36 * Path service implementation built on the virtual network service.
37 */
38public class VirtualNetworkPathService extends AbstractPathService
39 implements PathService, VnetService {
40
41 private static final String NETWORK_NULL = "Network ID cannot be null";
42
43 private final VirtualNetwork network;
44
45 /**
46 * Creates a new virtual network path service object.
47 *
48 * @param virtualNetworkManager virtual network manager service
49 * @param network virtual network
50 */
51
52 public VirtualNetworkPathService(VirtualNetworkService virtualNetworkManager, VirtualNetwork network) {
53 checkNotNull(network, NETWORK_NULL);
54 this.network = network;
55 topologyService = virtualNetworkManager.get(network.id(), TopologyService.class);
56 hostService = virtualNetworkManager.get(network.id(), HostService.class);
57 }
58
59 @Override
60 public Set<Path> getPaths(ElementId src, ElementId dst) {
61 return getPaths(src, dst, null);
62 }
63
64 @Override
65 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
66 return getDisjointPaths(src, dst, (LinkWeight) null);
67 }
68
69 @Override
70 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, Map<Link, Object> riskProfile) {
71 return getDisjointPaths(src, dst, null, riskProfile);
72 }
73
74 @Override
75 public VirtualNetwork network() {
76 return network;
77 }
78}