blob: 1bc666f7068804352bbc54e7e341a90c5a270905 [file] [log] [blame]
Hyunsun Moon2c3f0ee2017-04-06 16:47:21 +09001/*
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 */
16package org.opencord.cordvtn.impl;
17
18import org.onlab.packet.ChassisId;
19import org.onlab.packet.Ip4Address;
20import org.onlab.packet.TpPort;
21import org.onosproject.net.DefaultAnnotations;
22import org.onosproject.net.DefaultDevice;
23import org.onosproject.net.DefaultPort;
24import org.onosproject.net.Device;
25import org.onosproject.net.DeviceId;
26import org.onosproject.net.Port;
27import org.onosproject.net.PortNumber;
28import org.onosproject.net.provider.ProviderId;
29import org.opencord.cordvtn.api.net.CidrAddr;
30import org.opencord.cordvtn.api.node.CordVtnNode;
31import org.opencord.cordvtn.api.node.CordVtnNodeState;
32import org.opencord.cordvtn.api.node.SshAccessInfo;
33
34import static org.onosproject.net.AnnotationKeys.PORT_NAME;
35import static org.onosproject.net.Device.Type.SWITCH;
36
37/**
38 * Provides a set of test CordVtnNode parameters for use with CordVtnNode related tests.
39 */
40public abstract class CordVtnNodeTest {
41
42 public static final SshAccessInfo TEST_SSH_INFO = new SshAccessInfo(
43 Ip4Address.valueOf("192.168.0.1"),
44 TpPort.tpPort(22),
45 "root",
46 "/root/.ssh/id_rsa");
47 public static final CidrAddr TEST_CIDR_ADDR = CidrAddr.valueOf("192.168.0.1/24");
48 public static final String TEST_DATA_IFACE = "eth0";
49 public static final String TEST_VXLAN_IFACE = "vxlan";
50
51 public static Device createDevice(long devIdNum) {
52 return new DefaultDevice(new ProviderId("of", "foo"),
53 DeviceId.deviceId(String.format("of:%016d", devIdNum)),
54 SWITCH,
55 "manufacturer",
56 "hwVersion",
57 "swVersion",
58 "serialNumber",
59 new ChassisId(1));
60 }
61
62 public static Port createPort(Device device, long portNumber, String portName) {
63 return new DefaultPort(device,
64 PortNumber.portNumber(portNumber),
65 true,
66 DefaultAnnotations.builder().set(PORT_NAME, portName).build());
67 }
68
69 public static CordVtnNode createNode(String hostname, Device device, CordVtnNodeState state) {
70 return DefaultCordVtnNode.builder()
71 .hostname(hostname)
72 .hostManagementIp(TEST_CIDR_ADDR)
73 .localManagementIp(TEST_CIDR_ADDR)
74 .dataIp(TEST_CIDR_ADDR)
75 .integrationBridgeId(device.id())
76 .dataInterface(TEST_DATA_IFACE)
77 .sshInfo(TEST_SSH_INFO)
78 .state(state)
79 .build();
80 }
81}