blob: 1349d3037ad5b48d9808bac311f2f2a0d366ad7c [file] [log] [blame]
Hyunsun Moon090d77d2017-07-05 17:48:37 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Hyunsun Moon090d77d2017-07-05 17:48:37 +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 */
Jian Li5a38ab62018-07-02 22:34:11 +090016package org.onosproject.openstacknode.api;
Hyunsun Moon090d77d2017-07-05 17:48:37 +090017
18import org.onlab.packet.ChassisId;
19import org.onlab.packet.IpAddress;
20import org.onosproject.net.DefaultDevice;
21import org.onosproject.net.Device;
22import org.onosproject.net.DeviceId;
23import org.onosproject.net.provider.ProviderId;
Hyunsun Moon090d77d2017-07-05 17:48:37 +090024import org.onosproject.openstacknode.api.OpenstackNode.NodeType;
25
26import 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 Li1064e4f2018-05-29 16:16:53 +090031public abstract class OpenstackNodeTest {
Hyunsun Moon090d77d2017-07-05 17:48:37 +090032
Jian Li1064e4f2018-05-29 16:16:53 +090033 public static Device createDevice(long devIdNum) {
Hyunsun Moon090d77d2017-07-05 17:48:37 +090034 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 Li1064e4f2018-05-29 16:16:53 +090044 public static OpenstackNode createNode(String hostname, NodeType type,
Hyunsun Moon090d77d2017-07-05 17:48:37 +090045 Device intgBridge, IpAddress ipAddr,
46 NodeState state) {
Jian Li1064e4f2018-05-29 16:16:53 +090047 return DefaultOpenstackNode.builder()
Hyunsun Moon090d77d2017-07-05 17:48:37 +090048 .hostname(hostname)
49 .type(type)
50 .intgBridge(intgBridge.id())
51 .managementIp(ipAddr)
52 .dataIp(ipAddr)
53 .state(state)
54 .build();
55 }
56
Jian Li1064e4f2018-05-29 16:16:53 +090057 public static OpenstackNode createNode(String hostname, NodeType type,
daniel parkb18424c2018-02-05 15:43:43 +090058 Device intgBridge, IpAddress ipAddr,
59 String uplinkPort, NodeState state) {
Jian Li1064e4f2018-05-29 16:16:53 +090060 return DefaultOpenstackNode.builder()
Hyunsun Moon090d77d2017-07-05 17:48:37 +090061 .hostname(hostname)
62 .type(type)
63 .intgBridge(intgBridge.id())
Hyunsun Moon090d77d2017-07-05 17:48:37 +090064 .managementIp(ipAddr)
65 .dataIp(ipAddr)
daniel parkb18424c2018-02-05 15:43:43 +090066 .uplinkPort(uplinkPort)
Hyunsun Moon090d77d2017-07-05 17:48:37 +090067 .state(state)
68 .build();
69 }
70}