Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +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 | 090d77d | 2017-07-05 17:48:37 +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 | */ |
Jian Li | 5a38ab6 | 2018-07-02 22:34:11 +0900 | [diff] [blame] | 16 | package org.onosproject.openstacknode.api; |
Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [diff] [blame] | 17 | |
| 18 | import org.onlab.packet.ChassisId; |
| 19 | import org.onlab.packet.IpAddress; |
| 20 | import org.onosproject.net.DefaultDevice; |
| 21 | import org.onosproject.net.Device; |
| 22 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.provider.ProviderId; |
Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [diff] [blame] | 24 | import org.onosproject.openstacknode.api.OpenstackNode.NodeType; |
| 25 | |
| 26 | import static org.onosproject.net.Device.Type.SWITCH; |
| 27 | |
| 28 | /** |
| 29 | * Provides a set of test OpenstackNode parameters for use with OpenstackNode related tests. |
| 30 | */ |
Jian Li | 1064e4f | 2018-05-29 16:16:53 +0900 | [diff] [blame] | 31 | public abstract class OpenstackNodeTest { |
Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [diff] [blame] | 32 | |
Jian Li | 1064e4f | 2018-05-29 16:16:53 +0900 | [diff] [blame] | 33 | public static Device createDevice(long devIdNum) { |
Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [diff] [blame] | 34 | return new DefaultDevice(new ProviderId("of", "foo"), |
| 35 | DeviceId.deviceId(String.format("of:%016d", devIdNum)), |
| 36 | SWITCH, |
| 37 | "manufacturer", |
| 38 | "hwVersion", |
| 39 | "swVersion", |
| 40 | "serialNumber", |
| 41 | new ChassisId(1)); |
| 42 | } |
| 43 | |
Jian Li | 1064e4f | 2018-05-29 16:16:53 +0900 | [diff] [blame] | 44 | public static OpenstackNode createNode(String hostname, NodeType type, |
Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [diff] [blame] | 45 | Device intgBridge, IpAddress ipAddr, |
| 46 | NodeState state) { |
Jian Li | 1064e4f | 2018-05-29 16:16:53 +0900 | [diff] [blame] | 47 | return DefaultOpenstackNode.builder() |
Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [diff] [blame] | 48 | .hostname(hostname) |
| 49 | .type(type) |
| 50 | .intgBridge(intgBridge.id()) |
| 51 | .managementIp(ipAddr) |
| 52 | .dataIp(ipAddr) |
| 53 | .state(state) |
| 54 | .build(); |
| 55 | } |
| 56 | |
Jian Li | 1064e4f | 2018-05-29 16:16:53 +0900 | [diff] [blame] | 57 | public static OpenstackNode createNode(String hostname, NodeType type, |
daniel park | b18424c | 2018-02-05 15:43:43 +0900 | [diff] [blame] | 58 | Device intgBridge, IpAddress ipAddr, |
| 59 | String uplinkPort, NodeState state) { |
Jian Li | 1064e4f | 2018-05-29 16:16:53 +0900 | [diff] [blame] | 60 | return DefaultOpenstackNode.builder() |
Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [diff] [blame] | 61 | .hostname(hostname) |
| 62 | .type(type) |
| 63 | .intgBridge(intgBridge.id()) |
Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [diff] [blame] | 64 | .managementIp(ipAddr) |
| 65 | .dataIp(ipAddr) |
daniel park | b18424c | 2018-02-05 15:43:43 +0900 | [diff] [blame] | 66 | .uplinkPort(uplinkPort) |
Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [diff] [blame] | 67 | .state(state) |
| 68 | .build(); |
| 69 | } |
| 70 | } |