blob: 1c05a2ba6c29697c04bcb65039e3684f8d650d51 [file] [log] [blame]
Thomas Vachuska7b438af2015-07-07 09:52:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska7b438af2015-07-07 09:52: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 */
16package org.onosproject.incubator.net.virtual;
17
18import com.google.common.annotations.Beta;
yoonseonc6a69272017-01-12 18:22:20 -080019import org.onlab.osgi.ServiceDirectory;
yoonseon322c9c32016-12-07 16:47:02 -080020import org.onosproject.core.ApplicationId;
Yoonseon Han33821fb2017-02-24 13:40:44 +090021import org.onosproject.event.ListenerService;
Thomas Vachuska7b438af2015-07-07 09:52:07 -070022import org.onosproject.net.DeviceId;
23
sangyun-han3c3e99e2017-02-08 15:30:53 +090024import java.util.HashSet;
Thomas Vachuska7b438af2015-07-07 09:52:07 -070025import java.util.Set;
26
sangyun-han3c3e99e2017-02-08 15:30:53 +090027import static com.google.common.base.Preconditions.checkNotNull;
28
Thomas Vachuska7b438af2015-07-07 09:52:07 -070029/**
30 * Service for querying virtual network inventory.
31 */
32@Beta
Yoonseon Han33821fb2017-02-24 13:40:44 +090033public interface VirtualNetworkService
34 extends ListenerService<VirtualNetworkEvent, VirtualNetworkListener> {
Thomas Vachuska7b438af2015-07-07 09:52:07 -070035
36 /**
Brian Stanke0e5c94e2016-03-08 11:20:04 -050037 * The topic used for obtaining globally unique ids.
38 */
39 String VIRTUAL_NETWORK_TOPIC = "virtual-network-ids";
40
41 /**
Thomas Vachuska7b438af2015-07-07 09:52:07 -070042 * Returns a collection of all virtual networks created on behalf of the
43 * specified tenant.
44 *
45 * @param tenantId tenant identifier
46 * @return collection of networks
47 * @throws org.onlab.util.ItemNotFoundException if no such network found
48 */
49 Set<VirtualNetwork> getVirtualNetworks(TenantId tenantId);
50
51 /**
52 * Returns a collection of all virtual devices in the specified network.
53 *
54 * @param networkId network identifier
55 * @return collection of devices
56 * @throws org.onlab.util.ItemNotFoundException if no such network found
57 */
58 Set<VirtualDevice> getVirtualDevices(NetworkId networkId);
59
60 /**
Brian Stanke7a81b532016-06-14 15:43:51 -040061 * Returns a collection of all virtual hosts in the specified network.
62 *
63 * @param networkId network identifier
64 * @return collection of hosts
65 * @throws org.onlab.util.ItemNotFoundException if no such network found
66 */
67 Set<VirtualHost> getVirtualHosts(NetworkId networkId);
68
69 /**
Thomas Vachuska7b438af2015-07-07 09:52:07 -070070 * Returns collection of all virtual links in the specified network.
71 *
72 * @param networkId network identifier
73 * @return collection of links
74 * @throws org.onlab.util.ItemNotFoundException if no such network found
75 */
76 Set<VirtualLink> getVirtualLinks(NetworkId networkId);
77
78 /**
Brian Stanke612cebf2016-05-02 10:21:33 -040079 * Returns list of all virtual ports of the specified device. If the
80 * device identifier is null then all of the virtual ports in the specified
81 * network will be returned.
Thomas Vachuska7b438af2015-07-07 09:52:07 -070082 *
83 * @param networkId network identifier
84 * @param deviceId device identifier
85 * @return list of ports
86 * @throws org.onlab.util.ItemNotFoundException if no such network found
87 */
88 Set<VirtualPort> getVirtualPorts(NetworkId networkId, DeviceId deviceId);
89
90 /**
sangyun-han3c3e99e2017-02-08 15:30:53 +090091 * Returns list of physical device identifier mapping with the virtual
92 * device in the specified network. The physical devices are specified by
93 * port mapping mechanism.
94 *
95 * @param networkId network identifier
96 * @param virtualDevice the virtual device
97 * @return collection of the specified device's identifier
98 */
99 default Set<DeviceId> getPhysicalDevices(NetworkId networkId,
100 VirtualDevice virtualDevice) {
101 checkNotNull(networkId, "Network ID cannot be null");
102 checkNotNull(virtualDevice, "Virtual device cannot be null");
103 Set<VirtualPort> virtualPortSet =
104 getVirtualPorts(networkId, virtualDevice.id());
105 Set<DeviceId> physicalDeviceSet = new HashSet<>();
106
107 virtualPortSet.forEach(virtualPort -> {
108 if (virtualPort.realizedBy() != null) {
109 physicalDeviceSet.add(virtualPort.realizedBy().deviceId());
110 }
111 });
112
113 return physicalDeviceSet;
114 }
115
116 /**
Thomas Vachuska7b438af2015-07-07 09:52:07 -0700117 * Returns implementation of the specified service class for operating
118 * in the context of the given network.
119 * <p>
120 * The following services will be available:
121 * <ul>
122 * <li>{@link org.onosproject.net.device.DeviceService}</li>
123 * <li>{@link org.onosproject.net.link.LinkService}</li>
124 * <li>{@link org.onosproject.net.host.HostService}</li>
125 * <li>{@link org.onosproject.net.topology.TopologyService}</li>
126 * <li>{@link org.onosproject.net.topology.PathService}</li>
yoonseon97b9b592017-01-31 14:35:06 -0800127 * <li>{@link org.onosproject.net.packet.PacketService}</li>
Thomas Vachuska7b438af2015-07-07 09:52:07 -0700128 * <li>{@link org.onosproject.net.flow.FlowRuleService}</li>
129 * <li>{@link org.onosproject.net.flowobjective.FlowObjectiveService}</li>
130 * <li>{@link org.onosproject.net.intent.IntentService}</li>
131 * </ul>
132 *
133 * @param networkId network identifier
134 * @param serviceClass service class
135 * @param <T> type of service
136 * @return implementation class
137 * @throws org.onlab.util.ItemNotFoundException if no such network found
138 * @throws org.onlab.osgi.ServiceNotFoundException if no implementation found
139 */
140 <T> T get(NetworkId networkId, Class<T> serviceClass);
141
yoonseonc6a69272017-01-12 18:22:20 -0800142 /**
143 * Returns service directory.
144 *
145 * @return a service directory
146 */
147 ServiceDirectory getServiceDirectory();
yoonseon322c9c32016-12-07 16:47:02 -0800148
149 /**
150 * Returns the application identifier for a virtual network.
151 *
152 * @param networkId network identifier
153 * @return an representative application identifier for a virtual network
154 */
155 ApplicationId getVirtualNetworkApplicationId(NetworkId networkId);
Thomas Vachuska7b438af2015-07-07 09:52:07 -0700156}