2 * Copyright © 2017 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
9 package org.opendaylight.transportpce.inventory;
11 import static java.util.Objects.requireNonNull;
12 import static org.opendaylight.transportpce.inventory.utils.StringUtils.getCurrentTimestamp;
13 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareDashString;
14 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareEmptyString;
16 import java.sql.Connection;
17 import java.sql.PreparedStatement;
18 import java.sql.ResultSet;
19 import java.sql.SQLException;
20 import java.util.Optional;
21 import java.util.concurrent.ExecutionException;
22 import javax.sql.DataSource;
23 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
24 import org.opendaylight.transportpce.common.Timeouts;
25 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
26 import org.opendaylight.transportpce.inventory.query.Queries;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.CpSlots;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.external.links.ExternalLink;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.internal.links.InternalLink;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.ConnectionMap;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Degree;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Info;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Protocols;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.physical.links.PhysicalLink;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelf.Slots;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelves.Shelves;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.Interface1;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.ethernet.container.EthernetBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.Protocols1;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.PortConfig;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.nbr.list.IfName;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.och.container.OchBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.ots.container.OtsBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.attributes.Tcm;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.container.OduBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.ExpMsi;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.RxMsi;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.TxMsi;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.otu.container.OtuBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.wavelength.map.rev161014.wavelength.map.g.Wavelengths;
57 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
58 import org.slf4j.Logger;
59 import org.slf4j.LoggerFactory;
61 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
62 value = "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING",
63 justification = "TODO review the SQL statement generation process")
64 public class INode121 {
66 private static final Logger LOG = LoggerFactory.getLogger(INode121.class);
68 private final DataSource dataSource;
69 private final DeviceTransactionManager deviceTransactionManager;
71 public INode121(DataSource dataSource, DeviceTransactionManager deviceTransactionManager) {
72 this.dataSource = dataSource;
73 this.deviceTransactionManager = deviceTransactionManager;
76 public boolean addNode(String deviceId) {
78 InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
79 Optional<Info> infoOpt =
80 deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, infoIID,
81 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
83 if (infoOpt.isPresent()) {
84 deviceInfo = infoOpt.get();
86 LOG.warn("Could not get device info from DataBroker");
89 boolean sqlResult = false;
90 String query = Queries.getQuery().deviceInfoInsert().get();
91 LOG.info("Running {} query ", query);
92 try (Connection connection = dataSource.getConnection();
93 PreparedStatement preparedStatement = connection.prepareStatement(query)) {
94 Object[] prepareParameters = prepareDeviceInfoParameters(deviceInfo);
95 for (int i = 0; i < prepareParameters.length; i++) {
96 LOG.debug("Parameter {} has value {}", i + 1, prepareParameters[i]);
97 preparedStatement.setObject(i + 1, prepareParameters[i]);
100 int executeUpdate = preparedStatement.executeUpdate();
101 LOG.info("{} entries were added", executeUpdate);
104 LOG.debug("iNode AddNode call complete");
105 getRoadmShelves(deviceId);
106 LOG.debug("iNode getRoadmShelves call complete");
107 getCircuitPacks(deviceId);
108 LOG.debug("iNode getCircuitPacks call complete");
110 LOG.debug("iNode persist interfaces call");
111 persistDevInterfaces(deviceId, connection);
112 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");
120 LOG.debug("iNode persist wavelength map call");
121 persistDevWavelengthMap(deviceId, connection);
122 LOG.debug("iNode persist wavelength map call complete");
124 LOG.debug("iNode persist internal links map call");
125 persistDevInternalLinks(deviceId, connection);
126 LOG.debug("iNode persist internal links map call complete");
128 LOG.debug("iNode persist Physical links map call");
129 persistDevPhysicalLinks(deviceId, connection);
130 LOG.debug("iNode persist Physical links map call complete");
132 LOG.debug("iNode persist External links map call");
133 persistDevExternalLinks(deviceId, connection);
134 LOG.debug("iNode persist External links map call complete");
136 LOG.debug("iNode persist degree map call");
137 persistDevDegree(deviceId, connection);
138 LOG.debug("iNode persist degree map call complete");
140 LOG.debug("iNode persist srg map call");
141 persistDevSrg(deviceId, connection);
142 LOG.debug("iNode persist srg map call complete");
144 LOG.debug("iNode persist Roadm Connections call");
145 persistDevRoadmConnections(deviceId, connection);
146 LOG.debug("iNode persist Roadm Connections call complete");
148 LOG.debug("iNode persist Connection Map call");
149 persistDevConnectionMap(deviceId, connection);
150 LOG.debug("iNode persist Connection Map call complete");
152 } catch (SQLException | InterruptedException | ExecutionException e) {
153 LOG.error("Something wrong when storing node into DB", e);
158 public boolean nodeExists(String nodeId) {
159 String selectTableSQL = "select count(*) node_exists from inv_dev_info where node_id = ?";
161 LOG.info("Checking if {} exists in DB", nodeId);
162 try (Connection connection = dataSource.getConnection();
163 PreparedStatement preparedStmt = connection.prepareStatement(selectTableSQL)) {
164 preparedStmt.setString(1, nodeId);
165 try (ResultSet rs = preparedStmt.executeQuery()) {
167 nodeExists = rs.getInt("node_exists");
168 LOG.debug("Found {} devices matching {}", nodeExists, nodeId);
171 } catch (SQLException e) {
172 LOG.error("Something wrong when fetching node in DB", e);
174 return nodeExists == 0 ? false : true;
177 public void getRoadmShelves(String nodeId) throws InterruptedException, ExecutionException {
178 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
179 Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
180 LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT,
181 Timeouts.DEVICE_READ_TIMEOUT_UNIT);
183 LOG.info("Shelves size {}", deviceObject.get().getShelves().size());
184 try (Connection connection = requireNonNull(dataSource.getConnection())) {
185 for (int i = 0; i < deviceObject.get().getShelves().size(); i++) {
186 Shelves shelve = deviceObject.get().getShelves().get(i);
187 String shelfName = shelve.getShelfName();
189 LOG.info("Getting Shelve Details of {}", shelfName);
190 if (shelve.getSlots() != null) {
191 LOG.info("Slot Size {} ", shelve.getSlots().size());
192 persistShelveSlots(nodeId, shelve, connection);
194 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);
226 if (cp.getPorts() != null) {
227 persistCPPorts(nodeId, connection, cp);
229 persistCircuitPacks(nodeId, connection, cp);
231 } catch (SQLException e1) {
232 LOG.error("Something wrong when fetching Circuit Packs in DB", e1);
236 private void persistCircuitPacks(String nodeId, Connection connection, CircuitPacks cp) {
237 Object[] parameters = prepareCircuitPacksParameters(nodeId, cp);
238 String query = Queries.getQuery().deviceCircuitPackInsert().get();
239 LOG.info("Running {} query ", query);
240 try (PreparedStatement stmt = connection.prepareStatement(query)) {
241 for (int j = 0; j < parameters.length; j++) {
242 stmt.setObject(j + 1, parameters[j]);
245 stmt.clearParameters();
246 } catch (SQLException e) {
247 LOG.error("Something wrong when storing Circuit Packs in DB", e);
251 private void persistShelves(String nodeId, Connection connection, Shelves shelve) {
252 Object[] shelvesParameter = prepareShelvesParameters(nodeId, shelve);
253 String query = Queries.getQuery().deviceShelfInsert().get();
254 LOG.info("Running {} query ", query);
255 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
256 for (int j = 0; j < shelvesParameter.length; j++) {
257 preparedStmt.setObject(j + 1, shelvesParameter[j]);
259 preparedStmt.execute();
260 preparedStmt.clearParameters();
261 } catch (SQLException e) {
262 LOG.error("Something wrong when storing shelves in DB", e);
266 private void persistShelveSlots(String nodeId, Shelves shelves, Connection connection) {
267 String startTimetampStr = getCurrentTimestamp();
268 for (int i = 0; i < shelves.getSlots().size(); i++) {
269 Slots slot = shelves.getSlots().get(i);
270 LOG.info("Getting Slot Details of {}", slot.getSlotName());
271 Object[] parameters = new Object[]{nodeId,
272 shelves.getShelfName(),
275 slot.getProvisionedCircuitPack(),
279 String query = Queries.getQuery().deviceShelfSlotInsert().get();
280 LOG.info("Running {} query ", query);
281 try (PreparedStatement stmt = connection.prepareStatement(query)) {
282 for (int j = 0; j < parameters.length; j++) {
283 stmt.setObject(j + 1, parameters[j]);
286 stmt.clearParameters();
287 } catch (SQLException e) {
288 LOG.error("Something wrong when storing shelves slots in DB", e);
294 private void persistCircuitPacksSlots(String nodeId, CircuitPacks circuitPacks, Connection connection) {
295 String startTimetampStr = getCurrentTimestamp();
296 for (int i = 0; i < circuitPacks.getCpSlots().size(); i++) {
297 CpSlots cpSlot = circuitPacks.getCpSlots().get(i);
299 Object[] parameters = new Object[]{nodeId,
300 circuitPacks.getCircuitPackName(),
301 cpSlot.getSlotName(),
303 cpSlot.getProvisionedCircuitPack(),
308 String query = Queries.getQuery().deviceCPSlotInsert().get();
309 LOG.info("Running {} query ", query);
310 try (PreparedStatement stmt = connection.prepareStatement(query)) {
311 for (int j = 0; j < parameters.length; j++) {
312 stmt.setObject(j + 1, parameters[j]);
315 stmt.clearParameters();
316 } catch (SQLException e) {
317 LOG.error("Something wrong when storing Cirtcuits Packs slots in DB", e);
323 * Prepares parameters for device insert query.
325 * @param deviceInfo device information
326 * @return Object an object
328 private static Object[] prepareDeviceInfoParameters(Info deviceInfo) {
329 String startTimetampStr = getCurrentTimestamp();
331 String nodeId = prepareDashString(deviceInfo.getNodeId());
332 Long nodeNumber = deviceInfo.getNodeNumber().toJava();
333 String nodeTypeEnu = deviceInfo.getNodeType().getName();
334 String clli = prepareDashString(deviceInfo.getClli());
335 String vendor = prepareDashString(deviceInfo.getVendor());
336 String model = prepareDashString(deviceInfo.getModel());
337 String serialId = prepareDashString(deviceInfo.getSerialId());
338 String ipAddress = prepareDashString(deviceInfo.getIpAddress().getIpv4Address().getValue());
339 String prefixLength = prepareDashString(deviceInfo.getPrefixLength());
340 String defaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
341 String sourceEnum = deviceInfo.getSource().getName();
342 String currentIpAddress = prepareDashString(deviceInfo.getCurrentIpAddress().getIpv4Address().getValue());
343 String currentPrefixLength = prepareDashString(deviceInfo.getCurrentPrefixLength());
344 String currentDefaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
345 String macAddress = prepareDashString(deviceInfo.getMacAddress().getValue());
346 String softwareVersion = prepareDashString(deviceInfo.getSoftwareVersion());
347 //String openroadmVersion = "1.2.1";
348 String template = prepareDashString(deviceInfo.getTemplate());
349 String currentDatetime = prepareDashString(deviceInfo.getCurrentDatetime().getValue());
350 String geoLatitude = (deviceInfo.getGeoLocation() != null
351 ? prepareDashString(deviceInfo.getGeoLocation().getLatitude()) : "");
352 String geoLongitude = (deviceInfo.getGeoLocation() != null
353 ? prepareDashString(deviceInfo.getGeoLocation().getLongitude()) : "");
354 String maxDegrees = (deviceInfo.getMaxDegrees() == null ? "-1" : prepareDashString(deviceInfo.getMaxDegrees()));
355 String maxSrgs = (deviceInfo.getMaxSrgs() == null ? "-1" : prepareDashString(deviceInfo.getMaxSrgs()));
356 String swVersion = prepareDashString(deviceInfo.getSoftwareVersion()); //sw_version
357 String swValidationTimer = prepareDashString(""); //sw_validation_timer
358 String activationDateTime = prepareDashString(""); //activation_date_time
359 //Integer maxNumBin15minHistoricalPm = null;
360 //Integer maxNumBin24hourHistoricalPm = null;
361 /*jsonDevInfo = JsonStringBuilder.getDevInfoJson().replace("$$NODE-ID$$",nodeId)
362 .replace("$$NODE-NUMBER$$", nodeNumber)
363 .replace("$$NODE-TYPE$$",nodeType)
364 .replace("$$CLLI$$",clli)
365 .replace("$$VENDOR$$",vendor)
366 .replace("$$MODEL$$",model)
367 .replace("$$SERIAL-ID$$",serialId)
368 .replace("$$IPADDRESS$$",ipAddress)
369 .replace("$$PREFIX-LENGTH$$",prefixLength)
370 .replace("$$DEFAULTGATEWAY$$",defaultGateway)
371 .replace("$$SOURCE$$",String.valueOf(source))
372 .replace("$$CURRENT-IPADDRESS$$",currentIpAddress)
373 .replace("$$CURRENT-PREFIX-LENGTH$$",currentPrefixLength)
374 .replace("$$CURRENT-DEFAULTGATEWAY$$",currentDefailtGateway)
375 .replace("$$MACADDRESS$$",macAddress)
376 .replace("$$SOFTWAREVERSION$$",softwareVersion)
377 .replace("$$OPENROADM-VERSION$$",openroadmVersion)
378 .replace("$$TEMPLATE$$",template)
379 .replace("$$CURRENT-DATETIME$$",currentDatetime)
380 .replace("$$LATITUDE$$",latitude)
381 .replace("$$LONGITUDE$$",longitude)
382 .replace("$$MAX-DEGREES$$",maxDegrees)
383 .replace("$$MAX-SRGS$$",maxSrgs)
384 .replace("$$MAX-NUM-BIN-15MIN-HISTORICAL-PM$$",prepareDashString(""))
385 .replace("$$MAX-NUM-BIN-24HOUR-HISTORICAL-PM$$",prepareDashString(""))
386 .replace("$$SW-VERSION$$",swVersion)
387 .replace("$$SW-VALIDATION-TIMER$$",swValidationTimer)
388 .replace("$$ACTIVATION-DATE-TIME$$",activationDateTime);*/
405 currentDefaultGateway,
416 //maxNumBin15minHistoricalPm,
417 //maxNumBin24hourHistoricalPm,
428 private static Object[] prepareShelvesParameters(String nodeId, Shelves shelve) {
429 String startTimestamp = getCurrentTimestamp();
431 return new Object[]{nodeId,
432 shelve.getShelfName(),
433 shelve.getShelfType(),
435 shelve.getShelfPosition(),
436 (shelve.getAdministrativeState() == null ? null : shelve.getAdministrativeState().getIntValue()),
439 shelve.getSerialId(),
441 shelve.getProductCode(),
442 (shelve.getManufactureDate() == null ? null : shelve.getManufactureDate().getValue()),
444 shelve.getHardwareVersion(),
445 (shelve.getOperationalState() == null ? null : shelve.getOperationalState().getIntValue()),
446 (shelve.getEquipmentState() == null ? null : shelve.getEquipmentState().getIntValue()),
447 (shelve.getDueDate() == null ? null : shelve.getDueDate().getValue()),
453 private static Object[] prepareCPPortsParameters(String nodeId, CircuitPacks circuitPacks, Ports cpPort) {
455 String circuitPackName = circuitPacks.getCircuitPackName();
456 String portName = cpPort.getPortName();
457 String portType = cpPort.getPortType();
458 String portQualEnu = String.valueOf((cpPort.getPortQual() == null ? "-1" : cpPort.getPortQual().getName()));
459 String portWavelengthTypeEnu = "-1"; //cpPort.getPortWavelengthType().getIntValue(); /* Check error*/
460 String portDirectionEnu = String.valueOf((cpPort.getPortDirection() == null ? "" :
461 cpPort.getPortDirection().getName()));
462 String label = cpPort.getLabel();
463 String circuitId = cpPort.getCircuitId();
464 String administrativeStateEnu = (cpPort.getAdministrativeState() == null ? "" :
465 cpPort.getAdministrativeState().getName());
466 String operationalStateEnu =
467 (cpPort.getOperationalState() == null ? "" : cpPort.getOperationalState().getName());
468 String logicalConnectionPoint = cpPort.getLogicalConnectionPoint();
469 String parentPortCircuitPackName = (cpPort.getPartnerPort() == null ? "" :
470 (cpPort.getPartnerPort().getCircuitPackName() == null ? "" : cpPort.getPartnerPort().getCircuitPackName()));
471 String partnerPortPortName = (cpPort.getPartnerPort() == null ? "" :
472 (cpPort.getPartnerPort().getPortName() == null ? "" : cpPort.getPartnerPort().getPortName().toString()));
473 String partnerPortCircuitPackName = (cpPort.getParentPort() == null ? "" :
474 (cpPort.getParentPort().getCircuitPackName() == null ? "" : cpPort.getParentPort().getCircuitPackName()));
475 String parentPortPortName = (cpPort.getParentPort() == null ? "" :
476 (cpPort.getParentPort().getPortName() == null ? "" : cpPort.getParentPort().toString()));
477 String roadmPortPortPowerCapabilityMinRx = (cpPort.getRoadmPort() == null ? "" :
478 (cpPort.getRoadmPort().getPortPowerCapabilityMinRx() == null ? "" :
479 cpPort.getRoadmPort().getPortPowerCapabilityMinRx().toString()));
480 String roadmPortPortPowerCapabilityMinTx = (cpPort.getRoadmPort() == null ? "" :
481 (cpPort.getRoadmPort().getPortPowerCapabilityMinTx() == null ? "" :
482 cpPort.getRoadmPort().getPortPowerCapabilityMinTx().toString()));
483 String roadmPortPortPowerCapabilityMaxRx = (cpPort.getRoadmPort() == null ? "" :
484 (cpPort.getRoadmPort().getPortPowerCapabilityMaxRx() == null ? "" :
485 cpPort.getRoadmPort().getPortPowerCapabilityMaxRx().toString()));
486 String roadmPortPortPowerCapabilityMaxTx = (cpPort.getRoadmPort() == null ? "" :
487 (cpPort.getRoadmPort().getPortPowerCapabilityMaxTx() == null ? "" :
488 cpPort.getRoadmPort().getPortPowerCapabilityMaxTx().toString()));
489 //String roadmPortCapableWavelengths = "";
490 //String roadmPortAvailableWavelengths = "";
491 //String roadmPortUsedWavelengths = "";
492 String transponderPortPortPowerCapabilityMinRx = (cpPort.getTransponderPort() == null ? "" :
493 (cpPort.getTransponderPort().getPortPowerCapabilityMinRx() == null ? "" :
494 cpPort.getTransponderPort().getPortPowerCapabilityMinRx().toString()));
495 String transponderPortPortPowerCapabilityMinTx = (cpPort.getTransponderPort() == null ? "" :
496 (cpPort.getTransponderPort().getPortPowerCapabilityMinTx() == null ? "" :
497 cpPort.getTransponderPort().getPortPowerCapabilityMinTx().toString()));
498 String transponderPortPortPowerCapabilityMaxRx = (cpPort.getTransponderPort() == null ? "" :
499 (cpPort.getTransponderPort().getPortPowerCapabilityMaxRx() == null ? "" :
500 cpPort.getTransponderPort().getPortPowerCapabilityMaxRx().toString()));
501 String transponderPortPortPowerCapabilityMaxTx = (cpPort.getTransponderPort() == null ? "" :
502 (cpPort.getTransponderPort().getPortPowerCapabilityMaxTx() == null ? "" :
503 cpPort.getTransponderPort().getPortPowerCapabilityMaxTx().toString()));
504 //String transponderPortCapableWavelengths = "";
505 String otdrPortLaunchCableLength = (cpPort.getOtdrPort() == null ? "" :
506 (cpPort.getOtdrPort().getLaunchCableLength() == null ? "" :
507 cpPort.getOtdrPort().getLaunchCableLength().toString()));
508 String otdrPortPortDirection = (cpPort.getOtdrPort() == null ? "-1" :
509 (cpPort.getOtdrPort().getPortDirection() == null ? "-1" :
510 Integer.toString(cpPort.getOtdrPort().getPortDirection().getIntValue())));
511 //String ilaPortPortPowerCapabilityMixRx = "";
512 //String ilaPortPortPowerCapabilityMixTx = "";
513 //String ilaPortPortPowerCapabilityMaxRx = "";
514 //String ilaPortPortPowerCapabilityMaxTx = "";
516 String startTimestamp = getCurrentTimestamp();
518 return new Object[]{nodeId,
523 portWavelengthTypeEnu,
527 administrativeStateEnu,
529 logicalConnectionPoint,
530 partnerPortCircuitPackName,
532 parentPortCircuitPackName,
534 roadmPortPortPowerCapabilityMinRx,
535 roadmPortPortPowerCapabilityMinTx,
536 roadmPortPortPowerCapabilityMaxRx,
537 roadmPortPortPowerCapabilityMaxTx,
538 //roadmPortCapableWavelengths,
539 //roadmPortAvailableWavelengths,
540 //roadmPortUsedWavelengths,
542 transponderPortPortPowerCapabilityMinRx,
543 transponderPortPortPowerCapabilityMinTx,
544 transponderPortPortPowerCapabilityMaxRx,
545 transponderPortPortPowerCapabilityMaxTx,
546 //transponderPortCapableWavelengths,
548 otdrPortLaunchCableLength,
549 otdrPortPortDirection,
550 //ilaPortPortPowerCapabilityMixRx,
551 //ilaPortPortPowerCapabilityMixTx,
552 //ilaPortPortPowerCapabilityMaxRx,
553 //ilaPortPortPowerCapabilityMaxTx,
561 private static Object[] prepareCircuitPacksParameters(String nodeId, CircuitPacks cpack) {
562 String startTimestamp = getCurrentTimestamp();
563 return new Object[]{nodeId,
564 cpack.getCircuitPackName(),
565 cpack.getCircuitPackType(),
566 cpack.getCircuitPackProductCode(),
567 (cpack.getAdministrativeState() == null ? "" : cpack.getAdministrativeState().getIntValue()),
572 cpack.getProductCode(),
573 (cpack.getManufactureDate() == null ? "" : cpack.getManufactureDate().getValue()),
575 cpack.getHardwareVersion(),
576 (cpack.getOperationalState() == null ? -1 : cpack.getOperationalState().getIntValue()),
577 cpack.getCircuitPackCategory().getType().getIntValue(),
578 cpack.getCircuitPackCategory().getExtension(),
579 (cpack.getEquipmentState() == null ? -1 : cpack.getEquipmentState().getIntValue()),
580 cpack.getCircuitPackMode(),
584 prepareEmptyString(cpack.getDueDate()),
585 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
586 ((cpack.getParentCircuitPack().getCircuitPackName() == null) ? "" :
587 cpack.getParentCircuitPack().getCircuitPackName())
589 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
590 ((cpack.getParentCircuitPack().getCpSlotName() == null) ? "" :
591 cpack.getParentCircuitPack().getCpSlotName())
598 private void persistCPPorts(String nodeId, Connection connection, CircuitPacks circuitPacks) {
600 for (int i = 0; i < circuitPacks.getPorts().size(); i++) {
601 Object[] cpPortsParameters = prepareCPPortsParameters(nodeId, circuitPacks, circuitPacks.getPorts().get(i));
602 String query = Queries.getQuery().deviceCPPortInsert().get();
603 LOG.info("Running {} query ", query);
604 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
605 for (int j = 0; j < cpPortsParameters.length; j++) {
606 preparedStmt.setObject(j + 1, cpPortsParameters[j]);
608 preparedStmt.execute();
609 preparedStmt.clearParameters();
610 } catch (SQLException e) {
611 LOG.error("Something wrong when storing Cirtcuits Packs Ports in DB", e);
617 private Object[] prepareDevInterfaceParameters(String nodeId, Interface deviceInterface, Connection connection) {
619 String ethernetDuplexEnu = "";
620 String ethernetAutoNegotiationEnu = "";
621 String maintTestsignalTestpatternEnu = "";
622 String maintTestsignalTypeEnu = "";
623 String otuFecEnu = "";
624 String otuMaintTypeEnu = "";
625 //String otsFiberTypeEnu = "";
626 String ethernetSpeed = "-1";
627 String ethernetFec = "";
628 String ethernetMtu = "-1";
629 String ethernetCurrSpeed = "";
630 String ethernetCurrDuplex = "-1";
631 //String mciMcttpMinFreq = "";
632 //String mciMcttpMaxFreq = "";
633 //String mciMcttpCenterFreq = "";
634 //String mciMcttpSlotWidth = "";
635 //String mciNmcCtpFrequency = "";
636 //String mciNmcCtpWidth = "";
638 //String ochFrequency = "";
639 //String ochWidth = "";
640 String ochWavelengthNumber = "";
641 String ochModulationFormat = "";
642 String ochTransmitPower = "";
643 String otsSpanLossReceive = "";
644 String otsSpanLossTransmit = "";
645 //String otsIngressSpanLossAgingMargin = "";
646 //String otsEolMaxLoadPin = "";
648 //String oduFunction = "";
649 String oduMonitoringMode = "";
650 //String oduNoOamFunction = "";
651 String oduProactiveDelayMeasurementEnabled = "";
652 //String oduPoaTribPortNumber = "-1";
653 //String oduTxSapi = "";
654 //String oduTxDapi = "";
655 //String oduTxOperator = "";
656 //String oduAcceptedSapi = "";
657 //String oduAcceptedDapi = "";
658 //String oduAcceptedOperator = "";
659 //String oduExpectedSapi = "";
660 //String oduExpectedDapi = "";
661 //String oduTimActEnabled = "";
662 //String oduTimDetectMode = "";
663 //String oduDegmIntervals = "-1";
664 //String oduDegthrPercentage = "-1";
665 String opuPayloadType = "";
666 String opuRxPayloadType = "";
667 String opuExpPayloadType = "";
668 String opuPayloadInterface = "";
669 String maintTestsignalEnabled = "";
670 String maintTestsignalBiterrors = "-1";
671 String maintTestsignalBiterrorsterminal = "-1";
672 String maintTestsignalSyncseconds = "-1";
673 String maintTestsignalSyncsecondsterminal = "-1";
675 //String otuTxSapi = "";
676 //String otuTxDapi = "";
677 //String otuTxOperator = "";
678 //String otuAcceptedSapi = "";
679 //String otuAcceptedDapi = "";
680 //String otuAcceptedOperator = "";
681 //String otuExpectedSapi = "";
682 //String otuExpectedDapi = "";
683 //String otuTimActEnabled = "";
684 //String otuTimDetectMode = "";
685 //String otuDegmIntervals = "-1";
686 //String otuDegthrPercentage = "-1";
687 String otuMaintLoopbackEnabled = "";
688 //String mtOtuRate = "";
689 //String mtOtuFec = "";
690 //String mtOtuMaintLoopback = "";
691 //String mtOtuEnabled = "";
692 //String mtOtuType = "";
694 String name = deviceInterface.getName();
695 String description = deviceInterface.getDescription();
696 String type = deviceInterface.getType().getTypeName();
697 String administrativeStateEnu = deviceInterface.getAdministrativeState().getName();
698 int operationalState = deviceInterface.getOperationalState().getIntValue();
699 String circuitId = deviceInterface.getCircuitId();
700 String supportingInterface = deviceInterface.getSupportingInterface();
701 String supportingCircuitPackName = deviceInterface.getSupportingCircuitPackName();
702 String supportingPort = deviceInterface.getSupportingPort().toString();
704 switch (deviceInterface.getType().toString()) {
707 //EthernetBuilder ethIfBuilder = new EthernetBuilder();
708 EthernetBuilder ethIfBuilder = new EthernetBuilder(deviceInterface.augmentation(Interface1.class)
710 ethernetSpeed = (ethIfBuilder.getSpeed() == null ? "-1" :
711 Integer.toString(ethIfBuilder.getSpeed().intValue()));
712 ethernetFec = ethIfBuilder.getFec().getName();
713 ethernetDuplexEnu = (ethIfBuilder.getDuplex() == null ? "" : ethIfBuilder.getDuplex().getName());
714 ethernetMtu = ethIfBuilder.getMtu().toString();
715 ethernetAutoNegotiationEnu = ethIfBuilder.getAutoNegotiation().getName();
716 ethernetCurrSpeed = ethIfBuilder.getCurrSpeed();
717 ethernetCurrDuplex = ethIfBuilder.getCurrDuplex();
721 OchBuilder ochIfBuilder = new OchBuilder(deviceInterface.augmentation(
722 org.opendaylight.yang.gen.v1
723 .http.org.openroadm.optical.channel.interfaces.rev161014.Interface1.class)
725 ochRate = ochIfBuilder.getRate().getName();
726 ochWavelengthNumber = ochIfBuilder.getWavelengthNumber().toString();
727 ochModulationFormat = ochIfBuilder.getModulationFormat().getName();
728 ochTransmitPower = ochIfBuilder.getTransmitPower().toString();
732 OtsBuilder otsIfBuilder = new OtsBuilder(deviceInterface.augmentation(
733 org.opendaylight.yang.gen.v1
734 .http.org.openroadm.optical.transport.interfaces.rev161014.Interface1.class)
736 //otsFiberTypeEnu = String.valueOf(otsIfBuilder.getFiberType().getIntValue());
737 otsSpanLossReceive = otsIfBuilder.getSpanLossReceive().toString();
738 otsSpanLossTransmit = otsIfBuilder.getSpanLossTransmit().toString();
742 OduBuilder oduIfBuilder = new OduBuilder(deviceInterface.augmentation(
743 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1.class)
745 oduRate = String.valueOf(oduIfBuilder.getRate());
746 oduMonitoringMode = oduIfBuilder.getMonitoringMode().getName();
747 oduProactiveDelayMeasurementEnabled = oduIfBuilder.isProactiveDelayMeasurementEnabled().toString();
749 persistDevInterfaceTcm(nodeId, name, oduIfBuilder, connection);
750 persistDevInterfaceOtnOduTxMsi(nodeId, name, oduIfBuilder, connection);
751 persistDevInterfaceOtnOduRxMsi(nodeId, name, oduIfBuilder, connection);
752 persistDevInterfaceOtnOduExpMsi(nodeId, name, oduIfBuilder, connection);
754 opuPayloadType = oduIfBuilder.getOpu().getPayloadType();
755 opuRxPayloadType = oduIfBuilder.getOpu().getRxPayloadType();
756 opuExpPayloadType = oduIfBuilder.getOpu().getExpPayloadType();
757 opuPayloadInterface = oduIfBuilder.getOpu().getPayloadInterface();
758 /*persistDevInterfaceOtnOduTxMsi(nodeId,name,oduIfBuilder,connection);
759 persistDevInterfaceOtnOduRxMsi(nodeId,name,oduIfBuilder,connection);
760 persistDevInterfaceOtnOduExpMsi(nodeId,name,oduIfBuilder,connection); */
761 maintTestsignalEnabled = oduIfBuilder.getMaintTestsignal().isEnabled().toString();
762 maintTestsignalTestpatternEnu = oduIfBuilder.getMaintTestsignal().getTestPattern().getName();
763 maintTestsignalTypeEnu = oduIfBuilder.getMaintTestsignal().getType().getName();
764 maintTestsignalBiterrors = Integer.toString(
765 oduIfBuilder.getMaintTestsignal().getBitErrors().intValue());
766 maintTestsignalBiterrorsterminal = oduIfBuilder.getMaintTestsignal().getBitErrorsTerminal().toString();
767 maintTestsignalSyncseconds = oduIfBuilder.getMaintTestsignal().getSyncSeconds();
768 maintTestsignalSyncsecondsterminal = oduIfBuilder.getMaintTestsignal().getSyncSecondsTerminal();
772 OtuBuilder otuIfBuilder =
773 new OtuBuilder(deviceInterface.augmentation(
774 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1.class)
776 otuRate = otuIfBuilder.getRate().getName();
777 otuFecEnu = otuIfBuilder.getFec().getName();
778 otuMaintLoopbackEnabled = otuIfBuilder.getMaintLoopback().isEnabled().toString();
779 otuMaintTypeEnu = otuIfBuilder.getMaintLoopback().getType().getName();
783 LOG.error("could not get interface type");
787 String startTimestamp = getCurrentTimestamp();
789 return new Object[]{nodeId,
793 administrativeStateEnu,
794 Integer.toString(operationalState),
797 supportingCircuitPackName,
803 ethernetAutoNegotiationEnu,
808 //mciMcttpCenterFreq,
810 //mciNmcCtpFrequency,
812 "", "", "", "", "", "",
823 //otsIngressSpanLossAgingMargin,
832 oduProactiveDelayMeasurementEnabled,
833 //oduPoaTribPortNumber,
839 //oduAcceptedOperator,
845 //oduDegthrPercentage,
846 "-1", "", "", "", "", "","", "", "", "", "", "-1", "-1",
851 maintTestsignalEnabled,
852 maintTestsignalTestpatternEnu,
853 maintTestsignalTypeEnu,
854 maintTestsignalBiterrors,
855 maintTestsignalBiterrorsterminal,
856 maintTestsignalSyncseconds,
857 maintTestsignalSyncsecondsterminal,
865 //otuAcceptedOperator,
871 //otuDegthrPercentage,
872 "", "", "", "", "", "","", "", "", "", "-1", "-1",
873 otuMaintLoopbackEnabled,
877 //mtOtuMaintLoopback,
887 private static Object[] prepareDevInterfaceTcmParameters(String nodeId, String interfaceName, Tcm tcm) {
889 String layer = tcm.getLayer().toString();
890 String monitoringModeEnu = tcm.getMonitoringMode().getName();
891 String ltcActEnabled = tcm.isLtcActEnabled().toString();
892 String proactiveDelayMeasurementEnabled = tcm.isProactiveDelayMeasurementEnabled().toString();
893 //String tcmDirectionEnu = "";
894 //String timDetectModeEnu = "";
895 //String txSapi = "";
896 //String txDapi = "";
897 //String txOperator = "";
898 //String acceptedSapi = "";
899 //String acceptedDapi = "";
900 //String acceptedOperator = "";
901 //String expectedSapi = "";
902 //String expectedDapi = "";
903 //String timActEnabled = "";
904 //String degmIntervals = "";
905 //String degthrPercentage = "";
906 String startTimestamp = getCurrentTimestamp();
908 return new Object[]{nodeId,
913 proactiveDelayMeasurementEnabled,
927 "", "", "", "", "", "", "", "", "", "", "", "", "",
933 private static Object[] prepareDevInterfaceOtnOduTxMsiParameters(String nodeId, String interfaceName, TxMsi txMsi) {
935 String tribSlot = txMsi.getTribSlot().toString();
936 String odtuType = txMsi.getOdtuType().getTypeName();
937 String tribPort = txMsi.getTribPort().toString();
938 String tribPortPayload = txMsi.getTribPortPayload();
940 String startTimestamp = getCurrentTimestamp();
942 return new Object[]{nodeId,
954 private static Object[] prepareDevInterfaceOtnOduRxMsiParameters(String nodeId, String interfaceName, RxMsi rxMsi) {
956 String tribSlot = rxMsi.getTribSlot().toString();
957 String odtuType = rxMsi.getOdtuType().getTypeName();
958 String tribPort = rxMsi.getTribPort().toString();
959 String tribPortPayload = rxMsi.getTribPortPayload();
961 String startTimestamp = getCurrentTimestamp();
963 return new Object[]{nodeId,
976 private static Object[] prepareDevInterfaceOtnOduExpMsiParameters(String nodeId, String interfaceName,
979 String tribSlot = expMsi.getTribSlot().toString();
980 String odtuType = expMsi.getOdtuType().getTypeName();
981 String tribPort = expMsi.getTribPort().toString();
982 String tribPortPayload = expMsi.getTribPortPayload();
984 String startTimestamp = getCurrentTimestamp();
986 return new Object[]{nodeId,
998 private void persistDevInterfaces(String nodeId, Connection connection) {
1000 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1001 Optional<OrgOpenroadmDevice> deviceObject =
1002 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1003 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1005 /*InstanceIdentifier<Interface> interfaceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
1006 .child(Interface.class);
1007 Optional<Interface> interfaceOpt =
1008 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, interfaceIID,
1009 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); */
1011 for (int i = 0; i < deviceObject.get().getInterface().size(); i++) {
1012 Interface deviceInterface;
1014 deviceInterface = deviceObject.get().getInterface().get(i);
1015 /*if (interfaceOpt.isPresent()) {
1016 deviceInterface = interfaceOpt.get();
1018 LOG.warn("Could not get interface info");
1021 Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
1023 String query = Queries.getQuery().deviceInterfacesInsert().get();
1024 LOG.info("Running {} query ", query);
1025 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1026 for (int j = 0; j < parameters.length; j++) {
1027 stmt.setObject(j + 1, parameters[j]);
1030 stmt.clearParameters();
1031 } catch (SQLException e) {
1032 LOG.error("Something wrong when storing devices interfaces in DB", e);
1037 private void persistDevProtocols(String nodeId, Connection connection) {
1039 InstanceIdentifier<Protocols> protocolsIID =
1040 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1041 Optional<Protocols> protocolObject =
1042 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1043 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1044 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1045 LOG.error("LLDP subtree is missing");
1048 String adminstatusEnu = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1049 .getAdminStatus().getName();
1050 String msgTxtInterval = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1051 .getMsgTxInterval().toString();
1052 String mxgTxHoldMultiplier = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1053 .getMsgTxHoldMultiplier().toString();
1054 String startTimestamp = getCurrentTimestamp();
1055 persistDevProtocolLldpPortConfig(nodeId, connection);
1056 persistDevProtocolLldpNbrList(nodeId, connection);
1058 Object[] parameters = {nodeId,
1061 mxgTxHoldMultiplier,
1066 String query = Queries.getQuery().deviceProtocolInsert().get();
1067 LOG.info("Running {} query ", query);
1068 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1069 for (int j = 0; j < parameters.length; j++) {
1070 stmt.setObject(j + 1, parameters[j]);
1073 stmt.clearParameters();
1074 } catch (SQLException e) {
1075 LOG.error("Something wrong when storing devices protocols in DB", e);
1081 private void persistDevProtocolLldpPortConfig(String nodeId, Connection connection) {
1083 InstanceIdentifier<Protocols> protocolsIID =
1084 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1085 Optional<Protocols> protocolObject =
1086 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1087 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1088 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1089 LOG.error("LLDP subtree is missing");
1092 String startTimestamp = getCurrentTimestamp();
1093 for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().size(); i++) {
1094 PortConfig portConfig =
1095 protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().get(i);
1096 String ifName = portConfig.getIfName();
1097 String adminStatusEnu = portConfig.getAdminStatus().getName();
1099 Object[] parameters = {nodeId,
1106 String query = Queries.getQuery().deviceProtocolPortConfigInsert().get();
1107 LOG.info("Running {} query ", query);
1108 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1109 for (int j = 0; j < parameters.length; j++) {
1110 stmt.setObject(j + 1, parameters[j]);
1113 stmt.clearParameters();
1114 } catch (SQLException e) {
1115 LOG.error("Something wrong when storing devices protocols LLDP Port config in DB", e);
1122 private void persistDevProtocolLldpNbrList(String nodeId, Connection connection) {
1124 InstanceIdentifier<Protocols> protocolsIID =
1125 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1126 Optional<Protocols> protocolObject =
1127 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1128 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1129 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1131 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, protocolsIID,
1132 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1135 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1136 LOG.error("LLDP nbrlist subtree is missing for {}", nodeId);
1139 String startTimestamp = getCurrentTimestamp();
1140 for (int i = 0; i < protocolObject.get()
1141 .augmentation(Protocols1.class).getLldp().getNbrList().getIfName().size(); i++) {
1143 IfName ifNameObj = protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList()
1144 .getIfName().get(i);
1145 String ifName = ifNameObj.getIfName();
1146 String remotesysname = ifNameObj.getRemoteSysName();
1147 String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
1148 String remotemgmtaddress = ifNameObj.getRemoteMgmtAddress().getIpv4Address().toString();
1149 String remoteportidsubtypeEnu = ifNameObj.getRemotePortIdSubType().getName();
1150 String remoteportid = ifNameObj.getRemotePortId();
1151 String remotechassisidsubtypeEnu = ifNameObj.getRemoteChassisIdSubType().getName();
1152 String remotechassisid = ifNameObj.getRemoteChassisId();
1154 Object[] parameters = {nodeId,
1157 remotemgmtaddresssubtype,
1159 remoteportidsubtypeEnu,
1161 remotechassisidsubtypeEnu,
1167 String query = Queries.getQuery().deviceProtocolLldpNbrlistInsert().get();
1168 LOG.info("Running {} query ", query);
1169 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1170 for (int j = 0; j < parameters.length; j++) {
1171 stmt.setObject(j + 1, parameters[j]);
1174 stmt.clearParameters();
1175 } catch (SQLException e) {
1176 LOG.error("Something wrong when storing devices protocols LLDP list number in DB", e);
1183 private void persistDevInternalLinks(String nodeId, Connection connection) {
1185 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1186 Optional<OrgOpenroadmDevice> deviceObject =
1187 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1188 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1189 if (deviceObject.get().getInternalLink() == null) {
1191 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1192 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1194 if (deviceObject.get().getInternalLink() == null) {
1195 LOG.info("External links not found for {}", nodeId);
1199 String startTimestamp = getCurrentTimestamp();
1200 for (int i = 0; i < deviceObject.get().getInternalLink().size(); i++) {
1201 InternalLink internalLink = deviceObject.get().getInternalLink().get(i);
1202 String internalLinkName = internalLink.getInternalLinkName();
1203 String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
1204 String sourcePortName = internalLink.getSource().getPortName().toString();
1205 String destinationCircuitPackName = internalLink.getDestination().getCircuitPackName();
1206 String destinationPortName = internalLink.getDestination().getPortName().toString();
1208 Object[] parameters = {nodeId,
1210 sourceCircuitPackName,
1212 destinationCircuitPackName,
1213 destinationPortName,
1218 String query = Queries.getQuery().deviceInternalLinkInsert().get();
1219 LOG.info("Running {} query ", query);
1220 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1221 for (int j = 0; j < parameters.length; j++) {
1222 stmt.setObject(j + 1, parameters[j]);
1225 stmt.clearParameters();
1226 } catch (SQLException e) {
1227 LOG.error("Something wrong when storing devices internal links", e);
1235 private void persistDevExternalLinks(String nodeId, Connection connection) {
1237 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1238 Optional<OrgOpenroadmDevice> deviceObject =
1239 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1240 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1242 if (deviceObject.get().getExternalLink() == null) {
1244 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1245 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1247 if (deviceObject.get().getExternalLink() == null) {
1248 LOG.info("External links not found for {}", nodeId);
1250 String startTimestamp = getCurrentTimestamp();
1251 for (int i = 0; i < deviceObject.get().getExternalLink().size(); i++) {
1252 ExternalLink externalLink = deviceObject.get().getExternalLink().get(i);
1253 String externalLinkName = externalLink.getExternalLinkName();
1254 String sourceNodeId = externalLink.getSource().getNodeId();
1255 String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
1256 String sourcePortName = externalLink.getSource().getPortName();
1257 String destinationNodeId = externalLink.getDestination().getNodeId();
1258 String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
1259 String destinationPortName = externalLink.getDestination().getPortName();
1261 Object[] parameters = {nodeId,
1264 sourceCircuitPackName,
1267 destinationCircuitPackName,
1268 destinationPortName,
1273 String query = Queries.getQuery().deviceExternalLinkInsert().get();
1274 LOG.info("Running {} query ", query);
1275 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1276 for (int j = 0; j < parameters.length; j++) {
1277 stmt.setObject(j + 1, parameters[j]);
1280 stmt.clearParameters();
1281 } catch (SQLException e) {
1282 LOG.error("Something wrong when storing devices external links", e);
1289 private void persistDevPhysicalLinks(String nodeId, Connection connection) {
1291 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1292 Optional<OrgOpenroadmDevice> deviceObject =
1293 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1294 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1295 if (deviceObject.get().getPhysicalLink() == null) {
1297 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1298 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1300 if (deviceObject.get().getPhysicalLink() == null) {
1301 LOG.info("Physical links not found for {}", nodeId);
1304 String startTimestamp = getCurrentTimestamp();
1305 for (int i = 0; i < deviceObject.get().getPhysicalLink().size(); i++) {
1306 PhysicalLink physicalLink = deviceObject.get().getPhysicalLink().get(i);
1307 String physicalLinkName = physicalLink.getPhysicalLinkName();
1308 String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
1309 String sourcePortName = physicalLink.getSource().getPortName().toString();
1310 String destinationCircuitPackName = physicalLink.getDestination().getCircuitPackName();
1311 String destinationPortName = physicalLink.getDestination().getPortName().toString();
1313 Object[] parameters = {nodeId,
1315 sourceCircuitPackName,
1317 destinationCircuitPackName,
1318 destinationPortName,
1323 String query = Queries.getQuery().devicePhysicalLinkInsert().get();
1324 LOG.info("Running {} query ", query);
1325 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1326 for (int j = 0; j < parameters.length; j++) {
1327 stmt.setObject(j + 1, parameters[j]);
1330 stmt.clearParameters();
1331 } catch (SQLException e) {
1332 LOG.error("Something wrong when storing devices physical links", e);
1339 private void persistDevDegree(String nodeId, Connection connection) {
1341 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1342 Optional<OrgOpenroadmDevice> deviceObject =
1343 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1344 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1347 /*if (deviceObject.get().getDegree()==null){
1349 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1350 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1352 if (deviceObject.get().getDegree() == null) {
1353 LOG.warn("Degree info not found for {}", nodeId);
1356 String startTimestamp = getCurrentTimestamp();
1357 for (int i = 0; i < deviceObject.get().getDegree().size(); i++) {
1358 Degree degree = deviceObject.get().getDegree().get(i);
1359 String degreeNumber = degree.getDegreeNumber().toString();
1360 String maxWavelengths = degree.getMaxWavelengths().toString();
1361 String otdrPortCircuitPackName =
1362 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getCircuitPackName());
1363 String otdrPortPortName =
1364 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getPortName().toString());
1365 //String mcCapabilitiesSlotWidthGranularity = "";
1366 //String mcCapabilitiesCenterFreqGranularity = "";
1367 //String mcCapabilitiesMinSlots = "-1";
1368 //String mcCapabilitiesMaxSlots = "-1";
1369 persistDevDegreeCircuitPack(nodeId, degree, degreeNumber, connection);
1370 persistDevDegreeConnectionPort(nodeId, degree, degreeNumber, connection);
1372 Object[] parameters = {nodeId,
1375 otdrPortCircuitPackName,
1377 //mcCapabilitiesSlotWidthGranularity,
1378 //mcCapabilitiesCenterFreqGranularity,
1379 //mcCapabilitiesMinSlots,
1380 //mcCapabilitiesMaxSlots,
1386 String query = Queries.getQuery().deviceDegreeInsert().get();
1387 LOG.info("Running {} query ", query);
1388 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1389 for (int j = 0; j < parameters.length; j++) {
1390 stmt.setObject(j + 1, parameters[j]);
1393 stmt.clearParameters();
1394 } catch (SQLException e) {
1395 LOG.error("Something wrong when storing devices degrees", e);
1403 private void persistDevDegreeCircuitPack(String nodeId, Degree degree, String degreeNumber, Connection connection) {
1405 String startTimestamp = getCurrentTimestamp();
1406 for (int i = 0; i < degree.getCircuitPacks().size(); i++) {
1408 String circuitPackIndex = degree.getCircuitPacks().get(i).getIndex().toString();
1409 String circuitPackName = degree.getCircuitPacks().get(i).getCircuitPackName();
1411 Object[] parameters = {nodeId,
1419 String query = Queries.getQuery().deviceDegreeCircuitPackInsert().get();
1420 LOG.info("Running {} query ", query);
1421 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1422 for (int j = 0; j < parameters.length; j++) {
1423 stmt.setObject(j + 1, parameters[j]);
1426 stmt.clearParameters();
1427 } catch (SQLException e) {
1428 LOG.error("Something wrong when storing devices degrees circuit packs", e);
1434 private void persistDevDegreeConnectionPort(String nodeId, Degree degree, String degreeNumber,
1435 Connection connection) {
1437 String startTimestamp = getCurrentTimestamp();
1438 for (int i = 0; i < degree.getConnectionPorts().size(); i++) {
1440 String connectionPortIndex = degree.getConnectionPorts().get(i).getIndex().toString();
1441 String circuitPackName = degree.getConnectionPorts().get(i).getCircuitPackName();
1442 String portName = degree.getConnectionPorts().get(i).getPortName().toString();
1444 Object[] parameters = {nodeId,
1446 connectionPortIndex,
1453 String query = Queries.getQuery().deviceDegreeConnectionPortInsert().get();
1454 LOG.info("Running {} query ", query);
1455 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1456 for (int j = 0; j < parameters.length; j++) {
1457 stmt.setObject(j + 1, parameters[j]);
1460 stmt.clearParameters();
1461 } catch (SQLException e) {
1462 LOG.error("Something wrong when storing devices degrees connection ports", e);
1469 private void persistDevSrg(String nodeId, Connection connection) {
1471 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1472 Optional<OrgOpenroadmDevice> deviceObject =
1473 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1474 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1476 if (deviceObject.get().getSharedRiskGroup() == null) {
1478 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1479 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1481 if (deviceObject.get().getSharedRiskGroup() == null) {
1482 LOG.info("no srg found for node {} ", nodeId);
1484 String startTimestamp = getCurrentTimestamp();
1485 for (int i = 0; i < deviceObject.get().getSharedRiskGroup().size(); i++) {
1486 SharedRiskGroup sharedRiskGroup = deviceObject.get().getSharedRiskGroup().get(i);
1487 //String currentProvisionedAddDropPorts = "-1";
1488 //String mcCapSlotWidthGranularity = "";
1489 //String mcCapCenterFreqGranularity = "";
1490 //String mcCapMinSlots = "-1";
1491 //String mcCapMaxSlots = "-1";
1492 String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
1493 String srgNumber = sharedRiskGroup.getSrgNumber().toString();
1494 String wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getName();
1495 persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
1497 Object[] parameters = {nodeId,
1499 //currentProvisionedAddDropPorts,
1502 wavelengthDuplicationEnu,
1503 //mcCapSlotWidthGranularity,
1504 //mcCapCenterFreqGranularity,
1512 String query = Queries.getQuery().deviceSharedRiskGroupInsert().get();
1513 LOG.info("Running {} query ", query);
1514 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1515 for (int j = 0; j < parameters.length; j++) {
1516 stmt.setObject(j + 1, parameters[j]);
1519 stmt.clearParameters();
1520 } catch (SQLException e) {
1521 LOG.error("Something wrong when storing devices SRG", e);
1529 private void persistDevSrgCircuitPacks(String nodeId, SharedRiskGroup sharedRiskGroup, String srgNumber,
1530 Connection connection) {
1532 String startTimestamp = getCurrentTimestamp();
1533 for (int i = 0; i < sharedRiskGroup.getCircuitPacks().size(); i++) {
1535 String circuitPackindex = sharedRiskGroup.getCircuitPacks().get(i).getIndex().toString();
1536 String circuitPackName = sharedRiskGroup.getCircuitPacks().get(i).getCircuitPackName();
1538 Object[] parameters = {nodeId,
1546 String query = Queries.getQuery().deviceSrgCircuitPackInsert().get();
1547 LOG.info("Running {} query ", query);
1548 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1549 for (int j = 0; j < parameters.length; j++) {
1550 stmt.setObject(j + 1, parameters[j]);
1553 stmt.clearParameters();
1554 } catch (SQLException e) {
1555 LOG.error("Something wrong when storing devices SRG circuit packs", e);
1561 private void persistDevRoadmConnections(String nodeId, Connection connection) {
1563 //int opticalcontrolmodeEnu=-1;
1565 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1566 Optional<OrgOpenroadmDevice> deviceObject =
1567 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1568 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1570 if (deviceObject.get().getRoadmConnections() == null) {
1572 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1573 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1576 if (deviceObject.get().getRoadmConnections() != null) {
1577 String startTimestamp = getCurrentTimestamp();
1578 for (int i = 0; i < deviceObject.get().getRoadmConnections().size(); i++) {
1579 RoadmConnections roadmConnections = deviceObject.get().getRoadmConnections().get(i);
1580 String connectionNumber = roadmConnections.getConnectionNumber();
1581 //String connectionName = "";
1582 String wavelengthNumber = roadmConnections.getWavelengthNumber().toString();
1583 String opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getName();
1584 String targetOutputPower = roadmConnections.getTargetOutputPower().toString();
1585 String srcIf = roadmConnections.getSource().getSrcIf();
1586 String dstIf = roadmConnections.getDestination().getDstIf();
1588 Object[] parameters = {nodeId,
1593 opticalcontrolmodeEnu,
1601 String query = Queries.getQuery().deviceRoadmConnectionsInsert().get();
1602 LOG.info("Running {} query ", query);
1603 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1604 for (int j = 0; j < parameters.length; j++) {
1605 stmt.setObject(j + 1, parameters[j]);
1608 stmt.clearParameters();
1609 } catch (SQLException e) {
1610 LOG.error("Something wrong when storing devices ROADM connection ", e);
1615 LOG.info("ROADM Dev Connections not found!! for {}", nodeId);
1620 private void persistDevConnectionMap(String nodeId, Connection connection) {
1622 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1623 Optional<OrgOpenroadmDevice> deviceObject =
1624 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1625 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1627 String startTimestamp = getCurrentTimestamp();
1628 for (int i = 0; i < deviceObject.get().getConnectionMap().size(); i++) {
1629 ConnectionMap connectionMap = deviceObject.get().getConnectionMap().get(i);
1630 String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
1631 String sourceCircuitPackName = connectionMap.getSource().getCircuitPackName();
1632 String sourcePortName = connectionMap.getSource().getCircuitPackName();
1635 Object[] parameters = {nodeId,
1636 connectionMapNumber,
1637 sourceCircuitPackName,
1643 String query = Queries.getQuery().deviceConnectionMapInsert().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 connection map", e);
1658 private void persistDevWavelengthMap(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().getWavelengthMap().getWavelengths().size(); i++) {
1667 Wavelengths wavelengths = deviceObject.get().getWavelengthMap().getWavelengths().get(i);
1668 String wavelengthNumber = wavelengths.getWavelengthNumber().toString();
1669 String centerFrequency = wavelengths.getCenterFrequency().toString();
1670 String wavelength = wavelengths.getWavelength().toString();
1673 Object[] parameters = {nodeId,
1681 String query = Queries.getQuery().deviceWavelengthInsert().get();
1682 LOG.info("Running {} query ", query);
1683 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1684 for (int j = 0; j < parameters.length; j++) {
1685 stmt.setObject(j + 1, parameters[j]);
1688 stmt.clearParameters();
1689 } catch (SQLException e) {
1690 LOG.error("Something wrong when storing devices wavelength map", e);
1697 private void persistDevInterfaceTcm(String nodeId, String interfaceName, OduBuilder oduBuilder,
1698 Connection connection) {
1700 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1703 tcm = oduBuilder.getTcm().get(i);
1705 Object[] parameters = prepareDevInterfaceTcmParameters(nodeId, interfaceName, tcm);
1707 String query = Queries.getQuery().deviceInterfacesInsert().get();
1708 LOG.info("Running {} query ", query);
1709 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1710 for (int j = 0; j < parameters.length; j++) {
1711 stmt.setObject(j + 1, parameters[j]);
1714 stmt.clearParameters();
1715 } catch (SQLException e) {
1716 LOG.error("Something wrong when storing devices interface tcm", e);
1721 private void persistDevInterfaceOtnOduTxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1722 Connection connection) {
1724 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1727 txMsi = oduBuilder.getOpu().getMsi().getTxMsi().get(i);
1729 Object[] parameters = prepareDevInterfaceOtnOduTxMsiParameters(nodeId, interfaceName, txMsi);
1731 String query = Queries.getQuery().deviceInterfaceOtnOduTxMsiInsert().get();
1732 LOG.info("Running {} query ", query);
1733 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1734 for (int j = 0; j < parameters.length; j++) {
1735 stmt.setObject(j + 1, parameters[j]);
1738 stmt.clearParameters();
1739 } catch (SQLException e) {
1740 LOG.error("Something wrong when storing devices interface OTN ODU Tx MSI", e);
1746 private void persistDevInterfaceOtnOduRxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1747 Connection connection) {
1749 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1752 rxMsi = oduBuilder.getOpu().getMsi().getRxMsi().get(i);
1754 Object[] parameters = prepareDevInterfaceOtnOduRxMsiParameters(nodeId, interfaceName, rxMsi);
1756 String query = Queries.getQuery().deviceInterfaceOtnOduRxMsiInsert().get();
1757 LOG.info("Running {} query ", query);
1758 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1759 for (int j = 0; j < parameters.length; j++) {
1760 stmt.setObject(j + 1, parameters[j]);
1763 stmt.clearParameters();
1764 } catch (SQLException e) {
1765 LOG.error("Something wrong when storing devices interface OTN ODU Rx MSI", e);
1771 private void persistDevInterfaceOtnOduExpMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1772 Connection connection) {
1774 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1777 expMsi = oduBuilder.getOpu().getMsi().getExpMsi().get(i);
1779 Object[] parameters = prepareDevInterfaceOtnOduExpMsiParameters(nodeId, interfaceName, expMsi);
1781 String query = Queries.getQuery().deviceInterfaceOtnOduExpMsiInsert().get();
1782 LOG.info("Running {} query ", query);
1783 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1784 for (int j = 0; j < parameters.length; j++) {
1785 stmt.setObject(j + 1, parameters[j]);
1788 stmt.clearParameters();
1789 } catch (SQLException e) {
1790 LOG.error("Something wrong when storing devices interface OTN ODU Exp MSI", e);