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;
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.rstp.rev161014.rstp.bridge.port.attr.RstpBridgePortTable;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.container.rstp.RstpBridgeInstance;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.wavelength.map.rev161014.wavelength.map.g.Wavelengths;
59 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
60 import org.slf4j.Logger;
61 import org.slf4j.LoggerFactory;
63 public class INode121 {
65 private static final Logger LOG = LoggerFactory.getLogger(INode121.class);
67 private final DataSource dataSource;
68 private final DeviceTransactionManager deviceTransactionManager;
70 public INode121(DataSource dataSource, DeviceTransactionManager deviceTransactionManager) {
71 this.dataSource = dataSource;
72 this.deviceTransactionManager = deviceTransactionManager;
75 public boolean addNode(String deviceId) {
77 InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
78 Optional<Info> infoOpt =
79 deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, infoIID,
80 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
82 if (infoOpt.isPresent()) {
83 deviceInfo = infoOpt.get();
85 LOG.warn("Could not get device info from DataBroker");
88 boolean sqlResult = false;
89 String query = Queries.getQuery().deviceInfoInsert().get();
90 LOG.info("Running {} query ", query);
91 try (Connection connection = dataSource.getConnection();
92 PreparedStatement preparedStatement = connection.prepareStatement(query)) {
93 Object[] prepareParameters = prepareDeviceInfoParameters(deviceInfo);
94 for (int i = 0; i < prepareParameters.length; i++) {
95 LOG.debug("Parameter {} has value {}", i + 1, prepareParameters[i]);
96 preparedStatement.setObject(i + 1, prepareParameters[i]);
99 int executeUpdate = preparedStatement.executeUpdate();
100 LOG.info("{} entries were added", executeUpdate);
103 LOG.debug("iNode AddNode call complete");
104 getRoadmShelves(deviceId);
105 LOG.debug("iNode getRoadmShelves call complete");
106 getCircuitPacks(deviceId);
107 LOG.debug("iNode getCircuitPacks call complete");
109 LOG.debug("iNode persist interfaces call");
110 persistDevInterfaces(deviceId, connection);
111 LOG.debug("iNode persist interfaces call complete");
114 LOG.debug("iNode persist protocols call");
115 persistDevProtocols(deviceId, connection);
116 LOG.debug("iNode persist protocols call complete");
119 LOG.debug("iNode persist wavelength map call");
120 persistDevWavelengthMap(deviceId, connection);
121 LOG.debug("iNode persist wavelength map call complete");
123 LOG.debug("iNode persist internal links map call");
124 persistDevInternalLinks(deviceId, connection);
125 LOG.debug("iNode persist internal links map call complete");
127 LOG.debug("iNode persist Physical links map call");
128 persistDevPhysicalLinks(deviceId, connection);
129 LOG.debug("iNode persist Physical links map call complete");
131 LOG.debug("iNode persist External links map call");
132 persistDevExternalLinks(deviceId, connection);
133 LOG.debug("iNode persist External links map call complete");
135 LOG.debug("iNode persist degree map call");
136 persistDevDegree(deviceId, connection);
137 LOG.debug("iNode persist degree map call complete");
139 LOG.debug("iNode persist srg map call");
140 persistDevSrg(deviceId, connection);
141 LOG.debug("iNode persist srg map call complete");
143 LOG.debug("iNode persist Roadm Connections call");
144 persistDevRoadmConnections(deviceId, connection);
145 LOG.debug("iNode persist Roadm Connections call complete");
147 LOG.debug("iNode persist Connection Map call");
148 persistDevConnectionMap(deviceId, connection);
149 LOG.debug("iNode persist Connection Map call complete");
151 } catch (SQLException e) {
152 LOG.error(e.getMessage(), e);
153 } catch (InterruptedException e) {
154 LOG.error(e.getMessage(), e);
155 } catch (ExecutionException e) {
156 LOG.error(e.getMessage(), e);
161 public boolean nodeExists(String nodeId) {
162 String selectTableSQL = "select count(*) node_exists from inv_dev_info where node_id = ?";
164 LOG.info("Checking if {} exists in DB", nodeId);
165 try (Connection connection = dataSource.getConnection();
166 PreparedStatement preparedStmt = connection.prepareStatement(selectTableSQL)) {
167 preparedStmt.setString(1, nodeId);
168 try (ResultSet rs = preparedStmt.executeQuery()) {
170 nodeExists = rs.getInt("node_exists");
171 LOG.debug("Found {} devices matching {}", nodeExists, nodeId);
174 } catch (SQLException e) {
175 LOG.error(e.getMessage(), e);
177 return nodeExists == 0 ? false : true;
180 public void getRoadmShelves(String nodeId) throws InterruptedException, ExecutionException {
181 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
182 Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
183 LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT,
184 Timeouts.DEVICE_READ_TIMEOUT_UNIT);
186 LOG.info("Shelves size {}", deviceObject.get().getShelves().size());
187 try (Connection connection = dataSource.getConnection()) {
188 Preconditions.checkNotNull(connection);
189 for (int i = 0; i < deviceObject.get().getShelves().size(); i++) {
190 Shelves shelve = deviceObject.get().getShelves().get(i);
191 String shelfName = shelve.getShelfName();
193 LOG.info("Getting Shelve Details of {}", shelfName);
194 if (shelve.getSlots() != null) {
195 LOG.info("Slot Size {} ", shelve.getSlots().size());
196 persistShelveSlots(nodeId, shelve, connection);
198 LOG.info("No Slots for shelf {}", shelfName);
201 persistShelves(nodeId, connection, shelve);
203 } catch (SQLException e1) {
204 LOG.error(e1.getMessage(), e1);
208 public void getCircuitPacks(String nodeId) throws InterruptedException, ExecutionException {
209 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
210 Optional<OrgOpenroadmDevice> deviceObject =
211 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
212 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
213 if (!deviceObject.isPresent()) {
214 LOG.warn("Device object {} was not found", nodeId);
217 LOG.info("Circuit pack size {}", deviceObject.get().getCircuitPacks().size());
219 try (Connection connection = dataSource.getConnection()) {
220 Preconditions.checkNotNull(connection);
221 for (int i = 0; i < deviceObject.get().getCircuitPacks().size(); i++) {
222 CircuitPacks cp = deviceObject.get().getCircuitPacks().get(i);
224 if (cp.getCpSlots() != null) {
225 persistCircuitPacksSlots(nodeId, cp, connection);
227 LOG.info("Everything {}", cp);
228 LOG.info("CP is {}", cp);
230 //persistPorts(cp, connection);
231 if (cp.getPorts() != null) {
232 persistCPPorts(nodeId, connection, cp);
234 persistCircuitPacks(nodeId, connection, cp);
236 } catch (SQLException e1) {
237 LOG.error(e1.getMessage(), e1);
241 private void persistCircuitPacks(String nodeId, Connection connection, CircuitPacks cp) {
242 Object[] parameters = prepareCircuitPacksParameters(nodeId, cp);
243 String query = Queries.getQuery().deviceCircuitPackInsert().get();
244 LOG.info("Running {} query ", query);
245 try (PreparedStatement stmt = connection.prepareStatement(query)) {
246 for (int j = 0; j < parameters.length; j++) {
247 stmt.setObject(j + 1, parameters[j]);
250 stmt.clearParameters();
251 } catch (SQLException e) {
252 LOG.error(e.getMessage(), e);
256 private void persistShelves(String nodeId, Connection connection, Shelves shelve) {
257 Object[] shelvesParameter = prepareShelvesParameters(nodeId, shelve);
258 String query = Queries.getQuery().deviceShelfInsert().get();
259 LOG.info("Running {} query ", query);
260 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
261 for (int j = 0; j < shelvesParameter.length; j++) {
262 preparedStmt.setObject(j + 1, shelvesParameter[j]);
264 preparedStmt.execute();
265 preparedStmt.clearParameters();
266 } catch (SQLException e) {
267 LOG.error(e.getMessage(), e);
271 private void persistShelveSlots(String nodeId, Shelves shelves, Connection connection) {
272 String startTimetampStr = getCurrentTimestamp();
273 for (int i = 0; i < shelves.getSlots().size(); i++) {
274 Slots slot = shelves.getSlots().get(i);
275 LOG.info("Getting Slot Details of {}", slot.getSlotName());
276 Object[] parameters = new Object[]{nodeId,
277 shelves.getShelfName(),
280 slot.getProvisionedCircuitPack(),
284 String query = Queries.getQuery().deviceShelfSlotInsert().get();
285 LOG.info("Running {} query ", query);
286 try (PreparedStatement stmt = connection.prepareStatement(query)) {
287 for (int j = 0; j < parameters.length; j++) {
288 stmt.setObject(j + 1, parameters[j]);
291 stmt.clearParameters();
292 } catch (SQLException e) {
293 LOG.error(e.getMessage(), e);
299 private void persistCircuitPacksSlots(String nodeId, CircuitPacks circuitPacks, Connection connection) {
300 String startTimetampStr = getCurrentTimestamp();
301 for (int i = 0; i < circuitPacks.getCpSlots().size(); i++) {
302 CpSlots cpSlot = circuitPacks.getCpSlots().get(i);
304 Object[] parameters = new Object[]{nodeId,
305 circuitPacks.getCircuitPackName(),
306 cpSlot.getSlotName(),
308 cpSlot.getProvisionedCircuitPack(),
313 String query = Queries.getQuery().deviceCPSlotInsert().get();
314 LOG.info("Running {} query ", query);
315 try (PreparedStatement stmt = connection.prepareStatement(query)) {
316 for (int j = 0; j < parameters.length; j++) {
317 stmt.setObject(j + 1, parameters[j]);
320 stmt.clearParameters();
321 } catch (SQLException e) {
322 LOG.error(e.getMessage(), e);
327 private void persistPorts(CircuitPacks circuitPacks, Connection connection) {
328 LOG.warn("Ports are not persisted yet");
333 * Prepares parameters for device insert query.
335 * @param deviceInfo device information
336 * @return Object an object
338 private static Object[] prepareDeviceInfoParameters(Info deviceInfo) {
339 String startTimetampStr = getCurrentTimestamp();
341 String nodeId = prepareDashString(deviceInfo.getNodeId());
342 Long nodeNumber = deviceInfo.getNodeNumber().toJava();
343 String nodeTypeEnu = deviceInfo.getNodeType().getName();
344 String clli = prepareDashString(deviceInfo.getClli());
345 String vendor = prepareDashString(deviceInfo.getVendor());
346 String model = prepareDashString(deviceInfo.getModel());
347 String serialId = prepareDashString(deviceInfo.getSerialId());
348 String ipAddress = prepareDashString(deviceInfo.getIpAddress().getIpv4Address().getValue());
349 String prefixLength = prepareDashString(deviceInfo.getPrefixLength());
350 String defaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
351 String sourceEnum = deviceInfo.getSource().getName();
352 String currentIpAddress = prepareDashString(deviceInfo.getCurrentIpAddress().getIpv4Address().getValue());
353 String currentPrefixLength = prepareDashString(deviceInfo.getCurrentPrefixLength());
354 String currentDefaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
355 String macAddress = prepareDashString(deviceInfo.getMacAddress().getValue());
356 String softwareVersion = prepareDashString(deviceInfo.getSoftwareVersion());
357 //String openroadmVersion = "1.2.1";
358 String template = prepareDashString(deviceInfo.getTemplate());
359 String currentDatetime = prepareDashString(deviceInfo.getCurrentDatetime().getValue());
360 String geoLatitude = (deviceInfo.getGeoLocation() != null
361 ? prepareDashString(deviceInfo.getGeoLocation().getLatitude()) : "");
362 String geoLongitude = (deviceInfo.getGeoLocation() != null
363 ? prepareDashString(deviceInfo.getGeoLocation().getLongitude()) : "");
364 String maxDegrees = (deviceInfo.getMaxDegrees() == null ? "-1" : prepareDashString(deviceInfo.getMaxDegrees()));
365 String maxSrgs = (deviceInfo.getMaxSrgs() == null ? "-1" : prepareDashString(deviceInfo.getMaxSrgs()));
366 String swVersion = prepareDashString(deviceInfo.getSoftwareVersion()); //sw_version
367 String swValidationTimer = prepareDashString(""); //sw_validation_timer
368 String activationDateTime = prepareDashString(""); //activation_date_time
369 //Integer maxNumBin15minHistoricalPm = null;
370 //Integer maxNumBin24hourHistoricalPm = null;
371 /*jsonDevInfo = JsonStringBuilder.getDevInfoJson().replace("$$NODE-ID$$",nodeId)
372 .replace("$$NODE-NUMBER$$", nodeNumber)
373 .replace("$$NODE-TYPE$$",nodeType)
374 .replace("$$CLLI$$",clli)
375 .replace("$$VENDOR$$",vendor)
376 .replace("$$MODEL$$",model)
377 .replace("$$SERIAL-ID$$",serialId)
378 .replace("$$IPADDRESS$$",ipAddress)
379 .replace("$$PREFIX-LENGTH$$",prefixLength)
380 .replace("$$DEFAULTGATEWAY$$",defaultGateway)
381 .replace("$$SOURCE$$",String.valueOf(source))
382 .replace("$$CURRENT-IPADDRESS$$",currentIpAddress)
383 .replace("$$CURRENT-PREFIX-LENGTH$$",currentPrefixLength)
384 .replace("$$CURRENT-DEFAULTGATEWAY$$",currentDefailtGateway)
385 .replace("$$MACADDRESS$$",macAddress)
386 .replace("$$SOFTWAREVERSION$$",softwareVersion)
387 .replace("$$OPENROADM-VERSION$$",openroadmVersion)
388 .replace("$$TEMPLATE$$",template)
389 .replace("$$CURRENT-DATETIME$$",currentDatetime)
390 .replace("$$LATITUDE$$",latitude)
391 .replace("$$LONGITUDE$$",longitude)
392 .replace("$$MAX-DEGREES$$",maxDegrees)
393 .replace("$$MAX-SRGS$$",maxSrgs)
394 .replace("$$MAX-NUM-BIN-15MIN-HISTORICAL-PM$$",prepareDashString(""))
395 .replace("$$MAX-NUM-BIN-24HOUR-HISTORICAL-PM$$",prepareDashString(""))
396 .replace("$$SW-VERSION$$",swVersion)
397 .replace("$$SW-VALIDATION-TIMER$$",swValidationTimer)
398 .replace("$$ACTIVATION-DATE-TIME$$",activationDateTime);*/
415 currentDefaultGateway,
426 //maxNumBin15minHistoricalPm,
427 //maxNumBin24hourHistoricalPm,
438 private static Object[] prepareShelvesParameters(String nodeId, Shelves shelve) {
439 String startTimestamp = getCurrentTimestamp();
441 return new Object[]{nodeId,
442 shelve.getShelfName(),
443 shelve.getShelfType(),
445 shelve.getShelfPosition(),
446 (shelve.getAdministrativeState() == null ? null : shelve.getAdministrativeState().getIntValue()),
449 shelve.getSerialId(),
451 shelve.getProductCode(),
452 (shelve.getManufactureDate() == null ? null : shelve.getManufactureDate().getValue()),
454 shelve.getHardwareVersion(),
455 (shelve.getOperationalState() == null ? null : shelve.getOperationalState().getIntValue()),
456 (shelve.getEquipmentState() == null ? null : shelve.getEquipmentState().getIntValue()),
457 (shelve.getDueDate() == null ? null : shelve.getDueDate().getValue()),
463 private static Object[] prepareCPPortsParameters(String nodeId, CircuitPacks circuitPacks, Ports cpPort) {
465 String circuitPackName = circuitPacks.getCircuitPackName();
466 String portName = cpPort.getPortName();
467 String portType = cpPort.getPortType();
468 String portQualEnu = String.valueOf((cpPort.getPortQual() == null ? "-1" : cpPort.getPortQual().getName()));
469 String portWavelengthTypeEnu = "-1"; //cpPort.getPortWavelengthType().getIntValue(); /* Check error*/
470 String portDirectionEnu = String.valueOf((cpPort.getPortDirection() == null ? "" :
471 cpPort.getPortDirection().getName()));
472 String label = cpPort.getLabel();
473 String circuitId = cpPort.getCircuitId();
474 String administrativeStateEnu = (cpPort.getAdministrativeState() == null ? "" :
475 cpPort.getAdministrativeState().getName());
476 String operationalStateEnu =
477 (cpPort.getOperationalState() == null ? "" : cpPort.getOperationalState().getName());
478 String logicalConnectionPoint = cpPort.getLogicalConnectionPoint();
479 String parentPortCircuitPackName = (cpPort.getPartnerPort() == null ? "" :
480 (cpPort.getPartnerPort().getCircuitPackName() == null ? "" : cpPort.getPartnerPort().getCircuitPackName()));
481 String partnerPortPortName = (cpPort.getPartnerPort() == null ? "" :
482 (cpPort.getPartnerPort().getPortName() == null ? "" : cpPort.getPartnerPort().getPortName().toString()));
483 String partnerPortCircuitPackName = (cpPort.getParentPort() == null ? "" :
484 (cpPort.getParentPort().getCircuitPackName() == null ? "" : cpPort.getParentPort().getCircuitPackName()));
485 String parentPortPortName = (cpPort.getParentPort() == null ? "" :
486 (cpPort.getParentPort().getPortName() == null ? "" : cpPort.getParentPort().toString()));
487 String roadmPortPortPowerCapabilityMinRx = (cpPort.getRoadmPort() == null ? "" :
488 (cpPort.getRoadmPort().getPortPowerCapabilityMinRx() == null ? "" :
489 cpPort.getRoadmPort().getPortPowerCapabilityMinRx().toString()));
490 String roadmPortPortPowerCapabilityMinTx = (cpPort.getRoadmPort() == null ? "" :
491 (cpPort.getRoadmPort().getPortPowerCapabilityMinTx() == null ? "" :
492 cpPort.getRoadmPort().getPortPowerCapabilityMinTx().toString()));
493 String roadmPortPortPowerCapabilityMaxRx = (cpPort.getRoadmPort() == null ? "" :
494 (cpPort.getRoadmPort().getPortPowerCapabilityMaxRx() == null ? "" :
495 cpPort.getRoadmPort().getPortPowerCapabilityMaxRx().toString()));
496 String roadmPortPortPowerCapabilityMaxTx = (cpPort.getRoadmPort() == null ? "" :
497 (cpPort.getRoadmPort().getPortPowerCapabilityMaxTx() == null ? "" :
498 cpPort.getRoadmPort().getPortPowerCapabilityMaxTx().toString()));
499 //String roadmPortCapableWavelengths = "";
500 //String roadmPortAvailableWavelengths = "";
501 //String roadmPortUsedWavelengths = "";
502 String transponderPortPortPowerCapabilityMinRx = (cpPort.getTransponderPort() == null ? "" :
503 (cpPort.getTransponderPort().getPortPowerCapabilityMinRx() == null ? "" :
504 cpPort.getTransponderPort().getPortPowerCapabilityMinRx().toString()));
505 String transponderPortPortPowerCapabilityMinTx = (cpPort.getTransponderPort() == null ? "" :
506 (cpPort.getTransponderPort().getPortPowerCapabilityMinTx() == null ? "" :
507 cpPort.getTransponderPort().getPortPowerCapabilityMinTx().toString()));
508 String transponderPortPortPowerCapabilityMaxRx = (cpPort.getTransponderPort() == null ? "" :
509 (cpPort.getTransponderPort().getPortPowerCapabilityMaxRx() == null ? "" :
510 cpPort.getTransponderPort().getPortPowerCapabilityMaxRx().toString()));
511 String transponderPortPortPowerCapabilityMaxTx = (cpPort.getTransponderPort() == null ? "" :
512 (cpPort.getTransponderPort().getPortPowerCapabilityMaxTx() == null ? "" :
513 cpPort.getTransponderPort().getPortPowerCapabilityMaxTx().toString()));
514 //String transponderPortCapableWavelengths = "";
515 String otdrPortLaunchCableLength = (cpPort.getOtdrPort() == null ? "" :
516 (cpPort.getOtdrPort().getLaunchCableLength() == null ? "" :
517 cpPort.getOtdrPort().getLaunchCableLength().toString()));
518 String otdrPortPortDirection = (cpPort.getOtdrPort() == null ? "-1" :
519 (cpPort.getOtdrPort().getPortDirection() == null ? "-1" :
520 Integer.valueOf(cpPort.getOtdrPort().getPortDirection().getIntValue()).toString()));
521 //String ilaPortPortPowerCapabilityMixRx = "";
522 //String ilaPortPortPowerCapabilityMixTx = "";
523 //String ilaPortPortPowerCapabilityMaxRx = "";
524 //String ilaPortPortPowerCapabilityMaxTx = "";
526 String startTimestamp = getCurrentTimestamp();
528 return new Object[]{nodeId,
533 portWavelengthTypeEnu,
537 administrativeStateEnu,
539 logicalConnectionPoint,
540 partnerPortCircuitPackName,
542 parentPortCircuitPackName,
544 roadmPortPortPowerCapabilityMinRx,
545 roadmPortPortPowerCapabilityMinTx,
546 roadmPortPortPowerCapabilityMaxRx,
547 roadmPortPortPowerCapabilityMaxTx,
548 //roadmPortCapableWavelengths,
549 //roadmPortAvailableWavelengths,
550 //roadmPortUsedWavelengths,
552 transponderPortPortPowerCapabilityMinRx,
553 transponderPortPortPowerCapabilityMinTx,
554 transponderPortPortPowerCapabilityMaxRx,
555 transponderPortPortPowerCapabilityMaxTx,
556 //transponderPortCapableWavelengths,
558 otdrPortLaunchCableLength,
559 otdrPortPortDirection,
560 //ilaPortPortPowerCapabilityMixRx,
561 //ilaPortPortPowerCapabilityMixTx,
562 //ilaPortPortPowerCapabilityMaxRx,
563 //ilaPortPortPowerCapabilityMaxTx,
571 private static Object[] prepareCircuitPacksParameters(String nodeId, CircuitPacks cpack) {
572 String startTimestamp = getCurrentTimestamp();
573 return new Object[]{nodeId,
574 cpack.getCircuitPackName(),
575 cpack.getCircuitPackType(),
576 cpack.getCircuitPackProductCode(),
577 (cpack.getAdministrativeState() == null ? "" : cpack.getAdministrativeState().getIntValue()),
582 cpack.getProductCode(),
583 (cpack.getManufactureDate() == null ? "" : cpack.getManufactureDate().getValue()),
585 cpack.getHardwareVersion(),
586 (cpack.getOperationalState() == null ? -1 : cpack.getOperationalState().getIntValue()),
587 cpack.getCircuitPackCategory().getType().getIntValue(),
588 cpack.getCircuitPackCategory().getExtension(),
589 (cpack.getEquipmentState() == null ? -1 : cpack.getEquipmentState().getIntValue()),
590 cpack.getCircuitPackMode(),
594 prepareEmptyString(cpack.getDueDate()),
595 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
596 ((cpack.getParentCircuitPack().getCircuitPackName() == null) ? "" :
597 cpack.getParentCircuitPack().getCircuitPackName())
599 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
600 ((cpack.getParentCircuitPack().getCpSlotName() == null) ? "" :
601 cpack.getParentCircuitPack().getCpSlotName())
608 private void persistCPPorts(String nodeId, Connection connection, CircuitPacks circuitPacks) {
610 for (int i = 0; i < circuitPacks.getPorts().size(); i++) {
611 Object[] cpPortsParameters = prepareCPPortsParameters(nodeId, circuitPacks, circuitPacks.getPorts().get(i));
612 String query = Queries.getQuery().deviceCPPortInsert().get();
613 LOG.info("Running {} query ", query);
614 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
615 for (int j = 0; j < cpPortsParameters.length; j++) {
616 preparedStmt.setObject(j + 1, cpPortsParameters[j]);
618 preparedStmt.execute();
619 preparedStmt.clearParameters();
620 } catch (SQLException e) {
621 LOG.error(e.getMessage(), e);
627 private Object[] prepareDevInterfaceParameters(String nodeId, Interface deviceInterface, Connection connection) {
629 String ethernetDuplexEnu = "";
630 String ethernetAutoNegotiationEnu = "";
631 String maintTestsignalTestpatternEnu = "";
632 String maintTestsignalTypeEnu = "";
633 String otuFecEnu = "";
634 String otuMaintTypeEnu = "";
635 String otsFiberTypeEnu = "";
636 String ethernetSpeed = "-1";
637 String ethernetFec = "";
638 String ethernetMtu = "-1";
639 String ethernetCurrSpeed = "";
640 String ethernetCurrDuplex = "-1";
641 //String mciMcttpMinFreq = "";
642 //String mciMcttpMaxFreq = "";
643 //String mciMcttpCenterFreq = "";
644 //String mciMcttpSlotWidth = "";
645 //String mciNmcCtpFrequency = "";
646 //String mciNmcCtpWidth = "";
648 //String ochFrequency = "";
649 //String ochWidth = "";
650 String ochWavelengthNumber = "";
651 String ochModulationFormat = "";
652 String ochTransmitPower = "";
653 String otsSpanLossReceive = "";
654 String otsSpanLossTransmit = "";
655 //String otsIngressSpanLossAgingMargin = "";
656 //String otsEolMaxLoadPin = "";
658 //String oduFunction = "";
659 String oduMonitoringMode = "";
660 //String oduNoOamFunction = "";
661 String oduProactiveDelayMeasurementEnabled = "";
662 //String oduPoaTribPortNumber = "-1";
663 //String oduTxSapi = "";
664 //String oduTxDapi = "";
665 //String oduTxOperator = "";
666 //String oduAcceptedSapi = "";
667 //String oduAcceptedDapi = "";
668 //String oduAcceptedOperator = "";
669 //String oduExpectedSapi = "";
670 //String oduExpectedDapi = "";
671 //String oduTimActEnabled = "";
672 //String oduTimDetectMode = "";
673 //String oduDegmIntervals = "-1";
674 //String oduDegthrPercentage = "-1";
675 String opuPayloadType = "";
676 String opuRxPayloadType = "";
677 String opuExpPayloadType = "";
678 String opuPayloadInterface = "";
679 String maintTestsignalEnabled = "";
680 String maintTestsignalBiterrors = "-1";
681 String maintTestsignalBiterrorsterminal = "-1";
682 String maintTestsignalSyncseconds = "-1";
683 String maintTestsignalSyncsecondsterminal = "-1";
685 //String otuTxSapi = "";
686 //String otuTxDapi = "";
687 //String otuTxOperator = "";
688 //String otuAcceptedSapi = "";
689 //String otuAcceptedDapi = "";
690 //String otuAcceptedOperator = "";
691 //String otuExpectedSapi = "";
692 //String otuExpectedDapi = "";
693 //String otuTimActEnabled = "";
694 //String otuTimDetectMode = "";
695 //String otuDegmIntervals = "-1";
696 //String otuDegthrPercentage = "-1";
697 String otuMaintLoopbackEnabled = "";
698 //String mtOtuRate = "";
699 //String mtOtuFec = "";
700 //String mtOtuMaintLoopback = "";
701 //String mtOtuEnabled = "";
702 //String mtOtuType = "";
704 String name = deviceInterface.getName();
705 String description = deviceInterface.getDescription();
706 String type = deviceInterface.getType().getTypeName();
707 String administrativeStateEnu = deviceInterface.getAdministrativeState().getName();
708 int operationalState = deviceInterface.getOperationalState().getIntValue();
709 String circuitId = deviceInterface.getCircuitId();
710 String supportingInterface = deviceInterface.getSupportingInterface();
711 String supportingCircuitPackName = deviceInterface.getSupportingCircuitPackName();
712 String supportingPort = deviceInterface.getSupportingPort().toString();
714 switch (deviceInterface.getType().toString()) {
717 //EthernetBuilder ethIfBuilder = new EthernetBuilder();
718 EthernetBuilder ethIfBuilder = new EthernetBuilder(deviceInterface.augmentation(Interface1.class)
720 ethernetSpeed = (ethIfBuilder.getSpeed() == null ? "-1" :
721 Integer.valueOf(ethIfBuilder.getSpeed().intValue()).toString());
722 ethernetFec = ethIfBuilder.getFec().getName();
723 ethernetDuplexEnu = (ethIfBuilder.getDuplex() == null ? "" : ethIfBuilder.getDuplex().getName());
724 ethernetMtu = ethIfBuilder.getMtu().toString();
725 ethernetAutoNegotiationEnu = ethIfBuilder.getAutoNegotiation().getName();
726 ethernetCurrSpeed = ethIfBuilder.getCurrSpeed();
727 ethernetCurrDuplex = ethIfBuilder.getCurrDuplex();
731 OchBuilder ochIfBuilder = new OchBuilder(deviceInterface.augmentation(
732 org.opendaylight.yang.gen.v1
733 .http.org.openroadm.optical.channel.interfaces.rev161014.Interface1.class)
735 ochRate = ochIfBuilder.getRate().getName();
736 ochWavelengthNumber = ochIfBuilder.getWavelengthNumber().toString();
737 ochModulationFormat = ochIfBuilder.getModulationFormat().getName();
738 ochTransmitPower = ochIfBuilder.getTransmitPower().toString();
742 OtsBuilder otsIfBuilder = new OtsBuilder(deviceInterface.augmentation(
743 org.opendaylight.yang.gen.v1
744 .http.org.openroadm.optical.transport.interfaces.rev161014.Interface1.class)
746 otsFiberTypeEnu = String.valueOf(otsIfBuilder.getFiberType().getIntValue());
747 otsSpanLossReceive = otsIfBuilder.getSpanLossReceive().toString();
748 otsSpanLossTransmit = otsIfBuilder.getSpanLossTransmit().toString();
752 OduBuilder oduIfBuilder = new OduBuilder(deviceInterface.augmentation(
753 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1.class)
755 oduRate = String.valueOf(oduIfBuilder.getRate());
756 oduMonitoringMode = oduIfBuilder.getMonitoringMode().getName();
757 oduProactiveDelayMeasurementEnabled = oduIfBuilder.isProactiveDelayMeasurementEnabled().toString();
759 persistDevInterfaceTcm(nodeId, name, oduIfBuilder, connection);
760 persistDevInterfaceOtnOduTxMsi(nodeId, name, oduIfBuilder, connection);
761 persistDevInterfaceOtnOduRxMsi(nodeId, name, oduIfBuilder, connection);
762 persistDevInterfaceOtnOduExpMsi(nodeId, name, oduIfBuilder, connection);
764 opuPayloadType = oduIfBuilder.getOpu().getPayloadType();
765 opuRxPayloadType = oduIfBuilder.getOpu().getRxPayloadType();
766 opuExpPayloadType = oduIfBuilder.getOpu().getExpPayloadType();
767 opuPayloadInterface = oduIfBuilder.getOpu().getPayloadInterface();
768 /*persistDevInterfaceOtnOduTxMsi(nodeId,name,oduIfBuilder,connection);
769 persistDevInterfaceOtnOduRxMsi(nodeId,name,oduIfBuilder,connection);
770 persistDevInterfaceOtnOduExpMsi(nodeId,name,oduIfBuilder,connection); */
771 maintTestsignalEnabled = oduIfBuilder.getMaintTestsignal().isEnabled().toString();
772 maintTestsignalTestpatternEnu = oduIfBuilder.getMaintTestsignal().getTestPattern().getName();
773 maintTestsignalTypeEnu = oduIfBuilder.getMaintTestsignal().getType().getName();
774 maintTestsignalBiterrors = Integer.valueOf(oduIfBuilder.getMaintTestsignal().getBitErrors().intValue())
776 maintTestsignalBiterrorsterminal = oduIfBuilder.getMaintTestsignal().getBitErrorsTerminal().toString();
777 maintTestsignalSyncseconds = oduIfBuilder.getMaintTestsignal().getSyncSeconds();
778 maintTestsignalSyncsecondsterminal = oduIfBuilder.getMaintTestsignal().getSyncSecondsTerminal();
782 OtuBuilder otuIfBuilder =
783 new OtuBuilder(deviceInterface.augmentation(
784 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1.class)
786 otuRate = otuIfBuilder.getRate().getName();
787 otuFecEnu = otuIfBuilder.getFec().getName();
788 otuMaintLoopbackEnabled = otuIfBuilder.getMaintLoopback().isEnabled().toString();
789 otuMaintTypeEnu = otuIfBuilder.getMaintLoopback().getType().getName();
793 LOG.error("could not get interface type");
797 String startTimestamp = getCurrentTimestamp();
799 return new Object[]{nodeId,
803 administrativeStateEnu,
804 Integer.toString(operationalState),
807 supportingCircuitPackName,
813 ethernetAutoNegotiationEnu,
818 //mciMcttpCenterFreq,
820 //mciNmcCtpFrequency,
822 "", "", "", "", "", "",
833 //otsIngressSpanLossAgingMargin,
842 oduProactiveDelayMeasurementEnabled,
843 //oduPoaTribPortNumber,
849 //oduAcceptedOperator,
855 //oduDegthrPercentage,
856 "-1", "", "", "", "", "","", "", "", "", "", "-1", "-1",
861 maintTestsignalEnabled,
862 maintTestsignalTestpatternEnu,
863 maintTestsignalTypeEnu,
864 maintTestsignalBiterrors,
865 maintTestsignalBiterrorsterminal,
866 maintTestsignalSyncseconds,
867 maintTestsignalSyncsecondsterminal,
875 //otuAcceptedOperator,
881 //otuDegthrPercentage,
882 "", "", "", "", "", "","", "", "", "", "-1", "-1",
883 otuMaintLoopbackEnabled,
887 //mtOtuMaintLoopback,
897 private static Object[] prepareDevInterfaceTcmParameters(String nodeId, String interfaceName, Tcm tcm) {
899 String layer = tcm.getLayer().toString();
900 String monitoringModeEnu = tcm.getMonitoringMode().getName();
901 String ltcActEnabled = tcm.isLtcActEnabled().toString();
902 String proactiveDelayMeasurementEnabled = tcm.isProactiveDelayMeasurementEnabled().toString();
903 //String tcmDirectionEnu = "";
904 //String timDetectModeEnu = "";
905 //String txSapi = "";
906 //String txDapi = "";
907 //String txOperator = "";
908 //String acceptedSapi = "";
909 //String acceptedDapi = "";
910 //String acceptedOperator = "";
911 //String expectedSapi = "";
912 //String expectedDapi = "";
913 //String timActEnabled = "";
914 //String degmIntervals = "";
915 //String degthrPercentage = "";
916 String startTimestamp = getCurrentTimestamp();
918 return new Object[]{nodeId,
923 proactiveDelayMeasurementEnabled,
937 "", "", "", "", "", "", "", "", "", "", "", "", "",
943 private static Object[] prepareDevInterfaceOtnOduTxMsiParameters(String nodeId, String interfaceName, TxMsi txMsi) {
945 String tribSlot = txMsi.getTribSlot().toString();
946 String odtuType = txMsi.getOdtuType().getTypeName();
947 String tribPort = txMsi.getTribPort().toString();
948 String tribPortPayload = txMsi.getTribPortPayload();
950 String startTimestamp = getCurrentTimestamp();
952 return new Object[]{nodeId,
964 private static Object[] prepareDevInterfaceOtnOduRxMsiParameters(String nodeId, String interfaceName, RxMsi rxMsi) {
966 String tribSlot = rxMsi.getTribSlot().toString();
967 String odtuType = rxMsi.getOdtuType().getTypeName();
968 String tribPort = rxMsi.getTribPort().toString();
969 String tribPortPayload = rxMsi.getTribPortPayload();
971 String startTimestamp = getCurrentTimestamp();
973 return new Object[]{nodeId,
986 private static Object[] prepareDevInterfaceOtnOduExpMsiParameters(String nodeId, String interfaceName,
989 String tribSlot = expMsi.getTribSlot().toString();
990 String odtuType = expMsi.getOdtuType().getTypeName();
991 String tribPort = expMsi.getTribPort().toString();
992 String tribPortPayload = expMsi.getTribPortPayload();
994 String startTimestamp = getCurrentTimestamp();
996 return new Object[]{nodeId,
1008 private void persistDevInterfaces(String nodeId, Connection connection) {
1010 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1011 Optional<OrgOpenroadmDevice> deviceObject =
1012 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1013 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1015 /*InstanceIdentifier<Interface> interfaceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
1016 .child(Interface.class);
1017 Optional<Interface> interfaceOpt =
1018 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, interfaceIID,
1019 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); */
1021 for (int i = 0; i < deviceObject.get().getInterface().size(); i++) {
1022 Interface deviceInterface;
1024 deviceInterface = deviceObject.get().getInterface().get(i);
1025 /*if (interfaceOpt.isPresent()) {
1026 deviceInterface = interfaceOpt.get();
1028 LOG.warn("Could not get interface info");
1031 Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
1033 String query = Queries.getQuery().deviceInterfacesInsert().get();
1034 LOG.info("Running {} query ", query);
1035 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1036 for (int j = 0; j < parameters.length; j++) {
1037 stmt.setObject(j + 1, parameters[j]);
1040 stmt.clearParameters();
1041 } catch (SQLException e) {
1042 LOG.error(e.getMessage(), e);
1047 private void persistDevProtocols(String nodeId, Connection connection) {
1049 InstanceIdentifier<Protocols> protocolsIID =
1050 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1051 Optional<Protocols> protocolObject =
1052 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1053 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1054 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1055 LOG.error("LLDP subtree is missing");
1058 String adminstatusEnu = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1059 .getAdminStatus().getName();
1060 String msgTxtInterval = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1061 .getMsgTxInterval().toString();
1062 String mxgTxHoldMultiplier = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1063 .getMsgTxHoldMultiplier().toString();
1064 String startTimestamp = getCurrentTimestamp();
1065 persistDevProtocolLldpPortConfig(nodeId, connection);
1066 persistDevProtocolLldpNbrList(nodeId, connection);
1068 Object[] parameters = {nodeId,
1071 mxgTxHoldMultiplier,
1076 String query = Queries.getQuery().deviceProtocolInsert().get();
1077 LOG.info("Running {} query ", query);
1078 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1079 for (int j = 0; j < parameters.length; j++) {
1080 stmt.setObject(j + 1, parameters[j]);
1083 stmt.clearParameters();
1084 } catch (SQLException e) {
1085 LOG.error(e.getMessage(), e);
1091 private void persistDevProtocolLldpPortConfig(String nodeId, Connection connection) {
1093 InstanceIdentifier<Protocols> protocolsIID =
1094 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1095 Optional<Protocols> protocolObject =
1096 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1097 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1098 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1099 LOG.error("LLDP subtree is missing");
1102 String startTimestamp = getCurrentTimestamp();
1103 for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().size(); i++) {
1104 PortConfig portConfig =
1105 protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().get(i);
1106 String ifName = portConfig.getIfName();
1107 String adminStatusEnu = portConfig.getAdminStatus().getName();
1109 Object[] parameters = {nodeId,
1116 String query = Queries.getQuery().deviceProtocolPortConfigInsert().get();
1117 LOG.info("Running {} query ", query);
1118 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1119 for (int j = 0; j < parameters.length; j++) {
1120 stmt.setObject(j + 1, parameters[j]);
1123 stmt.clearParameters();
1124 } catch (SQLException e) {
1125 LOG.error(e.getMessage(), e);
1132 private void persistDevProtocolLldpNbrList(String nodeId, Connection connection) {
1134 InstanceIdentifier<Protocols> protocolsIID =
1135 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1136 Optional<Protocols> protocolObject =
1137 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1138 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1139 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1141 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, protocolsIID,
1142 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1145 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1146 LOG.error("LLDP nbrlist subtree is missing for {}", nodeId);
1149 String startTimestamp = getCurrentTimestamp();
1150 for (int i = 0; i < protocolObject.get()
1151 .augmentation(Protocols1.class).getLldp().getNbrList().getIfName().size(); i++) {
1153 IfName ifNameObj = protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList()
1154 .getIfName().get(i);
1155 String ifName = ifNameObj.getIfName();
1156 String remotesysname = ifNameObj.getRemoteSysName();
1157 String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
1158 String remotemgmtaddress = ifNameObj.getRemoteMgmtAddress().getIpv4Address().toString();
1159 String remoteportidsubtypeEnu = ifNameObj.getRemotePortIdSubType().getName();
1160 String remoteportid = ifNameObj.getRemotePortId();
1161 String remotechassisidsubtypeEnu = ifNameObj.getRemoteChassisIdSubType().getName();
1162 String remotechassisid = ifNameObj.getRemoteChassisId();
1164 Object[] parameters = {nodeId,
1167 remotemgmtaddresssubtype,
1169 remoteportidsubtypeEnu,
1171 remotechassisidsubtypeEnu,
1177 String query = Queries.getQuery().deviceProtocolLldpNbrlistInsert().get();
1178 LOG.info("Running {} query ", query);
1179 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1180 for (int j = 0; j < parameters.length; j++) {
1181 stmt.setObject(j + 1, parameters[j]);
1184 stmt.clearParameters();
1185 } catch (SQLException e) {
1186 LOG.error(e.getMessage(), e);
1193 private void persistDevProtocolRstp(String nodeId, Connection connection) {
1195 InstanceIdentifier<Protocols> protocolsIID =
1196 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1197 Optional<Protocols> protocolObject =
1198 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1199 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1200 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1201 LOG.error("LLDP subtree is missing");
1204 String startTimestamp = getCurrentTimestamp();
1205 for (int i = 0; i < protocolObject.get()
1206 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.Protocols1.class)
1207 .getRstp().getRstpBridgeInstance().size(); i++) {
1209 RstpBridgeInstance rstpBridgeInstance = protocolObject.get()
1210 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.Protocols1.class)
1211 .getRstp().getRstpBridgeInstance().get(i);
1212 String bridgeName = rstpBridgeInstance.getBridgeName();
1213 String bridgePriority = rstpBridgeInstance.getRstpConfig().getBridgePriority().toString();
1214 String shutdown = rstpBridgeInstance.getRstpConfig().getShutdown().toString();
1215 String holdTime = rstpBridgeInstance.getRstpConfig().getHoldTime().toString();
1216 String helloTime = rstpBridgeInstance.getRstpConfig().getHelloTime().toString();
1217 String maxAge = rstpBridgeInstance.getRstpConfig().getMaxAge().toString();
1218 String forwardDelay = rstpBridgeInstance.getRstpConfig().getForwardDelay().toString();
1219 String transmitHoldCount = rstpBridgeInstance.getRstpConfig().getTransmitHoldCount().toString();
1220 String rootBridgePort =
1221 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgePort().toString();
1222 String rootPathCost = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootPathCost().toString();
1223 String rootBridgePriority =
1224 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgePriority().toString();
1225 String rootBridgeId = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgeId().toString();
1226 String rootHoldTime = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootHoldTime().toString();
1227 String rootHelloTime = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootHelloTime().toString();
1228 String rootMaxAge = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootMaxAge().toString();
1229 String rootForwardDelay =
1230 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootForwardDelay().toString();
1231 String bridgeId = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getBridgeId().toString();
1232 String topoChangeCount =
1233 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getTopoChangeCount().toString();
1234 String timeSinceTopoChange =
1235 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getTimeSinceTopoChange().toString();
1237 persistDevProtocolRstpBridgePort(nodeId, bridgeName, rstpBridgeInstance, connection);
1238 persistDevProtocolRstpBridgePortAttr(nodeId, bridgeName, rstpBridgeInstance, connection);
1240 Object[] parameters = {nodeId,
1259 timeSinceTopoChange,
1264 String query = Queries.getQuery().deviceProtocolRstpInsert().get();
1265 LOG.info("Running {} query ", query);
1266 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1267 for (int j = 0; j < parameters.length; j++) {
1268 stmt.setObject(j + 1, parameters[j]);
1271 stmt.clearParameters();
1272 } catch (SQLException e) {
1273 LOG.error(e.getMessage(), e);
1279 private void persistDevProtocolRstpBridgePort(String nodeId, String bridgeName,
1280 RstpBridgeInstance rstpBridgeInstance, Connection connection) {
1282 String startTimestamp = getCurrentTimestamp();
1283 for (int i = 0; i < rstpBridgeInstance.getRstpConfig().getRstpBridgePortTable().size(); i++) {
1284 RstpBridgePortTable rstpBridgePortTable =
1285 rstpBridgeInstance.getRstpConfig().getRstpBridgePortTable().get(i);
1287 String ifName = rstpBridgePortTable.getIfname();
1288 String cost = rstpBridgePortTable.getCost().toString();
1289 String priority = rstpBridgePortTable.getPriority().toString();
1291 Object[] parameters = {nodeId,
1300 String query = Queries.getQuery().deviceProtocolRstpBridgePortInsert().get();
1301 LOG.info("Running {} query ", query);
1302 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1303 for (int j = 0; j < parameters.length; j++) {
1304 stmt.setObject(j + 1, parameters[j]);
1307 stmt.clearParameters();
1308 } catch (SQLException e) {
1309 LOG.error(e.getMessage(), e);
1315 private void persistDevProtocolRstpBridgePortAttr(String nodeId, String bridgeName,
1316 RstpBridgeInstance rstpBridgeInstance, Connection connection) {
1318 String startTimestamp = getCurrentTimestamp();
1319 for (int i = 0; i < rstpBridgeInstance.getRstpState().getRstpBridgePortAttr().getRstpBridgePortTable().size();
1322 org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.bridge.port.state.attr
1323 .RstpBridgePortTable rstpBridgePortTableAttr =
1324 rstpBridgeInstance.getRstpState().getRstpBridgePortAttr().getRstpBridgePortTable().get(i);
1326 String ifName = rstpBridgePortTableAttr.getIfname();
1327 String bridgePortState = rstpBridgePortTableAttr.getBridgePortState().getName();
1328 String bridgePortRole = rstpBridgePortTableAttr.getBridgePortRole().getName();
1329 String bridgePortId = rstpBridgePortTableAttr.getBridgePortId().toString();
1330 String openEdgeBridgePort = rstpBridgePortTableAttr.getOperEdgeBridgePort().toString();
1331 String designatedBridgePort = rstpBridgePortTableAttr.getDesignatedBridgePort().toString();
1332 String designatedBridgeId = rstpBridgePortTableAttr.getDesignatedBridgeid().toString();
1334 Object[] parameters = {nodeId,
1341 designatedBridgePort,
1347 String query = Queries.getQuery().deviceProtocolRstpBridgePortAttrInsert().get();
1348 LOG.info("Running {} query ", query);
1349 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1350 for (int j = 0; j < parameters.length; j++) {
1351 stmt.setObject(j + 1, parameters[j]);
1354 stmt.clearParameters();
1355 } catch (SQLException e) {
1356 LOG.error(e.getMessage(), e);
1363 private void persistDevInternalLinks(String nodeId, Connection connection) {
1365 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1366 Optional<OrgOpenroadmDevice> deviceObject =
1367 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1368 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1369 if (deviceObject.get().getInternalLink() == null) {
1371 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1372 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1374 if (deviceObject.get().getInternalLink() == null) {
1375 LOG.info("External links not found for {}", nodeId);
1379 String startTimestamp = getCurrentTimestamp();
1380 for (int i = 0; i < deviceObject.get().getInternalLink().size(); i++) {
1381 InternalLink internalLink = deviceObject.get().getInternalLink().get(i);
1382 String internalLinkName = internalLink.getInternalLinkName();
1383 String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
1384 String sourcePortName = internalLink.getSource().getPortName().toString();
1385 String destinationCircuitPackName = internalLink.getDestination().getCircuitPackName();
1386 String destinationPortName = internalLink.getDestination().getPortName().toString();
1388 Object[] parameters = {nodeId,
1390 sourceCircuitPackName,
1392 destinationCircuitPackName,
1393 destinationPortName,
1398 String query = Queries.getQuery().deviceInternalLinkInsert().get();
1399 LOG.info("Running {} query ", query);
1400 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1401 for (int j = 0; j < parameters.length; j++) {
1402 stmt.setObject(j + 1, parameters[j]);
1405 stmt.clearParameters();
1406 } catch (SQLException e) {
1407 LOG.error(e.getMessage(), e);
1415 private void persistDevExternalLinks(String nodeId, Connection connection) {
1417 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1418 Optional<OrgOpenroadmDevice> deviceObject =
1419 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1420 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1422 if (deviceObject.get().getExternalLink() == null) {
1424 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1425 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1427 if (deviceObject.get().getExternalLink() == null) {
1428 LOG.info("External links not found for {}", nodeId);
1430 String startTimestamp = getCurrentTimestamp();
1431 for (int i = 0; i < deviceObject.get().getExternalLink().size(); i++) {
1432 ExternalLink externalLink = deviceObject.get().getExternalLink().get(i);
1433 String externalLinkName = externalLink.getExternalLinkName();
1434 String sourceNodeId = externalLink.getSource().getNodeId();
1435 String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
1436 String sourcePortName = externalLink.getSource().getPortName().toString();
1437 String destinationNodeId = externalLink.getDestination().getNodeId();
1438 String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
1439 String destinationPortName = externalLink.getDestination().getPortName().toString();
1441 Object[] parameters = {nodeId,
1444 sourceCircuitPackName,
1447 destinationCircuitPackName,
1448 destinationPortName,
1453 String query = Queries.getQuery().deviceExternalLinkInsert().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(e.getMessage(), e);
1469 private void persistDevPhysicalLinks(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);
1475 if (deviceObject.get().getPhysicalLink() == null) {
1477 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1478 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1480 if (deviceObject.get().getPhysicalLink() == null) {
1481 LOG.info("Physical links not found for {}", nodeId);
1484 String startTimestamp = getCurrentTimestamp();
1485 for (int i = 0; i < deviceObject.get().getPhysicalLink().size(); i++) {
1486 PhysicalLink physicalLink = deviceObject.get().getPhysicalLink().get(i);
1487 String physicalLinkName = physicalLink.getPhysicalLinkName();
1488 String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
1489 String sourcePortName = physicalLink.getSource().getPortName().toString();
1490 String destinationCircuitPackName = physicalLink.getDestination().getCircuitPackName();
1491 String destinationPortName = physicalLink.getDestination().getPortName().toString();
1493 Object[] parameters = {nodeId,
1495 sourceCircuitPackName,
1497 destinationCircuitPackName,
1498 destinationPortName,
1503 String query = Queries.getQuery().devicePhysicalLinkInsert().get();
1504 LOG.info("Running {} query ", query);
1505 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1506 for (int j = 0; j < parameters.length; j++) {
1507 stmt.setObject(j + 1, parameters[j]);
1510 stmt.clearParameters();
1511 } catch (SQLException e) {
1512 LOG.error(e.getMessage(), e);
1519 private void persistDevDegree(String nodeId, Connection connection) {
1521 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1522 Optional<OrgOpenroadmDevice> deviceObject =
1523 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1524 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1527 /*if (deviceObject.get().getDegree()==null){
1529 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1530 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1532 if (deviceObject.get().getDegree() == null) {
1533 LOG.warn("Degree info not found for {}", nodeId);
1536 String startTimestamp = getCurrentTimestamp();
1537 for (int i = 0; i < deviceObject.get().getDegree().size(); i++) {
1538 Degree degree = deviceObject.get().getDegree().get(i);
1539 String degreeNumber = degree.getDegreeNumber().toString();
1540 String maxWavelengths = degree.getMaxWavelengths().toString();
1541 String otdrPortCircuitPackName =
1542 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getCircuitPackName());
1543 String otdrPortPortName =
1544 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getPortName().toString());
1545 //String mcCapabilitiesSlotWidthGranularity = "";
1546 //String mcCapabilitiesCenterFreqGranularity = "";
1547 //String mcCapabilitiesMinSlots = "-1";
1548 //String mcCapabilitiesMaxSlots = "-1";
1549 persistDevDegreeCircuitPack(nodeId, degree, degreeNumber, connection);
1550 persistDevDegreeConnectionPort(nodeId, degree, degreeNumber, connection);
1552 Object[] parameters = {nodeId,
1555 otdrPortCircuitPackName,
1557 //mcCapabilitiesSlotWidthGranularity,
1558 //mcCapabilitiesCenterFreqGranularity,
1559 //mcCapabilitiesMinSlots,
1560 //mcCapabilitiesMaxSlots,
1566 String query = Queries.getQuery().deviceDegreeInsert().get();
1567 LOG.info("Running {} query ", query);
1568 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1569 for (int j = 0; j < parameters.length; j++) {
1570 stmt.setObject(j + 1, parameters[j]);
1573 stmt.clearParameters();
1574 } catch (SQLException e) {
1575 LOG.error(e.getMessage(), e);
1583 private void persistDevDegreeCircuitPack(String nodeId, Degree degree, String degreeNumber, Connection connection) {
1585 String startTimestamp = getCurrentTimestamp();
1586 for (int i = 0; i < degree.getCircuitPacks().size(); i++) {
1588 String circuitPackIndex = degree.getCircuitPacks().get(i).getIndex().toString();
1589 String circuitPackName = degree.getCircuitPacks().get(i).getCircuitPackName();
1591 Object[] parameters = {nodeId,
1599 String query = Queries.getQuery().deviceDegreeCircuitPackInsert().get();
1600 LOG.info("Running {} query ", query);
1601 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1602 for (int j = 0; j < parameters.length; j++) {
1603 stmt.setObject(j + 1, parameters[j]);
1606 stmt.clearParameters();
1607 } catch (SQLException e) {
1608 LOG.error(e.getMessage(), e);
1614 private void persistDevDegreeConnectionPort(String nodeId, Degree degree, String degreeNumber,
1615 Connection connection) {
1617 String startTimestamp = getCurrentTimestamp();
1618 for (int i = 0; i < degree.getConnectionPorts().size(); i++) {
1620 String connectionPortIndex = degree.getConnectionPorts().get(i).getIndex().toString();
1621 String circuitPackName = degree.getConnectionPorts().get(i).getCircuitPackName();
1622 String portName = degree.getConnectionPorts().get(i).getPortName().toString();
1624 Object[] parameters = {nodeId,
1626 connectionPortIndex,
1633 String query = Queries.getQuery().deviceDegreeConnectionPortInsert().get();
1634 LOG.info("Running {} query ", query);
1635 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1636 for (int j = 0; j < parameters.length; j++) {
1637 stmt.setObject(j + 1, parameters[j]);
1640 stmt.clearParameters();
1641 } catch (SQLException e) {
1642 LOG.error(e.getMessage(), e);
1649 private void persistDevSrg(String nodeId, Connection connection) {
1651 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1652 Optional<OrgOpenroadmDevice> deviceObject =
1653 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1654 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1656 if (deviceObject.get().getSharedRiskGroup() == null) {
1658 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1659 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1661 if (deviceObject.get().getSharedRiskGroup() == null) {
1662 LOG.info("no srg found for node {} ", nodeId);
1664 String startTimestamp = getCurrentTimestamp();
1665 for (int i = 0; i < deviceObject.get().getSharedRiskGroup().size(); i++) {
1666 SharedRiskGroup sharedRiskGroup = deviceObject.get().getSharedRiskGroup().get(i);
1667 //String currentProvisionedAddDropPorts = "-1";
1668 //String mcCapSlotWidthGranularity = "";
1669 //String mcCapCenterFreqGranularity = "";
1670 //String mcCapMinSlots = "-1";
1671 //String mcCapMaxSlots = "-1";
1672 String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
1673 String srgNumber = sharedRiskGroup.getSrgNumber().toString();
1674 String wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getName();
1675 persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
1677 Object[] parameters = {nodeId,
1679 //currentProvisionedAddDropPorts,
1682 wavelengthDuplicationEnu,
1683 //mcCapSlotWidthGranularity,
1684 //mcCapCenterFreqGranularity,
1692 String query = Queries.getQuery().deviceSharedRiskGroupInsert().get();
1693 LOG.info("Running {} query ", query);
1694 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1695 for (int j = 0; j < parameters.length; j++) {
1696 stmt.setObject(j + 1, parameters[j]);
1699 stmt.clearParameters();
1700 } catch (SQLException e) {
1701 LOG.error(e.getMessage(), e);
1709 private void persistDevSrgCircuitPacks(String nodeId, SharedRiskGroup sharedRiskGroup, String srgNumber,
1710 Connection connection) {
1712 String startTimestamp = getCurrentTimestamp();
1713 for (int i = 0; i < sharedRiskGroup.getCircuitPacks().size(); i++) {
1715 String circuitPackindex = sharedRiskGroup.getCircuitPacks().get(i).getIndex().toString();
1716 String circuitPackName = sharedRiskGroup.getCircuitPacks().get(i).getCircuitPackName();
1718 Object[] parameters = {nodeId,
1726 String query = Queries.getQuery().deviceSrgCircuitPackInsert().get();
1727 LOG.info("Running {} query ", query);
1728 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1729 for (int j = 0; j < parameters.length; j++) {
1730 stmt.setObject(j + 1, parameters[j]);
1733 stmt.clearParameters();
1734 } catch (SQLException e) {
1735 LOG.error(e.getMessage(), e);
1741 private void persistDevRoadmConnections(String nodeId, Connection connection) {
1743 //int opticalcontrolmodeEnu=-1;
1745 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1746 Optional<OrgOpenroadmDevice> deviceObject =
1747 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1748 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1750 if (deviceObject.get().getRoadmConnections() == null) {
1752 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1753 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1756 if (deviceObject.get().getRoadmConnections() != null) {
1757 String startTimestamp = getCurrentTimestamp();
1758 for (int i = 0; i < deviceObject.get().getRoadmConnections().size(); i++) {
1759 RoadmConnections roadmConnections = deviceObject.get().getRoadmConnections().get(i);
1760 String connectionNumber = roadmConnections.getConnectionNumber();
1761 //String connectionName = "";
1762 String wavelengthNumber = roadmConnections.getWavelengthNumber().toString();
1763 String opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getName();
1764 String targetOutputPower = roadmConnections.getTargetOutputPower().toString();
1765 String srcIf = roadmConnections.getSource().getSrcIf();
1766 String dstIf = roadmConnections.getDestination().getDstIf();
1768 Object[] parameters = {nodeId,
1773 opticalcontrolmodeEnu,
1781 String query = Queries.getQuery().deviceRoadmConnectionsInsert().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(e.getMessage(), e);
1795 LOG.info("ROADM Dev Connections not found!! for {}", nodeId);
1800 private void persistDevConnectionMap(String nodeId, Connection connection) {
1802 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1803 Optional<OrgOpenroadmDevice> deviceObject =
1804 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1805 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1807 String startTimestamp = getCurrentTimestamp();
1808 for (int i = 0; i < deviceObject.get().getConnectionMap().size(); i++) {
1809 ConnectionMap connectionMap = deviceObject.get().getConnectionMap().get(i);
1810 String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
1811 String sourceCircuitPackName = connectionMap.getSource().getCircuitPackName();
1812 String sourcePortName = connectionMap.getSource().getCircuitPackName();
1815 Object[] parameters = {nodeId,
1816 connectionMapNumber,
1817 sourceCircuitPackName,
1823 String query = Queries.getQuery().deviceConnectionMapInsert().get();
1824 LOG.info("Running {} query ", query);
1825 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1826 for (int j = 0; j < parameters.length; j++) {
1827 stmt.setObject(j + 1, parameters[j]);
1830 stmt.clearParameters();
1831 } catch (SQLException e) {
1832 LOG.error(e.getMessage(), e);
1838 private void persistDevWavelengthMap(String nodeId, Connection connection) {
1840 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1841 Optional<OrgOpenroadmDevice> deviceObject =
1842 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1843 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1845 String startTimestamp = getCurrentTimestamp();
1846 for (int i = 0; i < deviceObject.get().getWavelengthMap().getWavelengths().size(); i++) {
1847 Wavelengths wavelengths = deviceObject.get().getWavelengthMap().getWavelengths().get(i);
1848 String wavelengthNumber = wavelengths.getWavelengthNumber().toString();
1849 String centerFrequency = wavelengths.getCenterFrequency().toString();
1850 String wavelength = wavelengths.getWavelength().toString();
1853 Object[] parameters = {nodeId,
1861 String query = Queries.getQuery().deviceWavelengthInsert().get();
1862 LOG.info("Running {} query ", query);
1863 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1864 for (int j = 0; j < parameters.length; j++) {
1865 stmt.setObject(j + 1, parameters[j]);
1868 stmt.clearParameters();
1869 } catch (SQLException e) {
1870 LOG.error(e.getMessage(), e);
1877 private void persistDevInterfaceTcm(String nodeId, String interfaceName, OduBuilder oduBuilder,
1878 Connection connection) {
1880 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1883 tcm = oduBuilder.getTcm().get(i);
1885 Object[] parameters = prepareDevInterfaceTcmParameters(nodeId, interfaceName, tcm);
1887 String query = Queries.getQuery().deviceInterfacesInsert().get();
1888 LOG.info("Running {} query ", query);
1889 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1890 for (int j = 0; j < parameters.length; j++) {
1891 stmt.setObject(j + 1, parameters[j]);
1894 stmt.clearParameters();
1895 } catch (SQLException e) {
1896 LOG.error(e.getMessage(), e);
1901 private void persistDevInterfaceOtnOduTxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1902 Connection connection) {
1904 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1907 txMsi = oduBuilder.getOpu().getMsi().getTxMsi().get(i);
1909 Object[] parameters = prepareDevInterfaceOtnOduTxMsiParameters(nodeId, interfaceName, txMsi);
1911 String query = Queries.getQuery().deviceInterfaceOtnOduTxMsiInsert().get();
1912 LOG.info("Running {} query ", query);
1913 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1914 for (int j = 0; j < parameters.length; j++) {
1915 stmt.setObject(j + 1, parameters[j]);
1918 stmt.clearParameters();
1919 } catch (SQLException e) {
1920 LOG.error(e.getMessage(), e);
1926 private void persistDevInterfaceOtnOduRxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1927 Connection connection) {
1929 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1932 rxMsi = oduBuilder.getOpu().getMsi().getRxMsi().get(i);
1934 Object[] parameters = prepareDevInterfaceOtnOduRxMsiParameters(nodeId, interfaceName, rxMsi);
1936 String query = Queries.getQuery().deviceInterfaceOtnOduRxMsiInsert().get();
1937 LOG.info("Running {} query ", query);
1938 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1939 for (int j = 0; j < parameters.length; j++) {
1940 stmt.setObject(j + 1, parameters[j]);
1943 stmt.clearParameters();
1944 } catch (SQLException e) {
1945 LOG.error(e.getMessage(), e);
1951 private void persistDevInterfaceOtnOduExpMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1952 Connection connection) {
1954 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1957 expMsi = oduBuilder.getOpu().getMsi().getExpMsi().get(i);
1959 Object[] parameters = prepareDevInterfaceOtnOduExpMsiParameters(nodeId, interfaceName, expMsi);
1961 String query = Queries.getQuery().deviceInterfaceOtnOduExpMsiInsert().get();
1962 LOG.info("Running {} query ", query);
1963 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1964 for (int j = 0; j < parameters.length; j++) {
1965 stmt.setObject(j + 1, parameters[j]);
1968 stmt.clearParameters();
1969 } catch (SQLException e) {
1970 LOG.error(e.getMessage(), e);