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 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 com.google.common.base.Preconditions;
17 import java.sql.Connection;
18 import java.sql.PreparedStatement;
19 import java.sql.ResultSet;
20 import java.sql.SQLException;
21 import java.util.Optional;
22 import java.util.concurrent.ExecutionException;
23 import javax.sql.DataSource;
25 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
26 import org.opendaylight.transportpce.common.Timeouts;
27 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
28 import org.opendaylight.transportpce.inventory.query.Queries;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.CpSlots;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.external.links.ExternalLink;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.internal.links.InternalLink;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.ConnectionMap;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Degree;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Info;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Protocols;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.physical.links.PhysicalLink;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelf.Slots;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelves.Shelves;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.Interface1;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.ethernet.container.EthernetBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.Protocols1;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.PortConfig;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.nbr.list.IfName;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.och.container.OchBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.ots.container.OtsBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.attributes.Tcm;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.container.OduBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.ExpMsi;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.RxMsi;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.TxMsi;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.otu.container.OtuBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.bridge.port.attr.RstpBridgePortTable;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.container.rstp.RstpBridgeInstance;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.wavelength.map.rev161014.wavelength.map.g.Wavelengths;
61 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
62 import org.slf4j.Logger;
63 import org.slf4j.LoggerFactory;
65 public class INode121 {
67 private static final Logger LOG = LoggerFactory.getLogger(INode121.class);
69 private final DataSource dataSource;
70 private final DeviceTransactionManager deviceTransactionManager;
72 public INode121(DataSource dataSource, DeviceTransactionManager deviceTransactionManager) {
73 this.dataSource = dataSource;
74 this.deviceTransactionManager = deviceTransactionManager;
77 public boolean addNode(String deviceId) {
79 InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
80 Optional<Info> infoOpt =
81 deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, infoIID,
82 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
84 if (infoOpt.isPresent()) {
85 deviceInfo = infoOpt.get();
87 LOG.warn("Could not get device info from DataBroker");
90 boolean sqlResult = false;
91 String query = Queries.getQuery().deviceInfoInsert().get();
92 LOG.info("Running {} query ", query);
93 try (Connection connection = dataSource.getConnection();
94 PreparedStatement preparedStatement = connection.prepareStatement(query)) {
95 Object[] prepareParameters = prepareDeviceInfoParameters(deviceInfo);
96 for (int i = 0; i < prepareParameters.length; i++) {
97 LOG.debug("Parameter {} has value {}", i + 1, prepareParameters[i]);
98 preparedStatement.setObject(i + 1, prepareParameters[i]);
101 int executeUpdate = preparedStatement.executeUpdate();
102 LOG.info("{} entries were added", executeUpdate);
105 LOG.debug("iNode AddNode call complete");
106 getRoadmShelves(deviceId);
107 LOG.debug("iNode getRoadmShelves call complete");
108 getCircuitPacks(deviceId);
109 LOG.debug("iNode getCircuitPacks call complete");
111 LOG.debug("iNode persist interfaces call");
112 persistDevInterfaces(deviceId, connection);
113 LOG.debug("iNode persist interfaces call complete");
116 LOG.debug("iNode persist protocols call");
117 persistDevProtocols(deviceId, connection);
118 LOG.debug("iNode persist protocols call complete");
121 LOG.debug("iNode persist wavelength map call");
122 persistDevWavelengthMap(deviceId, connection);
123 LOG.debug("iNode persist wavelength map call complete");
125 LOG.debug("iNode persist internal links map call");
126 persistDevInternalLinks(deviceId, connection);
127 LOG.debug("iNode persist internal links map call complete");
129 LOG.debug("iNode persist Physical links map call");
130 persistDevPhysicalLinks(deviceId, connection);
131 LOG.debug("iNode persist Physical links map call complete");
133 LOG.debug("iNode persist External links map call");
134 persistDevExternalLinks(deviceId, connection);
135 LOG.debug("iNode persist External links map call complete");
137 LOG.debug("iNode persist degree map call");
138 persistDevDegree(deviceId, connection);
139 LOG.debug("iNode persist degree map call complete");
141 LOG.debug("iNode persist srg map call");
142 persistDevSrg(deviceId, connection);
143 LOG.debug("iNode persist srg map call complete");
145 LOG.debug("iNode persist Roadm Connections call");
146 persistDevRoadmConnections(deviceId, connection);
147 LOG.debug("iNode persist Roadm Connections call complete");
149 LOG.debug("iNode persist Connection Map call");
150 persistDevConnectionMap(deviceId, connection);
151 LOG.debug("iNode persist Connection Map call complete");
153 } catch (SQLException e) {
154 LOG.error(e.getMessage(), e);
155 } catch (InterruptedException e) {
156 LOG.error(e.getMessage(), e);
157 } catch (ExecutionException e) {
158 LOG.error(e.getMessage(), e);
163 public boolean nodeExists(String nodeId) {
164 String selectTableSQL = "select count(*) node_exists from inv_dev_info where node_id = ?";
166 LOG.info("Checking if {} exists in DB", nodeId);
167 try (Connection connection = dataSource.getConnection();
168 PreparedStatement preparedStmt = connection.prepareStatement(selectTableSQL)) {
169 preparedStmt.setString(1, nodeId);
170 try (ResultSet rs = preparedStmt.executeQuery()) {
172 nodeExists = rs.getInt("node_exists");
173 LOG.debug("Found {} devices matching {}", nodeExists, nodeId);
176 } catch (SQLException e) {
177 LOG.error(e.getMessage(), e);
179 return nodeExists == 0 ? false : true;
182 public void getRoadmShelves(String nodeId) throws InterruptedException, ExecutionException {
183 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
184 Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
185 LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT,
186 Timeouts.DEVICE_READ_TIMEOUT_UNIT);
188 LOG.info("Shelves size {}", deviceObject.get().getShelves().size());
189 try (Connection connection = dataSource.getConnection()) {
190 Preconditions.checkNotNull(connection);
191 for (int i = 0; i < deviceObject.get().getShelves().size(); i++) {
192 Shelves shelve = deviceObject.get().getShelves().get(i);
193 String shelfName = shelve.getShelfName();
195 LOG.info("Getting Shelve Details of {}", shelfName);
196 if (shelve.getSlots() != null) {
197 LOG.info("Slot Size {} ", shelve.getSlots().size());
198 persistShelveSlots(nodeId, shelve, connection);
200 LOG.info("No Slots for shelf {}", shelfName);
203 persistShelves(nodeId, connection, shelve);
205 } catch (SQLException e1) {
206 LOG.error(e1.getMessage(), e1);
210 public void getCircuitPacks(String nodeId) throws InterruptedException, ExecutionException {
211 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
212 Optional<OrgOpenroadmDevice> deviceObject =
213 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
214 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
215 if (!deviceObject.isPresent()) {
216 LOG.warn("Device object {} was not found", nodeId);
219 LOG.info("Circuit pack size {}", deviceObject.get().getCircuitPacks().size());
221 try (Connection connection = dataSource.getConnection()) {
222 Preconditions.checkNotNull(connection);
223 for (int i = 0; i < deviceObject.get().getCircuitPacks().size(); i++) {
224 CircuitPacks cp = deviceObject.get().getCircuitPacks().get(i);
226 if (cp.getCpSlots() != null) {
227 persistCircuitPacksSlots(nodeId, cp, connection);
229 LOG.info("Everything {}", cp);
230 LOG.info("CP is {}", cp);
232 //persistPorts(cp, connection);
233 if (cp.getPorts() != null) {
234 persistCPPorts(nodeId, connection, cp);
236 persistCircuitPacks(nodeId, connection, cp);
238 } catch (SQLException e1) {
239 LOG.error(e1.getMessage(), e1);
243 private void persistCircuitPacks(String nodeId, Connection connection, CircuitPacks cp) {
244 Object[] parameters = prepareCircuitPacksParameters(nodeId, cp);
245 String query = Queries.getQuery().deviceCircuitPackInsert().get();
246 LOG.info("Running {} query ", query);
247 try (PreparedStatement stmt = connection.prepareStatement(query)) {
248 for (int j = 0; j < parameters.length; j++) {
249 stmt.setObject(j + 1, parameters[j]);
252 stmt.clearParameters();
253 } catch (SQLException e) {
254 LOG.error(e.getMessage(), e);
258 private void persistShelves(String nodeId, Connection connection, Shelves shelve) {
259 Object[] shelvesParameter = prepareShelvesParameters(nodeId, shelve);
260 String query = Queries.getQuery().deviceShelfInsert().get();
261 LOG.info("Running {} query ", query);
262 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
263 for (int j = 0; j < shelvesParameter.length; j++) {
264 preparedStmt.setObject(j + 1, shelvesParameter[j]);
266 preparedStmt.execute();
267 preparedStmt.clearParameters();
268 } catch (SQLException e) {
269 LOG.error(e.getMessage(), e);
273 private void persistShelveSlots(String nodeId, Shelves shelves, Connection connection) {
274 String startTimetampStr = getCurrentTimestamp();
275 for (int i = 0; i < shelves.getSlots().size(); i++) {
276 Slots slot = shelves.getSlots().get(i);
277 LOG.info("Getting Slot Details of {}", slot.getSlotName());
278 Object[] parameters = new Object[]{nodeId,
279 shelves.getShelfName(),
282 slot.getProvisionedCircuitPack(),
286 String query = Queries.getQuery().deviceShelfSlotInsert().get();
287 LOG.info("Running {} query ", query);
288 try (PreparedStatement stmt = connection.prepareStatement(query)) {
289 for (int j = 0; j < parameters.length; j++) {
290 stmt.setObject(j + 1, parameters[j]);
293 stmt.clearParameters();
294 } catch (SQLException e) {
295 LOG.error(e.getMessage(), e);
301 private void persistCircuitPacksSlots(String nodeId, CircuitPacks circuitPacks, Connection connection) {
302 String startTimetampStr = getCurrentTimestamp();
303 for (int i = 0; i < circuitPacks.getCpSlots().size(); i++) {
304 CpSlots cpSlot = circuitPacks.getCpSlots().get(i);
306 Object[] parameters = new Object[]{nodeId,
307 circuitPacks.getCircuitPackName(),
308 cpSlot.getSlotName(),
310 cpSlot.getProvisionedCircuitPack(),
315 String query = Queries.getQuery().deviceCPSlotInsert().get();
316 LOG.info("Running {} query ", query);
317 try (PreparedStatement stmt = connection.prepareStatement(query)) {
318 for (int j = 0; j < parameters.length; j++) {
319 stmt.setObject(j + 1, parameters[j]);
322 stmt.clearParameters();
323 } catch (SQLException e) {
324 LOG.error(e.getMessage(), e);
329 private void persistPorts(CircuitPacks circuitPacks, Connection connection) {
330 LOG.warn("Ports are not persisted yet");
335 * Prepares parameters for device insert query.
337 * @param deviceInfo device information
338 * @return Object an object
340 private static Object[] prepareDeviceInfoParameters(Info deviceInfo) {
341 String startTimetampStr = getCurrentTimestamp();
343 String nodeId = prepareDashString(deviceInfo.getNodeId());
344 Long nodeNumber = deviceInfo.getNodeNumber();
345 String nodeTypeEnu = deviceInfo.getNodeType().getName();
346 String clli = prepareDashString(deviceInfo.getClli());
347 String vendor = prepareDashString(deviceInfo.getVendor());
348 String model = prepareDashString(deviceInfo.getModel());
349 String serialId = prepareDashString(deviceInfo.getSerialId());
350 String ipAddress = prepareDashString(deviceInfo.getIpAddress().getIpv4Address().getValue());
351 String prefixLength = prepareDashString(deviceInfo.getPrefixLength());
352 String defaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
353 String sourceEnum = deviceInfo.getSource().getName();
354 String currentIpAddress = prepareDashString(deviceInfo.getCurrentIpAddress().getIpv4Address().getValue());
355 String currentPrefixLength = prepareDashString(deviceInfo.getCurrentPrefixLength());
356 String currentDefaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
357 String macAddress = prepareDashString(deviceInfo.getMacAddress().getValue());
358 String softwareVersion = prepareDashString(deviceInfo.getSoftwareVersion());
359 //String openroadmVersion = "1.2.1";
360 String template = prepareDashString(deviceInfo.getTemplate());
361 String currentDatetime = prepareDashString(deviceInfo.getCurrentDatetime().getValue());
362 String geoLatitude = (deviceInfo.getGeoLocation() != null
363 ? prepareDashString(deviceInfo.getGeoLocation().getLatitude()) : "");
364 String geoLongitude = (deviceInfo.getGeoLocation() != null
365 ? prepareDashString(deviceInfo.getGeoLocation().getLongitude()) : "");
366 String maxDegrees = (deviceInfo.getMaxDegrees() == null ? "-1" : prepareDashString(deviceInfo.getMaxDegrees()));
367 String maxSrgs = (deviceInfo.getMaxSrgs() == null ? "-1" : prepareDashString(deviceInfo.getMaxSrgs()));
368 String swVersion = prepareDashString(deviceInfo.getSoftwareVersion()); //sw_version
369 String swValidationTimer = prepareDashString(""); //sw_validation_timer
370 String activationDateTime = prepareDashString(""); //activation_date_time
371 //Integer maxNumBin15minHistoricalPm = null;
372 //Integer maxNumBin24hourHistoricalPm = null;
373 /*jsonDevInfo = JsonStringBuilder.getDevInfoJson().replace("$$NODE-ID$$",nodeId)
374 .replace("$$NODE-NUMBER$$", nodeNumber)
375 .replace("$$NODE-TYPE$$",nodeType)
376 .replace("$$CLLI$$",clli)
377 .replace("$$VENDOR$$",vendor)
378 .replace("$$MODEL$$",model)
379 .replace("$$SERIAL-ID$$",serialId)
380 .replace("$$IPADDRESS$$",ipAddress)
381 .replace("$$PREFIX-LENGTH$$",prefixLength)
382 .replace("$$DEFAULTGATEWAY$$",defaultGateway)
383 .replace("$$SOURCE$$",String.valueOf(source))
384 .replace("$$CURRENT-IPADDRESS$$",currentIpAddress)
385 .replace("$$CURRENT-PREFIX-LENGTH$$",currentPrefixLength)
386 .replace("$$CURRENT-DEFAULTGATEWAY$$",currentDefailtGateway)
387 .replace("$$MACADDRESS$$",macAddress)
388 .replace("$$SOFTWAREVERSION$$",softwareVersion)
389 .replace("$$OPENROADM-VERSION$$",openroadmVersion)
390 .replace("$$TEMPLATE$$",template)
391 .replace("$$CURRENT-DATETIME$$",currentDatetime)
392 .replace("$$LATITUDE$$",latitude)
393 .replace("$$LONGITUDE$$",longitude)
394 .replace("$$MAX-DEGREES$$",maxDegrees)
395 .replace("$$MAX-SRGS$$",maxSrgs)
396 .replace("$$MAX-NUM-BIN-15MIN-HISTORICAL-PM$$",prepareDashString(""))
397 .replace("$$MAX-NUM-BIN-24HOUR-HISTORICAL-PM$$",prepareDashString(""))
398 .replace("$$SW-VERSION$$",swVersion)
399 .replace("$$SW-VALIDATION-TIMER$$",swValidationTimer)
400 .replace("$$ACTIVATION-DATE-TIME$$",activationDateTime);*/
417 currentDefaultGateway,
428 //maxNumBin15minHistoricalPm,
429 //maxNumBin24hourHistoricalPm,
440 private static Object[] prepareShelvesParameters(String nodeId, Shelves shelve) {
441 String startTimestamp = getCurrentTimestamp();
443 return new Object[]{nodeId,
444 shelve.getShelfName(),
445 shelve.getShelfType(),
447 shelve.getShelfPosition(),
448 (shelve.getAdministrativeState() == null ? null : shelve.getAdministrativeState().getIntValue()),
451 shelve.getSerialId(),
453 shelve.getProductCode(),
454 (shelve.getManufactureDate() == null ? null : shelve.getManufactureDate().getValue()),
456 shelve.getHardwareVersion(),
457 (shelve.getOperationalState() == null ? null : shelve.getOperationalState().getIntValue()),
458 (shelve.getEquipmentState() == null ? null : shelve.getEquipmentState().getIntValue()),
459 (shelve.getDueDate() == null ? null : shelve.getDueDate().getValue()),
465 private static Object[] prepareCPPortsParameters(String nodeId, CircuitPacks circuitPacks, Ports cpPort) {
467 String circuitPackName = circuitPacks.getCircuitPackName();
468 String portName = cpPort.getPortName();
469 String portType = cpPort.getPortType();
470 String portQualEnu = String.valueOf((cpPort.getPortQual() == null ? "-1" : cpPort.getPortQual().getName()));
471 String portWavelengthTypeEnu = "-1"; //cpPort.getPortWavelengthType().getIntValue(); /* Check error*/
472 String portDirectionEnu = String.valueOf((cpPort.getPortDirection() == null ? "" :
473 cpPort.getPortDirection().getName()));
474 String label = cpPort.getLabel();
475 String circuitId = cpPort.getCircuitId();
476 String administrativeStateEnu = (cpPort.getAdministrativeState() == null ? "" :
477 cpPort.getAdministrativeState().getName());
478 String operationalStateEnu =
479 (cpPort.getOperationalState() == null ? "" : cpPort.getOperationalState().getName());
480 String logicalConnectionPoint = cpPort.getLogicalConnectionPoint();
481 String parentPortCircuitPackName = (cpPort.getPartnerPort() == null ? "" :
482 (cpPort.getPartnerPort().getCircuitPackName() == null ? "" : cpPort.getPartnerPort().getCircuitPackName()));
483 String partnerPortPortName = (cpPort.getPartnerPort() == null ? "" :
484 (cpPort.getPartnerPort().getPortName() == null ? "" : cpPort.getPartnerPort().getPortName().toString()));
485 String partnerPortCircuitPackName = (cpPort.getParentPort() == null ? "" :
486 (cpPort.getParentPort().getCircuitPackName() == null ? "" : cpPort.getParentPort().getCircuitPackName()));
487 String parentPortPortName = (cpPort.getParentPort() == null ? "" :
488 (cpPort.getParentPort().getPortName() == null ? "" : cpPort.getParentPort().toString()));
489 String roadmPortPortPowerCapabilityMinRx = (cpPort.getRoadmPort() == null ? "" :
490 (cpPort.getRoadmPort().getPortPowerCapabilityMinRx() == null ? "" :
491 cpPort.getRoadmPort().getPortPowerCapabilityMinRx().toString()));
492 String roadmPortPortPowerCapabilityMinTx = (cpPort.getRoadmPort() == null ? "" :
493 (cpPort.getRoadmPort().getPortPowerCapabilityMinTx() == null ? "" :
494 cpPort.getRoadmPort().getPortPowerCapabilityMinTx().toString()));
495 String roadmPortPortPowerCapabilityMaxRx = (cpPort.getRoadmPort() == null ? "" :
496 (cpPort.getRoadmPort().getPortPowerCapabilityMaxRx() == null ? "" :
497 cpPort.getRoadmPort().getPortPowerCapabilityMaxRx().toString()));
498 String roadmPortPortPowerCapabilityMaxTx = (cpPort.getRoadmPort() == null ? "" :
499 (cpPort.getRoadmPort().getPortPowerCapabilityMaxTx() == null ? "" :
500 cpPort.getRoadmPort().getPortPowerCapabilityMaxTx().toString()));
501 //String roadmPortCapableWavelengths = "";
502 //String roadmPortAvailableWavelengths = "";
503 //String roadmPortUsedWavelengths = "";
504 String transponderPortPortPowerCapabilityMinRx = (cpPort.getTransponderPort() == null ? "" :
505 (cpPort.getTransponderPort().getPortPowerCapabilityMinRx() == null ? "" :
506 cpPort.getTransponderPort().getPortPowerCapabilityMinRx().toString()));
507 String transponderPortPortPowerCapabilityMinTx = (cpPort.getTransponderPort() == null ? "" :
508 (cpPort.getTransponderPort().getPortPowerCapabilityMinTx() == null ? "" :
509 cpPort.getTransponderPort().getPortPowerCapabilityMinTx().toString()));
510 String transponderPortPortPowerCapabilityMaxRx = (cpPort.getTransponderPort() == null ? "" :
511 (cpPort.getTransponderPort().getPortPowerCapabilityMaxRx() == null ? "" :
512 cpPort.getTransponderPort().getPortPowerCapabilityMaxRx().toString()));
513 String transponderPortPortPowerCapabilityMaxTx = (cpPort.getTransponderPort() == null ? "" :
514 (cpPort.getTransponderPort().getPortPowerCapabilityMaxTx() == null ? "" :
515 cpPort.getTransponderPort().getPortPowerCapabilityMaxTx().toString()));
516 //String transponderPortCapableWavelengths = "";
517 String otdrPortLaunchCableLength = (cpPort.getOtdrPort() == null ? "" :
518 (cpPort.getOtdrPort().getLaunchCableLength() == null ? "" :
519 cpPort.getOtdrPort().getLaunchCableLength().toString()));
520 String otdrPortPortDirection = (cpPort.getOtdrPort() == null ? "-1" :
521 (cpPort.getOtdrPort().getPortDirection() == null ? "-1" :
522 Integer.valueOf(cpPort.getOtdrPort().getPortDirection().getIntValue()).toString()));
523 //String ilaPortPortPowerCapabilityMixRx = "";
524 //String ilaPortPortPowerCapabilityMixTx = "";
525 //String ilaPortPortPowerCapabilityMaxRx = "";
526 //String ilaPortPortPowerCapabilityMaxTx = "";
528 String startTimestamp = getCurrentTimestamp();
530 return new Object[]{nodeId,
535 portWavelengthTypeEnu,
539 administrativeStateEnu,
541 logicalConnectionPoint,
542 partnerPortCircuitPackName,
544 parentPortCircuitPackName,
546 roadmPortPortPowerCapabilityMinRx,
547 roadmPortPortPowerCapabilityMinTx,
548 roadmPortPortPowerCapabilityMaxRx,
549 roadmPortPortPowerCapabilityMaxTx,
550 //roadmPortCapableWavelengths,
551 //roadmPortAvailableWavelengths,
552 //roadmPortUsedWavelengths,
554 transponderPortPortPowerCapabilityMinRx,
555 transponderPortPortPowerCapabilityMinTx,
556 transponderPortPortPowerCapabilityMaxRx,
557 transponderPortPortPowerCapabilityMaxTx,
558 //transponderPortCapableWavelengths,
560 otdrPortLaunchCableLength,
561 otdrPortPortDirection,
562 //ilaPortPortPowerCapabilityMixRx,
563 //ilaPortPortPowerCapabilityMixTx,
564 //ilaPortPortPowerCapabilityMaxRx,
565 //ilaPortPortPowerCapabilityMaxTx,
573 private static Object[] prepareCircuitPacksParameters(String nodeId, CircuitPacks cpack) {
574 String startTimestamp = getCurrentTimestamp();
575 return new Object[]{nodeId,
576 cpack.getCircuitPackName(),
577 cpack.getCircuitPackType(),
578 cpack.getCircuitPackProductCode(),
579 (cpack.getAdministrativeState() == null ? "" : cpack.getAdministrativeState().getIntValue()),
584 cpack.getProductCode(),
585 (cpack.getManufactureDate() == null ? "" : cpack.getManufactureDate().getValue()),
587 cpack.getHardwareVersion(),
588 (cpack.getOperationalState() == null ? -1 : cpack.getOperationalState().getIntValue()),
589 cpack.getCircuitPackCategory().getType().getIntValue(),
590 cpack.getCircuitPackCategory().getExtension(),
591 (cpack.getEquipmentState() == null ? -1 : cpack.getEquipmentState().getIntValue()),
592 cpack.getCircuitPackMode(),
596 prepareEmptyString(cpack.getDueDate()),
597 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
598 ((cpack.getParentCircuitPack().getCircuitPackName() == null) ? "" :
599 cpack.getParentCircuitPack().getCircuitPackName())
601 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
602 ((cpack.getParentCircuitPack().getCpSlotName() == null) ? "" :
603 cpack.getParentCircuitPack().getCpSlotName())
610 private void persistCPPorts(String nodeId, Connection connection, CircuitPacks circuitPacks) {
612 for (int i = 0; i < circuitPacks.getPorts().size(); i++) {
613 Object[] cpPortsParameters = prepareCPPortsParameters(nodeId, circuitPacks, circuitPacks.getPorts().get(i));
614 String query = Queries.getQuery().deviceCPPortInsert().get();
615 LOG.info("Running {} query ", query);
616 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
617 for (int j = 0; j < cpPortsParameters.length; j++) {
618 preparedStmt.setObject(j + 1, cpPortsParameters[j]);
620 preparedStmt.execute();
621 preparedStmt.clearParameters();
622 } catch (SQLException e) {
623 LOG.error(e.getMessage(), e);
629 private Object[] prepareDevInterfaceParameters(String nodeId, Interface deviceInterface, Connection connection) {
631 String ethernetDuplexEnu = "";
632 String ethernetAutoNegotiationEnu = "";
633 String maintTestsignalTestpatternEnu = "";
634 String maintTestsignalTypeEnu = "";
635 String otuFecEnu = "";
636 String otuMaintTypeEnu = "";
637 String otsFiberTypeEnu = "";
638 String ethernetSpeed = "-1";
639 String ethernetFec = "";
640 String ethernetMtu = "-1";
641 String ethernetCurrSpeed = "";
642 String ethernetCurrDuplex = "-1";
643 //String mciMcttpMinFreq = "";
644 //String mciMcttpMaxFreq = "";
645 //String mciMcttpCenterFreq = "";
646 //String mciMcttpSlotWidth = "";
647 //String mciNmcCtpFrequency = "";
648 //String mciNmcCtpWidth = "";
650 //String ochFrequency = "";
651 //String ochWidth = "";
652 String ochWavelengthNumber = "";
653 String ochModulationFormat = "";
654 String ochTransmitPower = "";
655 String otsSpanLossReceive = "";
656 String otsSpanLossTransmit = "";
657 //String otsIngressSpanLossAgingMargin = "";
658 //String otsEolMaxLoadPin = "";
660 //String oduFunction = "";
661 String oduMonitoringMode = "";
662 //String oduNoOamFunction = "";
663 String oduProactiveDelayMeasurementEnabled = "";
664 //String oduPoaTribPortNumber = "-1";
665 //String oduTxSapi = "";
666 //String oduTxDapi = "";
667 //String oduTxOperator = "";
668 //String oduAcceptedSapi = "";
669 //String oduAcceptedDapi = "";
670 //String oduAcceptedOperator = "";
671 //String oduExpectedSapi = "";
672 //String oduExpectedDapi = "";
673 //String oduTimActEnabled = "";
674 //String oduTimDetectMode = "";
675 //String oduDegmIntervals = "-1";
676 //String oduDegthrPercentage = "-1";
677 String opuPayloadType = "";
678 String opuRxPayloadType = "";
679 String opuExpPayloadType = "";
680 String opuPayloadInterface = "";
681 String maintTestsignalEnabled = "";
682 String maintTestsignalBiterrors = "-1";
683 String maintTestsignalBiterrorsterminal = "-1";
684 String maintTestsignalSyncseconds = "-1";
685 String maintTestsignalSyncsecondsterminal = "-1";
687 //String otuTxSapi = "";
688 //String otuTxDapi = "";
689 //String otuTxOperator = "";
690 //String otuAcceptedSapi = "";
691 //String otuAcceptedDapi = "";
692 //String otuAcceptedOperator = "";
693 //String otuExpectedSapi = "";
694 //String otuExpectedDapi = "";
695 //String otuTimActEnabled = "";
696 //String otuTimDetectMode = "";
697 //String otuDegmIntervals = "-1";
698 //String otuDegthrPercentage = "-1";
699 String otuMaintLoopbackEnabled = "";
700 //String mtOtuRate = "";
701 //String mtOtuFec = "";
702 //String mtOtuMaintLoopback = "";
703 //String mtOtuEnabled = "";
704 //String mtOtuType = "";
706 String name = deviceInterface.getName();
707 String description = deviceInterface.getDescription();
708 String type = deviceInterface.getType().getTypeName();
709 String administrativeStateEnu = deviceInterface.getAdministrativeState().getName();
710 int operationalState = deviceInterface.getOperationalState().getIntValue();
711 String circuitId = deviceInterface.getCircuitId();
712 String supportingInterface = deviceInterface.getSupportingInterface();
713 String supportingCircuitPackName = deviceInterface.getSupportingCircuitPackName();
714 String supportingPort = deviceInterface.getSupportingPort().toString();
716 switch (deviceInterface.getType().toString()) {
719 //EthernetBuilder ethIfBuilder = new EthernetBuilder();
720 EthernetBuilder ethIfBuilder = new EthernetBuilder(deviceInterface.augmentation(Interface1.class)
722 ethernetSpeed = (ethIfBuilder.getSpeed() == null ? "-1" :
723 Integer.valueOf(ethIfBuilder.getSpeed().intValue()).toString());
724 ethernetFec = ethIfBuilder.getFec().getName();
725 ethernetDuplexEnu = (ethIfBuilder.getDuplex() == null ? "" : ethIfBuilder.getDuplex().getName());
726 ethernetMtu = ethIfBuilder.getMtu().toString();
727 ethernetAutoNegotiationEnu = ethIfBuilder.getAutoNegotiation().getName();
728 ethernetCurrSpeed = ethIfBuilder.getCurrSpeed();
729 ethernetCurrDuplex = ethIfBuilder.getCurrDuplex();
733 OchBuilder ochIfBuilder = new OchBuilder(deviceInterface.augmentation(
734 org.opendaylight.yang.gen.v1
735 .http.org.openroadm.optical.channel.interfaces.rev161014.Interface1.class)
737 ochRate = ochIfBuilder.getRate().getName();
738 ochWavelengthNumber = ochIfBuilder.getWavelengthNumber().toString();
739 ochModulationFormat = ochIfBuilder.getModulationFormat().getName();
740 ochTransmitPower = ochIfBuilder.getTransmitPower().toString();
744 OtsBuilder otsIfBuilder = new OtsBuilder(deviceInterface.augmentation(
745 org.opendaylight.yang.gen.v1
746 .http.org.openroadm.optical.transport.interfaces.rev161014.Interface1.class)
748 otsFiberTypeEnu = String.valueOf(otsIfBuilder.getFiberType().getIntValue());
749 otsSpanLossReceive = otsIfBuilder.getSpanLossReceive().toString();
750 otsSpanLossTransmit = otsIfBuilder.getSpanLossTransmit().toString();
754 OduBuilder oduIfBuilder = new OduBuilder(deviceInterface.augmentation(
755 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1.class)
757 oduRate = String.valueOf(oduIfBuilder.getRate());
758 oduMonitoringMode = oduIfBuilder.getMonitoringMode().getName();
759 oduProactiveDelayMeasurementEnabled = oduIfBuilder.isProactiveDelayMeasurementEnabled().toString();
761 persistDevInterfaceTcm(nodeId, name, oduIfBuilder, connection);
762 persistDevInterfaceOtnOduTxMsi(nodeId, name, oduIfBuilder, connection);
763 persistDevInterfaceOtnOduRxMsi(nodeId, name, oduIfBuilder, connection);
764 persistDevInterfaceOtnOduExpMsi(nodeId, name, oduIfBuilder, connection);
766 opuPayloadType = oduIfBuilder.getOpu().getPayloadType();
767 opuRxPayloadType = oduIfBuilder.getOpu().getRxPayloadType();
768 opuExpPayloadType = oduIfBuilder.getOpu().getExpPayloadType();
769 opuPayloadInterface = oduIfBuilder.getOpu().getPayloadInterface();
770 /*persistDevInterfaceOtnOduTxMsi(nodeId,name,oduIfBuilder,connection);
771 persistDevInterfaceOtnOduRxMsi(nodeId,name,oduIfBuilder,connection);
772 persistDevInterfaceOtnOduExpMsi(nodeId,name,oduIfBuilder,connection); */
773 maintTestsignalEnabled = oduIfBuilder.getMaintTestsignal().isEnabled().toString();
774 maintTestsignalTestpatternEnu = oduIfBuilder.getMaintTestsignal().getTestPattern().getName();
775 maintTestsignalTypeEnu = oduIfBuilder.getMaintTestsignal().getType().getName();
776 maintTestsignalBiterrors = Integer.valueOf(oduIfBuilder.getMaintTestsignal().getBitErrors().intValue())
778 maintTestsignalBiterrorsterminal = oduIfBuilder.getMaintTestsignal().getBitErrorsTerminal().toString();
779 maintTestsignalSyncseconds = oduIfBuilder.getMaintTestsignal().getSyncSeconds();
780 maintTestsignalSyncsecondsterminal = oduIfBuilder.getMaintTestsignal().getSyncSecondsTerminal();
784 OtuBuilder otuIfBuilder =
785 new OtuBuilder(deviceInterface.augmentation(
786 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1.class)
788 otuRate = otuIfBuilder.getRate().getName();
789 otuFecEnu = otuIfBuilder.getFec().getName();
790 otuMaintLoopbackEnabled = otuIfBuilder.getMaintLoopback().isEnabled().toString();
791 otuMaintTypeEnu = otuIfBuilder.getMaintLoopback().getType().getName();
795 LOG.error("could not get interface type");
799 String startTimestamp = getCurrentTimestamp();
801 return new Object[]{nodeId,
805 administrativeStateEnu,
806 Integer.toString(operationalState),
809 supportingCircuitPackName,
815 ethernetAutoNegotiationEnu,
820 //mciMcttpCenterFreq,
822 //mciNmcCtpFrequency,
824 "", "", "", "", "", "",
835 //otsIngressSpanLossAgingMargin,
844 oduProactiveDelayMeasurementEnabled,
845 //oduPoaTribPortNumber,
851 //oduAcceptedOperator,
857 //oduDegthrPercentage,
858 "-1", "", "", "", "", "","", "", "", "", "", "-1", "-1",
863 maintTestsignalEnabled,
864 maintTestsignalTestpatternEnu,
865 maintTestsignalTypeEnu,
866 maintTestsignalBiterrors,
867 maintTestsignalBiterrorsterminal,
868 maintTestsignalSyncseconds,
869 maintTestsignalSyncsecondsterminal,
877 //otuAcceptedOperator,
883 //otuDegthrPercentage,
884 "", "", "", "", "", "","", "", "", "", "-1", "-1",
885 otuMaintLoopbackEnabled,
889 //mtOtuMaintLoopback,
899 private static Object[] prepareDevInterfaceTcmParameters(String nodeId, String interfaceName, Tcm tcm) {
901 String layer = tcm.getLayer().toString();
902 String monitoringModeEnu = tcm.getMonitoringMode().getName();
903 String ltcActEnabled = tcm.isLtcActEnabled().toString();
904 String proactiveDelayMeasurementEnabled = tcm.isProactiveDelayMeasurementEnabled().toString();
905 //String tcmDirectionEnu = "";
906 //String timDetectModeEnu = "";
907 //String txSapi = "";
908 //String txDapi = "";
909 //String txOperator = "";
910 //String acceptedSapi = "";
911 //String acceptedDapi = "";
912 //String acceptedOperator = "";
913 //String expectedSapi = "";
914 //String expectedDapi = "";
915 //String timActEnabled = "";
916 //String degmIntervals = "";
917 //String degthrPercentage = "";
918 String startTimestamp = getCurrentTimestamp();
920 return new Object[]{nodeId,
925 proactiveDelayMeasurementEnabled,
939 "", "", "", "", "", "", "", "", "", "", "", "", "",
945 private static Object[] prepareDevInterfaceOtnOduTxMsiParameters(String nodeId, String interfaceName, TxMsi txMsi) {
947 String tribSlot = txMsi.getTribSlot().toString();
948 String odtuType = txMsi.getOdtuType().getTypeName();
949 String tribPort = txMsi.getTribPort().toString();
950 String tribPortPayload = txMsi.getTribPortPayload();
952 String startTimestamp = getCurrentTimestamp();
954 return new Object[]{nodeId,
966 private static Object[] prepareDevInterfaceOtnOduRxMsiParameters(String nodeId, String interfaceName, RxMsi rxMsi) {
968 String tribSlot = rxMsi.getTribSlot().toString();
969 String odtuType = rxMsi.getOdtuType().getTypeName();
970 String tribPort = rxMsi.getTribPort().toString();
971 String tribPortPayload = rxMsi.getTribPortPayload();
973 String startTimestamp = getCurrentTimestamp();
975 return new Object[]{nodeId,
988 private static Object[] prepareDevInterfaceOtnOduExpMsiParameters(String nodeId, String interfaceName,
991 String tribSlot = expMsi.getTribSlot().toString();
992 String odtuType = expMsi.getOdtuType().getTypeName();
993 String tribPort = expMsi.getTribPort().toString();
994 String tribPortPayload = expMsi.getTribPortPayload();
996 String startTimestamp = getCurrentTimestamp();
998 return new Object[]{nodeId,
1010 private void persistDevInterfaces(String nodeId, Connection connection) {
1012 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1013 Optional<OrgOpenroadmDevice> deviceObject =
1014 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1015 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1017 /*InstanceIdentifier<Interface> interfaceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
1018 .child(Interface.class);
1019 Optional<Interface> interfaceOpt =
1020 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, interfaceIID,
1021 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); */
1023 for (int i = 0; i < deviceObject.get().getInterface().size(); i++) {
1024 Interface deviceInterface;
1026 deviceInterface = deviceObject.get().getInterface().get(i);
1027 /*if (interfaceOpt.isPresent()) {
1028 deviceInterface = interfaceOpt.get();
1030 LOG.warn("Could not get interface info");
1033 Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
1035 String query = Queries.getQuery().deviceInterfacesInsert().get();
1036 LOG.info("Running {} query ", query);
1037 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1038 for (int j = 0; j < parameters.length; j++) {
1039 stmt.setObject(j + 1, parameters[j]);
1042 stmt.clearParameters();
1043 } catch (SQLException e) {
1044 LOG.error(e.getMessage(), e);
1049 private void persistDevProtocols(String nodeId, Connection connection) {
1051 InstanceIdentifier<Protocols> protocolsIID =
1052 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1053 Optional<Protocols> protocolObject =
1054 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1055 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1056 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1057 LOG.error("LLDP subtree is missing");
1060 String adminstatusEnu = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1061 .getAdminStatus().getName();
1062 String msgTxtInterval = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1063 .getMsgTxInterval().toString();
1064 String mxgTxHoldMultiplier = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1065 .getMsgTxHoldMultiplier().toString();
1066 String startTimestamp = getCurrentTimestamp();
1067 persistDevProtocolLldpPortConfig(nodeId, connection);
1068 persistDevProtocolLldpNbrList(nodeId, connection);
1070 Object[] parameters = {nodeId,
1073 mxgTxHoldMultiplier,
1078 String query = Queries.getQuery().deviceProtocolInsert().get();
1079 LOG.info("Running {} query ", query);
1080 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1081 for (int j = 0; j < parameters.length; j++) {
1082 stmt.setObject(j + 1, parameters[j]);
1085 stmt.clearParameters();
1086 } catch (SQLException e) {
1087 LOG.error(e.getMessage(), e);
1093 private void persistDevProtocolLldpPortConfig(String nodeId, Connection connection) {
1095 InstanceIdentifier<Protocols> protocolsIID =
1096 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1097 Optional<Protocols> protocolObject =
1098 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1099 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1100 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1101 LOG.error("LLDP subtree is missing");
1104 String startTimestamp = getCurrentTimestamp();
1105 for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().size(); i++) {
1106 PortConfig portConfig =
1107 protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().get(i);
1108 String ifName = portConfig.getIfName();
1109 String adminStatusEnu = portConfig.getAdminStatus().getName();
1111 Object[] parameters = {nodeId,
1118 String query = Queries.getQuery().deviceProtocolPortConfigInsert().get();
1119 LOG.info("Running {} query ", query);
1120 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1121 for (int j = 0; j < parameters.length; j++) {
1122 stmt.setObject(j + 1, parameters[j]);
1125 stmt.clearParameters();
1126 } catch (SQLException e) {
1127 LOG.error(e.getMessage(), e);
1134 private void persistDevProtocolLldpNbrList(String nodeId, Connection connection) {
1136 InstanceIdentifier<Protocols> protocolsIID =
1137 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1138 Optional<Protocols> protocolObject =
1139 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1140 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1141 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1143 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, protocolsIID,
1144 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1147 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1148 LOG.error("LLDP nbrlist subtree is missing for {}", nodeId);
1151 String startTimestamp = getCurrentTimestamp();
1152 for (int i = 0; i < protocolObject.get()
1153 .augmentation(Protocols1.class).getLldp().getNbrList().getIfName().size(); i++) {
1155 IfName ifNameObj = protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList()
1156 .getIfName().get(i);
1157 String ifName = ifNameObj.getIfName();
1158 String remotesysname = ifNameObj.getRemoteSysName();
1159 String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
1160 String remotemgmtaddress = ifNameObj.getRemoteMgmtAddress().getIpv4Address().toString();
1161 String remoteportidsubtypeEnu = ifNameObj.getRemotePortIdSubType().getName();
1162 String remoteportid = ifNameObj.getRemotePortId();
1163 String remotechassisidsubtypeEnu = ifNameObj.getRemoteChassisIdSubType().getName();
1164 String remotechassisid = ifNameObj.getRemoteChassisId();
1166 Object[] parameters = {nodeId,
1169 remotemgmtaddresssubtype,
1171 remoteportidsubtypeEnu,
1173 remotechassisidsubtypeEnu,
1179 String query = Queries.getQuery().deviceProtocolLldpNbrlistInsert().get();
1180 LOG.info("Running {} query ", query);
1181 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1182 for (int j = 0; j < parameters.length; j++) {
1183 stmt.setObject(j + 1, parameters[j]);
1186 stmt.clearParameters();
1187 } catch (SQLException e) {
1188 LOG.error(e.getMessage(), e);
1195 private void persistDevProtocolRstp(String nodeId, Connection connection) {
1197 InstanceIdentifier<Protocols> protocolsIID =
1198 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1199 Optional<Protocols> protocolObject =
1200 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1201 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1202 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1203 LOG.error("LLDP subtree is missing");
1206 String startTimestamp = getCurrentTimestamp();
1207 for (int i = 0; i < protocolObject.get()
1208 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.Protocols1.class)
1209 .getRstp().getRstpBridgeInstance().size(); i++) {
1211 RstpBridgeInstance rstpBridgeInstance = protocolObject.get()
1212 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.Protocols1.class)
1213 .getRstp().getRstpBridgeInstance().get(i);
1214 String bridgeName = rstpBridgeInstance.getBridgeName();
1215 String bridgePriority = rstpBridgeInstance.getRstpConfig().getBridgePriority().toString();
1216 String shutdown = rstpBridgeInstance.getRstpConfig().getShutdown().toString();
1217 String holdTime = rstpBridgeInstance.getRstpConfig().getHoldTime().toString();
1218 String helloTime = rstpBridgeInstance.getRstpConfig().getHelloTime().toString();
1219 String maxAge = rstpBridgeInstance.getRstpConfig().getMaxAge().toString();
1220 String forwardDelay = rstpBridgeInstance.getRstpConfig().getForwardDelay().toString();
1221 String transmitHoldCount = rstpBridgeInstance.getRstpConfig().getTransmitHoldCount().toString();
1222 String rootBridgePort =
1223 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgePort().toString();
1224 String rootPathCost = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootPathCost().toString();
1225 String rootBridgePriority =
1226 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgePriority().toString();
1227 String rootBridgeId = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgeId().toString();
1228 String rootHoldTime = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootHoldTime().toString();
1229 String rootHelloTime = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootHelloTime().toString();
1230 String rootMaxAge = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootMaxAge().toString();
1231 String rootForwardDelay =
1232 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootForwardDelay().toString();
1233 String bridgeId = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getBridgeId().toString();
1234 String topoChangeCount =
1235 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getTopoChangeCount().toString();
1236 String timeSinceTopoChange =
1237 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getTimeSinceTopoChange().toString();
1239 persistDevProtocolRstpBridgePort(nodeId, bridgeName, rstpBridgeInstance, connection);
1240 persistDevProtocolRstpBridgePortAttr(nodeId, bridgeName, rstpBridgeInstance, connection);
1242 Object[] parameters = {nodeId,
1261 timeSinceTopoChange,
1266 String query = Queries.getQuery().deviceProtocolRstpInsert().get();
1267 LOG.info("Running {} query ", query);
1268 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1269 for (int j = 0; j < parameters.length; j++) {
1270 stmt.setObject(j + 1, parameters[j]);
1273 stmt.clearParameters();
1274 } catch (SQLException e) {
1275 LOG.error(e.getMessage(), e);
1281 private void persistDevProtocolRstpBridgePort(String nodeId, String bridgeName,
1282 RstpBridgeInstance rstpBridgeInstance, Connection connection) {
1284 String startTimestamp = getCurrentTimestamp();
1285 for (int i = 0; i < rstpBridgeInstance.getRstpConfig().getRstpBridgePortTable().size(); i++) {
1286 RstpBridgePortTable rstpBridgePortTable =
1287 rstpBridgeInstance.getRstpConfig().getRstpBridgePortTable().get(i);
1289 String ifName = rstpBridgePortTable.getIfname();
1290 String cost = rstpBridgePortTable.getCost().toString();
1291 String priority = rstpBridgePortTable.getPriority().toString();
1293 Object[] parameters = {nodeId,
1302 String query = Queries.getQuery().deviceProtocolRstpBridgePortInsert().get();
1303 LOG.info("Running {} query ", query);
1304 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1305 for (int j = 0; j < parameters.length; j++) {
1306 stmt.setObject(j + 1, parameters[j]);
1309 stmt.clearParameters();
1310 } catch (SQLException e) {
1311 LOG.error(e.getMessage(), e);
1317 private void persistDevProtocolRstpBridgePortAttr(String nodeId, String bridgeName,
1318 RstpBridgeInstance rstpBridgeInstance, Connection connection) {
1320 String startTimestamp = getCurrentTimestamp();
1321 for (int i = 0; i < rstpBridgeInstance.getRstpState().getRstpBridgePortAttr().getRstpBridgePortTable().size();
1324 org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.bridge.port.state.attr
1325 .RstpBridgePortTable rstpBridgePortTableAttr =
1326 rstpBridgeInstance.getRstpState().getRstpBridgePortAttr().getRstpBridgePortTable().get(i);
1328 String ifName = rstpBridgePortTableAttr.getIfname();
1329 String bridgePortState = rstpBridgePortTableAttr.getBridgePortState().getName();
1330 String bridgePortRole = rstpBridgePortTableAttr.getBridgePortRole().getName();
1331 String bridgePortId = rstpBridgePortTableAttr.getBridgePortId().toString();
1332 String openEdgeBridgePort = rstpBridgePortTableAttr.getOperEdgeBridgePort().toString();
1333 String designatedBridgePort = rstpBridgePortTableAttr.getDesignatedBridgePort().toString();
1334 String designatedBridgeId = rstpBridgePortTableAttr.getDesignatedBridgeid().toString();
1336 Object[] parameters = {nodeId,
1343 designatedBridgePort,
1349 String query = Queries.getQuery().deviceProtocolRstpBridgePortAttrInsert().get();
1350 LOG.info("Running {} query ", query);
1351 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1352 for (int j = 0; j < parameters.length; j++) {
1353 stmt.setObject(j + 1, parameters[j]);
1356 stmt.clearParameters();
1357 } catch (SQLException e) {
1358 LOG.error(e.getMessage(), e);
1365 private void persistDevInternalLinks(String nodeId, Connection connection) {
1367 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1368 Optional<OrgOpenroadmDevice> deviceObject =
1369 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1370 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1371 if (deviceObject.get().getInternalLink() == null) {
1373 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1374 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1376 if (deviceObject.get().getInternalLink() == null) {
1377 LOG.info("External links not found for {}", nodeId);
1381 String startTimestamp = getCurrentTimestamp();
1382 for (int i = 0; i < deviceObject.get().getInternalLink().size(); i++) {
1383 InternalLink internalLink = deviceObject.get().getInternalLink().get(i);
1384 String internalLinkName = internalLink.getInternalLinkName();
1385 String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
1386 String sourcePortName = internalLink.getSource().getPortName().toString();
1387 String destinationCircuitPackName = internalLink.getDestination().getCircuitPackName();
1388 String destinationPortName = internalLink.getDestination().getPortName().toString();
1390 Object[] parameters = {nodeId,
1392 sourceCircuitPackName,
1394 destinationCircuitPackName,
1395 destinationPortName,
1400 String query = Queries.getQuery().deviceInternalLinkInsert().get();
1401 LOG.info("Running {} query ", query);
1402 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1403 for (int j = 0; j < parameters.length; j++) {
1404 stmt.setObject(j + 1, parameters[j]);
1407 stmt.clearParameters();
1408 } catch (SQLException e) {
1409 LOG.error(e.getMessage(), e);
1417 private void persistDevExternalLinks(String nodeId, Connection connection) {
1419 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1420 Optional<OrgOpenroadmDevice> deviceObject =
1421 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1422 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1424 if (deviceObject.get().getExternalLink() == null) {
1426 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1427 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1429 if (deviceObject.get().getExternalLink() == null) {
1430 LOG.info("External links not found for {}", nodeId);
1432 String startTimestamp = getCurrentTimestamp();
1433 for (int i = 0; i < deviceObject.get().getExternalLink().size(); i++) {
1434 ExternalLink externalLink = deviceObject.get().getExternalLink().get(i);
1435 String externalLinkName = externalLink.getExternalLinkName();
1436 String sourceNodeId = externalLink.getSource().getNodeId();
1437 String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
1438 String sourcePortName = externalLink.getSource().getPortName().toString();
1439 String destinationNodeId = externalLink.getDestination().getNodeId();
1440 String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
1441 String destinationPortName = externalLink.getDestination().getPortName().toString();
1443 Object[] parameters = {nodeId,
1446 sourceCircuitPackName,
1449 destinationCircuitPackName,
1450 destinationPortName,
1455 String query = Queries.getQuery().deviceExternalLinkInsert().get();
1456 LOG.info("Running {} query ", query);
1457 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1458 for (int j = 0; j < parameters.length; j++) {
1459 stmt.setObject(j + 1, parameters[j]);
1462 stmt.clearParameters();
1463 } catch (SQLException e) {
1464 LOG.error(e.getMessage(), e);
1471 private void persistDevPhysicalLinks(String nodeId, Connection connection) {
1473 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1474 Optional<OrgOpenroadmDevice> deviceObject =
1475 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1476 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1477 if (deviceObject.get().getPhysicalLink() == null) {
1479 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1480 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1482 if (deviceObject.get().getPhysicalLink() == null) {
1483 LOG.info("Physical links not found for {}", nodeId);
1486 String startTimestamp = getCurrentTimestamp();
1487 for (int i = 0; i < deviceObject.get().getPhysicalLink().size(); i++) {
1488 PhysicalLink physicalLink = deviceObject.get().getPhysicalLink().get(i);
1489 String physicalLinkName = physicalLink.getPhysicalLinkName();
1490 String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
1491 String sourcePortName = physicalLink.getSource().getPortName().toString();
1492 String destinationCircuitPackName = physicalLink.getDestination().getCircuitPackName();
1493 String destinationPortName = physicalLink.getDestination().getPortName().toString();
1495 Object[] parameters = {nodeId,
1497 sourceCircuitPackName,
1499 destinationCircuitPackName,
1500 destinationPortName,
1505 String query = Queries.getQuery().devicePhysicalLinkInsert().get();
1506 LOG.info("Running {} query ", query);
1507 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1508 for (int j = 0; j < parameters.length; j++) {
1509 stmt.setObject(j + 1, parameters[j]);
1512 stmt.clearParameters();
1513 } catch (SQLException e) {
1514 LOG.error(e.getMessage(), e);
1521 private void persistDevDegree(String nodeId, Connection connection) {
1523 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1524 Optional<OrgOpenroadmDevice> deviceObject =
1525 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1526 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1529 /*if (deviceObject.get().getDegree()==null){
1531 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1532 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1534 if (deviceObject.get().getDegree() == null) {
1535 LOG.warn("Degree info not found for {}", nodeId);
1538 String startTimestamp = getCurrentTimestamp();
1539 for (int i = 0; i < deviceObject.get().getDegree().size(); i++) {
1540 Degree degree = deviceObject.get().getDegree().get(i);
1541 String degreeNumber = degree.getDegreeNumber().toString();
1542 String maxWavelengths = degree.getMaxWavelengths().toString();
1543 String otdrPortCircuitPackName =
1544 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getCircuitPackName());
1545 String otdrPortPortName =
1546 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getPortName().toString());
1547 //String mcCapabilitiesSlotWidthGranularity = "";
1548 //String mcCapabilitiesCenterFreqGranularity = "";
1549 //String mcCapabilitiesMinSlots = "-1";
1550 //String mcCapabilitiesMaxSlots = "-1";
1551 persistDevDegreeCircuitPack(nodeId, degree, degreeNumber, connection);
1552 persistDevDegreeConnectionPort(nodeId, degree, degreeNumber, connection);
1554 Object[] parameters = {nodeId,
1557 otdrPortCircuitPackName,
1559 //mcCapabilitiesSlotWidthGranularity,
1560 //mcCapabilitiesCenterFreqGranularity,
1561 //mcCapabilitiesMinSlots,
1562 //mcCapabilitiesMaxSlots,
1568 String query = Queries.getQuery().deviceDegreeInsert().get();
1569 LOG.info("Running {} query ", query);
1570 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1571 for (int j = 0; j < parameters.length; j++) {
1572 stmt.setObject(j + 1, parameters[j]);
1575 stmt.clearParameters();
1576 } catch (SQLException e) {
1577 LOG.error(e.getMessage(), e);
1585 private void persistDevDegreeCircuitPack(String nodeId, Degree degree, String degreeNumber, Connection connection) {
1587 String startTimestamp = getCurrentTimestamp();
1588 for (int i = 0; i < degree.getCircuitPacks().size(); i++) {
1590 String circuitPackIndex = degree.getCircuitPacks().get(i).getIndex().toString();
1591 String circuitPackName = degree.getCircuitPacks().get(i).getCircuitPackName();
1593 Object[] parameters = {nodeId,
1601 String query = Queries.getQuery().deviceDegreeCircuitPackInsert().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(e.getMessage(), e);
1616 private void persistDevDegreeConnectionPort(String nodeId, Degree degree, String degreeNumber,
1617 Connection connection) {
1619 String startTimestamp = getCurrentTimestamp();
1620 for (int i = 0; i < degree.getConnectionPorts().size(); i++) {
1622 String connectionPortIndex = degree.getConnectionPorts().get(i).getIndex().toString();
1623 String circuitPackName = degree.getConnectionPorts().get(i).getCircuitPackName();
1624 String portName = degree.getConnectionPorts().get(i).getPortName().toString();
1626 Object[] parameters = {nodeId,
1628 connectionPortIndex,
1635 String query = Queries.getQuery().deviceDegreeConnectionPortInsert().get();
1636 LOG.info("Running {} query ", query);
1637 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1638 for (int j = 0; j < parameters.length; j++) {
1639 stmt.setObject(j + 1, parameters[j]);
1642 stmt.clearParameters();
1643 } catch (SQLException e) {
1644 LOG.error(e.getMessage(), e);
1651 private void persistDevSrg(String nodeId, Connection connection) {
1653 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1654 Optional<OrgOpenroadmDevice> deviceObject =
1655 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1656 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1658 if (deviceObject.get().getSharedRiskGroup() == null) {
1660 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1661 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1663 if (deviceObject.get().getSharedRiskGroup() == null) {
1664 LOG.info("no srg found for node {} ", nodeId);
1666 String startTimestamp = getCurrentTimestamp();
1667 for (int i = 0; i < deviceObject.get().getSharedRiskGroup().size(); i++) {
1668 SharedRiskGroup sharedRiskGroup = deviceObject.get().getSharedRiskGroup().get(i);
1669 //String currentProvisionedAddDropPorts = "-1";
1670 //String mcCapSlotWidthGranularity = "";
1671 //String mcCapCenterFreqGranularity = "";
1672 //String mcCapMinSlots = "-1";
1673 //String mcCapMaxSlots = "-1";
1674 String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
1675 String srgNumber = sharedRiskGroup.getSrgNumber().toString();
1676 String wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getName();
1677 persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
1679 Object[] parameters = {nodeId,
1681 //currentProvisionedAddDropPorts,
1684 wavelengthDuplicationEnu,
1685 //mcCapSlotWidthGranularity,
1686 //mcCapCenterFreqGranularity,
1694 String query = Queries.getQuery().deviceSharedRiskGroupInsert().get();
1695 LOG.info("Running {} query ", query);
1696 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1697 for (int j = 0; j < parameters.length; j++) {
1698 stmt.setObject(j + 1, parameters[j]);
1701 stmt.clearParameters();
1702 } catch (SQLException e) {
1703 LOG.error(e.getMessage(), e);
1711 private void persistDevSrgCircuitPacks(String nodeId, SharedRiskGroup sharedRiskGroup, String srgNumber,
1712 Connection connection) {
1714 String startTimestamp = getCurrentTimestamp();
1715 for (int i = 0; i < sharedRiskGroup.getCircuitPacks().size(); i++) {
1717 String circuitPackindex = sharedRiskGroup.getCircuitPacks().get(i).getIndex().toString();
1718 String circuitPackName = sharedRiskGroup.getCircuitPacks().get(i).getCircuitPackName();
1720 Object[] parameters = {nodeId,
1728 String query = Queries.getQuery().deviceSrgCircuitPackInsert().get();
1729 LOG.info("Running {} query ", query);
1730 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1731 for (int j = 0; j < parameters.length; j++) {
1732 stmt.setObject(j + 1, parameters[j]);
1735 stmt.clearParameters();
1736 } catch (SQLException e) {
1737 LOG.error(e.getMessage(), e);
1743 private void persistDevRoadmConnections(String nodeId, Connection connection) {
1745 //int opticalcontrolmodeEnu=-1;
1747 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1748 Optional<OrgOpenroadmDevice> deviceObject =
1749 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1750 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1752 if (deviceObject.get().getRoadmConnections() == null) {
1754 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1755 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1758 if (deviceObject.get().getRoadmConnections() != null) {
1759 String startTimestamp = getCurrentTimestamp();
1760 for (int i = 0; i < deviceObject.get().getRoadmConnections().size(); i++) {
1761 RoadmConnections roadmConnections = deviceObject.get().getRoadmConnections().get(i);
1762 String connectionNumber = roadmConnections.getConnectionNumber();
1763 //String connectionName = "";
1764 String wavelengthNumber = roadmConnections.getWavelengthNumber().toString();
1765 String opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getName();
1766 String targetOutputPower = roadmConnections.getTargetOutputPower().toString();
1767 String srcIf = roadmConnections.getSource().getSrcIf();
1768 String dstIf = roadmConnections.getDestination().getDstIf();
1770 Object[] parameters = {nodeId,
1775 opticalcontrolmodeEnu,
1783 String query = Queries.getQuery().deviceRoadmConnectionsInsert().get();
1784 LOG.info("Running {} query ", query);
1785 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1786 for (int j = 0; j < parameters.length; j++) {
1787 stmt.setObject(j + 1, parameters[j]);
1790 stmt.clearParameters();
1791 } catch (SQLException e) {
1792 LOG.error(e.getMessage(), e);
1797 LOG.info("ROADM Dev Connections not found!! for {}", nodeId);
1802 private void persistDevConnectionMap(String nodeId, Connection connection) {
1804 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1805 Optional<OrgOpenroadmDevice> deviceObject =
1806 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1807 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1809 String startTimestamp = getCurrentTimestamp();
1810 for (int i = 0; i < deviceObject.get().getConnectionMap().size(); i++) {
1811 ConnectionMap connectionMap = deviceObject.get().getConnectionMap().get(i);
1812 String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
1813 String sourceCircuitPackName = connectionMap.getSource().getCircuitPackName();
1814 String sourcePortName = connectionMap.getSource().getCircuitPackName();
1817 Object[] parameters = {nodeId,
1818 connectionMapNumber,
1819 sourceCircuitPackName,
1825 String query = Queries.getQuery().deviceConnectionMapInsert().get();
1826 LOG.info("Running {} query ", query);
1827 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1828 for (int j = 0; j < parameters.length; j++) {
1829 stmt.setObject(j + 1, parameters[j]);
1832 stmt.clearParameters();
1833 } catch (SQLException e) {
1834 LOG.error(e.getMessage(), e);
1840 private void persistDevWavelengthMap(String nodeId, Connection connection) {
1842 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1843 Optional<OrgOpenroadmDevice> deviceObject =
1844 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1845 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1847 String startTimestamp = getCurrentTimestamp();
1848 for (int i = 0; i < deviceObject.get().getWavelengthMap().getWavelengths().size(); i++) {
1849 Wavelengths wavelengths = deviceObject.get().getWavelengthMap().getWavelengths().get(i);
1850 String wavelengthNumber = wavelengths.getWavelengthNumber().toString();
1851 String centerFrequency = wavelengths.getCenterFrequency().toString();
1852 String wavelength = wavelengths.getWavelength().toString();
1855 Object[] parameters = {nodeId,
1863 String query = Queries.getQuery().deviceWavelengthInsert().get();
1864 LOG.info("Running {} query ", query);
1865 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1866 for (int j = 0; j < parameters.length; j++) {
1867 stmt.setObject(j + 1, parameters[j]);
1870 stmt.clearParameters();
1871 } catch (SQLException e) {
1872 LOG.error(e.getMessage(), e);
1879 private void persistDevInterfaceTcm(String nodeId, String interfaceName, OduBuilder oduBuilder,
1880 Connection connection) {
1882 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1885 tcm = oduBuilder.getTcm().get(i);
1887 Object[] parameters = prepareDevInterfaceTcmParameters(nodeId, interfaceName, tcm);
1889 String query = Queries.getQuery().deviceInterfacesInsert().get();
1890 LOG.info("Running {} query ", query);
1891 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1892 for (int j = 0; j < parameters.length; j++) {
1893 stmt.setObject(j + 1, parameters[j]);
1896 stmt.clearParameters();
1897 } catch (SQLException e) {
1898 LOG.error(e.getMessage(), e);
1903 private void persistDevInterfaceOtnOduTxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1904 Connection connection) {
1906 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1909 txMsi = oduBuilder.getOpu().getMsi().getTxMsi().get(i);
1911 Object[] parameters = prepareDevInterfaceOtnOduTxMsiParameters(nodeId, interfaceName, txMsi);
1913 String query = Queries.getQuery().deviceInterfaceOtnOduTxMsiInsert().get();
1914 LOG.info("Running {} query ", query);
1915 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1916 for (int j = 0; j < parameters.length; j++) {
1917 stmt.setObject(j + 1, parameters[j]);
1920 stmt.clearParameters();
1921 } catch (SQLException e) {
1922 LOG.error(e.getMessage(), e);
1928 private void persistDevInterfaceOtnOduRxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1929 Connection connection) {
1931 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1934 rxMsi = oduBuilder.getOpu().getMsi().getRxMsi().get(i);
1936 Object[] parameters = prepareDevInterfaceOtnOduRxMsiParameters(nodeId, interfaceName, rxMsi);
1938 String query = Queries.getQuery().deviceInterfaceOtnOduRxMsiInsert().get();
1939 LOG.info("Running {} query ", query);
1940 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1941 for (int j = 0; j < parameters.length; j++) {
1942 stmt.setObject(j + 1, parameters[j]);
1945 stmt.clearParameters();
1946 } catch (SQLException e) {
1947 LOG.error(e.getMessage(), e);
1953 private void persistDevInterfaceOtnOduExpMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1954 Connection connection) {
1956 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1959 expMsi = oduBuilder.getOpu().getMsi().getExpMsi().get(i);
1961 Object[] parameters = prepareDevInterfaceOtnOduExpMsiParameters(nodeId, interfaceName, expMsi);
1963 String query = Queries.getQuery().deviceInterfaceOtnOduExpMsiInsert().get();
1964 LOG.info("Running {} query ", query);
1965 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1966 for (int j = 0; j < parameters.length; j++) {
1967 stmt.setObject(j + 1, parameters[j]);
1970 stmt.clearParameters();
1971 } catch (SQLException e) {
1972 LOG.error(e.getMessage(), e);