blob: d93f6523963ce5fbaa596ae9d30ab29888e9adb3 [file] [log] [blame]
Rohit Singh35fd94c2019-11-11 16:38:18 +05301/*
2 * Copyright 2019-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 *
16 * This Work is contributed by Sterlite Technologies
17 */
18package org.onosproject.drivers.odtn;
19
20import org.onlab.osgi.DefaultServiceDirectory;
21import org.onosproject.net.DeviceId;
22import org.onosproject.net.PortNumber;
23import org.onosproject.net.device.DeviceService;
24import org.slf4j.Logger;
25import org.slf4j.LoggerFactory;
26
27/*
28 * Driver Implementation of the BitErrorRateConfig for Cassini terminal devices.
29 */
30public class CassiniBitErrorRateState extends OpenconfigBitErrorRateState {
31
32 private static final Logger log = LoggerFactory.getLogger(CassiniBitErrorRateState.class);
33
34 private static final String OC_NAME = "oc-name";
35 private static final String PORT_NOT_PRESENT = "Port is not present";
36
37 /*
38 * This method is used for getting Cassini Component name.
39 * from DeviceService port annotations by key ("oc-name")
40 *
41 * @param deviceId the device identifier
42 * @param port the port identifier
43 * @return String value representing cassini component name
44 */
45 @Override
46 protected String ocName(DeviceId deviceId, PortNumber port) {
47 DeviceService deviceService = DefaultServiceDirectory.getService(DeviceService.class);
48 if (deviceService.getPort(deviceId, port) == null) {
49 throw new IllegalArgumentException(PORT_NOT_PRESENT);
50 }
51 return deviceService.getPort(deviceId, port).annotations().value(OC_NAME);
52 }
53}