blob: 87266734f867b5fec70913061de3a6d6bdc39e64 [file] [log] [blame]
kmcpeakeb172d5f2015-12-10 11:30:43 +00001/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14package org.onosproject.provider.snmp.device.impl;
15
16import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.I_Device;
17import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0._OidRegistry;
18import com.btisystems.pronx.ems.core.model.ClassRegistry;
19import com.btisystems.pronx.ems.core.model.IClassRegistry;
20import com.btisystems.pronx.ems.core.model.NetworkDevice;
21import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
kmcpeakeb172d5f2015-12-10 11:30:43 +000022import org.onosproject.net.device.DefaultDeviceDescription;
23import org.onosproject.net.device.DeviceDescription;
24import org.slf4j.Logger;
kmcpeakeb172d5f2015-12-10 11:30:43 +000025import org.snmp4j.smi.OID;
26
Marc De Leenheerc662d322016-02-18 16:05:10 -080027import java.io.IOException;
28import java.util.Arrays;
29
30import static org.slf4j.LoggerFactory.getLogger;
31
kmcpeakeb172d5f2015-12-10 11:30:43 +000032/**
33 * A vendor-specific implementation supporting BTI Systems BTI-7000 equipment.
Andrea Campanella3eca4a82016-02-10 17:35:14 -080034 * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture.
kmcpeakeb172d5f2015-12-10 11:30:43 +000035 */
Andrea Campanella3eca4a82016-02-10 17:35:14 -080036@Deprecated
kmcpeakeb172d5f2015-12-10 11:30:43 +000037public class Bti7000DeviceDescriptionProvider implements SnmpDeviceDescriptionProvider {
38 private final Logger log = getLogger(getClass());
39 protected static final IClassRegistry CLASS_REGISTRY =
40 new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class);
41 private static final String UNKNOWN = "unknown";
42
43 @Override
44 public DeviceDescription populateDescription(ISnmpSession session, DeviceDescription description) {
45 NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
46 session.getAddress().getHostAddress());
47 try {
48 session.walkDevice(networkDevice, Arrays.asList(new OID[]{
49 CLASS_REGISTRY.getClassToOidMap().get(
50 com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class)}));
51
52 com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System systemTree =
53 (com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System)
54 networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get(
55 com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class));
56 if (systemTree != null) {
57 String[] systemComponents = systemTree.getSysDescr().split(";");
58 return new DefaultDeviceDescription(description.deviceUri(), description.type(),
59 systemComponents[0], systemComponents[2], systemComponents[3],
Marc De Leenheerc662d322016-02-18 16:05:10 -080060 UNKNOWN, description.chassisId(), description.annotations());
kmcpeakeb172d5f2015-12-10 11:30:43 +000061 }
62 } catch (IOException ex) {
63 log.error("Error reading details for device {}.", session.getAddress(), ex);
64 }
65 return description;
66 }
67
68}