2 * Copyright © 2016 AT&T and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.inventory;
10 import static java.util.Objects.requireNonNull;
11 import static org.opendaylight.transportpce.inventory.utils.StringUtils.getCurrentTimestamp;
12 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareDashString;
13 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareEmptyString;
15 import java.sql.Connection;
16 import java.sql.PreparedStatement;
17 import java.sql.ResultSet;
18 import java.sql.SQLException;
19 import java.util.Optional;
20 import java.util.concurrent.ExecutionException;
21 import javax.sql.DataSource;
22 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
23 import org.opendaylight.transportpce.common.Timeouts;
24 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
25 import org.opendaylight.transportpce.inventory.query.Queries;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.CpSlots;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.external.links.ExternalLink;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.internal.links.InternalLink;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.ConnectionMap;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Degree;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Info;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Protocols;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.physical.links.PhysicalLink;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelf.Slots;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelves.Shelves;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.Interface1;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.ethernet.container.EthernetBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.Protocols1;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.PortConfig;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.nbr.list.IfName;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.och.container.OchBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.ots.container.OtsBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.attributes.Tcm;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.container.OduBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.ExpMsi;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.RxMsi;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.TxMsi;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.otu.container.OtuBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.bridge.port.attr.RstpBridgePortTable;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.container.rstp.RstpBridgeInstance;
57 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
58 import org.slf4j.Logger;
59 import org.slf4j.LoggerFactory;
62 public class INode221 {
63 private static final Logger LOG = LoggerFactory.getLogger(INode221.class);
65 private final DataSource dataSource;
66 private final DeviceTransactionManager deviceTransactionManager;
68 public INode221(DataSource dataSource, DeviceTransactionManager deviceTransactionManager) {
69 this.dataSource = dataSource;
70 this.deviceTransactionManager = deviceTransactionManager;
73 public boolean addNode(String deviceId) {
75 InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
76 Optional<Info> infoOpt =
77 deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, infoIID,
78 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
80 if (infoOpt.isPresent()) {
81 deviceInfo = infoOpt.get();
83 LOG.warn("Could not get device info from DataBroker");
86 boolean sqlResult = false;
87 String query = Queries.getQuery().deviceInfoInsert().get();
88 LOG.info("Running {} query ", query);
89 try (Connection connection = dataSource.getConnection();
90 PreparedStatement preparedStatement = connection.prepareStatement(query)) {
91 Object[] prepareParameters = prepareDeviceInfoParameters(deviceInfo);
92 for (int i = 0; i < prepareParameters.length; i++) {
93 LOG.debug("Parameter {} has value {}", i + 1, prepareParameters[i]);
94 preparedStatement.setObject(i + 1, prepareParameters[i]);
97 int executeUpdate = preparedStatement.executeUpdate();
98 LOG.info("{} entries were added", executeUpdate);
101 LOG.info("iNode AddNode call complete");
102 getRoadmShelves(deviceId);
103 LOG.info("iNode getRoadmShelves call complete");
104 getCircuitPacks(deviceId);
105 LOG.debug("iNode getCircuitPacks call complete");
107 LOG.debug("iNode persist interfaces call");
108 persistDevInterfaces(deviceId, connection);
109 LOG.debug("iNode persist interfaces call complete");
111 LOG.debug("iNode persist interfaces call");
112 persistDevInterfaces(deviceId, connection);
113 LOG.debug("iNode persist interfaces call complete");
115 LOG.debug("iNode persist protocols call");
116 persistDevProtocols(deviceId, connection);
117 LOG.debug("iNode persist protocols call complete");
119 // LOG.debug("iNode persist wavelength map call");
120 // persistDevWavelengthMap(deviceId, connection);
121 // LOG.debug("iNode persist wavelength map call complete");
123 LOG.debug("iNode persist internal links map call");
124 persistDevInternalLinks(deviceId, connection);
125 LOG.debug("iNode persist internal links map call complete");
127 LOG.debug("iNode persist Physical links map call");
128 persistDevPhysicalLinks(deviceId, connection);
129 LOG.debug("iNode persist Physical links map call complete");
131 LOG.debug("iNode persist External links map call");
132 persistDevExternalLinks(deviceId, connection);
133 LOG.debug("iNode persist External links map call complete");
135 LOG.debug("iNode persist degree map call");
136 persistDevDegree(deviceId, connection);
137 LOG.debug("iNode persist degree map call complete");
139 LOG.debug("iNode persist srg map call");
140 persistDevSrg(deviceId, connection);
141 LOG.debug("iNode persist srg map call complete");
143 LOG.debug("iNode persist Roadm Connections call");
144 persistDevRoadmConnections(deviceId, connection);
145 LOG.debug("iNode persist Roadm Connections call complete");
147 LOG.debug("iNode persist Connection Map call");
148 persistDevConnectionMap(deviceId, connection);
149 LOG.debug("iNode persist Connection Map call complete");
151 } catch (SQLException | InterruptedException | ExecutionException e) {
152 LOG.error("Something wrong when storing node into DB", e);
157 public boolean nodeExists(String nodeId) {
158 String selectTableSQL = "select count(*) node_exists from inv_dev_info where node_id = ?";
160 LOG.info("Checking if {} exists in DB", nodeId);
161 try (Connection connection = dataSource.getConnection();
162 PreparedStatement preparedStmt = connection.prepareStatement(selectTableSQL)) {
163 preparedStmt.setString(1, nodeId);
164 try (ResultSet rs = preparedStmt.executeQuery()) {
166 nodeExists = rs.getInt("node_exists");
167 LOG.debug("Found {} devices matching {}", nodeExists, nodeId);
170 } catch (SQLException e) {
171 LOG.error("Something wrong when fetching node in DB", e);
173 return nodeExists == 0 ? false : true;
176 public void getRoadmShelves(String nodeId) throws InterruptedException, ExecutionException {
177 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
178 Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
179 LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT,
180 Timeouts.DEVICE_READ_TIMEOUT_UNIT);
182 LOG.info("Shelves size {}", deviceObject.get().getShelves().size());
183 try (Connection connection = requireNonNull(dataSource.getConnection())) {
184 for (int i = 0; i < deviceObject.get().getShelves().size(); i++) {
185 Shelves shelve = deviceObject.get().getShelves().get(i);
186 String shelfName = shelve.getShelfName();
188 LOG.info("Getting Shelve Details of {}", shelfName);
189 if (shelve.getSlots() != null) {
190 LOG.info("Slot Size {} ", shelve.getSlots().size());
191 persistShelveSlots(nodeId, shelve, connection);
193 LOG.info("No Slots for shelf {}", shelfName);
197 persistShelves(nodeId, connection, shelve);
199 } catch (SQLException e1) {
200 LOG.error("Something wrong when fetching ROADM shelves in DB", e1);
204 public void getCircuitPacks(String nodeId) throws InterruptedException, ExecutionException {
205 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
206 Optional<OrgOpenroadmDevice> deviceObject =
207 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
208 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
209 if (!deviceObject.isPresent()) {
210 LOG.warn("Device object {} was not found", nodeId);
213 LOG.info("Circuit pack size {}", deviceObject.get().getCircuitPacks().size());
215 try (Connection connection = requireNonNull(dataSource.getConnection())) {
216 for (int i = 0; i < deviceObject.get().getCircuitPacks().size(); i++) {
217 CircuitPacks cp = deviceObject.get().getCircuitPacks().get(i);
219 if (cp.getCpSlots() != null) {
220 persistCircuitPacksSlots(nodeId, cp, connection);
222 LOG.info("Everything {}", cp);
223 LOG.info("CP is {}", cp);
225 persistPorts(cp, connection);
227 persistCircuitPacks(nodeId, connection, cp);
229 } catch (SQLException e1) {
230 LOG.error("Something wrong when fetching Circuit Packs in DB", e1);
234 private void persistCircuitPacks(String nodeId, Connection connection, CircuitPacks cp) {
235 Object[] parameters = prepareCircuitPacksParameters(nodeId, cp);
236 String query = Queries.getQuery().deviceCircuitPackInsert().get();
237 LOG.info("Running {} query ", query);
238 try (PreparedStatement stmt = connection.prepareStatement(query)) {
239 for (int j = 0; j < parameters.length; j++) {
240 stmt.setObject(j + 1, parameters[j]);
243 stmt.clearParameters();
244 } catch (SQLException e) {
245 LOG.error("Something wrong when storing Circuit Packs in DB", e);
249 private void persistShelves(String nodeId, Connection connection, Shelves shelve) {
250 Object[] shelvesParameter = prepareShelvesParameters(nodeId, shelve);
251 String query = Queries.getQuery().deviceShelfInsert().get();
252 LOG.info("Running {} query ", query);
253 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
254 for (int j = 0; j < shelvesParameter.length; j++) {
255 preparedStmt.setObject(j + 1, shelvesParameter[j]);
257 preparedStmt.execute();
258 preparedStmt.clearParameters();
259 } catch (SQLException e) {
260 LOG.error("Something wrong when storing shelves in DB", e);
264 private void persistShelveSlots(String nodeId, Shelves shelves, Connection connection) {
265 String startTimetampStr = getCurrentTimestamp();
266 for (int i = 0; i < shelves.getSlots().size(); i++) {
267 Slots slot = shelves.getSlots().get(i);
268 LOG.info("Getting Slot Details of {}", slot.getSlotName());
269 Object[] parameters = new Object[]{nodeId,
270 shelves.getShelfName(),
273 slot.getProvisionedCircuitPack(),
277 String query = Queries.getQuery().deviceShelfSlotInsert().get();
278 LOG.info("Running {} query ", query);
279 try (PreparedStatement stmt = connection.prepareStatement(query)) {
280 for (int j = 0; j < parameters.length; j++) {
281 stmt.setObject(j + 1, parameters[j]);
284 stmt.clearParameters();
285 } catch (SQLException e) {
286 LOG.error("Something wrong when storing shelves slots in DB", e);
292 private void persistCircuitPacksSlots(String nodeId, CircuitPacks circuitPacks, Connection connection) {
293 String startTimetampStr = getCurrentTimestamp();
294 for (int i = 0; i < circuitPacks.getCpSlots().size(); i++) {
295 CpSlots cpSlot = circuitPacks.getCpSlots().get(i);
297 Object[] parameters = new Object[]{nodeId,
298 circuitPacks.getCircuitPackName(),
299 cpSlot.getSlotName(),
301 cpSlot.getProvisionedCircuitPack(),
305 String query = Queries.getQuery().deviceCPSlotInsert().get();
306 LOG.info("Running {} query ", query);
307 try (PreparedStatement stmt = connection.prepareStatement(query)) {
308 for (int j = 0; j < parameters.length; j++) {
309 stmt.setObject(j + 1, parameters[j]);
312 stmt.clearParameters();
313 } catch (SQLException e) {
314 LOG.error("Something wrong when storing Cirtcuits Packs slots in DB", e);
319 private void persistPorts(CircuitPacks circuitPacks, Connection connection) {
320 LOG.warn("Ports are not persisted yet");
325 * Prepares parameters for device insert query.
327 * @param deviceInfo device info
328 * @return Object Object
330 private static Object[] prepareDeviceInfoParameters(Info deviceInfo) {
331 String startTimetampStr = getCurrentTimestamp();
332 //Integer maxNumBin15minHistoricalPm = null;
333 //Integer maxNumBin24hourHistoricalPm = null;
334 //String serialId = "";
336 String nodeId = prepareDashString(deviceInfo.getNodeId());
337 Long nodeNumber = deviceInfo.getNodeNumber().toJava();
338 Integer nodeTypeEnu = deviceInfo.getNodeType().getIntValue();
339 String clli = prepareDashString(deviceInfo.getClli());
340 String vendor = prepareDashString(deviceInfo.getVendor());
341 String model = prepareDashString(deviceInfo.getModel());
342 String ipAddress = prepareDashString(deviceInfo.getIpAddress().getIpv4Address().getValue());
343 String prefixLength = prepareDashString(deviceInfo.getPrefixLength());
344 String defaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
345 Integer sourceEnum = deviceInfo.getSource().getIntValue();
346 String currentIpAddress = prepareDashString(deviceInfo.getCurrentIpAddress().getIpv4Address().getValue());
347 String currentPrefixLength = prepareDashString(deviceInfo.getCurrentPrefixLength());
348 String currentDefaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
349 String macAddress = prepareDashString(deviceInfo.getMacAddress().getValue());
350 String softwareVersion = prepareDashString(deviceInfo.getSoftwareVersion());
351 String openroadmVersion = "2.2.1";
352 String template = prepareDashString(deviceInfo.getTemplate());
353 String currentDatetime = prepareDashString(deviceInfo.getCurrentDatetime().getValue());
355 (deviceInfo.getGeoLocation() != null ? prepareDashString(deviceInfo.getGeoLocation().getLatitude()) : "");
356 String geoLongitude =
357 (deviceInfo.getGeoLocation() != null ? prepareDashString(deviceInfo.getGeoLocation().getLongitude()) : "");
358 String maxDegrees = prepareDashString(deviceInfo.getMaxDegrees()); // max_degrees
359 String maxSrgs = prepareDashString(deviceInfo.getMaxSrgs()); //max_srgs
360 String swVersion = prepareDashString(deviceInfo.getSoftwareVersion()); //sw_version
361 String swValidationTimer = prepareDashString(""); //sw_validation_timer
362 String activationDateTime = prepareDashString(""); //activation_date_time
363 /*jsonDevInfo = JsonStringBuilder.getDevInfoJson().replace("$$NODE-ID$$",nodeId)
364 .replace("$$NODE-NUMBER$$", nodeNumber)
365 .replace("$$NODE-TYPE$$",nodeType)
366 .replace("$$CLLI$$",clli)
367 .replace("$$VENDOR$$",vendor)
368 .replace("$$MODEL$$",model)
369 .replace("$$SERIAL-ID$$",serialId)
370 .replace("$$IPADDRESS$$",ipAddress)
371 .replace("$$PREFIX-LENGTH$$",prefixLength)
372 .replace("$$DEFAULTGATEWAY$$",defaultGateway)
373 .replace("$$SOURCE$$",String.valueOf(source))
374 .replace("$$CURRENT-IPADDRESS$$",currentIpAddress)
375 .replace("$$CURRENT-PREFIX-LENGTH$$",currentPrefixLength)
376 .replace("$$CURRENT-DEFAULTGATEWAY$$",currentDefailtGateway)
377 .replace("$$MACADDRESS$$",macAddress)
378 .replace("$$SOFTWAREVERSION$$",softwareVersion)
379 .replace("$$OPENROADM-VERSION$$",openroadmVersion)
380 .replace("$$TEMPLATE$$",template)
381 .replace("$$CURRENT-DATETIME$$",currentDatetime)
382 .replace("$$LATITUDE$$",latitude)
383 .replace("$$LONGITUDE$$",longitude)
384 .replace("$$MAX-DEGREES$$",maxDegrees)
385 .replace("$$MAX-SRGS$$",maxSrgs)
386 .replace("$$MAX-NUM-BIN-15MIN-HISTORICAL-PM$$",prepareDashString(""))
387 .replace("$$MAX-NUM-BIN-24HOUR-HISTORICAL-PM$$",prepareDashString(""))
388 .replace("$$SW-VERSION$$",swVersion)
389 .replace("$$SW-VALIDATION-TIMER$$",swValidationTimer)
390 .replace("$$ACTIVATION-DATE-TIME$$",activationDateTime);*/
408 currentDefaultGateway,
418 //maxNumBin15minHistoricalPm,
419 //maxNumBin24hourHistoricalPm,
430 private static Object[] prepareShelvesParameters(String nodeId, Shelves shelve) {
431 String startTimestamp = getCurrentTimestamp();
433 return new Object[]{nodeId,
434 shelve.getShelfName(),
435 shelve.getShelfType(),
437 shelve.getShelfPosition(),
438 (shelve.getAdministrativeState() == null ? null : shelve.getAdministrativeState().getIntValue()),
441 shelve.getSerialId(),
443 shelve.getProductCode(),
444 (shelve.getManufactureDate() == null ? null : shelve.getManufactureDate().getValue()),
446 shelve.getHardwareVersion(),
447 (shelve.getOperationalState() == null ? null : shelve.getOperationalState().getIntValue()),
448 (shelve.getEquipmentState() == null ? null : shelve.getEquipmentState().getIntValue()),
449 (shelve.getDueDate() == null ? null : shelve.getDueDate().getValue()),
455 private static Object[] prepareCPPortsParameters(String nodeId, CircuitPacks circuitPacks, Ports cpPort) {
457 String circuitPackName = circuitPacks.getCircuitPackName();
458 String portName = cpPort.getPortName();
459 String portType = cpPort.getPortType();
460 String portQualEnu = String.valueOf(cpPort.getPortQual().getIntValue());
461 String portWavelengthTypeEnu = String.valueOf(cpPort.getPortWavelengthType().getIntValue());
462 String portDirectionEnu = String.valueOf(cpPort.getPortDirection().getIntValue());
463 String label = cpPort.getLabel();
464 String circuitId = cpPort.getCircuitId();
465 String administrativeStateEnu =
466 (cpPort.getAdministrativeState() == null ? "" :
467 String.valueOf(cpPort.getAdministrativeState().getIntValue()));
468 String operationalStateEnu =
469 (cpPort.getOperationalState() == null ? "" : String.valueOf(cpPort.getOperationalState().getIntValue()));
470 String logicalConnectionPoint = cpPort.getLogicalConnectionPoint();
471 String partnerPortCircuitPackName = cpPort.getPartnerPort().getCircuitPackName();
472 String partnerPortPortName = cpPort.getPartnerPort().getPortName().toString();
473 String parentPortCircuitPackName = cpPort.getParentPort().getCircuitPackName();
474 String parentPortPortName = cpPort.getParentPort().getPortName().toString();
475 String roadmPortPortPowerCapabilityMinRx = cpPort.getRoadmPort().getPortPowerCapabilityMinRx().toString();
476 String roadmPortPortPowerCapabilityMinTx = cpPort.getRoadmPort().getPortPowerCapabilityMinTx().toString();
477 String roadmPortPortPowerCapabilityMaxRx = cpPort.getRoadmPort().getPortPowerCapabilityMaxRx().toString();
478 String roadmPortPortPowerCapabilityMaxTx = cpPort.getRoadmPort().getPortPowerCapabilityMaxTx().toString();
479 //String roadmPortCapableWavelengths = "";
480 //String roadmPortAvailableWavelengths = "";
481 //String roadmPortUsedWavelengths = "";
482 String transponderPortPortPowerCapabilityMinRx =
483 cpPort.getTransponderPort().getPortPowerCapabilityMinRx().toString();
484 String transponderPortPortPowerCapabilityMinTx =
485 cpPort.getTransponderPort().getPortPowerCapabilityMinTx().toString();
486 String transponderPortPortPowerCapabilityMaxRx =
487 cpPort.getTransponderPort().getPortPowerCapabilityMaxRx().toString();
488 String transponderPortPortPowerCapabilityMaxTx =
489 cpPort.getTransponderPort().getPortPowerCapabilityMaxTx().toString();
490 //String transponderPortCapableWavelengths = "";
491 String otdrPortLaunchCableLength = cpPort.getOtdrPort().getLaunchCableLength().toString();
492 String otdrPortPortDirection = String.valueOf(cpPort.getOtdrPort().getPortDirection().getIntValue());
493 //String ilaPortPortPowerCapabilityMixRx = "";
494 //String ilaPortPortPowerCapabilityMixTx = "";
495 //String ilaPortPortPowerCapabilityMaxRx = "";
496 //String ilaPortPortPowerCapabilityMaxTx = "";
498 String startTimestamp = getCurrentTimestamp();
500 return new Object[]{nodeId,
505 portWavelengthTypeEnu,
509 administrativeStateEnu,
511 logicalConnectionPoint,
512 partnerPortCircuitPackName,
514 parentPortCircuitPackName,
516 roadmPortPortPowerCapabilityMinRx,
517 roadmPortPortPowerCapabilityMinTx,
518 roadmPortPortPowerCapabilityMaxRx,
519 roadmPortPortPowerCapabilityMaxTx,
520 //roadmPortCapableWavelengths,
521 //roadmPortAvailableWavelengths,
522 //roadmPortUsedWavelengths,
524 transponderPortPortPowerCapabilityMinRx,
525 transponderPortPortPowerCapabilityMinTx,
526 transponderPortPortPowerCapabilityMaxRx,
527 transponderPortPortPowerCapabilityMaxTx,
528 //transponderPortCapableWavelengths,
530 otdrPortLaunchCableLength,
531 otdrPortPortDirection,
532 //ilaPortPortPowerCapabilityMixRx,
533 //ilaPortPortPowerCapabilityMixTx,
534 //ilaPortPortPowerCapabilityMaxRx,
535 //ilaPortPortPowerCapabilityMaxTx,
543 private static Object[] prepareCircuitPacksParameters(String nodeId, CircuitPacks cpack) {
544 String startTimestamp = getCurrentTimestamp();
545 return new Object[]{nodeId,
546 cpack.getCircuitPackName(),
547 cpack.getCircuitPackType(),
548 cpack.getCircuitPackProductCode(),
549 (cpack.getAdministrativeState() == null ? "" : cpack.getAdministrativeState().getIntValue()),
554 cpack.getProductCode(),
555 (cpack.getManufactureDate() == null ? "" : cpack.getManufactureDate().getValue()),
557 cpack.getHardwareVersion(),
558 prepareEmptyString(cpack.getOperationalState().getIntValue()),
559 cpack.getCircuitPackCategory().getType().getName(),
560 cpack.getCircuitPackCategory().getExtension(),
561 (cpack.getEquipmentState() == null ? "" : cpack.getEquipmentState().getIntValue()),
562 cpack.getCircuitPackMode(),
566 prepareEmptyString(cpack.getDueDate()),
567 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
568 ((cpack.getParentCircuitPack().getCircuitPackName() == null) ? "" :
569 cpack.getParentCircuitPack().getCircuitPackName())
571 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
572 ((cpack.getParentCircuitPack().getCpSlotName() == null) ? "" :
573 cpack.getParentCircuitPack().getCpSlotName())
580 private void persistCPPorts(String nodeId, Connection connection, CircuitPacks circuitPacks) {
581 for (int i = 0; i < circuitPacks.getPorts().size(); i++) {
582 Object[] cpPortsParameters = prepareCPPortsParameters(nodeId, circuitPacks, circuitPacks.getPorts().get(i));
583 String query = Queries.getQuery().deviceCPPortInsert().get();
584 LOG.info("Running {} query ", query);
585 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
586 for (int j = 0; j < cpPortsParameters.length; j++) {
587 preparedStmt.setObject(j + 1, cpPortsParameters[j]);
589 preparedStmt.execute();
590 preparedStmt.clearParameters();
591 } catch (SQLException e) {
592 LOG.error("Something wrong when storing Cirtcuits Packs Ports in DB", e);
598 private Object[] prepareDevInterfaceParameters(String nodeId, Interface deviceInterface, Connection connection) {
600 int administrativeStateEnu = deviceInterface.getAdministrativeState().getIntValue();
601 int operationalState = deviceInterface.getOperationalState().getIntValue();
602 int ethernetDuplexEnu = -1;
603 int ethernetAutoNegotiationEnu = -1;
604 int maintTestsignalTestpatternEnu = -1;
605 int maintTestsignalTypeEnu = -1;
607 int otuMaintTypeEnu = -1;
608 //int otsFiberTypeEnu = -1;
609 String name = deviceInterface.getName();
610 String description = deviceInterface.getDescription();
611 String type = deviceInterface.getType().getTypeName();
612 String circuitId = deviceInterface.getCircuitId();
613 String supportingInterface = deviceInterface.getSupportingInterface();
614 String supportingCircuitPackName = deviceInterface.getSupportingCircuitPackName();
615 String supportingPort = deviceInterface.getSupportingPort().toString();
616 String ethernetSpeed = "";
617 String ethernetFec = "";
618 String ethernetMtu = "";
619 String ethernetCurrSpeed = "";
620 String ethernetCurrDuplex = "";
621 //String mciMcttpMinFreq = "";
622 //String mciMcttpMaxFreq = "";
623 //String mciMcttpCenterFreq = "";
624 //String mciMcttpSlotWidth = "";
625 //String mciNmcCtpFrequency = "";
626 //String mciNmcCtpWidth = "";
628 //String ochFrequency = "";
629 //String ochWidth = "";
630 //String ochWavelengthNumber = "";
631 String ochModulationFormat = "";
632 String ochTransmitPower = "";
633 String otsSpanLossReceive = "";
634 String otsSpanLossTransmit = "";
635 //String otsIngressSpanLossAgingMargin = "";
636 //String otsEolMaxLoadPin = "";
637 String oduRate = ""; //BUG in following case switch statement ???
638 //String oduFunction = "";
639 String oduMonitoringMode = "";
640 //String oduNoOamFunction = "";
641 String oduProactiveDelayMeasurementEnabled = "";
642 //String oduPoaTribPortNumber = "";
643 //String oduTxSapi = "";
644 //String oduTxDapi = "";
645 //String oduTxOperator = "";
646 //String oduAcceptedSapi = "";
647 //String oduAcceptedDapi = "";
648 //String oduAcceptedOperator = "";
649 //String oduExpectedSapi = "";
650 //String oduExpectedDapi = "";
651 //String oduTimActEnabled = "";
652 //String oduTimDetectMode = "";
653 //String oduDegmIntervals = "";
654 //String oduDegthrPercentage = "";
655 String opuPayloadType = "";
656 String opuRxPayloadType = "";
657 String opuExpPayloadType = "";
658 String opuPayloadInterface = "";
659 String maintTestsignalEnabled = "";
660 String maintTestsignalBiterrors = "";
661 String maintTestsignalBiterrorsterminal = "";
662 String maintTestsignalSyncseconds = "";
663 String maintTestsignalSyncsecondsterminal = "";
665 //String otuTxSapi = "";
666 //String otuTxDapi = "";
667 //String otuTxOperator = "";
668 //String otuAcceptedSapi = "";
669 //String otuAcceptedDapi = "";
670 //String otuAcceptedOperator = "";
671 //String otuExpectedSapi = "";
672 //String otuExpectedDapi = "";
673 //String otuTimActEnabled = "";
674 //String otuTimDetectMode = "";
675 //String otuDegmIntervals = "";
676 //String otuDegthrPercentage = "";
677 String otuMaintLoopbackEnabled = "";
678 //String mtOtuRate = "";
679 //String mtOtuFec = "";
680 //String mtOtuMaintLoopback = "";
681 //String mtOtuEnabled = "";
682 //String mtOtuType = "";
684 switch (deviceInterface.getType().toString()) {
687 //EthernetBuilder ethIfBuilder = new EthernetBuilder();
688 EthernetBuilder ethIfBuilder =
689 new EthernetBuilder(deviceInterface.augmentation(Interface1.class).getEthernet());
690 ethernetSpeed = ethIfBuilder.getSpeed().toString();
691 ethernetFec = ethIfBuilder.getFec().getName();
692 ethernetDuplexEnu = ethIfBuilder.getDuplex().getIntValue();
693 ethernetMtu = ethIfBuilder.getMtu().toString();
694 ethernetAutoNegotiationEnu = ethIfBuilder.getAutoNegotiation().getIntValue();
695 ethernetCurrSpeed = ethIfBuilder.getCurrSpeed();
696 ethernetCurrDuplex = ethIfBuilder.getCurrDuplex();
700 OchBuilder ochIfBuilder = new OchBuilder(deviceInterface.augmentation(
701 org.opendaylight.yang.gen.v1
702 .http.org.openroadm.optical.channel.interfaces.rev161014.Interface1.class)
704 ochRate = ochIfBuilder.getRate().getName();
705 //ochWavelengthNumber = ochIfBuilder.getWavelengthNumber().toString();
706 ochModulationFormat = ochIfBuilder.getModulationFormat().getName();
707 ochTransmitPower = ochIfBuilder.getTransmitPower().toString();
711 OtsBuilder otsIfBuilder = new OtsBuilder(deviceInterface.augmentation(
712 org.opendaylight.yang.gen.v1
713 .http.org.openroadm.optical.transport.interfaces.rev161014.Interface1.class)
715 int otsFiberTypeEnu = otsIfBuilder.getFiberType().getIntValue();
716 otsSpanLossReceive = otsIfBuilder.getSpanLossReceive().toString();
717 otsSpanLossTransmit = otsIfBuilder.getSpanLossTransmit().toString();
721 OduBuilder oduIfBuilder = new OduBuilder(deviceInterface.augmentation(
722 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1.class)
724 oduRate = String.valueOf(oduIfBuilder.getRate());
725 oduMonitoringMode = oduIfBuilder.getMonitoringMode().getName();
726 oduProactiveDelayMeasurementEnabled = oduIfBuilder.isProactiveDelayMeasurementEnabled().toString();
728 persistDevInterfaceTcm(nodeId, name, oduIfBuilder, connection);
729 persistDevInterfaceOtnOduTxMsi(nodeId, name, oduIfBuilder, connection);
730 persistDevInterfaceOtnOduRxMsi(nodeId, name, oduIfBuilder, connection);
731 persistDevInterfaceOtnOduExpMsi(nodeId, name, oduIfBuilder, connection);
733 opuPayloadType = oduIfBuilder.getOpu().getPayloadType();
734 opuRxPayloadType = oduIfBuilder.getOpu().getRxPayloadType();
735 opuExpPayloadType = oduIfBuilder.getOpu().getExpPayloadType();
736 opuPayloadInterface = oduIfBuilder.getOpu().getPayloadInterface();
737 /*persistDevInterfaceOtnOduTxMsi(nodeId,name,oduIfBuilder,connection);
738 persistDevInterfaceOtnOduRxMsi(nodeId,name,oduIfBuilder,connection);
739 persistDevInterfaceOtnOduExpMsi(nodeId,name,oduIfBuilder,connection); */
740 maintTestsignalEnabled = oduIfBuilder.getMaintTestsignal().isEnabled().toString();
741 maintTestsignalTestpatternEnu = oduIfBuilder.getMaintTestsignal().getTestPattern().getIntValue();
742 maintTestsignalTypeEnu = oduIfBuilder.getMaintTestsignal().getType().getIntValue();
743 maintTestsignalBiterrors = oduIfBuilder.getMaintTestsignal().getBitErrors().toString();
744 maintTestsignalBiterrorsterminal = oduIfBuilder.getMaintTestsignal().getBitErrorsTerminal().toString();
745 maintTestsignalSyncseconds = oduIfBuilder.getMaintTestsignal().getSyncSeconds();
746 maintTestsignalSyncsecondsterminal = oduIfBuilder.getMaintTestsignal().getSyncSecondsTerminal();
750 OtuBuilder otuIfBuilder = new OtuBuilder(deviceInterface.augmentation(
751 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1.class)
753 otuRate = otuIfBuilder.getRate().getName();
754 otuFecEnu = otuIfBuilder.getFec().getIntValue();
755 otuMaintLoopbackEnabled = otuIfBuilder.getMaintLoopback().isEnabled().toString();
756 otuMaintTypeEnu = otuIfBuilder.getMaintLoopback().getType().getIntValue();
760 LOG.error("Could not get interface type");
763 String startTimestamp = getCurrentTimestamp();
765 return new Object[]{nodeId,
769 Integer.toString(administrativeStateEnu),
770 Integer.toString(operationalState),
773 supportingCircuitPackName,
777 Integer.toString(ethernetDuplexEnu),
779 Integer.toString(ethernetAutoNegotiationEnu),
784 //mciMcttpCenterFreq,
786 //mciNmcCtpFrequency,
788 "", "", "", "", "", "",
792 //ochWavelengthNumber,
796 //Integer.toString(otsFiberTypeEnu),
800 //otsIngressSpanLossAgingMargin,
809 oduProactiveDelayMeasurementEnabled,
810 //oduPoaTribPortNumber,
816 //oduAcceptedOperator,
822 //oduDegthrPercentage,
823 "", "", "", "", "", "", "", "", "", "", "", "", "",
828 maintTestsignalEnabled,
829 Integer.toString(maintTestsignalTestpatternEnu),
830 Integer.toString(maintTestsignalTypeEnu),
831 maintTestsignalBiterrors,
832 maintTestsignalBiterrorsterminal,
833 maintTestsignalSyncseconds,
834 maintTestsignalSyncsecondsterminal,
836 Integer.toString(otuFecEnu),
842 //otuAcceptedOperator,
848 //otuDegthrPercentage,
849 "", "", "", "", "", "", "", "", "", "", "", "",
850 otuMaintLoopbackEnabled,
851 Integer.toString(otuMaintTypeEnu),
854 //mtOtuMaintLoopback,
864 private static Object[] prepareDevInterfaceTcmParameters(String nodeId, String interfaceName, Tcm tcm) {
867 String layer = tcm.getLayer().toString();
868 int monitoringModeEnu = tcm.getMonitoringMode().getIntValue();
869 String ltcActEnabled = tcm.isLtcActEnabled().toString();
870 String proactiveDelayMeasurementEnabled = tcm.isProactiveDelayMeasurementEnabled().toString();
871 //int tcmDirectionEnu = -1;
872 //int timDetectModeEnu = -1;
873 //String txSapi = "";
874 //String txDapi = "";
875 //String txOperator = "";
876 //String acceptedSapi = "";
877 //String acceptedDapi = "";
878 //String acceptedOperator = "";
879 //String expectedSapi = "";
880 //String expectedDapi = "";
881 //String timActEnabled = "";
882 //String degmIntervals = "";
883 //String degthrPercentage = "";
885 String startTimestamp = getCurrentTimestamp();
887 return new Object[]{nodeId,
890 Integer.toString(monitoringModeEnu),
892 proactiveDelayMeasurementEnabled,
893 //Integer.toString(tcmDirectionEnu),
904 "", "", "", "", "", "", "", "", "",
905 //Integer.toString(timDetectModeEnu),
915 private static Object[] prepareDevInterfaceOtnOduTxMsiParameters(String nodeId, String interfaceName, TxMsi txMsi) {
917 String tribSlot = txMsi.getTribSlot().toString();
918 String odtuType = txMsi.getOdtuType().getTypeName();
919 String tribPort = txMsi.getTribPort().toString();
920 String tribPortPayload = txMsi.getTribPortPayload();
922 String startTimestamp = getCurrentTimestamp();
924 return new Object[]{nodeId,
936 private static Object[] prepareDevInterfaceOtnOduRxMsiParameters(String nodeId, String interfaceName, RxMsi rxMsi) {
938 String tribSlot = rxMsi.getTribSlot().toString();
939 String odtuType = rxMsi.getOdtuType().getTypeName();
940 String tribPort = rxMsi.getTribPort().toString();
941 String tribPortPayload = rxMsi.getTribPortPayload();
943 String startTimestamp = getCurrentTimestamp();
945 return new Object[]{nodeId,
958 private static Object[] prepareDevInterfaceOtnOduExpMsiParameters(String nodeId, String interfaceName,
961 String tribSlot = expMsi.getTribSlot().toString();
962 String odtuType = expMsi.getOdtuType().getTypeName();
963 String tribPort = expMsi.getTribPort().toString();
964 String tribPortPayload = expMsi.getTribPortPayload();
966 String startTimestamp = getCurrentTimestamp();
968 return new Object[]{nodeId,
980 private void persistDevInterfaces(String nodeId, Connection connection) {
982 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
983 Optional<OrgOpenroadmDevice> deviceObject =
984 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
985 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
987 /*InstanceIdentifier<Interface> interfaceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
988 .child(Interface.class);
989 Optional<Interface> interfaceOpt =
990 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, interfaceIID,
991 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); */
993 for (int i = 0; i < deviceObject.get().getInterface().size(); i++) {
994 Interface deviceInterface;
996 deviceInterface = deviceObject.get().getInterface().get(i);
997 /*if (interfaceOpt.isPresent()) {
998 deviceInterface = interfaceOpt.get();
1000 LOG.warn("Could not get interface info");
1003 Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
1005 String query = Queries.getQuery().deviceInterfacesInsert().get();
1006 LOG.info("Running {} query ", query);
1007 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1008 for (int j = 0; j < parameters.length; j++) {
1009 stmt.setObject(j + 1, parameters[j]);
1012 stmt.clearParameters();
1013 } catch (SQLException e) {
1014 LOG.error("Something wrong when storing devices interfaces in DB", e);
1019 private void persistDevProtocols(String nodeId, Connection connection) {
1021 InstanceIdentifier<Protocols> protocolsIID =
1022 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1023 Optional<Protocols> protocolObject =
1024 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1025 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1026 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1027 LOG.error("LLDP subtree is missing");
1030 int adminstatusEnu =
1031 protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getAdminStatus()
1033 String msgTxtInterval =
1034 protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getMsgTxInterval()
1036 String mxgTxHoldMultiplier =
1037 protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getMsgTxHoldMultiplier()
1039 String startTimestamp = getCurrentTimestamp();
1040 persistDevProtocolLldpPortConfig(nodeId, connection);
1041 persistDevProtocolLldpNbrList(nodeId, connection);
1043 Object[] parameters = {nodeId,
1044 Integer.toString(adminstatusEnu),
1046 mxgTxHoldMultiplier,
1051 String query = Queries.getQuery().deviceProtocolInsert().get();
1052 LOG.info("Running {} query ", query);
1053 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1054 for (int j = 0; j < parameters.length; j++) {
1055 stmt.setObject(j + 1, parameters[j]);
1058 stmt.clearParameters();
1059 } catch (SQLException e) {
1060 LOG.error("Something wrong when storing devices protocols in DB", e);
1066 private void persistDevProtocolLldpPortConfig(String nodeId, Connection connection) {
1068 InstanceIdentifier<Protocols> protocolsIID =
1069 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1070 Optional<Protocols> protocolObject =
1071 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1072 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1073 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1074 LOG.error("LLDP subtree is missing");
1077 String startTimestamp = getCurrentTimestamp();
1078 for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().size(); i++) {
1080 PortConfig portConfig =
1081 protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().get(i);
1082 String ifName = portConfig.getIfName();
1083 int adminStatusEnu = portConfig.getAdminStatus().getIntValue();
1085 Object[] parameters = {nodeId,
1087 Integer.toString(adminStatusEnu),
1092 String query = Queries.getQuery().deviceProtocolPortConfigInsert().get();
1093 LOG.info("Running {} query ", query);
1094 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1095 for (int j = 0; j < parameters.length; j++) {
1096 stmt.setObject(j + 1, parameters[j]);
1099 stmt.clearParameters();
1100 } catch (SQLException e) {
1101 LOG.error("Something wrong when storing devices protocols LLDP Port config in DB", e);
1108 private void persistDevProtocolLldpNbrList(String nodeId, Connection connection) {
1110 InstanceIdentifier<Protocols> protocolsIID =
1111 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1112 Optional<Protocols> protocolObject =
1113 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1114 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1115 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1116 LOG.error("LLDP subtree is missing");
1119 String startTimestamp = getCurrentTimestamp();
1120 for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().getIfName()
1124 protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().getIfName().get(i);
1125 String ifName = ifNameObj.getIfName();
1126 String remotesysname = ifNameObj.getRemoteSysName();
1127 String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
1128 String remotemgmtaddress = ifNameObj.getRemoteMgmtAddress().getIpv4Address().toString();
1129 int remoteportidsubtypeEnu = ifNameObj.getRemotePortIdSubType().getIntValue();
1130 String remoteportid = ifNameObj.getRemotePortId();
1131 int remotechassisidsubtypeEnu = ifNameObj.getRemoteChassisIdSubType().getIntValue();
1132 String remotechassisid = ifNameObj.getRemoteChassisId();
1134 Object[] parameters = {nodeId,
1137 remotemgmtaddresssubtype,
1139 Integer.toString(remoteportidsubtypeEnu),
1141 Integer.toString(remotechassisidsubtypeEnu),
1147 String query = Queries.getQuery().deviceProtocolLldpNbrlistInsert().get();
1148 LOG.info("Running {} query ", query);
1149 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1150 for (int j = 0; j < parameters.length; j++) {
1151 stmt.setObject(j + 1, parameters[j]);
1154 stmt.clearParameters();
1155 } catch (SQLException e) {
1156 LOG.error("Something wrong when storing devices protocols LLDP list number in DB", e);
1162 private void persistDevProtocolRstp(String nodeId, Connection connection) {
1164 InstanceIdentifier<Protocols> protocolsIID =
1165 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1166 Optional<Protocols> protocolObject =
1167 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1168 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1169 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1170 LOG.error("LLDP subtree is missing");
1173 String startTimestamp = getCurrentTimestamp();
1174 for (int i = 0; i < protocolObject.get()
1175 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.Protocols1.class)
1176 .getRstp().getRstpBridgeInstance().size(); i++) {
1178 RstpBridgeInstance rstpBridgeInstance = protocolObject.get()
1179 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.Protocols1.class)
1180 .getRstp().getRstpBridgeInstance().get(i);
1181 String bridgeName = rstpBridgeInstance.getBridgeName();
1182 String bridgePriority = rstpBridgeInstance.getRstpConfig().getBridgePriority().toString();
1183 String shutdown = rstpBridgeInstance.getRstpConfig().getShutdown().toString();
1184 String holdTime = rstpBridgeInstance.getRstpConfig().getHoldTime().toString();
1185 String helloTime = rstpBridgeInstance.getRstpConfig().getHelloTime().toString();
1186 String maxAge = rstpBridgeInstance.getRstpConfig().getMaxAge().toString();
1187 String forwardDelay = rstpBridgeInstance.getRstpConfig().getForwardDelay().toString();
1188 String transmitHoldCount = rstpBridgeInstance.getRstpConfig().getTransmitHoldCount().toString();
1189 String rootBridgePort =
1190 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgePort().toString();
1191 String rootPathCost = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootPathCost().toString();
1192 String rootBridgePriority =
1193 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgePriority().toString();
1194 String rootBridgeId = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgeId().toString();
1195 String rootHoldTime = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootHoldTime().toString();
1196 String rootHelloTime = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootHelloTime().toString();
1197 String rootMaxAge = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootMaxAge().toString();
1198 String rootForwardDelay =
1199 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootForwardDelay().toString();
1200 String bridgeId = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getBridgeId().toString();
1201 String topoChangeCount =
1202 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getTopoChangeCount().toString();
1203 String timeSinceTopoChange =
1204 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getTimeSinceTopoChange().toString();
1206 persistDevProtocolRstpBridgePort(nodeId, bridgeName, rstpBridgeInstance, connection);
1207 persistDevProtocolRstpBridgePortAttr(nodeId, bridgeName, rstpBridgeInstance, connection);
1209 Object[] parameters = {nodeId,
1228 timeSinceTopoChange,
1233 String query = Queries.getQuery().deviceProtocolRstpInsert().get();
1234 LOG.info("Running {} query ", query);
1235 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1236 for (int j = 0; j < parameters.length; j++) {
1237 stmt.setObject(j + 1, parameters[j]);
1240 stmt.clearParameters();
1241 } catch (SQLException e) {
1242 LOG.error("Something wrong when storing devices protocols LLDP RSTP", e);
1248 private void persistDevProtocolRstpBridgePort(String nodeId, String bridgeName,
1249 RstpBridgeInstance rstpBridgeInstance, Connection connection) {
1251 String startTimestamp = getCurrentTimestamp();
1252 for (int i = 0; i < rstpBridgeInstance.getRstpConfig().getRstpBridgePortTable().size(); i++) {
1253 RstpBridgePortTable rstpBridgePortTable =
1254 rstpBridgeInstance.getRstpConfig().getRstpBridgePortTable().get(i);
1256 String ifName = rstpBridgePortTable.getIfname();
1257 String cost = rstpBridgePortTable.getCost().toString();
1258 String priority = rstpBridgePortTable.getPriority().toString();
1260 Object[] parameters = {nodeId,
1269 String query = Queries.getQuery().deviceProtocolRstpBridgePortInsert().get();
1270 LOG.info("Running {} query ", query);
1271 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1272 for (int j = 0; j < parameters.length; j++) {
1273 stmt.setObject(j + 1, parameters[j]);
1276 stmt.clearParameters();
1277 } catch (SQLException e) {
1278 LOG.error("Something wrong when storing devices protocols LLDP RSTP bridge port", e);
1284 private void persistDevProtocolRstpBridgePortAttr(String nodeId, String bridgeName,
1285 RstpBridgeInstance rstpBridgeInstance, Connection connection) {
1287 String startTimestamp = getCurrentTimestamp();
1288 for (int i = 0; i < rstpBridgeInstance.getRstpState().getRstpBridgePortAttr().getRstpBridgePortTable().size();
1291 org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.bridge.port.state.attr
1292 .RstpBridgePortTable rstpBridgePortTableAttr =
1293 rstpBridgeInstance.getRstpState().getRstpBridgePortAttr().getRstpBridgePortTable().get(i);
1295 String ifName = rstpBridgePortTableAttr.getIfname();
1296 String bridgePortState = rstpBridgePortTableAttr.getBridgePortState().getName();
1297 String bridgePortRole = rstpBridgePortTableAttr.getBridgePortRole().getName();
1298 String bridgePortId = rstpBridgePortTableAttr.getBridgePortId().toString();
1299 String openEdgeBridgePort = rstpBridgePortTableAttr.getOperEdgeBridgePort().toString();
1300 String designatedBridgePort = rstpBridgePortTableAttr.getDesignatedBridgePort().toString();
1301 String designatedBridgeId = rstpBridgePortTableAttr.getDesignatedBridgeid().toString();
1303 Object[] parameters = {nodeId,
1310 designatedBridgePort,
1316 String query = Queries.getQuery().deviceProtocolRstpBridgePortAttrInsert().get();
1317 LOG.info("Running {} query ", query);
1318 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1319 for (int j = 0; j < parameters.length; j++) {
1320 stmt.setObject(j + 1, parameters[j]);
1323 stmt.clearParameters();
1324 } catch (SQLException e) {
1325 LOG.error("Something wrong when storing devices protocols LLDP RSTP bridge port attributes", e);
1332 private void persistDevInternalLinks(String nodeId, Connection connection) {
1334 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1335 Optional<OrgOpenroadmDevice> deviceObject =
1336 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1337 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1339 String startTimestamp = getCurrentTimestamp();
1340 for (int i = 0; i < deviceObject.get().getInternalLink().size(); i++) {
1341 InternalLink internalLink = deviceObject.get().getInternalLink().get(i);
1342 String internalLinkName = internalLink.getInternalLinkName();
1343 String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
1344 String sourcePortName = internalLink.getSource().getPortName().toString();
1345 String destinationCircuitPackName = internalLink.getDestination().getCircuitPackName();
1346 String destinationPortName = internalLink.getDestination().getPortName().toString();
1348 Object[] parameters = {nodeId,
1350 sourceCircuitPackName,
1352 destinationCircuitPackName,
1353 destinationPortName,
1358 String query = Queries.getQuery().deviceInternalLinkInsert().get();
1359 LOG.info("Running {} query ", query);
1360 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1361 for (int j = 0; j < parameters.length; j++) {
1362 stmt.setObject(j + 1, parameters[j]);
1365 stmt.clearParameters();
1366 } catch (SQLException e) {
1367 LOG.error("Something wrong when storing devices internal links", e);
1374 private void persistDevExternalLinks(String nodeId, Connection connection) {
1376 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1377 Optional<OrgOpenroadmDevice> deviceObject =
1378 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1379 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1381 String startTimestamp = getCurrentTimestamp();
1382 for (int i = 0; i < deviceObject.get().getExternalLink().size(); i++) {
1383 ExternalLink externalLink = deviceObject.get().getExternalLink().get(i);
1384 String externalLinkName = externalLink.getExternalLinkName();
1385 String sourceNodeId = externalLink.getSource().getNodeId();
1386 String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
1387 String sourcePortName = externalLink.getSource().getPortName();
1388 String destinationNodeId = externalLink.getDestination().getNodeId();
1389 String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
1390 String destinationPortName = externalLink.getDestination().getPortName();
1392 Object[] parameters = {nodeId,
1395 sourceCircuitPackName,
1398 destinationCircuitPackName,
1399 destinationPortName,
1404 String query = Queries.getQuery().deviceExternalLinkInsert().get();
1405 LOG.info("Running {} query ", query);
1406 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1407 for (int j = 0; j < parameters.length; j++) {
1408 stmt.setObject(j + 1, parameters[j]);
1411 stmt.clearParameters();
1412 } catch (SQLException e) {
1413 LOG.error("Something wrong when storing devices external links", e);
1419 private void persistDevPhysicalLinks(String nodeId, Connection connection) {
1421 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1422 Optional<OrgOpenroadmDevice> deviceObject =
1423 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1424 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1426 String startTimestamp = getCurrentTimestamp();
1427 for (int i = 0; i < deviceObject.get().getPhysicalLink().size(); i++) {
1428 PhysicalLink physicalLink = deviceObject.get().getPhysicalLink().get(i);
1429 String physicalLinkName = physicalLink.getPhysicalLinkName();
1430 String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
1431 String sourcePortName = physicalLink.getSource().getPortName().toString();
1432 String destinationCircuitPackName = physicalLink.getDestination().getCircuitPackName();
1433 String destinationPortName = physicalLink.getDestination().getPortName().toString();
1435 Object[] parameters = {nodeId,
1437 sourceCircuitPackName,
1439 destinationCircuitPackName,
1440 destinationPortName,
1445 String query = Queries.getQuery().devicePhysicalLinkInsert().get();
1446 LOG.info("Running {} query ", query);
1447 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1448 for (int j = 0; j < parameters.length; j++) {
1449 stmt.setObject(j + 1, parameters[j]);
1452 stmt.clearParameters();
1453 } catch (SQLException e) {
1454 LOG.error("Something wrong when storing devices physical links", e);
1460 private void persistDevDegree(String nodeId, Connection connection) {
1462 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1463 Optional<OrgOpenroadmDevice> deviceObject =
1464 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1465 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1467 String startTimestamp = getCurrentTimestamp();
1468 for (int i = 0; i < deviceObject.get().getDegree().size(); i++) {
1469 Degree degree = deviceObject.get().getDegree().get(i);
1470 String degreeNumber = degree.getDegreeNumber().toString();
1471 String maxWavelengths = degree.getMaxWavelengths().toString();
1472 String otdrPortCircuitPackName = degree.getOtdrPort().getCircuitPackName();
1473 String otdrPortPortName = degree.getOtdrPort().getPortName().toString();
1474 persistDevDegreeCircuitPack(nodeId, degree, degreeNumber, connection);
1475 persistDevDegreeConnectionPort(nodeId, degree, degreeNumber, connection);
1476 //String mcCapabilitiesSlotWidthGranularity = "";
1477 //String mcCapabilitiesCenterFreqGranularity = "";
1478 //String mcCapabilitiesMinSlots = "";
1479 //String mcCapabilitiesMaxSlots = "";
1481 Object[] parameters = {nodeId,
1484 otdrPortCircuitPackName,
1486 //mcCapabilitiesSlotWidthGranularity,
1487 //mcCapabilitiesCenterFreqGranularity,
1488 //mcCapabilitiesMinSlots,
1489 //mcCapabilitiesMaxSlots,
1495 String query = Queries.getQuery().deviceDegreeInsert().get();
1496 LOG.info("Running {} query ", query);
1497 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1498 for (int j = 0; j < parameters.length; j++) {
1499 stmt.setObject(j + 1, parameters[j]);
1502 stmt.clearParameters();
1503 } catch (SQLException e) {
1504 LOG.error("Something wrong when storing devices degrees", e);
1511 private void persistDevDegreeCircuitPack(String nodeId, Degree degree, String degreeNumber, Connection connection) {
1513 String startTimestamp = getCurrentTimestamp();
1514 for (int i = 0; i < degree.getCircuitPacks().size(); i++) {
1516 String circuitPackIndex = degree.getCircuitPacks().get(i).getIndex().toString();
1517 String circuitPackName = degree.getCircuitPacks().get(i).getCircuitPackName();
1519 Object[] parameters = {nodeId,
1527 String query = Queries.getQuery().deviceDegreeCircuitPackInsert().get();
1528 LOG.info("Running {} query ", query);
1529 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1530 for (int j = 0; j < parameters.length; j++) {
1531 stmt.setObject(j + 1, parameters[j]);
1534 stmt.clearParameters();
1535 } catch (SQLException e) {
1536 LOG.error("Something wrong when storing devices degrees circuit packs", e);
1542 private void persistDevDegreeConnectionPort(String nodeId, Degree degree, String degreeNumber,
1543 Connection connection) {
1545 String startTimestamp = getCurrentTimestamp();
1546 for (int i = 0; i < degree.getConnectionPorts().size(); i++) {
1548 String connectionPortIndex = degree.getConnectionPorts().get(i).getIndex().toString();
1549 String circuitPackName = degree.getConnectionPorts().get(i).getCircuitPackName();
1550 String portName = degree.getConnectionPorts().get(i).getPortName().toString();
1552 Object[] parameters = {nodeId,
1554 connectionPortIndex,
1561 String query = Queries.getQuery().deviceDegreeConnectionPortInsert().get();
1562 LOG.info("Running {} query ", query);
1563 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1564 for (int j = 0; j < parameters.length; j++) {
1565 stmt.setObject(j + 1, parameters[j]);
1568 stmt.clearParameters();
1569 } catch (SQLException e) {
1570 LOG.error("Something wrong when storing devices degrees connection ports", e);
1577 private void persistDevSrg(String nodeId, Connection connection) {
1579 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1580 Optional<OrgOpenroadmDevice> deviceObject =
1581 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1582 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1584 String startTimestamp = getCurrentTimestamp();
1585 for (int i = 0; i < deviceObject.get().getSharedRiskGroup().size(); i++) {
1586 SharedRiskGroup sharedRiskGroup = deviceObject.get().getSharedRiskGroup().get(i);
1587 String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
1588 String srgNumber = sharedRiskGroup.getSrgNumber().toString();
1589 int wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getIntValue();
1590 persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
1591 //String currentProvisionedAddDropPorts = "";
1592 //String mcCapSlotWidthGranularity = "";
1593 //String mcCapCenterFreqGranularity = "";
1594 //String mcCapMinSlots = "";
1595 //String mcCapMaxSlots = "";
1597 Object[] parameters = {nodeId,
1599 //currentProvisionedAddDropPorts,
1602 //mcCapSlotWidthGranularity,
1603 //mcCapCenterFreqGranularity,
1611 String query = Queries.getQuery().deviceSharedRiskGroupInsert().get();
1612 LOG.info("Running {} query ", query);
1613 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1614 for (int j = 0; j < parameters.length; j++) {
1615 stmt.setObject(j + 1, parameters[j]);
1618 stmt.clearParameters();
1619 } catch (SQLException e) {
1620 LOG.error("Something wrong when storing devices SRG", e);
1626 private void persistDevSrgCircuitPacks(String nodeId, SharedRiskGroup sharedRiskGroup, String srgNumber,
1627 Connection connection) {
1629 String startTimestamp = getCurrentTimestamp();
1630 for (int i = 0; i < sharedRiskGroup.getCircuitPacks().size(); i++) {
1632 String circuitPackindex = sharedRiskGroup.getCircuitPacks().get(i).getIndex().toString();
1633 String circuitPackName = sharedRiskGroup.getCircuitPacks().get(i).getCircuitPackName();
1635 Object[] parameters = {nodeId,
1643 String query = Queries.getQuery().deviceSrgCircuitPackInsert().get();
1644 LOG.info("Running {} query ", query);
1645 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1646 for (int j = 0; j < parameters.length; j++) {
1647 stmt.setObject(j + 1, parameters[j]);
1650 stmt.clearParameters();
1651 } catch (SQLException e) {
1652 LOG.error("Something wrong when storing devices SRG circuit packs", e);
1658 private void persistDevRoadmConnections(String nodeId, Connection connection) {
1660 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1661 Optional<OrgOpenroadmDevice> deviceObject =
1662 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1663 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1665 String startTimestamp = getCurrentTimestamp();
1666 for (int i = 0; i < deviceObject.get().getRoadmConnections().size(); i++) {
1667 RoadmConnections roadmConnections = deviceObject.get().getRoadmConnections().get(i);
1668 int opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getIntValue();
1669 //String connectionName = "";
1670 //String connectionNumber = "";
1671 //String wavelengthNumber = "";
1672 String targetOutputPower = roadmConnections.getTargetOutputPower().toString();
1673 String srcIf = roadmConnections.getSource().getSrcIf();
1674 String dstIf = roadmConnections.getDestination().getDstIf();
1676 Object[] parameters = {nodeId,
1681 Integer.toString(opticalcontrolmodeEnu),
1690 String query = Queries.getQuery().deviceRoadmConnectionsInsert().get();
1691 LOG.info("Running {} query ", query);
1692 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1693 for (int j = 0; j < parameters.length; j++) {
1694 stmt.setObject(j + 1, parameters[j]);
1697 stmt.clearParameters();
1698 } catch (SQLException e) {
1699 LOG.error("Something wrong when storing devices ROADM connection ", e);
1706 private void persistDevConnectionMap(String nodeId, Connection connection) {
1708 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1709 Optional<OrgOpenroadmDevice> deviceObject =
1710 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1711 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1713 String startTimestamp = getCurrentTimestamp();
1714 for (int i = 0; i < deviceObject.get().getConnectionMap().size(); i++) {
1715 ConnectionMap connectionMap = deviceObject.get().getConnectionMap().get(i);
1716 String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
1717 String sourceCircuitPackName = connectionMap.getSource().getCircuitPackName();
1718 String sourcePortName = connectionMap.getSource().getCircuitPackName();
1721 Object[] parameters = {nodeId,
1722 connectionMapNumber,
1723 sourceCircuitPackName,
1729 String query = Queries.getQuery().deviceConnectionMapInsert().get();
1730 LOG.info("Running {} query ", query);
1731 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1732 for (int j = 0; j < parameters.length; j++) {
1733 stmt.setObject(j + 1, parameters[j]);
1736 stmt.clearParameters();
1737 } catch (SQLException e) {
1738 LOG.error("Something wrong when storing devices connection map", e);
1744 private void persistDevWavelengthMap(String nodeId, Connection connection) {
1747 String wavelengthNumber="", centerFrequency="", wavelength="";;
1749 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1750 Optional<OrgOpenroadmDevice> deviceObject =
1751 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1752 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1755 String startTimestamp = getCurrentTimestamp();
1756 for (int i = 0; i<deviceObject.get().getWavelengthMap().getWavelengths().size(); i++) {
1757 Wavelengths wavelengths = deviceObject.get().getWavelengthMap().getWavelengths().get(i);
1758 wavelengthNumber=wavelengths.getWavelengthNumber().toString();
1759 centerFrequency=wavelengths.getCenterFrequency().toString();
1760 wavelength=wavelengths.getWavelength().toString();
1763 Object[] parameters = {nodeId,
1771 String query = Queries.getQuery().deviceWavelengthInsert().get();
1772 LOG.info("Running {} query ", query);
1773 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1774 for (int j = 0; j < parameters.length; j++) {
1775 stmt.setObject(j + 1, parameters[j]);
1778 stmt.clearParameters();
1779 } catch (SQLException e) {
1780 LOG.error("Something wrong when storing devices wavelength map", e);
1788 private void persistDevInterfaceTcm(String nodeId, String interfaceName, OduBuilder oduBuilder,
1789 Connection connection) {
1791 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1794 tcm = oduBuilder.getTcm().get(i);
1796 Object[] parameters = prepareDevInterfaceTcmParameters(nodeId, interfaceName, tcm);
1798 String query = Queries.getQuery().deviceInterfacesInsert().get();
1799 LOG.info("Running {} query ", query);
1800 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1801 for (int j = 0; j < parameters.length; j++) {
1802 stmt.setObject(j + 1, parameters[j]);
1805 stmt.clearParameters();
1806 } catch (SQLException e) {
1807 LOG.error("Something wrong when storing devices interface tcm", e);
1812 private void persistDevInterfaceOtnOduTxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1813 Connection connection) {
1815 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1818 txMsi = oduBuilder.getOpu().getMsi().getTxMsi().get(i);
1820 Object[] parameters = prepareDevInterfaceOtnOduTxMsiParameters(nodeId, interfaceName, txMsi);
1822 String query = Queries.getQuery().deviceInterfaceOtnOduTxMsiInsert().get();
1823 LOG.info("Running {} query ", query);
1824 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1825 for (int j = 0; j < parameters.length; j++) {
1826 stmt.setObject(j + 1, parameters[j]);
1829 stmt.clearParameters();
1830 } catch (SQLException e) {
1831 LOG.error("Something wrong when storing devices interface OTN ODU Tx MSI", e);
1837 private void persistDevInterfaceOtnOduRxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1838 Connection connection) {
1840 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1843 rxMsi = oduBuilder.getOpu().getMsi().getRxMsi().get(i);
1845 Object[] parameters = prepareDevInterfaceOtnOduRxMsiParameters(nodeId, interfaceName, rxMsi);
1847 String query = Queries.getQuery().deviceInterfaceOtnOduRxMsiInsert().get();
1848 LOG.info("Running {} query ", query);
1849 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1850 for (int j = 0; j < parameters.length; j++) {
1851 stmt.setObject(j + 1, parameters[j]);
1854 stmt.clearParameters();
1855 } catch (SQLException e) {
1856 LOG.error("Something wrong when storing devices interface OTN ODU Rx MSI", e);
1862 private void persistDevInterfaceOtnOduExpMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1863 Connection connection) {
1865 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1868 expMsi = oduBuilder.getOpu().getMsi().getExpMsi().get(i);
1870 Object[] parameters = prepareDevInterfaceOtnOduExpMsiParameters(nodeId, interfaceName, expMsi);
1872 String query = Queries.getQuery().deviceInterfaceOtnOduExpMsiInsert().get();
1873 LOG.info("Running {} query ", query);
1874 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1875 for (int j = 0; j < parameters.length; j++) {
1876 stmt.setObject(j + 1, parameters[j]);
1879 stmt.clearParameters();
1880 } catch (SQLException e) {
1881 LOG.error("Something wrong when storing devices interface OTN ODU Exp MSI", e);