blob: 53bd593598818ff4941c77de5518c858def31087 [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 */
16package org.onosproject.openstacknode.impl;
17
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;
24import org.onosproject.openstacknode.api.NodeState;
25import org.onosproject.openstacknode.api.OpenstackNode;
26import org.onosproject.openstacknode.api.OpenstackNode.NodeType;
27
28import static org.onosproject.net.Device.Type.SWITCH;
29
30/**
31 * Provides a set of test OpenstackNode parameters for use with OpenstackNode related tests.
32 */
33abstract 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) {
sanghof8164112017-07-14 14:33:16 +090049 return org.onosproject.openstacknode.impl.DefaultOpenstackNode.builder()
Hyunsun Moon090d77d2017-07-05 17:48:37 +090050 .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) {
sanghof8164112017-07-14 14:33:16 +090062 return org.onosproject.openstacknode.impl.DefaultOpenstackNode.builder()
Hyunsun Moon090d77d2017-07-05 17:48:37 +090063 .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}