2 * Copyright © 2017 AT&T and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.inventory;
11 import static java.util.Objects.requireNonNull;
12 import static org.opendaylight.transportpce.inventory.utils.StringUtils.getCurrentTimestamp;
13 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareDashString;
14 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareEmptyString;
16 import java.sql.Connection;
17 import java.sql.PreparedStatement;
18 import java.sql.ResultSet;
19 import java.sql.SQLException;
20 import java.util.Optional;
21 import java.util.concurrent.ExecutionException;
22 import javax.sql.DataSource;
23 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
24 import org.opendaylight.transportpce.common.Timeouts;
25 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
26 import org.opendaylight.transportpce.inventory.query.Queries;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.CpSlots;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.external.links.ExternalLink;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.internal.links.InternalLink;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.ConnectionMap;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Degree;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Info;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Protocols;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.physical.links.PhysicalLink;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelf.Slots;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelves.Shelves;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.Interface1;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.ethernet.container.EthernetBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.Protocols1;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.PortConfig;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.nbr.list.IfName;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.och.container.OchBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.ots.container.OtsBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.attributes.Tcm;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.container.OduBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.ExpMsi;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.RxMsi;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.TxMsi;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.otu.container.OtuBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.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 = requireNonNull(dataSource.getConnection())) {
188 for (int i = 0; i < deviceObject.get().getShelves().size(); i++) {
189 Shelves shelve = deviceObject.get().getShelves().get(i);
190 String shelfName = shelve.getShelfName();
192 LOG.info("Getting Shelve Details of {}", shelfName);
193 if (shelve.getSlots() != null) {
194 LOG.info("Slot Size {} ", shelve.getSlots().size());
195 persistShelveSlots(nodeId, shelve, connection);
197 LOG.info("No Slots for shelf {}", shelfName);
200 persistShelves(nodeId, connection, shelve);
202 } catch (SQLException e1) {
203 LOG.error(e1.getMessage(), e1);
207 public void getCircuitPacks(String nodeId) throws InterruptedException, ExecutionException {
208 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
209 Optional<OrgOpenroadmDevice> deviceObject =
210 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
211 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
212 if (!deviceObject.isPresent()) {
213 LOG.warn("Device object {} was not found", nodeId);
216 LOG.info("Circuit pack size {}", deviceObject.get().getCircuitPacks().size());
218 try (Connection connection = requireNonNull(dataSource.getConnection())) {
219 for (int i = 0; i < deviceObject.get().getCircuitPacks().size(); i++) {
220 CircuitPacks cp = deviceObject.get().getCircuitPacks().get(i);
222 if (cp.getCpSlots() != null) {
223 persistCircuitPacksSlots(nodeId, cp, connection);
225 LOG.info("Everything {}", cp);
226 LOG.info("CP is {}", cp);
228 //persistPorts(cp, connection);
229 if (cp.getPorts() != null) {
230 persistCPPorts(nodeId, connection, cp);
232 persistCircuitPacks(nodeId, connection, cp);
234 } catch (SQLException e1) {
235 LOG.error(e1.getMessage(), e1);
239 private void persistCircuitPacks(String nodeId, Connection connection, CircuitPacks cp) {
240 Object[] parameters = prepareCircuitPacksParameters(nodeId, cp);
241 String query = Queries.getQuery().deviceCircuitPackInsert().get();
242 LOG.info("Running {} query ", query);
243 try (PreparedStatement stmt = connection.prepareStatement(query)) {
244 for (int j = 0; j < parameters.length; j++) {
245 stmt.setObject(j + 1, parameters[j]);
248 stmt.clearParameters();
249 } catch (SQLException e) {
250 LOG.error(e.getMessage(), e);
254 private void persistShelves(String nodeId, Connection connection, Shelves shelve) {
255 Object[] shelvesParameter = prepareShelvesParameters(nodeId, shelve);
256 String query = Queries.getQuery().deviceShelfInsert().get();
257 LOG.info("Running {} query ", query);
258 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
259 for (int j = 0; j < shelvesParameter.length; j++) {
260 preparedStmt.setObject(j + 1, shelvesParameter[j]);
262 preparedStmt.execute();
263 preparedStmt.clearParameters();
264 } catch (SQLException e) {
265 LOG.error(e.getMessage(), e);
269 private void persistShelveSlots(String nodeId, Shelves shelves, Connection connection) {
270 String startTimetampStr = getCurrentTimestamp();
271 for (int i = 0; i < shelves.getSlots().size(); i++) {
272 Slots slot = shelves.getSlots().get(i);
273 LOG.info("Getting Slot Details of {}", slot.getSlotName());
274 Object[] parameters = new Object[]{nodeId,
275 shelves.getShelfName(),
278 slot.getProvisionedCircuitPack(),
282 String query = Queries.getQuery().deviceShelfSlotInsert().get();
283 LOG.info("Running {} query ", query);
284 try (PreparedStatement stmt = connection.prepareStatement(query)) {
285 for (int j = 0; j < parameters.length; j++) {
286 stmt.setObject(j + 1, parameters[j]);
289 stmt.clearParameters();
290 } catch (SQLException e) {
291 LOG.error(e.getMessage(), e);
297 private void persistCircuitPacksSlots(String nodeId, CircuitPacks circuitPacks, Connection connection) {
298 String startTimetampStr = getCurrentTimestamp();
299 for (int i = 0; i < circuitPacks.getCpSlots().size(); i++) {
300 CpSlots cpSlot = circuitPacks.getCpSlots().get(i);
302 Object[] parameters = new Object[]{nodeId,
303 circuitPacks.getCircuitPackName(),
304 cpSlot.getSlotName(),
306 cpSlot.getProvisionedCircuitPack(),
311 String query = Queries.getQuery().deviceCPSlotInsert().get();
312 LOG.info("Running {} query ", query);
313 try (PreparedStatement stmt = connection.prepareStatement(query)) {
314 for (int j = 0; j < parameters.length; j++) {
315 stmt.setObject(j + 1, parameters[j]);
318 stmt.clearParameters();
319 } catch (SQLException e) {
320 LOG.error(e.getMessage(), e);
325 private void persistPorts(CircuitPacks circuitPacks, Connection connection) {
326 LOG.warn("Ports are not persisted yet");
331 * Prepares parameters for device insert query.
333 * @param deviceInfo device information
334 * @return Object an object
336 private static Object[] prepareDeviceInfoParameters(Info deviceInfo) {
337 String startTimetampStr = getCurrentTimestamp();
339 String nodeId = prepareDashString(deviceInfo.getNodeId());
340 Long nodeNumber = deviceInfo.getNodeNumber().toJava();
341 String nodeTypeEnu = deviceInfo.getNodeType().getName();
342 String clli = prepareDashString(deviceInfo.getClli());
343 String vendor = prepareDashString(deviceInfo.getVendor());
344 String model = prepareDashString(deviceInfo.getModel());
345 String serialId = prepareDashString(deviceInfo.getSerialId());
346 String ipAddress = prepareDashString(deviceInfo.getIpAddress().getIpv4Address().getValue());
347 String prefixLength = prepareDashString(deviceInfo.getPrefixLength());
348 String defaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
349 String sourceEnum = deviceInfo.getSource().getName();
350 String currentIpAddress = prepareDashString(deviceInfo.getCurrentIpAddress().getIpv4Address().getValue());
351 String currentPrefixLength = prepareDashString(deviceInfo.getCurrentPrefixLength());
352 String currentDefaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
353 String macAddress = prepareDashString(deviceInfo.getMacAddress().getValue());
354 String softwareVersion = prepareDashString(deviceInfo.getSoftwareVersion());
355 //String openroadmVersion = "1.2.1";
356 String template = prepareDashString(deviceInfo.getTemplate());
357 String currentDatetime = prepareDashString(deviceInfo.getCurrentDatetime().getValue());
358 String geoLatitude = (deviceInfo.getGeoLocation() != null
359 ? prepareDashString(deviceInfo.getGeoLocation().getLatitude()) : "");
360 String geoLongitude = (deviceInfo.getGeoLocation() != null
361 ? prepareDashString(deviceInfo.getGeoLocation().getLongitude()) : "");
362 String maxDegrees = (deviceInfo.getMaxDegrees() == null ? "-1" : prepareDashString(deviceInfo.getMaxDegrees()));
363 String maxSrgs = (deviceInfo.getMaxSrgs() == null ? "-1" : prepareDashString(deviceInfo.getMaxSrgs()));
364 String swVersion = prepareDashString(deviceInfo.getSoftwareVersion()); //sw_version
365 String swValidationTimer = prepareDashString(""); //sw_validation_timer
366 String activationDateTime = prepareDashString(""); //activation_date_time
367 //Integer maxNumBin15minHistoricalPm = null;
368 //Integer maxNumBin24hourHistoricalPm = null;
369 /*jsonDevInfo = JsonStringBuilder.getDevInfoJson().replace("$$NODE-ID$$",nodeId)
370 .replace("$$NODE-NUMBER$$", nodeNumber)
371 .replace("$$NODE-TYPE$$",nodeType)
372 .replace("$$CLLI$$",clli)
373 .replace("$$VENDOR$$",vendor)
374 .replace("$$MODEL$$",model)
375 .replace("$$SERIAL-ID$$",serialId)
376 .replace("$$IPADDRESS$$",ipAddress)
377 .replace("$$PREFIX-LENGTH$$",prefixLength)
378 .replace("$$DEFAULTGATEWAY$$",defaultGateway)
379 .replace("$$SOURCE$$",String.valueOf(source))
380 .replace("$$CURRENT-IPADDRESS$$",currentIpAddress)
381 .replace("$$CURRENT-PREFIX-LENGTH$$",currentPrefixLength)
382 .replace("$$CURRENT-DEFAULTGATEWAY$$",currentDefailtGateway)
383 .replace("$$MACADDRESS$$",macAddress)
384 .replace("$$SOFTWAREVERSION$$",softwareVersion)
385 .replace("$$OPENROADM-VERSION$$",openroadmVersion)
386 .replace("$$TEMPLATE$$",template)
387 .replace("$$CURRENT-DATETIME$$",currentDatetime)
388 .replace("$$LATITUDE$$",latitude)
389 .replace("$$LONGITUDE$$",longitude)
390 .replace("$$MAX-DEGREES$$",maxDegrees)
391 .replace("$$MAX-SRGS$$",maxSrgs)
392 .replace("$$MAX-NUM-BIN-15MIN-HISTORICAL-PM$$",prepareDashString(""))
393 .replace("$$MAX-NUM-BIN-24HOUR-HISTORICAL-PM$$",prepareDashString(""))
394 .replace("$$SW-VERSION$$",swVersion)
395 .replace("$$SW-VALIDATION-TIMER$$",swValidationTimer)
396 .replace("$$ACTIVATION-DATE-TIME$$",activationDateTime);*/
413 currentDefaultGateway,
424 //maxNumBin15minHistoricalPm,
425 //maxNumBin24hourHistoricalPm,
436 private static Object[] prepareShelvesParameters(String nodeId, Shelves shelve) {
437 String startTimestamp = getCurrentTimestamp();
439 return new Object[]{nodeId,
440 shelve.getShelfName(),
441 shelve.getShelfType(),
443 shelve.getShelfPosition(),
444 (shelve.getAdministrativeState() == null ? null : shelve.getAdministrativeState().getIntValue()),
447 shelve.getSerialId(),
449 shelve.getProductCode(),
450 (shelve.getManufactureDate() == null ? null : shelve.getManufactureDate().getValue()),
452 shelve.getHardwareVersion(),
453 (shelve.getOperationalState() == null ? null : shelve.getOperationalState().getIntValue()),
454 (shelve.getEquipmentState() == null ? null : shelve.getEquipmentState().getIntValue()),
455 (shelve.getDueDate() == null ? null : shelve.getDueDate().getValue()),
461 private static Object[] prepareCPPortsParameters(String nodeId, CircuitPacks circuitPacks, Ports cpPort) {
463 String circuitPackName = circuitPacks.getCircuitPackName();
464 String portName = cpPort.getPortName();
465 String portType = cpPort.getPortType();
466 String portQualEnu = String.valueOf((cpPort.getPortQual() == null ? "-1" : cpPort.getPortQual().getName()));
467 String portWavelengthTypeEnu = "-1"; //cpPort.getPortWavelengthType().getIntValue(); /* Check error*/
468 String portDirectionEnu = String.valueOf((cpPort.getPortDirection() == null ? "" :
469 cpPort.getPortDirection().getName()));
470 String label = cpPort.getLabel();
471 String circuitId = cpPort.getCircuitId();
472 String administrativeStateEnu = (cpPort.getAdministrativeState() == null ? "" :
473 cpPort.getAdministrativeState().getName());
474 String operationalStateEnu =
475 (cpPort.getOperationalState() == null ? "" : cpPort.getOperationalState().getName());
476 String logicalConnectionPoint = cpPort.getLogicalConnectionPoint();
477 String parentPortCircuitPackName = (cpPort.getPartnerPort() == null ? "" :
478 (cpPort.getPartnerPort().getCircuitPackName() == null ? "" : cpPort.getPartnerPort().getCircuitPackName()));
479 String partnerPortPortName = (cpPort.getPartnerPort() == null ? "" :
480 (cpPort.getPartnerPort().getPortName() == null ? "" : cpPort.getPartnerPort().getPortName().toString()));
481 String partnerPortCircuitPackName = (cpPort.getParentPort() == null ? "" :
482 (cpPort.getParentPort().getCircuitPackName() == null ? "" : cpPort.getParentPort().getCircuitPackName()));
483 String parentPortPortName = (cpPort.getParentPort() == null ? "" :
484 (cpPort.getParentPort().getPortName() == null ? "" : cpPort.getParentPort().toString()));
485 String roadmPortPortPowerCapabilityMinRx = (cpPort.getRoadmPort() == null ? "" :
486 (cpPort.getRoadmPort().getPortPowerCapabilityMinRx() == null ? "" :
487 cpPort.getRoadmPort().getPortPowerCapabilityMinRx().toString()));
488 String roadmPortPortPowerCapabilityMinTx = (cpPort.getRoadmPort() == null ? "" :
489 (cpPort.getRoadmPort().getPortPowerCapabilityMinTx() == null ? "" :
490 cpPort.getRoadmPort().getPortPowerCapabilityMinTx().toString()));
491 String roadmPortPortPowerCapabilityMaxRx = (cpPort.getRoadmPort() == null ? "" :
492 (cpPort.getRoadmPort().getPortPowerCapabilityMaxRx() == null ? "" :
493 cpPort.getRoadmPort().getPortPowerCapabilityMaxRx().toString()));
494 String roadmPortPortPowerCapabilityMaxTx = (cpPort.getRoadmPort() == null ? "" :
495 (cpPort.getRoadmPort().getPortPowerCapabilityMaxTx() == null ? "" :
496 cpPort.getRoadmPort().getPortPowerCapabilityMaxTx().toString()));
497 //String roadmPortCapableWavelengths = "";
498 //String roadmPortAvailableWavelengths = "";
499 //String roadmPortUsedWavelengths = "";
500 String transponderPortPortPowerCapabilityMinRx = (cpPort.getTransponderPort() == null ? "" :
501 (cpPort.getTransponderPort().getPortPowerCapabilityMinRx() == null ? "" :
502 cpPort.getTransponderPort().getPortPowerCapabilityMinRx().toString()));
503 String transponderPortPortPowerCapabilityMinTx = (cpPort.getTransponderPort() == null ? "" :
504 (cpPort.getTransponderPort().getPortPowerCapabilityMinTx() == null ? "" :
505 cpPort.getTransponderPort().getPortPowerCapabilityMinTx().toString()));
506 String transponderPortPortPowerCapabilityMaxRx = (cpPort.getTransponderPort() == null ? "" :
507 (cpPort.getTransponderPort().getPortPowerCapabilityMaxRx() == null ? "" :
508 cpPort.getTransponderPort().getPortPowerCapabilityMaxRx().toString()));
509 String transponderPortPortPowerCapabilityMaxTx = (cpPort.getTransponderPort() == null ? "" :
510 (cpPort.getTransponderPort().getPortPowerCapabilityMaxTx() == null ? "" :
511 cpPort.getTransponderPort().getPortPowerCapabilityMaxTx().toString()));
512 //String transponderPortCapableWavelengths = "";
513 String otdrPortLaunchCableLength = (cpPort.getOtdrPort() == null ? "" :
514 (cpPort.getOtdrPort().getLaunchCableLength() == null ? "" :
515 cpPort.getOtdrPort().getLaunchCableLength().toString()));
516 String otdrPortPortDirection = (cpPort.getOtdrPort() == null ? "-1" :
517 (cpPort.getOtdrPort().getPortDirection() == null ? "-1" :
518 Integer.valueOf(cpPort.getOtdrPort().getPortDirection().getIntValue()).toString()));
519 //String ilaPortPortPowerCapabilityMixRx = "";
520 //String ilaPortPortPowerCapabilityMixTx = "";
521 //String ilaPortPortPowerCapabilityMaxRx = "";
522 //String ilaPortPortPowerCapabilityMaxTx = "";
524 String startTimestamp = getCurrentTimestamp();
526 return new Object[]{nodeId,
531 portWavelengthTypeEnu,
535 administrativeStateEnu,
537 logicalConnectionPoint,
538 partnerPortCircuitPackName,
540 parentPortCircuitPackName,
542 roadmPortPortPowerCapabilityMinRx,
543 roadmPortPortPowerCapabilityMinTx,
544 roadmPortPortPowerCapabilityMaxRx,
545 roadmPortPortPowerCapabilityMaxTx,
546 //roadmPortCapableWavelengths,
547 //roadmPortAvailableWavelengths,
548 //roadmPortUsedWavelengths,
550 transponderPortPortPowerCapabilityMinRx,
551 transponderPortPortPowerCapabilityMinTx,
552 transponderPortPortPowerCapabilityMaxRx,
553 transponderPortPortPowerCapabilityMaxTx,
554 //transponderPortCapableWavelengths,
556 otdrPortLaunchCableLength,
557 otdrPortPortDirection,
558 //ilaPortPortPowerCapabilityMixRx,
559 //ilaPortPortPowerCapabilityMixTx,
560 //ilaPortPortPowerCapabilityMaxRx,
561 //ilaPortPortPowerCapabilityMaxTx,
569 private static Object[] prepareCircuitPacksParameters(String nodeId, CircuitPacks cpack) {
570 String startTimestamp = getCurrentTimestamp();
571 return new Object[]{nodeId,
572 cpack.getCircuitPackName(),
573 cpack.getCircuitPackType(),
574 cpack.getCircuitPackProductCode(),
575 (cpack.getAdministrativeState() == null ? "" : cpack.getAdministrativeState().getIntValue()),
580 cpack.getProductCode(),
581 (cpack.getManufactureDate() == null ? "" : cpack.getManufactureDate().getValue()),
583 cpack.getHardwareVersion(),
584 (cpack.getOperationalState() == null ? -1 : cpack.getOperationalState().getIntValue()),
585 cpack.getCircuitPackCategory().getType().getIntValue(),
586 cpack.getCircuitPackCategory().getExtension(),
587 (cpack.getEquipmentState() == null ? -1 : cpack.getEquipmentState().getIntValue()),
588 cpack.getCircuitPackMode(),
592 prepareEmptyString(cpack.getDueDate()),
593 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
594 ((cpack.getParentCircuitPack().getCircuitPackName() == null) ? "" :
595 cpack.getParentCircuitPack().getCircuitPackName())
597 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
598 ((cpack.getParentCircuitPack().getCpSlotName() == null) ? "" :
599 cpack.getParentCircuitPack().getCpSlotName())
606 private void persistCPPorts(String nodeId, Connection connection, CircuitPacks circuitPacks) {
608 for (int i = 0; i < circuitPacks.getPorts().size(); i++) {
609 Object[] cpPortsParameters = prepareCPPortsParameters(nodeId, circuitPacks, circuitPacks.getPorts().get(i));
610 String query = Queries.getQuery().deviceCPPortInsert().get();
611 LOG.info("Running {} query ", query);
612 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
613 for (int j = 0; j < cpPortsParameters.length; j++) {
614 preparedStmt.setObject(j + 1, cpPortsParameters[j]);
616 preparedStmt.execute();
617 preparedStmt.clearParameters();
618 } catch (SQLException e) {
619 LOG.error(e.getMessage(), e);
625 private Object[] prepareDevInterfaceParameters(String nodeId, Interface deviceInterface, Connection connection) {
627 String ethernetDuplexEnu = "";
628 String ethernetAutoNegotiationEnu = "";
629 String maintTestsignalTestpatternEnu = "";
630 String maintTestsignalTypeEnu = "";
631 String otuFecEnu = "";
632 String otuMaintTypeEnu = "";
633 String otsFiberTypeEnu = "";
634 String ethernetSpeed = "-1";
635 String ethernetFec = "";
636 String ethernetMtu = "-1";
637 String ethernetCurrSpeed = "";
638 String ethernetCurrDuplex = "-1";
639 //String mciMcttpMinFreq = "";
640 //String mciMcttpMaxFreq = "";
641 //String mciMcttpCenterFreq = "";
642 //String mciMcttpSlotWidth = "";
643 //String mciNmcCtpFrequency = "";
644 //String mciNmcCtpWidth = "";
646 //String ochFrequency = "";
647 //String ochWidth = "";
648 String ochWavelengthNumber = "";
649 String ochModulationFormat = "";
650 String ochTransmitPower = "";
651 String otsSpanLossReceive = "";
652 String otsSpanLossTransmit = "";
653 //String otsIngressSpanLossAgingMargin = "";
654 //String otsEolMaxLoadPin = "";
656 //String oduFunction = "";
657 String oduMonitoringMode = "";
658 //String oduNoOamFunction = "";
659 String oduProactiveDelayMeasurementEnabled = "";
660 //String oduPoaTribPortNumber = "-1";
661 //String oduTxSapi = "";
662 //String oduTxDapi = "";
663 //String oduTxOperator = "";
664 //String oduAcceptedSapi = "";
665 //String oduAcceptedDapi = "";
666 //String oduAcceptedOperator = "";
667 //String oduExpectedSapi = "";
668 //String oduExpectedDapi = "";
669 //String oduTimActEnabled = "";
670 //String oduTimDetectMode = "";
671 //String oduDegmIntervals = "-1";
672 //String oduDegthrPercentage = "-1";
673 String opuPayloadType = "";
674 String opuRxPayloadType = "";
675 String opuExpPayloadType = "";
676 String opuPayloadInterface = "";
677 String maintTestsignalEnabled = "";
678 String maintTestsignalBiterrors = "-1";
679 String maintTestsignalBiterrorsterminal = "-1";
680 String maintTestsignalSyncseconds = "-1";
681 String maintTestsignalSyncsecondsterminal = "-1";
683 //String otuTxSapi = "";
684 //String otuTxDapi = "";
685 //String otuTxOperator = "";
686 //String otuAcceptedSapi = "";
687 //String otuAcceptedDapi = "";
688 //String otuAcceptedOperator = "";
689 //String otuExpectedSapi = "";
690 //String otuExpectedDapi = "";
691 //String otuTimActEnabled = "";
692 //String otuTimDetectMode = "";
693 //String otuDegmIntervals = "-1";
694 //String otuDegthrPercentage = "-1";
695 String otuMaintLoopbackEnabled = "";
696 //String mtOtuRate = "";
697 //String mtOtuFec = "";
698 //String mtOtuMaintLoopback = "";
699 //String mtOtuEnabled = "";
700 //String mtOtuType = "";
702 String name = deviceInterface.getName();
703 String description = deviceInterface.getDescription();
704 String type = deviceInterface.getType().getTypeName();
705 String administrativeStateEnu = deviceInterface.getAdministrativeState().getName();
706 int operationalState = deviceInterface.getOperationalState().getIntValue();
707 String circuitId = deviceInterface.getCircuitId();
708 String supportingInterface = deviceInterface.getSupportingInterface();
709 String supportingCircuitPackName = deviceInterface.getSupportingCircuitPackName();
710 String supportingPort = deviceInterface.getSupportingPort().toString();
712 switch (deviceInterface.getType().toString()) {
715 //EthernetBuilder ethIfBuilder = new EthernetBuilder();
716 EthernetBuilder ethIfBuilder = new EthernetBuilder(deviceInterface.augmentation(Interface1.class)
718 ethernetSpeed = (ethIfBuilder.getSpeed() == null ? "-1" :
719 Integer.valueOf(ethIfBuilder.getSpeed().intValue()).toString());
720 ethernetFec = ethIfBuilder.getFec().getName();
721 ethernetDuplexEnu = (ethIfBuilder.getDuplex() == null ? "" : ethIfBuilder.getDuplex().getName());
722 ethernetMtu = ethIfBuilder.getMtu().toString();
723 ethernetAutoNegotiationEnu = ethIfBuilder.getAutoNegotiation().getName();
724 ethernetCurrSpeed = ethIfBuilder.getCurrSpeed();
725 ethernetCurrDuplex = ethIfBuilder.getCurrDuplex();
729 OchBuilder ochIfBuilder = new OchBuilder(deviceInterface.augmentation(
730 org.opendaylight.yang.gen.v1
731 .http.org.openroadm.optical.channel.interfaces.rev161014.Interface1.class)
733 ochRate = ochIfBuilder.getRate().getName();
734 ochWavelengthNumber = ochIfBuilder.getWavelengthNumber().toString();
735 ochModulationFormat = ochIfBuilder.getModulationFormat().getName();
736 ochTransmitPower = ochIfBuilder.getTransmitPower().toString();
740 OtsBuilder otsIfBuilder = new OtsBuilder(deviceInterface.augmentation(
741 org.opendaylight.yang.gen.v1
742 .http.org.openroadm.optical.transport.interfaces.rev161014.Interface1.class)
744 otsFiberTypeEnu = String.valueOf(otsIfBuilder.getFiberType().getIntValue());
745 otsSpanLossReceive = otsIfBuilder.getSpanLossReceive().toString();
746 otsSpanLossTransmit = otsIfBuilder.getSpanLossTransmit().toString();
750 OduBuilder oduIfBuilder = new OduBuilder(deviceInterface.augmentation(
751 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1.class)
753 oduRate = String.valueOf(oduIfBuilder.getRate());
754 oduMonitoringMode = oduIfBuilder.getMonitoringMode().getName();
755 oduProactiveDelayMeasurementEnabled = oduIfBuilder.isProactiveDelayMeasurementEnabled().toString();
757 persistDevInterfaceTcm(nodeId, name, oduIfBuilder, connection);
758 persistDevInterfaceOtnOduTxMsi(nodeId, name, oduIfBuilder, connection);
759 persistDevInterfaceOtnOduRxMsi(nodeId, name, oduIfBuilder, connection);
760 persistDevInterfaceOtnOduExpMsi(nodeId, name, oduIfBuilder, connection);
762 opuPayloadType = oduIfBuilder.getOpu().getPayloadType();
763 opuRxPayloadType = oduIfBuilder.getOpu().getRxPayloadType();
764 opuExpPayloadType = oduIfBuilder.getOpu().getExpPayloadType();
765 opuPayloadInterface = oduIfBuilder.getOpu().getPayloadInterface();
766 /*persistDevInterfaceOtnOduTxMsi(nodeId,name,oduIfBuilder,connection);
767 persistDevInterfaceOtnOduRxMsi(nodeId,name,oduIfBuilder,connection);
768 persistDevInterfaceOtnOduExpMsi(nodeId,name,oduIfBuilder,connection); */
769 maintTestsignalEnabled = oduIfBuilder.getMaintTestsignal().isEnabled().toString();
770 maintTestsignalTestpatternEnu = oduIfBuilder.getMaintTestsignal().getTestPattern().getName();
771 maintTestsignalTypeEnu = oduIfBuilder.getMaintTestsignal().getType().getName();
772 maintTestsignalBiterrors = Integer.valueOf(oduIfBuilder.getMaintTestsignal().getBitErrors().intValue())
774 maintTestsignalBiterrorsterminal = oduIfBuilder.getMaintTestsignal().getBitErrorsTerminal().toString();
775 maintTestsignalSyncseconds = oduIfBuilder.getMaintTestsignal().getSyncSeconds();
776 maintTestsignalSyncsecondsterminal = oduIfBuilder.getMaintTestsignal().getSyncSecondsTerminal();
780 OtuBuilder otuIfBuilder =
781 new OtuBuilder(deviceInterface.augmentation(
782 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1.class)
784 otuRate = otuIfBuilder.getRate().getName();
785 otuFecEnu = otuIfBuilder.getFec().getName();
786 otuMaintLoopbackEnabled = otuIfBuilder.getMaintLoopback().isEnabled().toString();
787 otuMaintTypeEnu = otuIfBuilder.getMaintLoopback().getType().getName();
791 LOG.error("could not get interface type");
795 String startTimestamp = getCurrentTimestamp();
797 return new Object[]{nodeId,
801 administrativeStateEnu,
802 Integer.toString(operationalState),
805 supportingCircuitPackName,
811 ethernetAutoNegotiationEnu,
816 //mciMcttpCenterFreq,
818 //mciNmcCtpFrequency,
820 "", "", "", "", "", "",
831 //otsIngressSpanLossAgingMargin,
840 oduProactiveDelayMeasurementEnabled,
841 //oduPoaTribPortNumber,
847 //oduAcceptedOperator,
853 //oduDegthrPercentage,
854 "-1", "", "", "", "", "","", "", "", "", "", "-1", "-1",
859 maintTestsignalEnabled,
860 maintTestsignalTestpatternEnu,
861 maintTestsignalTypeEnu,
862 maintTestsignalBiterrors,
863 maintTestsignalBiterrorsterminal,
864 maintTestsignalSyncseconds,
865 maintTestsignalSyncsecondsterminal,
873 //otuAcceptedOperator,
879 //otuDegthrPercentage,
880 "", "", "", "", "", "","", "", "", "", "-1", "-1",
881 otuMaintLoopbackEnabled,
885 //mtOtuMaintLoopback,
895 private static Object[] prepareDevInterfaceTcmParameters(String nodeId, String interfaceName, Tcm tcm) {
897 String layer = tcm.getLayer().toString();
898 String monitoringModeEnu = tcm.getMonitoringMode().getName();
899 String ltcActEnabled = tcm.isLtcActEnabled().toString();
900 String proactiveDelayMeasurementEnabled = tcm.isProactiveDelayMeasurementEnabled().toString();
901 //String tcmDirectionEnu = "";
902 //String timDetectModeEnu = "";
903 //String txSapi = "";
904 //String txDapi = "";
905 //String txOperator = "";
906 //String acceptedSapi = "";
907 //String acceptedDapi = "";
908 //String acceptedOperator = "";
909 //String expectedSapi = "";
910 //String expectedDapi = "";
911 //String timActEnabled = "";
912 //String degmIntervals = "";
913 //String degthrPercentage = "";
914 String startTimestamp = getCurrentTimestamp();
916 return new Object[]{nodeId,
921 proactiveDelayMeasurementEnabled,
935 "", "", "", "", "", "", "", "", "", "", "", "", "",
941 private static Object[] prepareDevInterfaceOtnOduTxMsiParameters(String nodeId, String interfaceName, TxMsi txMsi) {
943 String tribSlot = txMsi.getTribSlot().toString();
944 String odtuType = txMsi.getOdtuType().getTypeName();
945 String tribPort = txMsi.getTribPort().toString();
946 String tribPortPayload = txMsi.getTribPortPayload();
948 String startTimestamp = getCurrentTimestamp();
950 return new Object[]{nodeId,
962 private static Object[] prepareDevInterfaceOtnOduRxMsiParameters(String nodeId, String interfaceName, RxMsi rxMsi) {
964 String tribSlot = rxMsi.getTribSlot().toString();
965 String odtuType = rxMsi.getOdtuType().getTypeName();
966 String tribPort = rxMsi.getTribPort().toString();
967 String tribPortPayload = rxMsi.getTribPortPayload();
969 String startTimestamp = getCurrentTimestamp();
971 return new Object[]{nodeId,
984 private static Object[] prepareDevInterfaceOtnOduExpMsiParameters(String nodeId, String interfaceName,
987 String tribSlot = expMsi.getTribSlot().toString();
988 String odtuType = expMsi.getOdtuType().getTypeName();
989 String tribPort = expMsi.getTribPort().toString();
990 String tribPortPayload = expMsi.getTribPortPayload();
992 String startTimestamp = getCurrentTimestamp();
994 return new Object[]{nodeId,
1006 private void persistDevInterfaces(String nodeId, Connection connection) {
1008 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1009 Optional<OrgOpenroadmDevice> deviceObject =
1010 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1011 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1013 /*InstanceIdentifier<Interface> interfaceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
1014 .child(Interface.class);
1015 Optional<Interface> interfaceOpt =
1016 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, interfaceIID,
1017 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); */
1019 for (int i = 0; i < deviceObject.get().getInterface().size(); i++) {
1020 Interface deviceInterface;
1022 deviceInterface = deviceObject.get().getInterface().get(i);
1023 /*if (interfaceOpt.isPresent()) {
1024 deviceInterface = interfaceOpt.get();
1026 LOG.warn("Could not get interface info");
1029 Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
1031 String query = Queries.getQuery().deviceInterfacesInsert().get();
1032 LOG.info("Running {} query ", query);
1033 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1034 for (int j = 0; j < parameters.length; j++) {
1035 stmt.setObject(j + 1, parameters[j]);
1038 stmt.clearParameters();
1039 } catch (SQLException e) {
1040 LOG.error(e.getMessage(), e);
1045 private void persistDevProtocols(String nodeId, Connection connection) {
1047 InstanceIdentifier<Protocols> protocolsIID =
1048 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1049 Optional<Protocols> protocolObject =
1050 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1051 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1052 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1053 LOG.error("LLDP subtree is missing");
1056 String adminstatusEnu = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1057 .getAdminStatus().getName();
1058 String msgTxtInterval = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1059 .getMsgTxInterval().toString();
1060 String mxgTxHoldMultiplier = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1061 .getMsgTxHoldMultiplier().toString();
1062 String startTimestamp = getCurrentTimestamp();
1063 persistDevProtocolLldpPortConfig(nodeId, connection);
1064 persistDevProtocolLldpNbrList(nodeId, connection);
1066 Object[] parameters = {nodeId,
1069 mxgTxHoldMultiplier,
1074 String query = Queries.getQuery().deviceProtocolInsert().get();
1075 LOG.info("Running {} query ", query);
1076 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1077 for (int j = 0; j < parameters.length; j++) {
1078 stmt.setObject(j + 1, parameters[j]);
1081 stmt.clearParameters();
1082 } catch (SQLException e) {
1083 LOG.error(e.getMessage(), e);
1089 private void persistDevProtocolLldpPortConfig(String nodeId, Connection connection) {
1091 InstanceIdentifier<Protocols> protocolsIID =
1092 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1093 Optional<Protocols> protocolObject =
1094 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1095 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1096 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1097 LOG.error("LLDP subtree is missing");
1100 String startTimestamp = getCurrentTimestamp();
1101 for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().size(); i++) {
1102 PortConfig portConfig =
1103 protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().get(i);
1104 String ifName = portConfig.getIfName();
1105 String adminStatusEnu = portConfig.getAdminStatus().getName();
1107 Object[] parameters = {nodeId,
1114 String query = Queries.getQuery().deviceProtocolPortConfigInsert().get();
1115 LOG.info("Running {} query ", query);
1116 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1117 for (int j = 0; j < parameters.length; j++) {
1118 stmt.setObject(j + 1, parameters[j]);
1121 stmt.clearParameters();
1122 } catch (SQLException e) {
1123 LOG.error(e.getMessage(), e);
1130 private void persistDevProtocolLldpNbrList(String nodeId, Connection connection) {
1132 InstanceIdentifier<Protocols> protocolsIID =
1133 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1134 Optional<Protocols> protocolObject =
1135 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1136 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1137 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1139 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, protocolsIID,
1140 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1143 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1144 LOG.error("LLDP nbrlist subtree is missing for {}", nodeId);
1147 String startTimestamp = getCurrentTimestamp();
1148 for (int i = 0; i < protocolObject.get()
1149 .augmentation(Protocols1.class).getLldp().getNbrList().getIfName().size(); i++) {
1151 IfName ifNameObj = protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList()
1152 .getIfName().get(i);
1153 String ifName = ifNameObj.getIfName();
1154 String remotesysname = ifNameObj.getRemoteSysName();
1155 String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
1156 String remotemgmtaddress = ifNameObj.getRemoteMgmtAddress().getIpv4Address().toString();
1157 String remoteportidsubtypeEnu = ifNameObj.getRemotePortIdSubType().getName();
1158 String remoteportid = ifNameObj.getRemotePortId();
1159 String remotechassisidsubtypeEnu = ifNameObj.getRemoteChassisIdSubType().getName();
1160 String remotechassisid = ifNameObj.getRemoteChassisId();
1162 Object[] parameters = {nodeId,
1165 remotemgmtaddresssubtype,
1167 remoteportidsubtypeEnu,
1169 remotechassisidsubtypeEnu,
1175 String query = Queries.getQuery().deviceProtocolLldpNbrlistInsert().get();
1176 LOG.info("Running {} query ", query);
1177 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1178 for (int j = 0; j < parameters.length; j++) {
1179 stmt.setObject(j + 1, parameters[j]);
1182 stmt.clearParameters();
1183 } catch (SQLException e) {
1184 LOG.error(e.getMessage(), e);
1191 private void persistDevProtocolRstp(String nodeId, Connection connection) {
1193 InstanceIdentifier<Protocols> protocolsIID =
1194 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1195 Optional<Protocols> protocolObject =
1196 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1197 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1198 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1199 LOG.error("LLDP subtree is missing");
1202 String startTimestamp = getCurrentTimestamp();
1203 for (int i = 0; i < protocolObject.get()
1204 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.Protocols1.class)
1205 .getRstp().getRstpBridgeInstance().size(); i++) {
1207 RstpBridgeInstance rstpBridgeInstance = protocolObject.get()
1208 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.Protocols1.class)
1209 .getRstp().getRstpBridgeInstance().get(i);
1210 String bridgeName = rstpBridgeInstance.getBridgeName();
1211 String bridgePriority = rstpBridgeInstance.getRstpConfig().getBridgePriority().toString();
1212 String shutdown = rstpBridgeInstance.getRstpConfig().getShutdown().toString();
1213 String holdTime = rstpBridgeInstance.getRstpConfig().getHoldTime().toString();
1214 String helloTime = rstpBridgeInstance.getRstpConfig().getHelloTime().toString();
1215 String maxAge = rstpBridgeInstance.getRstpConfig().getMaxAge().toString();
1216 String forwardDelay = rstpBridgeInstance.getRstpConfig().getForwardDelay().toString();
1217 String transmitHoldCount = rstpBridgeInstance.getRstpConfig().getTransmitHoldCount().toString();
1218 String rootBridgePort =
1219 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgePort().toString();
1220 String rootPathCost = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootPathCost().toString();
1221 String rootBridgePriority =
1222 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgePriority().toString();
1223 String rootBridgeId = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootBridgeId().toString();
1224 String rootHoldTime = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootHoldTime().toString();
1225 String rootHelloTime = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootHelloTime().toString();
1226 String rootMaxAge = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootMaxAge().toString();
1227 String rootForwardDelay =
1228 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getRootForwardDelay().toString();
1229 String bridgeId = rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getBridgeId().toString();
1230 String topoChangeCount =
1231 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getTopoChangeCount().toString();
1232 String timeSinceTopoChange =
1233 rstpBridgeInstance.getRstpState().getRstpBridgeAttr().getTimeSinceTopoChange().toString();
1235 persistDevProtocolRstpBridgePort(nodeId, bridgeName, rstpBridgeInstance, connection);
1236 persistDevProtocolRstpBridgePortAttr(nodeId, bridgeName, rstpBridgeInstance, connection);
1238 Object[] parameters = {nodeId,
1257 timeSinceTopoChange,
1262 String query = Queries.getQuery().deviceProtocolRstpInsert().get();
1263 LOG.info("Running {} query ", query);
1264 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1265 for (int j = 0; j < parameters.length; j++) {
1266 stmt.setObject(j + 1, parameters[j]);
1269 stmt.clearParameters();
1270 } catch (SQLException e) {
1271 LOG.error(e.getMessage(), e);
1277 private void persistDevProtocolRstpBridgePort(String nodeId, String bridgeName,
1278 RstpBridgeInstance rstpBridgeInstance, Connection connection) {
1280 String startTimestamp = getCurrentTimestamp();
1281 for (int i = 0; i < rstpBridgeInstance.getRstpConfig().getRstpBridgePortTable().size(); i++) {
1282 RstpBridgePortTable rstpBridgePortTable =
1283 rstpBridgeInstance.getRstpConfig().getRstpBridgePortTable().get(i);
1285 String ifName = rstpBridgePortTable.getIfname();
1286 String cost = rstpBridgePortTable.getCost().toString();
1287 String priority = rstpBridgePortTable.getPriority().toString();
1289 Object[] parameters = {nodeId,
1298 String query = Queries.getQuery().deviceProtocolRstpBridgePortInsert().get();
1299 LOG.info("Running {} query ", query);
1300 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1301 for (int j = 0; j < parameters.length; j++) {
1302 stmt.setObject(j + 1, parameters[j]);
1305 stmt.clearParameters();
1306 } catch (SQLException e) {
1307 LOG.error(e.getMessage(), e);
1313 private void persistDevProtocolRstpBridgePortAttr(String nodeId, String bridgeName,
1314 RstpBridgeInstance rstpBridgeInstance, Connection connection) {
1316 String startTimestamp = getCurrentTimestamp();
1317 for (int i = 0; i < rstpBridgeInstance.getRstpState().getRstpBridgePortAttr().getRstpBridgePortTable().size();
1320 org.opendaylight.yang.gen.v1.http.org.openroadm.rstp.rev161014.rstp.bridge.port.state.attr
1321 .RstpBridgePortTable rstpBridgePortTableAttr =
1322 rstpBridgeInstance.getRstpState().getRstpBridgePortAttr().getRstpBridgePortTable().get(i);
1324 String ifName = rstpBridgePortTableAttr.getIfname();
1325 String bridgePortState = rstpBridgePortTableAttr.getBridgePortState().getName();
1326 String bridgePortRole = rstpBridgePortTableAttr.getBridgePortRole().getName();
1327 String bridgePortId = rstpBridgePortTableAttr.getBridgePortId().toString();
1328 String openEdgeBridgePort = rstpBridgePortTableAttr.getOperEdgeBridgePort().toString();
1329 String designatedBridgePort = rstpBridgePortTableAttr.getDesignatedBridgePort().toString();
1330 String designatedBridgeId = rstpBridgePortTableAttr.getDesignatedBridgeid().toString();
1332 Object[] parameters = {nodeId,
1339 designatedBridgePort,
1345 String query = Queries.getQuery().deviceProtocolRstpBridgePortAttrInsert().get();
1346 LOG.info("Running {} query ", query);
1347 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1348 for (int j = 0; j < parameters.length; j++) {
1349 stmt.setObject(j + 1, parameters[j]);
1352 stmt.clearParameters();
1353 } catch (SQLException e) {
1354 LOG.error(e.getMessage(), e);
1361 private void persistDevInternalLinks(String nodeId, Connection connection) {
1363 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1364 Optional<OrgOpenroadmDevice> deviceObject =
1365 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1366 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1367 if (deviceObject.get().getInternalLink() == null) {
1369 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1370 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1372 if (deviceObject.get().getInternalLink() == null) {
1373 LOG.info("External links not found for {}", nodeId);
1377 String startTimestamp = getCurrentTimestamp();
1378 for (int i = 0; i < deviceObject.get().getInternalLink().size(); i++) {
1379 InternalLink internalLink = deviceObject.get().getInternalLink().get(i);
1380 String internalLinkName = internalLink.getInternalLinkName();
1381 String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
1382 String sourcePortName = internalLink.getSource().getPortName().toString();
1383 String destinationCircuitPackName = internalLink.getDestination().getCircuitPackName();
1384 String destinationPortName = internalLink.getDestination().getPortName().toString();
1386 Object[] parameters = {nodeId,
1388 sourceCircuitPackName,
1390 destinationCircuitPackName,
1391 destinationPortName,
1396 String query = Queries.getQuery().deviceInternalLinkInsert().get();
1397 LOG.info("Running {} query ", query);
1398 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1399 for (int j = 0; j < parameters.length; j++) {
1400 stmt.setObject(j + 1, parameters[j]);
1403 stmt.clearParameters();
1404 } catch (SQLException e) {
1405 LOG.error(e.getMessage(), e);
1413 private void persistDevExternalLinks(String nodeId, Connection connection) {
1415 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1416 Optional<OrgOpenroadmDevice> deviceObject =
1417 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1418 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1420 if (deviceObject.get().getExternalLink() == null) {
1422 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1423 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1425 if (deviceObject.get().getExternalLink() == null) {
1426 LOG.info("External links not found for {}", nodeId);
1428 String startTimestamp = getCurrentTimestamp();
1429 for (int i = 0; i < deviceObject.get().getExternalLink().size(); i++) {
1430 ExternalLink externalLink = deviceObject.get().getExternalLink().get(i);
1431 String externalLinkName = externalLink.getExternalLinkName();
1432 String sourceNodeId = externalLink.getSource().getNodeId();
1433 String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
1434 String sourcePortName = externalLink.getSource().getPortName().toString();
1435 String destinationNodeId = externalLink.getDestination().getNodeId();
1436 String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
1437 String destinationPortName = externalLink.getDestination().getPortName().toString();
1439 Object[] parameters = {nodeId,
1442 sourceCircuitPackName,
1445 destinationCircuitPackName,
1446 destinationPortName,
1451 String query = Queries.getQuery().deviceExternalLinkInsert().get();
1452 LOG.info("Running {} query ", query);
1453 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1454 for (int j = 0; j < parameters.length; j++) {
1455 stmt.setObject(j + 1, parameters[j]);
1458 stmt.clearParameters();
1459 } catch (SQLException e) {
1460 LOG.error(e.getMessage(), e);
1467 private void persistDevPhysicalLinks(String nodeId, Connection connection) {
1469 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1470 Optional<OrgOpenroadmDevice> deviceObject =
1471 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1472 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1473 if (deviceObject.get().getPhysicalLink() == null) {
1475 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1476 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1478 if (deviceObject.get().getPhysicalLink() == null) {
1479 LOG.info("Physical links not found for {}", nodeId);
1482 String startTimestamp = getCurrentTimestamp();
1483 for (int i = 0; i < deviceObject.get().getPhysicalLink().size(); i++) {
1484 PhysicalLink physicalLink = deviceObject.get().getPhysicalLink().get(i);
1485 String physicalLinkName = physicalLink.getPhysicalLinkName();
1486 String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
1487 String sourcePortName = physicalLink.getSource().getPortName().toString();
1488 String destinationCircuitPackName = physicalLink.getDestination().getCircuitPackName();
1489 String destinationPortName = physicalLink.getDestination().getPortName().toString();
1491 Object[] parameters = {nodeId,
1493 sourceCircuitPackName,
1495 destinationCircuitPackName,
1496 destinationPortName,
1501 String query = Queries.getQuery().devicePhysicalLinkInsert().get();
1502 LOG.info("Running {} query ", query);
1503 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1504 for (int j = 0; j < parameters.length; j++) {
1505 stmt.setObject(j + 1, parameters[j]);
1508 stmt.clearParameters();
1509 } catch (SQLException e) {
1510 LOG.error(e.getMessage(), e);
1517 private void persistDevDegree(String nodeId, Connection connection) {
1519 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1520 Optional<OrgOpenroadmDevice> deviceObject =
1521 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1522 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1525 /*if (deviceObject.get().getDegree()==null){
1527 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1528 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1530 if (deviceObject.get().getDegree() == null) {
1531 LOG.warn("Degree info not found for {}", nodeId);
1534 String startTimestamp = getCurrentTimestamp();
1535 for (int i = 0; i < deviceObject.get().getDegree().size(); i++) {
1536 Degree degree = deviceObject.get().getDegree().get(i);
1537 String degreeNumber = degree.getDegreeNumber().toString();
1538 String maxWavelengths = degree.getMaxWavelengths().toString();
1539 String otdrPortCircuitPackName =
1540 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getCircuitPackName());
1541 String otdrPortPortName =
1542 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getPortName().toString());
1543 //String mcCapabilitiesSlotWidthGranularity = "";
1544 //String mcCapabilitiesCenterFreqGranularity = "";
1545 //String mcCapabilitiesMinSlots = "-1";
1546 //String mcCapabilitiesMaxSlots = "-1";
1547 persistDevDegreeCircuitPack(nodeId, degree, degreeNumber, connection);
1548 persistDevDegreeConnectionPort(nodeId, degree, degreeNumber, connection);
1550 Object[] parameters = {nodeId,
1553 otdrPortCircuitPackName,
1555 //mcCapabilitiesSlotWidthGranularity,
1556 //mcCapabilitiesCenterFreqGranularity,
1557 //mcCapabilitiesMinSlots,
1558 //mcCapabilitiesMaxSlots,
1564 String query = Queries.getQuery().deviceDegreeInsert().get();
1565 LOG.info("Running {} query ", query);
1566 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1567 for (int j = 0; j < parameters.length; j++) {
1568 stmt.setObject(j + 1, parameters[j]);
1571 stmt.clearParameters();
1572 } catch (SQLException e) {
1573 LOG.error(e.getMessage(), e);
1581 private void persistDevDegreeCircuitPack(String nodeId, Degree degree, String degreeNumber, Connection connection) {
1583 String startTimestamp = getCurrentTimestamp();
1584 for (int i = 0; i < degree.getCircuitPacks().size(); i++) {
1586 String circuitPackIndex = degree.getCircuitPacks().get(i).getIndex().toString();
1587 String circuitPackName = degree.getCircuitPacks().get(i).getCircuitPackName();
1589 Object[] parameters = {nodeId,
1597 String query = Queries.getQuery().deviceDegreeCircuitPackInsert().get();
1598 LOG.info("Running {} query ", query);
1599 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1600 for (int j = 0; j < parameters.length; j++) {
1601 stmt.setObject(j + 1, parameters[j]);
1604 stmt.clearParameters();
1605 } catch (SQLException e) {
1606 LOG.error(e.getMessage(), e);
1612 private void persistDevDegreeConnectionPort(String nodeId, Degree degree, String degreeNumber,
1613 Connection connection) {
1615 String startTimestamp = getCurrentTimestamp();
1616 for (int i = 0; i < degree.getConnectionPorts().size(); i++) {
1618 String connectionPortIndex = degree.getConnectionPorts().get(i).getIndex().toString();
1619 String circuitPackName = degree.getConnectionPorts().get(i).getCircuitPackName();
1620 String portName = degree.getConnectionPorts().get(i).getPortName().toString();
1622 Object[] parameters = {nodeId,
1624 connectionPortIndex,
1631 String query = Queries.getQuery().deviceDegreeConnectionPortInsert().get();
1632 LOG.info("Running {} query ", query);
1633 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1634 for (int j = 0; j < parameters.length; j++) {
1635 stmt.setObject(j + 1, parameters[j]);
1638 stmt.clearParameters();
1639 } catch (SQLException e) {
1640 LOG.error(e.getMessage(), e);
1647 private void persistDevSrg(String nodeId, Connection connection) {
1649 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1650 Optional<OrgOpenroadmDevice> deviceObject =
1651 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1652 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1654 if (deviceObject.get().getSharedRiskGroup() == null) {
1656 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1657 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1659 if (deviceObject.get().getSharedRiskGroup() == null) {
1660 LOG.info("no srg found for node {} ", nodeId);
1662 String startTimestamp = getCurrentTimestamp();
1663 for (int i = 0; i < deviceObject.get().getSharedRiskGroup().size(); i++) {
1664 SharedRiskGroup sharedRiskGroup = deviceObject.get().getSharedRiskGroup().get(i);
1665 //String currentProvisionedAddDropPorts = "-1";
1666 //String mcCapSlotWidthGranularity = "";
1667 //String mcCapCenterFreqGranularity = "";
1668 //String mcCapMinSlots = "-1";
1669 //String mcCapMaxSlots = "-1";
1670 String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
1671 String srgNumber = sharedRiskGroup.getSrgNumber().toString();
1672 String wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getName();
1673 persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
1675 Object[] parameters = {nodeId,
1677 //currentProvisionedAddDropPorts,
1680 wavelengthDuplicationEnu,
1681 //mcCapSlotWidthGranularity,
1682 //mcCapCenterFreqGranularity,
1690 String query = Queries.getQuery().deviceSharedRiskGroupInsert().get();
1691 LOG.info("Running {} query ", query);
1692 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1693 for (int j = 0; j < parameters.length; j++) {
1694 stmt.setObject(j + 1, parameters[j]);
1697 stmt.clearParameters();
1698 } catch (SQLException e) {
1699 LOG.error(e.getMessage(), e);
1707 private void persistDevSrgCircuitPacks(String nodeId, SharedRiskGroup sharedRiskGroup, String srgNumber,
1708 Connection connection) {
1710 String startTimestamp = getCurrentTimestamp();
1711 for (int i = 0; i < sharedRiskGroup.getCircuitPacks().size(); i++) {
1713 String circuitPackindex = sharedRiskGroup.getCircuitPacks().get(i).getIndex().toString();
1714 String circuitPackName = sharedRiskGroup.getCircuitPacks().get(i).getCircuitPackName();
1716 Object[] parameters = {nodeId,
1724 String query = Queries.getQuery().deviceSrgCircuitPackInsert().get();
1725 LOG.info("Running {} query ", query);
1726 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1727 for (int j = 0; j < parameters.length; j++) {
1728 stmt.setObject(j + 1, parameters[j]);
1731 stmt.clearParameters();
1732 } catch (SQLException e) {
1733 LOG.error(e.getMessage(), e);
1739 private void persistDevRoadmConnections(String nodeId, Connection connection) {
1741 //int opticalcontrolmodeEnu=-1;
1743 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1744 Optional<OrgOpenroadmDevice> deviceObject =
1745 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1746 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1748 if (deviceObject.get().getRoadmConnections() == null) {
1750 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1751 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1754 if (deviceObject.get().getRoadmConnections() != null) {
1755 String startTimestamp = getCurrentTimestamp();
1756 for (int i = 0; i < deviceObject.get().getRoadmConnections().size(); i++) {
1757 RoadmConnections roadmConnections = deviceObject.get().getRoadmConnections().get(i);
1758 String connectionNumber = roadmConnections.getConnectionNumber();
1759 //String connectionName = "";
1760 String wavelengthNumber = roadmConnections.getWavelengthNumber().toString();
1761 String opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getName();
1762 String targetOutputPower = roadmConnections.getTargetOutputPower().toString();
1763 String srcIf = roadmConnections.getSource().getSrcIf();
1764 String dstIf = roadmConnections.getDestination().getDstIf();
1766 Object[] parameters = {nodeId,
1771 opticalcontrolmodeEnu,
1779 String query = Queries.getQuery().deviceRoadmConnectionsInsert().get();
1780 LOG.info("Running {} query ", query);
1781 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1782 for (int j = 0; j < parameters.length; j++) {
1783 stmt.setObject(j + 1, parameters[j]);
1786 stmt.clearParameters();
1787 } catch (SQLException e) {
1788 LOG.error(e.getMessage(), e);
1793 LOG.info("ROADM Dev Connections not found!! for {}", nodeId);
1798 private void persistDevConnectionMap(String nodeId, Connection connection) {
1800 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1801 Optional<OrgOpenroadmDevice> deviceObject =
1802 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1803 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1805 String startTimestamp = getCurrentTimestamp();
1806 for (int i = 0; i < deviceObject.get().getConnectionMap().size(); i++) {
1807 ConnectionMap connectionMap = deviceObject.get().getConnectionMap().get(i);
1808 String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
1809 String sourceCircuitPackName = connectionMap.getSource().getCircuitPackName();
1810 String sourcePortName = connectionMap.getSource().getCircuitPackName();
1813 Object[] parameters = {nodeId,
1814 connectionMapNumber,
1815 sourceCircuitPackName,
1821 String query = Queries.getQuery().deviceConnectionMapInsert().get();
1822 LOG.info("Running {} query ", query);
1823 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1824 for (int j = 0; j < parameters.length; j++) {
1825 stmt.setObject(j + 1, parameters[j]);
1828 stmt.clearParameters();
1829 } catch (SQLException e) {
1830 LOG.error(e.getMessage(), e);
1836 private void persistDevWavelengthMap(String nodeId, Connection connection) {
1838 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1839 Optional<OrgOpenroadmDevice> deviceObject =
1840 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1841 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1843 String startTimestamp = getCurrentTimestamp();
1844 for (int i = 0; i < deviceObject.get().getWavelengthMap().getWavelengths().size(); i++) {
1845 Wavelengths wavelengths = deviceObject.get().getWavelengthMap().getWavelengths().get(i);
1846 String wavelengthNumber = wavelengths.getWavelengthNumber().toString();
1847 String centerFrequency = wavelengths.getCenterFrequency().toString();
1848 String wavelength = wavelengths.getWavelength().toString();
1851 Object[] parameters = {nodeId,
1859 String query = Queries.getQuery().deviceWavelengthInsert().get();
1860 LOG.info("Running {} query ", query);
1861 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1862 for (int j = 0; j < parameters.length; j++) {
1863 stmt.setObject(j + 1, parameters[j]);
1866 stmt.clearParameters();
1867 } catch (SQLException e) {
1868 LOG.error(e.getMessage(), e);
1875 private void persistDevInterfaceTcm(String nodeId, String interfaceName, OduBuilder oduBuilder,
1876 Connection connection) {
1878 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1881 tcm = oduBuilder.getTcm().get(i);
1883 Object[] parameters = prepareDevInterfaceTcmParameters(nodeId, interfaceName, tcm);
1885 String query = Queries.getQuery().deviceInterfacesInsert().get();
1886 LOG.info("Running {} query ", query);
1887 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1888 for (int j = 0; j < parameters.length; j++) {
1889 stmt.setObject(j + 1, parameters[j]);
1892 stmt.clearParameters();
1893 } catch (SQLException e) {
1894 LOG.error(e.getMessage(), e);
1899 private void persistDevInterfaceOtnOduTxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1900 Connection connection) {
1902 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1905 txMsi = oduBuilder.getOpu().getMsi().getTxMsi().get(i);
1907 Object[] parameters = prepareDevInterfaceOtnOduTxMsiParameters(nodeId, interfaceName, txMsi);
1909 String query = Queries.getQuery().deviceInterfaceOtnOduTxMsiInsert().get();
1910 LOG.info("Running {} query ", query);
1911 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1912 for (int j = 0; j < parameters.length; j++) {
1913 stmt.setObject(j + 1, parameters[j]);
1916 stmt.clearParameters();
1917 } catch (SQLException e) {
1918 LOG.error(e.getMessage(), e);
1924 private void persistDevInterfaceOtnOduRxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1925 Connection connection) {
1927 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1930 rxMsi = oduBuilder.getOpu().getMsi().getRxMsi().get(i);
1932 Object[] parameters = prepareDevInterfaceOtnOduRxMsiParameters(nodeId, interfaceName, rxMsi);
1934 String query = Queries.getQuery().deviceInterfaceOtnOduRxMsiInsert().get();
1935 LOG.info("Running {} query ", query);
1936 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1937 for (int j = 0; j < parameters.length; j++) {
1938 stmt.setObject(j + 1, parameters[j]);
1941 stmt.clearParameters();
1942 } catch (SQLException e) {
1943 LOG.error(e.getMessage(), e);
1949 private void persistDevInterfaceOtnOduExpMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1950 Connection connection) {
1952 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1955 expMsi = oduBuilder.getOpu().getMsi().getExpMsi().get(i);
1957 Object[] parameters = prepareDevInterfaceOtnOduExpMsiParameters(nodeId, interfaceName, expMsi);
1959 String query = Queries.getQuery().deviceInterfaceOtnOduExpMsiInsert().get();
1960 LOG.info("Running {} query ", query);
1961 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1962 for (int j = 0; j < parameters.length; j++) {
1963 stmt.setObject(j + 1, parameters[j]);
1966 stmt.clearParameters();
1967 } catch (SQLException e) {
1968 LOG.error(e.getMessage(), e);