blob: 96d3b4ed44a4da78017e1cb7573678efbddb343b [file] [log] [blame]
Yuta HIGUCHI8c6e1942018-04-05 13:40:51 -07001/*
2 * Copyright 2018-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.odtn.behaviour;
17
Yuta HIGUCHIe4702af2018-05-18 17:17:34 -070018import static com.google.common.base.Preconditions.checkNotNull;
19
Yuta HIGUCHI8c6e1942018-04-05 13:40:51 -070020import java.util.List;
21
22import org.onosproject.net.device.DeviceDescriptionDiscovery;
23import org.onosproject.net.device.PortDescription;
24
Yuta HIGUCHI44e3a612018-05-11 15:03:39 -070025import com.google.common.annotations.Beta;
26
Yuta HIGUCHI8c6e1942018-04-05 13:40:51 -070027/**
28 * DeviceDescriptionDiscovery used in ODTN.
29 *
Yuta HIGUCHIe9df0c42018-05-07 16:24:42 -070030 * Just declaring certain Annotations will be required.
Yuta HIGUCHI8c6e1942018-04-05 13:40:51 -070031 */
Yuta HIGUCHI44e3a612018-05-11 15:03:39 -070032@Beta
Yuta HIGUCHI8c6e1942018-04-05 13:40:51 -070033public interface OdtnDeviceDescriptionDiscovery
34 extends DeviceDescriptionDiscovery {
35
36 /**
Yuta HIGUCHI44e3a612018-05-11 15:03:39 -070037 * Annotations key intended for a Port, which stores OpenConfig component name.
Yuta HIGUCHIe4702af2018-05-18 17:17:34 -070038 * <p>
39 * Optional; only for purpose of debugging.
Yuta HIGUCHI8c6e1942018-04-05 13:40:51 -070040 */
41 String OC_NAME = "oc-name";
42
43 /**
Yuta HIGUCHI44e3a612018-05-11 15:03:39 -070044 * Annotations key intended for a Port, which stores OpenConfig component type.
Yuta HIGUCHIe4702af2018-05-18 17:17:34 -070045 * <p>
46 * Optional; only for purpose of debugging.
Yuta HIGUCHI8c6e1942018-04-05 13:40:51 -070047 */
48 String OC_TYPE = "oc-type";
49
Yuta HIGUCHI44e3a612018-05-11 15:03:39 -070050 /**
51 * Annotations key intended for a Port,
52 * which stores string identifier used to
Yuta HIGUCHI4b11fab2018-05-15 13:03:29 -070053 * logically group Ports corresponding to a transponder, etc.
Yuta HIGUCHI44e3a612018-05-11 15:03:39 -070054 */
Yuta HIGUCHI4b11fab2018-05-15 13:03:29 -070055 String CONNECTION_ID = "odtn-connection-id";
Yuta HIGUCHI44e3a612018-05-11 15:03:39 -070056
Yuta HIGUCHIe4702af2018-05-18 17:17:34 -070057 /**
58 * Annotations key for a Port,
59 * which describes role of the port annotated.
60 * Value must be one of “client” or “line”.
61 *
62 * @see OdtnPortType
63 */
64 String PORT_TYPE = "odtn-port-type";
65
66 enum OdtnPortType {
67 CLIENT("client"),
68 LINE("line");
69
70 private final String value;
71
72 OdtnPortType(String value) {
73 this.value = value;
74 }
75
76 /**
77 * Returns the value to be used as Annotations value.
78 * @return value
79 */
80 public String value() {
81 return value;
82 }
83
84 /**
85 * Returns the corresponding enum value from a string value.
86 * @param value to look up
87 * @return OdtnPortType
88 *
89 * @throws NullPointerException if {@code value} was null
90 * @throws IllegalArgumentException if non-OdtnPortValue was given
91 */
92 public static OdtnPortType fromValue(String value) {
93 checkNotNull(value);
94 if (value.equalsIgnoreCase(CLIENT.value())) {
95 return CLIENT;
96 } else if (value.equalsIgnoreCase(LINE.value())) {
97 return LINE;
98 } else {
99 throw new IllegalArgumentException("Invalid value: " + value);
100 }
101 }
102 }
Yuta HIGUCHI44e3a612018-05-11 15:03:39 -0700103
104 /**
105 * OpenConfig component property name to store,
106 * decimal integer index to be used when creating PortNumber.
Yuta HIGUCHIe4702af2018-05-18 17:17:34 -0700107 * <p>
108 * Optional if providing original implementation other than
109 * odtn-driver supplied driver.
Yuta HIGUCHI44e3a612018-05-11 15:03:39 -0700110 */
111 String ONOS_PORT_INDEX = "onos-index";
112
Yuta HIGUCHI8c6e1942018-04-05 13:40:51 -0700113 // overriding just to make checkstyle happy
114 @Override
115 List<PortDescription> discoverPortDetails();
116
117}