blob: 96d3c314f7a09862c7029746436d8ff97f56dd2e [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
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.host;
tom5bcc9462014-09-19 10:11:31 -070017
Jonathan Hart15ea3702015-08-31 11:22:10 +020018import org.onlab.packet.IpAddress;
19import org.onlab.packet.MacAddress;
20import org.onlab.packet.VlanId;
Brian O'Connorabafb502014-12-02 22:26:20 -080021import org.onosproject.net.ConnectPoint;
22import org.onosproject.net.DeviceId;
23import org.onosproject.net.Host;
24import org.onosproject.net.HostId;
Charles Chan888e20a2017-05-01 15:44:23 -070025import org.onosproject.net.HostLocation;
Charles Chan47933752017-11-30 15:37:50 -080026import org.onosproject.net.host.HostLocationProbingService.ProbeMode;
Brian O'Connorabafb502014-12-02 22:26:20 -080027import org.onosproject.net.provider.ProviderId;
28import org.onosproject.store.Store;
Jonathan Hart15ea3702015-08-31 11:22:10 +020029
30import java.util.Set;
tom5bcc9462014-09-19 10:11:31 -070031
tom5bcc9462014-09-19 10:11:31 -070032/**
tome4729872014-09-23 00:37:37 -070033 * Manages inventory of end-station hosts; not intended for direct use.
tom5bcc9462014-09-19 10:11:31 -070034 */
tomf80c9722014-09-24 14:49:18 -070035public interface HostStore extends Store<HostEvent, HostStoreDelegate> {
tom5bcc9462014-09-19 10:11:31 -070036
37 /**
38 * Creates a new host or updates the existing one based on the specified
39 * description.
40 *
41 * @param providerId provider identification
42 * @param hostId host identification
43 * @param hostDescription host description data
Brian O'Connorf107bd72015-09-21 15:31:03 -070044 * @param replaceIps replace IP set if true, merge IP set otherwise
tom5bcc9462014-09-19 10:11:31 -070045 * @return appropriate event or null if no change resulted
46 */
47 HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId,
Brian O'Connorf107bd72015-09-21 15:31:03 -070048 HostDescription hostDescription,
49 boolean replaceIps);
tom5bcc9462014-09-19 10:11:31 -070050
51 /**
52 * Removes the specified host from the inventory.
53 *
54 * @param hostId host identification
55 * @return remove event or null if host was not found
56 */
57 HostEvent removeHost(HostId hostId);
58
59 /**
samanwita palc40e5ed2015-09-24 11:01:51 -070060 * Removes the specified ip from the host entry.
61 *
62 * @param hostId host identification
63 * @param ipAddress ipAddress to be removed
64 * @return remove event or null if host was not found
65 */
66 HostEvent removeIp(HostId hostId, IpAddress ipAddress);
67
68 /**
Charles Chan47933752017-11-30 15:37:50 -080069 * Append the specified location to the host entry.
70 *
71 * @param hostId host identification
72 * @param location location to be added
73 */
74 void appendLocation(HostId hostId, HostLocation location);
75
76 /**
Charles Chan888e20a2017-05-01 15:44:23 -070077 * Removes the specified location from the host entry.
78 *
79 * @param hostId host identification
80 * @param location location to be removed
81 */
82 void removeLocation(HostId hostId, HostLocation location);
83
84 /**
tom5bcc9462014-09-19 10:11:31 -070085 * Returns the number of hosts in the store.
86 *
87 * @return host count
88 */
89 int getHostCount();
90
91 /**
92 * Returns a collection of all hosts in the store.
93 *
94 * @return iterable collection of all hosts
95 */
96 Iterable<Host> getHosts();
97
98 /**
99 * Returns the host with the specified identifer.
100 *
101 * @param hostId host identification
102 * @return host or null if not found
103 */
104 Host getHost(HostId hostId);
105
106 /**
107 * Returns the set of all hosts within the specified VLAN.
108 *
109 * @param vlanId vlan id
110 * @return set of hosts in the vlan
111 */
112 Set<Host> getHosts(VlanId vlanId);
113
114 /**
115 * Returns the set of hosts with the specified MAC address.
116 *
117 * @param mac mac address
118 * @return set of hosts with the given mac
119 */
120 Set<Host> getHosts(MacAddress mac);
121
122 /**
123 * Returns the set of hosts with the specified IP address.
124 *
125 * @param ip ip address
126 * @return set of hosts with the given IP
127 */
Pavlin Radoslavov33f228a2014-10-27 19:33:16 -0700128 Set<Host> getHosts(IpAddress ip);
tom5bcc9462014-09-19 10:11:31 -0700129
130 /**
131 * Returns the set of hosts whose location falls on the given connection point.
132 *
133 * @param connectPoint connection point
134 * @return set of hosts
135 */
136 Set<Host> getConnectedHosts(ConnectPoint connectPoint);
137
138 /**
139 * Returns the set of hosts whose location falls on the given device.
140 *
141 * @param deviceId infrastructure device identifier
142 * @return set of hosts
143 */
144 Set<Host> getConnectedHosts(DeviceId deviceId);
145
Charles Chan35a32322017-08-14 11:42:11 -0700146 /**
147 * Notifies HostStore the beginning of pending host location verification and
148 * retrieves the unique MAC address for the probe.
149 *
150 * @param hostId ID of the host
Charles Chan47933752017-11-30 15:37:50 -0800151 * @param connectPoint the connect point that is under verification
152 * @param probeMode probe mode
Charles Chan35a32322017-08-14 11:42:11 -0700153 * @return probeMac, the source MAC address ONOS uses to probe the host
154 */
Charles Chan47933752017-11-30 15:37:50 -0800155 default MacAddress addPendingHostLocation(HostId hostId, ConnectPoint connectPoint, ProbeMode probeMode) {
Charles Chan35a32322017-08-14 11:42:11 -0700156 return MacAddress.NONE;
157 }
158
159 /**
160 * Notifies HostStore the end of pending host location verification.
161 *
162 * @param probeMac the source MAC address ONOS uses to probe the host
163 */
164 default void removePendingHostLocation(MacAddress probeMac) {}
tom5bcc9462014-09-19 10:11:31 -0700165}