Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.host; |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | 15ea370 | 2015-08-31 11:22:10 +0200 | [diff] [blame] | 18 | import org.onlab.packet.IpAddress; |
| 19 | import org.onlab.packet.MacAddress; |
| 20 | import org.onlab.packet.VlanId; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 21 | import org.onosproject.net.ConnectPoint; |
| 22 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.Host; |
| 24 | import org.onosproject.net.HostId; |
Charles Chan | 888e20a | 2017-05-01 15:44:23 -0700 | [diff] [blame] | 25 | import org.onosproject.net.HostLocation; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 26 | import org.onosproject.net.provider.ProviderId; |
| 27 | import org.onosproject.store.Store; |
Jonathan Hart | 15ea370 | 2015-08-31 11:22:10 +0200 | [diff] [blame] | 28 | |
| 29 | import java.util.Set; |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 30 | |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 31 | /** |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 32 | * Manages inventory of end-station hosts; not intended for direct use. |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 33 | */ |
tom | f80c972 | 2014-09-24 14:49:18 -0700 | [diff] [blame] | 34 | public interface HostStore extends Store<HostEvent, HostStoreDelegate> { |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 35 | |
| 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'Connor | f107bd7 | 2015-09-21 15:31:03 -0700 | [diff] [blame] | 43 | * @param replaceIps replace IP set if true, merge IP set otherwise |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 44 | * @return appropriate event or null if no change resulted |
| 45 | */ |
| 46 | HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId, |
Brian O'Connor | f107bd7 | 2015-09-21 15:31:03 -0700 | [diff] [blame] | 47 | HostDescription hostDescription, |
| 48 | boolean replaceIps); |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 49 | |
| 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 pal | c40e5ed | 2015-09-24 11:01:51 -0700 | [diff] [blame] | 59 | * 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 Chan | 4793375 | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 68 | * 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 Chan | 888e20a | 2017-05-01 15:44:23 -0700 | [diff] [blame] | 76 | * 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 | /** |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 84 | * 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 Radoslavov | 33f228a | 2014-10-27 19:33:16 -0700 | [diff] [blame] | 127 | Set<Host> getHosts(IpAddress ip); |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 128 | |
| 129 | /** |
| 130 | * Returns the set of hosts whose location falls on the given connection point. |
| 131 | * |
| 132 | * @param connectPoint connection point |
| 133 | * @return set of hosts |
| 134 | */ |
| 135 | Set<Host> getConnectedHosts(ConnectPoint connectPoint); |
| 136 | |
| 137 | /** |
| 138 | * Returns the set of hosts whose location falls on the given device. |
| 139 | * |
| 140 | * @param deviceId infrastructure device identifier |
| 141 | * @return set of hosts |
| 142 | */ |
| 143 | Set<Host> getConnectedHosts(DeviceId deviceId); |
| 144 | |
Charles Chan | 35a3232 | 2017-08-14 11:42:11 -0700 | [diff] [blame] | 145 | /** |
| 146 | * Notifies HostStore the beginning of pending host location verification and |
| 147 | * retrieves the unique MAC address for the probe. |
| 148 | * |
| 149 | * @param hostId ID of the host |
Charles Chan | 4793375 | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 150 | * @param connectPoint the connect point that is under verification |
| 151 | * @param probeMode probe mode |
Charles Chan | 35a3232 | 2017-08-14 11:42:11 -0700 | [diff] [blame] | 152 | * @return probeMac, the source MAC address ONOS uses to probe the host |
| 153 | */ |
Charles Chan | 4793375 | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 154 | default MacAddress addPendingHostLocation(HostId hostId, ConnectPoint connectPoint, ProbeMode probeMode) { |
Charles Chan | 35a3232 | 2017-08-14 11:42:11 -0700 | [diff] [blame] | 155 | return MacAddress.NONE; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Notifies HostStore the end of pending host location verification. |
| 160 | * |
| 161 | * @param probeMac the source MAC address ONOS uses to probe the host |
| 162 | */ |
| 163 | default void removePendingHostLocation(MacAddress probeMac) {} |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 164 | } |