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 | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | /** |
Hyunsun Moon | 44aac66 | 2017-02-18 02:07:01 +0900 | [diff] [blame] | 61 | * Returns the OpenStack network ID of the instance port. |
| 62 | * |
| 63 | * @return openstack network id |
| 64 | */ |
| 65 | String networkId(); |
| 66 | |
| 67 | /** |
| 68 | * Returns the OpenStack port ID of a given host. |
| 69 | * |
| 70 | * @return openstack port id |
| 71 | */ |
| 72 | String portId(); |
| 73 | |
| 74 | /** |
| 75 | * Returns the MAC address of the instance port. |
| 76 | * |
| 77 | * @return mac address |
| 78 | */ |
| 79 | MacAddress macAddress(); |
| 80 | |
| 81 | /** |
| 82 | * Returns the IP address of the instance port. |
| 83 | * |
| 84 | * @return ip address |
| 85 | */ |
| 86 | IpAddress ipAddress(); |
| 87 | |
| 88 | /** |
| 89 | * Returns the device ID of the instance port. |
| 90 | * |
| 91 | * @return device id |
| 92 | */ |
| 93 | DeviceId deviceId(); |
| 94 | |
| 95 | /** |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 96 | * Returns the old device ID of the instance port. |
| 97 | * This method returns valid value only if the VM is in migration phase. |
| 98 | * |
| 99 | * @return device id |
| 100 | */ |
| 101 | DeviceId oldDeviceId(); |
| 102 | |
| 103 | /** |
Hyunsun Moon | 44aac66 | 2017-02-18 02:07:01 +0900 | [diff] [blame] | 104 | * Returns the port number of the instance port. |
| 105 | * |
| 106 | * @return port number |
| 107 | */ |
| 108 | PortNumber portNumber(); |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 109 | |
| 110 | /** |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 111 | * Returns the old port number of the instance port. |
| 112 | * This method returns valid value only if the VM is in migration phase. |
| 113 | * |
| 114 | * @return port number |
| 115 | */ |
| 116 | PortNumber oldPortNumber(); |
| 117 | |
| 118 | /** |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 119 | * Returns the state of the instance port. |
| 120 | * |
| 121 | * @return state of port |
| 122 | */ |
| 123 | State state(); |
| 124 | |
| 125 | /** |
| 126 | * Returns new instance port instance with given state. |
| 127 | * |
| 128 | * @param newState updated state |
| 129 | * @return updated instance port |
| 130 | */ |
| 131 | InstancePort updateState(State newState); |
| 132 | |
| 133 | /** |
Jian Li | 46b7400 | 2018-07-15 18:39:08 +0900 | [diff] [blame] | 134 | * Returns new instance port instance with the given prev location data. |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 135 | * |
| 136 | * @param oldDeviceId old device ID |
| 137 | * @param oldPortNumber old port number |
| 138 | * @return updated instance port |
| 139 | */ |
Jian Li | 46b7400 | 2018-07-15 18:39:08 +0900 | [diff] [blame] | 140 | InstancePort updatePrevLocation(DeviceId oldDeviceId, PortNumber oldPortNumber); |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 141 | |
| 142 | /** |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 143 | * Builder of new instance port. |
| 144 | */ |
| 145 | interface Builder { |
| 146 | |
| 147 | /** |
| 148 | * Builds an immutable instance port instance. |
| 149 | * |
| 150 | * @return instance port |
| 151 | */ |
| 152 | InstancePort build(); |
| 153 | |
| 154 | /** |
| 155 | * Returns instance port builder with supplied network identifier. |
| 156 | * |
| 157 | * @param networkId network identifier |
| 158 | * @return instance port builder |
| 159 | */ |
| 160 | Builder networkId(String networkId); |
| 161 | |
| 162 | /** |
| 163 | * Returns instance port builder with supplied port identifier. |
| 164 | * |
| 165 | * @param portId port identifier |
| 166 | * @return instance port builder |
| 167 | */ |
| 168 | Builder portId(String portId); |
| 169 | |
| 170 | /** |
| 171 | * Returns instance port builder with supplied Mac Address. |
| 172 | * |
| 173 | * @param macAddress MAC address |
| 174 | * @return instance port builder |
| 175 | */ |
| 176 | Builder macAddress(MacAddress macAddress); |
| 177 | |
| 178 | /** |
| 179 | * Returns instance port builder with supplied IP Address. |
| 180 | * |
| 181 | * @param ipAddress IP address |
| 182 | * @return instance port builder |
| 183 | */ |
| 184 | Builder ipAddress(IpAddress ipAddress); |
| 185 | |
| 186 | /** |
| 187 | * Returns instance port builder with supplied Device identifier. |
| 188 | * |
| 189 | * @param deviceId device identifier |
| 190 | * @return instance port builder |
| 191 | */ |
| 192 | Builder deviceId(DeviceId deviceId); |
| 193 | |
| 194 | /** |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 195 | * Returns instance port builder with supplied old Device identifier. |
| 196 | * |
| 197 | * @param oldDeviceId device identifier |
| 198 | * @return instance port builder |
| 199 | */ |
| 200 | Builder oldDeviceId(DeviceId oldDeviceId); |
| 201 | |
| 202 | /** |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 203 | * Returns instance port builder with supplied port number. |
| 204 | * |
| 205 | * @param portNumber port number |
| 206 | * @return instance port builder |
| 207 | */ |
| 208 | Builder portNumber(PortNumber portNumber); |
| 209 | |
| 210 | /** |
Jian Li | ec5c32b | 2018-07-13 14:28:58 +0900 | [diff] [blame] | 211 | * Returns instance port builder with supplied old port number. |
| 212 | * |
| 213 | * @param oldPortNumber port number |
| 214 | * @return instance port builder |
| 215 | */ |
| 216 | Builder oldPortNumber(PortNumber oldPortNumber); |
| 217 | |
| 218 | /** |
Jian Li | ecae438 | 2018-06-28 17:41:12 +0900 | [diff] [blame] | 219 | * Returns instance port builder with supplied state. |
| 220 | * |
| 221 | * @param state state |
| 222 | * @return instance port builder |
| 223 | */ |
| 224 | Builder state(State state); |
| 225 | } |
Hyunsun Moon | 44aac66 | 2017-02-18 02:07:01 +0900 | [diff] [blame] | 226 | } |