Hyunsun Moon | 44aac66 | 2017-02-18 02:07:01 +0900 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Hyunsun Moon | 44aac66 | 2017-02-18 02:07:01 +0900 | [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 | */ |
| 16 | package org.onosproject.openstacknetworking.api; |
| 17 | |
| 18 | import org.onlab.packet.IpAddress; |
| 19 | import org.onlab.packet.MacAddress; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.PortNumber; |
| 22 | |
| 23 | /** |
| 24 | * Representation of virtual instance port. |
| 25 | */ |
| 26 | public interface InstancePort { |
| 27 | |
| 28 | /** |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 29 | * List of instance port states. |
| 30 | */ |
| 31 | enum State { |
| 32 | |
| 33 | /** |
| 34 | * Signifies that the given instance port is in active state. |
| 35 | */ |
| 36 | ACTIVE, |
| 37 | |
| 38 | /** |
| 39 | * Signifies that the given instance port is in inactive state due to |
| 40 | * host termination. |
| 41 | */ |
| 42 | INACTIVE, |
| 43 | |
| 44 | /** |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 45 | * Signifies that the given instance port is in migrating state. |
| 46 | */ |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 47 | MIGRATING, |
| 48 | |
| 49 | /** |
| 50 | * Signifies that the given instance port will be removed soon. |
| 51 | */ |
| 52 | REMOVED, |
| 53 | |
| 54 | /** |
| 55 | * Signifies that the given instance port has been migrated. |
| 56 | */ |
| 57 | MIGRATED, |
Jian Li | 8a5fb64 | 2018-09-14 15:50:04 +0900 | [diff] [blame] | 58 | |
| 59 | /** |
| 60 | * Signifies that the given instance port in the pending status for removal. |
| 61 | */ |
| 62 | REMOVE_PENDING, |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | /** |
Hyunsun Moon | 44aac66 | 2017-02-18 02:07:01 +0900 | [diff] [blame] | 66 | * Returns the OpenStack network ID of the instance port. |
| 67 | * |
| 68 | * @return openstack network id |
| 69 | */ |
| 70 | String networkId(); |
| 71 | |
| 72 | /** |
| 73 | * Returns the OpenStack port ID of a given host. |
| 74 | * |
| 75 | * @return openstack port id |
| 76 | */ |
| 77 | String portId(); |
| 78 | |
| 79 | /** |
| 80 | * Returns the MAC address of the instance port. |
| 81 | * |
| 82 | * @return mac address |
| 83 | */ |
| 84 | MacAddress macAddress(); |
| 85 | |
| 86 | /** |
| 87 | * Returns the IP address of the instance port. |
| 88 | * |
| 89 | * @return ip address |
| 90 | */ |
| 91 | IpAddress ipAddress(); |
| 92 | |
| 93 | /** |
| 94 | * Returns the device ID of the instance port. |
| 95 | * |
| 96 | * @return device id |
| 97 | */ |
| 98 | DeviceId deviceId(); |
| 99 | |
| 100 | /** |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 101 | * Returns the old device ID of the instance port. |
| 102 | * This method returns valid value only if the VM is in migration phase. |
| 103 | * |
| 104 | * @return device id |
| 105 | */ |
| 106 | DeviceId oldDeviceId(); |
| 107 | |
| 108 | /** |
Hyunsun Moon | 44aac66 | 2017-02-18 02:07:01 +0900 | [diff] [blame] | 109 | * Returns the port number of the instance port. |
| 110 | * |
| 111 | * @return port number |
| 112 | */ |
| 113 | PortNumber portNumber(); |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 114 | |
| 115 | /** |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 116 | * Returns the old port number of the instance port. |
| 117 | * This method returns valid value only if the VM is in migration phase. |
| 118 | * |
| 119 | * @return port number |
| 120 | */ |
| 121 | PortNumber oldPortNumber(); |
| 122 | |
| 123 | /** |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 124 | * Returns the state of the instance port. |
| 125 | * |
| 126 | * @return state of port |
| 127 | */ |
| 128 | State state(); |
| 129 | |
| 130 | /** |
| 131 | * Returns new instance port instance with given state. |
| 132 | * |
| 133 | * @param newState updated state |
| 134 | * @return updated instance port |
| 135 | */ |
| 136 | InstancePort updateState(State newState); |
| 137 | |
| 138 | /** |
Jian Li | 46b7400 | 2018-07-15 18:39:08 +0900 | [diff] [blame] | 139 | * Returns new instance port instance with the given prev location data. |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 140 | * |
| 141 | * @param oldDeviceId old device ID |
| 142 | * @param oldPortNumber old port number |
| 143 | * @return updated instance port |
| 144 | */ |
Jian Li | 46b7400 | 2018-07-15 18:39:08 +0900 | [diff] [blame] | 145 | InstancePort updatePrevLocation(DeviceId oldDeviceId, PortNumber oldPortNumber); |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 146 | |
| 147 | /** |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 148 | * Builder of new instance port. |
| 149 | */ |
| 150 | interface Builder { |
| 151 | |
| 152 | /** |
| 153 | * Builds an immutable instance port instance. |
| 154 | * |
| 155 | * @return instance port |
| 156 | */ |
| 157 | InstancePort build(); |
| 158 | |
| 159 | /** |
| 160 | * Returns instance port builder with supplied network identifier. |
| 161 | * |
| 162 | * @param networkId network identifier |
| 163 | * @return instance port builder |
| 164 | */ |
| 165 | Builder networkId(String networkId); |
| 166 | |
| 167 | /** |
| 168 | * Returns instance port builder with supplied port identifier. |
| 169 | * |
| 170 | * @param portId port identifier |
| 171 | * @return instance port builder |
| 172 | */ |
| 173 | Builder portId(String portId); |
| 174 | |
| 175 | /** |
| 176 | * Returns instance port builder with supplied Mac Address. |
| 177 | * |
| 178 | * @param macAddress MAC address |
| 179 | * @return instance port builder |
| 180 | */ |
| 181 | Builder macAddress(MacAddress macAddress); |
| 182 | |
| 183 | /** |
| 184 | * Returns instance port builder with supplied IP Address. |
| 185 | * |
| 186 | * @param ipAddress IP address |
| 187 | * @return instance port builder |
| 188 | */ |
| 189 | Builder ipAddress(IpAddress ipAddress); |
| 190 | |
| 191 | /** |
| 192 | * Returns instance port builder with supplied Device identifier. |
| 193 | * |
| 194 | * @param deviceId device identifier |
| 195 | * @return instance port builder |
| 196 | */ |
| 197 | Builder deviceId(DeviceId deviceId); |
| 198 | |
| 199 | /** |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 200 | * Returns instance port builder with supplied old Device identifier. |
| 201 | * |
| 202 | * @param oldDeviceId device identifier |
| 203 | * @return instance port builder |
| 204 | */ |
| 205 | Builder oldDeviceId(DeviceId oldDeviceId); |
| 206 | |
| 207 | /** |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 208 | * Returns instance port builder with supplied port number. |
| 209 | * |
| 210 | * @param portNumber port number |
| 211 | * @return instance port builder |
| 212 | */ |
| 213 | Builder portNumber(PortNumber portNumber); |
| 214 | |
| 215 | /** |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 216 | * Returns instance port builder with supplied old port number. |
| 217 | * |
| 218 | * @param oldPortNumber port number |
| 219 | * @return instance port builder |
| 220 | */ |
| 221 | Builder oldPortNumber(PortNumber oldPortNumber); |
| 222 | |
| 223 | /** |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 224 | * Returns instance port builder with supplied state. |
| 225 | * |
| 226 | * @param state state |
| 227 | * @return instance port builder |
| 228 | */ |
| 229 | Builder state(State state); |
| 230 | } |
Hyunsun Moon | 44aac66 | 2017-02-18 02:07:01 +0900 | [diff] [blame] | 231 | } |