Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Laboratory |
| 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.openstacknode.impl; |
| 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; |
| 24 | import org.onosproject.openstacknode.api.NodeState; |
| 25 | import org.onosproject.openstacknode.api.OpenstackNode; |
| 26 | import org.onosproject.openstacknode.api.OpenstackNode.NodeType; |
| 27 | |
| 28 | import static org.onosproject.net.Device.Type.SWITCH; |
| 29 | |
| 30 | /** |
| 31 | * Provides a set of test OpenstackNode parameters for use with OpenstackNode related tests. |
| 32 | */ |
| 33 | abstract class OpenstackNodeTest { |
| 34 | |
| 35 | protected static Device createDevice(long devIdNum) { |
| 36 | return new DefaultDevice(new ProviderId("of", "foo"), |
| 37 | DeviceId.deviceId(String.format("of:%016d", devIdNum)), |
| 38 | SWITCH, |
| 39 | "manufacturer", |
| 40 | "hwVersion", |
| 41 | "swVersion", |
| 42 | "serialNumber", |
| 43 | new ChassisId(1)); |
| 44 | } |
| 45 | |
| 46 | protected static OpenstackNode createNode(String hostname, NodeType type, |
| 47 | Device intgBridge, IpAddress ipAddr, |
| 48 | NodeState state) { |
| 49 | return DefaultOpenstackNode.builder() |
| 50 | .hostname(hostname) |
| 51 | .type(type) |
| 52 | .intgBridge(intgBridge.id()) |
| 53 | .managementIp(ipAddr) |
| 54 | .dataIp(ipAddr) |
| 55 | .state(state) |
| 56 | .build(); |
| 57 | } |
| 58 | |
| 59 | protected static OpenstackNode createNode(String hostname, NodeType type, |
| 60 | Device intgBridge, Device routerBridge, |
| 61 | IpAddress ipAddr, NodeState state) { |
| 62 | return DefaultOpenstackNode.builder() |
| 63 | .hostname(hostname) |
| 64 | .type(type) |
| 65 | .intgBridge(intgBridge.id()) |
| 66 | .routerBridge(routerBridge.id()) |
| 67 | .managementIp(ipAddr) |
| 68 | .dataIp(ipAddr) |
| 69 | .state(state) |
| 70 | .build(); |
| 71 | } |
| 72 | } |