blob: 5c44c966be2018f04d3e20e3ec78688437b01d35 [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 /**
Jian Liecae4382018-06-28 17:41:12 +090045 * Signifies that the given instance port is in migrating state.
46 */
Jian Liec5c32b2018-07-13 14:28:58 +090047 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 Liecae4382018-06-28 17:41:12 +090058 }
59
60 /**
Hyunsun Moon44aac662017-02-18 02:07:01 +090061 * 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 Liec5c32b2018-07-13 14:28:58 +090096 * 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 Moon44aac662017-02-18 02:07:01 +0900104 * Returns the port number of the instance port.
105 *
106 * @return port number
107 */
108 PortNumber portNumber();
Jian Liecae4382018-06-28 17:41:12 +0900109
110 /**
Jian Liec5c32b2018-07-13 14:28:58 +0900111 * 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 Liecae4382018-06-28 17:41:12 +0900119 * 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 Li46b74002018-07-15 18:39:08 +0900134 * Returns new instance port instance with the given prev location data.
Jian Liec5c32b2018-07-13 14:28:58 +0900135 *
136 * @param oldDeviceId old device ID
137 * @param oldPortNumber old port number
138 * @return updated instance port
139 */
Jian Li46b74002018-07-15 18:39:08 +0900140 InstancePort updatePrevLocation(DeviceId oldDeviceId, PortNumber oldPortNumber);
Jian Liec5c32b2018-07-13 14:28:58 +0900141
142 /**
Jian Liecae4382018-06-28 17:41:12 +0900143 * 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 Liec5c32b2018-07-13 14:28:58 +0900195 * 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 Liecae4382018-06-28 17:41:12 +0900203 * 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 Liec5c32b2018-07-13 14:28:58 +0900211 * 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 Liecae4382018-06-28 17:41:12 +0900219 * 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 Moon44aac662017-02-18 02:07:01 +0900226}