blob: 83c0741cf10b3186f8145c0bc153000aeee1d37a [file] [log] [blame]
Hyunsun Moon44aac662017-02-18 02:07:01 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Hyunsun Moon44aac662017-02-18 02:07:01 +09003 *
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.openstacknetworking.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 instance port.
25 */
26public interface InstancePort {
27
28 /**
Jian Liecae4382018-06-28 17:41:12 +090029 * 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 /**
45 * Signifies that the given instance port is in pending removal state.
46 */
47 PENDING_REMOVAL,
48
49 /**
50 * Signifies that the given instance port is in migrating state.
51 */
Jian Liec5c32b2018-07-13 14:28:58 +090052 MIGRATING,
53
54 /**
55 * Signifies that the given instance port will be removed soon.
56 */
57 REMOVED,
58
59 /**
60 * Signifies that the given instance port has been migrated.
61 */
62 MIGRATED,
Jian Liecae4382018-06-28 17:41:12 +090063 }
64
65 /**
Hyunsun Moon44aac662017-02-18 02:07:01 +090066 * 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 Liec5c32b2018-07-13 14:28:58 +0900101 * 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 Moon44aac662017-02-18 02:07:01 +0900109 * Returns the port number of the instance port.
110 *
111 * @return port number
112 */
113 PortNumber portNumber();
Jian Liecae4382018-06-28 17:41:12 +0900114
115 /**
Jian Liec5c32b2018-07-13 14:28:58 +0900116 * 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 Liecae4382018-06-28 17:41:12 +0900124 * 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 Li46b74002018-07-15 18:39:08 +0900139 * Returns new instance port instance with the given prev location data.
Jian Liec5c32b2018-07-13 14:28:58 +0900140 *
141 * @param oldDeviceId old device ID
142 * @param oldPortNumber old port number
143 * @return updated instance port
144 */
Jian Li46b74002018-07-15 18:39:08 +0900145 InstancePort updatePrevLocation(DeviceId oldDeviceId, PortNumber oldPortNumber);
Jian Liec5c32b2018-07-13 14:28:58 +0900146
147 /**
Jian Liecae4382018-06-28 17:41:12 +0900148 * 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 Liec5c32b2018-07-13 14:28:58 +0900200 * 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 Liecae4382018-06-28 17:41:12 +0900208 * 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 Liec5c32b2018-07-13 14:28:58 +0900216 * 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 Liecae4382018-06-28 17:41:12 +0900224 * 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 Moon44aac662017-02-18 02:07:01 +0900231}