blob: abb1643aed0ce93103d3f155ccfc834acc48d5e5 [file] [log] [blame]
Jian Li4eb0cf42020-12-19 04:01:49 +09001/*
2 * Copyright 2020-present Open Networking Foundation
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 */
16package org.onosproject.kubevirtnode.api;
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;
24
25import static org.onosproject.net.Device.Type.SWITCH;
26
27/**
28 * Provides a set of test KubevirtNode parameters for use with KubevirtNode related tests.
29 */
30public abstract class KubevirtNodeTest {
31
32 public static Device createDevice(long devIdNum) {
33 return new DefaultDevice(new ProviderId("of", "foo"),
34 DeviceId.deviceId(String.format("of:%016d", devIdNum)),
35 SWITCH,
36 "manufacturer",
37 "hwVersion",
38 "swVersion",
39 "serialNumber",
40 new ChassisId(1));
41 }
42
43 public static KubevirtNode createNode(String hostname, KubevirtNode.Type type,
44 Device intgBridge, IpAddress ipAddr,
45 KubevirtNodeState state) {
46 return DefaultKubevirtNode.builder()
47 .hostname(hostname)
48 .type(type)
49 .intgBridge(intgBridge.id())
50 .managementIp(ipAddr)
51 .dataIp(ipAddr)
52 .state(state)
53 .build();
54 }
55}