blob: 5dfc62b37d0faddf76b73f330ee818853ec7defd [file] [log] [blame]
Claudine Chiu45920dd2016-07-28 19:19:46 +00001/*
2 *
3 * * Copyright 2016-present Open Networking Laboratory
4 * *
5 * * Licensed under the Apache License, Version 2.0 (the "License");
6 * * you may not use this file except in compliance with the License.
7 * * You may obtain a copy of the License at
8 * *
9 * * http://www.apache.org/licenses/LICENSE-2.0
10 * *
11 * * Unless required by applicable law or agreed to in writing, software
12 * * distributed under the License is distributed on an "AS IS" BASIS,
13 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * * See the License for the specific language governing permissions and
15 * * limitations under the License.
16 *
17 */
18
19package org.onosproject.incubator.net.virtual.impl;
20
21import org.onosproject.incubator.net.virtual.VirtualNetwork;
22import org.onosproject.incubator.net.virtual.VirtualNetworkService;
23import org.onosproject.net.DisjointPath;
24import org.onosproject.net.ElementId;
25import org.onosproject.net.Link;
26import org.onosproject.net.Path;
27import org.onosproject.net.host.HostService;
28import org.onosproject.net.topology.LinkWeight;
29import org.onosproject.net.topology.PathService;
30import org.onosproject.net.topology.AbstractPathService;
31import org.onosproject.net.topology.TopologyService;
32
33import java.util.Map;
34import java.util.Set;
35
36import static com.google.common.base.Preconditions.checkNotNull;
37
38/**
39 * Path service implementation built on the virtual network service.
40 */
41public class VirtualNetworkPathService extends AbstractPathService
42 implements PathService, VnetService {
43
44 private static final String NETWORK_NULL = "Network ID cannot be null";
45
46 private final VirtualNetwork network;
47
48 /**
49 * Creates a new virtual network path service object.
50 *
51 * @param virtualNetworkManager virtual network manager service
52 * @param network virtual network
53 */
54
55 public VirtualNetworkPathService(VirtualNetworkService virtualNetworkManager, VirtualNetwork network) {
56 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
73 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, Map<Link, Object> riskProfile) {
74 return getDisjointPaths(src, dst, null, riskProfile);
75 }
76
77 @Override
78 public VirtualNetwork network() {
79 return network;
80 }
81}