blob: 633de512462d84f401a31adffc2ae3ef9dbf1e8c [file] [log] [blame]
Jian Lifc55e422019-01-21 14:39:34 +09001/*
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 */
16package org.onosproject.k8snetworking.api;
17
18import org.onlab.packet.IpAddress;
19import org.onlab.packet.MacAddress;
20import org.onosproject.net.DeviceId;
21import org.onosproject.net.PortNumber;
22
23/**
24 * Representation of virtual port.
25 */
26public 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 /**
Jian Li4aa17642019-01-30 00:01:11 +0900102 * Returns new port instance with the given port number.
103 *
104 * @param portNumber updated port number
105 * @return updated port
106 */
107 K8sPort updatePortNumber(PortNumber portNumber);
108
109 /**
Jian Li732c3422020-09-07 17:01:11 +0900110 * Returns new port instance with the given device ID.
111 *
112 * @param deviceId device identifier
113 * @return updated port
114 */
115 K8sPort updateDeviceId(DeviceId deviceId);
116
117 /**
Jian Lifc55e422019-01-21 14:39:34 +0900118 * Builder of new port.
119 */
120 interface Builder {
121
122 /**
123 * Builds an immutable port instance.
124 *
125 * @return kubernetes port
126 */
127 K8sPort build();
128
129 /**
130 * Returns port builder with supplied network ID.
131 *
132 * @param networkId network ID
133 * @return port builder
134 */
135 Builder networkId(String networkId);
136
137 /**
138 * Returns port builder with supplied port ID.
139 *
140 * @param portId port ID
141 * @return port builder
142 */
143 Builder portId(String portId);
144
145 /**
146 * Returns port builder with supplied MAC address.
147 *
148 * @param macAddress MAC address
149 * @return port builder
150 */
151 Builder macAddress(MacAddress macAddress);
152
153 /**
154 * Returns port builder with supplied IP address.
155 *
156 * @param ipAddress IP address
157 * @return port builder
158 */
159 Builder ipAddress(IpAddress ipAddress);
160
161 /**
162 * Returns port builder with supplied device ID.
163 *
164 * @param deviceId device ID
165 * @return port builder
166 */
167 Builder deviceId(DeviceId deviceId);
168
169 /**
170 * Returns port builder with supplied port number.
171 *
172 * @param portNumber port number
173 * @return port builder
174 */
175 Builder portNumber(PortNumber portNumber);
176
177 /**
178 * Returns port builder with supplied port state.
179 *
180 * @param state port state
181 * @return port builder
182 */
183 Builder state(State state);
184 }
185}