Jian Li | fc55e42 | 2019-01-21 14:39:34 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019-present Open Networking Foundation |
| 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.k8snetworking.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 port. |
| 25 | */ |
| 26 | public interface K8sPort { |
| 27 | |
| 28 | /** |
| 29 | * List of instance port state. |
| 30 | */ |
| 31 | enum State { |
| 32 | |
| 33 | /** |
| 34 | * Signifies that the given port is in active state. |
| 35 | */ |
| 36 | ACTIVE, |
| 37 | |
| 38 | /** |
| 39 | * Signifies that the given port is in inactive state. |
| 40 | */ |
| 41 | INACTIVE, |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Returns the kubernetes network ID that the port is associated with. |
| 46 | * |
| 47 | * @return kubernetes network ID |
| 48 | */ |
| 49 | String networkId(); |
| 50 | |
| 51 | /** |
| 52 | * Returns the kubernetes port ID. |
| 53 | * |
| 54 | * @return kubernetes port ID |
| 55 | */ |
| 56 | String portId(); |
| 57 | |
| 58 | /** |
| 59 | * Returns the MAC address of the port. |
| 60 | * |
| 61 | * @return MAC address |
| 62 | */ |
| 63 | MacAddress macAddress(); |
| 64 | |
| 65 | /** |
| 66 | * Returns the IP address of the port. |
| 67 | * |
| 68 | * @return IP address |
| 69 | */ |
| 70 | IpAddress ipAddress(); |
| 71 | |
| 72 | /** |
| 73 | * Returns the device ID of the port. |
| 74 | * |
| 75 | * @return device ID |
| 76 | */ |
| 77 | DeviceId deviceId(); |
| 78 | |
| 79 | /** |
| 80 | * Returns the port number of the port. |
| 81 | * |
| 82 | * @return port number |
| 83 | */ |
| 84 | PortNumber portNumber(); |
| 85 | |
| 86 | /** |
| 87 | * Returns the state of the port. |
| 88 | * |
| 89 | * @return state of port |
| 90 | */ |
| 91 | State state(); |
| 92 | |
| 93 | /** |
| 94 | * Returns new port instance with the given state. |
| 95 | * |
| 96 | * @param newState updated state |
| 97 | * @return updated port |
| 98 | */ |
| 99 | K8sPort updateState(State newState); |
| 100 | |
| 101 | /** |
| 102 | * Builder of new port. |
| 103 | */ |
| 104 | interface Builder { |
| 105 | |
| 106 | /** |
| 107 | * Builds an immutable port instance. |
| 108 | * |
| 109 | * @return kubernetes port |
| 110 | */ |
| 111 | K8sPort build(); |
| 112 | |
| 113 | /** |
| 114 | * Returns port builder with supplied network ID. |
| 115 | * |
| 116 | * @param networkId network ID |
| 117 | * @return port builder |
| 118 | */ |
| 119 | Builder networkId(String networkId); |
| 120 | |
| 121 | /** |
| 122 | * Returns port builder with supplied port ID. |
| 123 | * |
| 124 | * @param portId port ID |
| 125 | * @return port builder |
| 126 | */ |
| 127 | Builder portId(String portId); |
| 128 | |
| 129 | /** |
| 130 | * Returns port builder with supplied MAC address. |
| 131 | * |
| 132 | * @param macAddress MAC address |
| 133 | * @return port builder |
| 134 | */ |
| 135 | Builder macAddress(MacAddress macAddress); |
| 136 | |
| 137 | /** |
| 138 | * Returns port builder with supplied IP address. |
| 139 | * |
| 140 | * @param ipAddress IP address |
| 141 | * @return port builder |
| 142 | */ |
| 143 | Builder ipAddress(IpAddress ipAddress); |
| 144 | |
| 145 | /** |
| 146 | * Returns port builder with supplied device ID. |
| 147 | * |
| 148 | * @param deviceId device ID |
| 149 | * @return port builder |
| 150 | */ |
| 151 | Builder deviceId(DeviceId deviceId); |
| 152 | |
| 153 | /** |
| 154 | * Returns port builder with supplied port number. |
| 155 | * |
| 156 | * @param portNumber port number |
| 157 | * @return port builder |
| 158 | */ |
| 159 | Builder portNumber(PortNumber portNumber); |
| 160 | |
| 161 | /** |
| 162 | * Returns port builder with supplied port state. |
| 163 | * |
| 164 | * @param state port state |
| 165 | * @return port builder |
| 166 | */ |
| 167 | Builder state(State state); |
| 168 | } |
| 169 | } |