blob: 2bad087988474362d83462b43bd6c3b13046f4e3 [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;
Brian O'Connorabafb502014-12-02 22:26:20 -080026import org.onosproject.net.provider.ProviderId;
27import org.onosproject.store.Store;
Jonathan Hart15ea3702015-08-31 11:22:10 +020028
29import java.util.Set;
tom5bcc9462014-09-19 10:11:31 -070030
tom5bcc9462014-09-19 10:11:31 -070031/**
tome4729872014-09-23 00:37:37 -070032 * Manages inventory of end-station hosts; not intended for direct use.
tom5bcc9462014-09-19 10:11:31 -070033 */
tomf80c9722014-09-24 14:49:18 -070034public interface HostStore extends Store<HostEvent, HostStoreDelegate> {
tom5bcc9462014-09-19 10:11:31 -070035
36 /**
37 * Creates a new host or updates the existing one based on the specified
38 * description.
39 *
40 * @param providerId provider identification
41 * @param hostId host identification
42 * @param hostDescription host description data
Brian O'Connorf107bd72015-09-21 15:31:03 -070043 * @param replaceIps replace IP set if true, merge IP set otherwise
tom5bcc9462014-09-19 10:11:31 -070044 * @return appropriate event or null if no change resulted
45 */
46 HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId,
Brian O'Connorf107bd72015-09-21 15:31:03 -070047 HostDescription hostDescription,
48 boolean replaceIps);
tom5bcc9462014-09-19 10:11:31 -070049
50 /**
51 * Removes the specified host from the inventory.
52 *
53 * @param hostId host identification
54 * @return remove event or null if host was not found
55 */
56 HostEvent removeHost(HostId hostId);
57
58 /**
samanwita palc40e5ed2015-09-24 11:01:51 -070059 * Removes the specified ip from the host entry.
60 *
61 * @param hostId host identification
62 * @param ipAddress ipAddress to be removed
63 * @return remove event or null if host was not found
64 */
65 HostEvent removeIp(HostId hostId, IpAddress ipAddress);
66
67 /**
Charles Chan47933752017-11-30 15:37:50 -080068 * Append the specified location to the host entry.
69 *
70 * @param hostId host identification
71 * @param location location to be added
72 */
73 void appendLocation(HostId hostId, HostLocation location);
74
75 /**
Charles Chan888e20a2017-05-01 15:44:23 -070076 * Removes the specified location from the host entry.
77 *
78 * @param hostId host identification
79 * @param location location to be removed
80 */
81 void removeLocation(HostId hostId, HostLocation location);
82
83 /**
tom5bcc9462014-09-19 10:11:31 -070084 * Returns the number of hosts in the store.
85 *
86 * @return host count
87 */
88 int getHostCount();
89
90 /**
91 * Returns a collection of all hosts in the store.
92 *
93 * @return iterable collection of all hosts
94 */
95 Iterable<Host> getHosts();
96
97 /**
98 * Returns the host with the specified identifer.
99 *
100 * @param hostId host identification
101 * @return host or null if not found
102 */
103 Host getHost(HostId hostId);
104
105 /**
106 * Returns the set of all hosts within the specified VLAN.
107 *
108 * @param vlanId vlan id
109 * @return set of hosts in the vlan
110 */
111 Set<Host> getHosts(VlanId vlanId);
112
113 /**
114 * Returns the set of hosts with the specified MAC address.
115 *
116 * @param mac mac address
117 * @return set of hosts with the given mac
118 */
119 Set<Host> getHosts(MacAddress mac);
120
121 /**
122 * Returns the set of hosts with the specified IP address.
123 *
124 * @param ip ip address
125 * @return set of hosts with the given IP
126 */
Pavlin Radoslavov33f228a2014-10-27 19:33:16 -0700127 Set<Host> getHosts(IpAddress ip);
tom5bcc9462014-09-19 10:11:31 -0700128
129 /**
Charles Chanf42939d2019-12-06 19:19:30 -0800130 * Returns the set of hosts that attach to the specified connection point.
tom5bcc9462014-09-19 10:11:31 -0700131 *
132 * @param connectPoint connection point
133 * @return set of hosts
134 */
135 Set<Host> getConnectedHosts(ConnectPoint connectPoint);
136
137 /**
Charles Chanb51e8442020-03-08 17:41:11 -0700138 * Returns the set of host that attach to the specified connect point.
139 *
140 * @param connectPoint connect point
141 * @param matchAuxLocations true to match on the auxLocations, false to match on locations of the hosts
142 * @return set of hosts connected to the connection point
143 */
144 default Set<Host> getConnectedHosts(ConnectPoint connectPoint, boolean matchAuxLocations) {
145 return getConnectedHosts(connectPoint);
146 }
147
148 /**
Charles Chanf42939d2019-12-06 19:19:30 -0800149 * Returns the set of hosts that attach to the specified device.
tom5bcc9462014-09-19 10:11:31 -0700150 *
151 * @param deviceId infrastructure device identifier
152 * @return set of hosts
153 */
154 Set<Host> getConnectedHosts(DeviceId deviceId);
155
Charles Chan35a32322017-08-14 11:42:11 -0700156 /**
157 * Notifies HostStore the beginning of pending host location verification and
158 * retrieves the unique MAC address for the probe.
159 *
160 * @param hostId ID of the host
Charles Chan47933752017-11-30 15:37:50 -0800161 * @param connectPoint the connect point that is under verification
162 * @param probeMode probe mode
Charles Chan35a32322017-08-14 11:42:11 -0700163 * @return probeMac, the source MAC address ONOS uses to probe the host
164 */
Charles Chan47933752017-11-30 15:37:50 -0800165 default MacAddress addPendingHostLocation(HostId hostId, ConnectPoint connectPoint, ProbeMode probeMode) {
Charles Chan35a32322017-08-14 11:42:11 -0700166 return MacAddress.NONE;
167 }
168
169 /**
170 * Notifies HostStore the end of pending host location verification.
171 *
172 * @param probeMac the source MAC address ONOS uses to probe the host
173 */
174 default void removePendingHostLocation(MacAddress probeMac) {}
jobind19b7142019-05-17 09:46:52 -0400175
176 /**
177 * Update the host to suspended state to true
178 * denotes host is in suspended state.
179 *
180 * @param id ID of the host
181 */
182 default void suspend(HostId id){}
183
184 /**
185 * Update the host suspended state to false
186 * denotes host is in unsuspended state.
187 *
188 * @param id ID of the host
189 */
190 default void unsuspend(HostId id){}
191
tom5bcc9462014-09-19 10:11:31 -0700192}