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;
21 import java.util.Optional;
22 import java.util.concurrent.ExecutionException;
23 import javax.sql.DataSource;
24 import org.eclipse.jdt.annotation.NonNull;
25 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
26 import org.opendaylight.transportpce.common.Timeouts;
27 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
28 import org.opendaylight.transportpce.inventory.query.Queries;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.CpSlots;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.CpSlotsKey;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.PortsKey;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacksKey;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.ConnectionPorts;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.ConnectionPortsKey;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.external.links.ExternalLink;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.external.links.ExternalLinkKey;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.internal.links.InternalLink;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.internal.links.InternalLinkKey;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.ConnectionMap;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.ConnectionMapKey;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Degree;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.DegreeKey;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Info;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Protocols;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsKey;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroupKey;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.physical.links.PhysicalLink;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.physical.links.PhysicalLinkKey;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelf.Slots;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelf.SlotsKey;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelves.Shelves;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelves.ShelvesKey;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.Interface1;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.ethernet.container.EthernetBuilder;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.Protocols1;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.PortConfig;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.PortConfigKey;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.nbr.list.IfName;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.nbr.list.IfNameKey;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.och.container.OchBuilder;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.ots.container.OtsBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.attributes.Tcm;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.attributes.TcmKey;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.container.OduBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.ExpMsi;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.ExpMsiKey;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.RxMsi;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.RxMsiKey;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.TxMsi;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.TxMsiKey;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.otu.container.OtuBuilder;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.wavelength.map.rev161014.wavelength.map.g.Wavelengths;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.wavelength.map.rev161014.wavelength.map.g.WavelengthsKey;
81 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
82 import org.slf4j.Logger;
83 import org.slf4j.LoggerFactory;
85 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
86 value = "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING",
87 justification = "TODO review the SQL statement generation process")
88 public class INode121 {
90 private static final Logger LOG = LoggerFactory.getLogger(INode121.class);
92 private final DataSource dataSource;
93 private final DeviceTransactionManager deviceTransactionManager;
95 public INode121(DataSource dataSource, DeviceTransactionManager deviceTransactionManager) {
96 this.dataSource = dataSource;
97 this.deviceTransactionManager = deviceTransactionManager;
100 public boolean addNode(String deviceId) {
102 InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
103 Optional<Info> infoOpt =
104 deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, infoIID,
105 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
107 if (infoOpt.isPresent()) {
108 deviceInfo = infoOpt.get();
110 LOG.warn("Could not get device info from DataBroker");
113 boolean sqlResult = false;
114 String query = Queries.getQuery().deviceInfoInsert().get();
115 LOG.info("Running {} query ", query);
116 try (Connection connection = dataSource.getConnection();
117 PreparedStatement preparedStatement = connection.prepareStatement(query)) {
118 Object[] prepareParameters = prepareDeviceInfoParameters(deviceInfo);
119 for (int i = 0; i < prepareParameters.length; i++) {
120 LOG.debug("Parameter {} has value {}", i + 1, prepareParameters[i]);
121 preparedStatement.setObject(i + 1, prepareParameters[i]);
124 int executeUpdate = preparedStatement.executeUpdate();
125 LOG.info("{} entries were added", executeUpdate);
128 LOG.debug("iNode AddNode call complete");
129 getRoadmShelves(deviceId);
130 LOG.debug("iNode getRoadmShelves call complete");
131 getCircuitPacks(deviceId);
132 LOG.debug("iNode getCircuitPacks call complete");
134 LOG.debug("iNode persist interfaces call");
135 persistDevInterfaces(deviceId, connection);
136 LOG.debug("iNode persist interfaces call complete");
139 LOG.debug("iNode persist protocols call");
140 persistDevProtocols(deviceId, connection);
141 LOG.debug("iNode persist protocols call complete");
144 LOG.debug("iNode persist wavelength map call");
145 persistDevWavelengthMap(deviceId, connection);
146 LOG.debug("iNode persist wavelength map call complete");
148 LOG.debug("iNode persist internal links map call");
149 persistDevInternalLinks(deviceId, connection);
150 LOG.debug("iNode persist internal links map call complete");
152 LOG.debug("iNode persist Physical links map call");
153 persistDevPhysicalLinks(deviceId, connection);
154 LOG.debug("iNode persist Physical links map call complete");
156 LOG.debug("iNode persist External links map call");
157 persistDevExternalLinks(deviceId, connection);
158 LOG.debug("iNode persist External links map call complete");
160 LOG.debug("iNode persist degree map call");
161 persistDevDegree(deviceId, connection);
162 LOG.debug("iNode persist degree map call complete");
164 LOG.debug("iNode persist srg map call");
165 persistDevSrg(deviceId, connection);
166 LOG.debug("iNode persist srg map call complete");
168 LOG.debug("iNode persist Roadm Connections call");
169 persistDevRoadmConnections(deviceId, connection);
170 LOG.debug("iNode persist Roadm Connections call complete");
172 LOG.debug("iNode persist Connection Map call");
173 persistDevConnectionMap(deviceId, connection);
174 LOG.debug("iNode persist Connection Map call complete");
176 } catch (SQLException | InterruptedException | ExecutionException e) {
177 LOG.error("Something wrong when storing node into DB", e);
182 public boolean nodeExists(String nodeId) {
183 String selectTableSQL = "select count(*) node_exists from inv_dev_info where node_id = ?";
185 LOG.info("Checking if {} exists in DB", nodeId);
186 try (Connection connection = dataSource.getConnection();
187 PreparedStatement preparedStmt = connection.prepareStatement(selectTableSQL)) {
188 preparedStmt.setString(1, nodeId);
189 try (ResultSet rs = preparedStmt.executeQuery()) {
191 nodeExists = rs.getInt("node_exists");
192 LOG.debug("Found {} devices matching {}", nodeExists, nodeId);
195 } catch (SQLException e) {
196 LOG.error("Something wrong when fetching node in DB", e);
198 return nodeExists == 0 ? false : true;
201 public void getRoadmShelves(String nodeId) throws InterruptedException, ExecutionException {
202 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
203 Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
204 LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT,
205 Timeouts.DEVICE_READ_TIMEOUT_UNIT);
206 if (deviceObject.isPresent()) {
207 Map<ShelvesKey, Shelves> shelvesMap = deviceObject.get().nonnullShelves();
208 LOG.info("Shelves size {}", shelvesMap.size());
209 try (Connection connection = requireNonNull(dataSource.getConnection())) {
210 for (Map.Entry<ShelvesKey, Shelves> shelveEntry : shelvesMap.entrySet()) {
211 Shelves shelve = shelveEntry.getValue();
212 String shelfName = shelve.getShelfName();
213 LOG.info("Getting Shelve Details of {}", shelfName);
214 if (shelve.getSlots() != null) {
215 LOG.info("Slot Size {} ", shelve.getSlots().size());
216 persistShelveSlots(nodeId, shelve, connection);
218 LOG.info("No Slots for shelf {}", shelfName);
221 persistShelves(nodeId, connection, shelve);
223 } catch (SQLException e1) {
224 LOG.error("Something wrong when fetching ROADM shelves in DB", e1);
229 public void getCircuitPacks(String nodeId) throws InterruptedException, ExecutionException {
230 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
231 Optional<OrgOpenroadmDevice> deviceObject =
232 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
233 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
234 if (!deviceObject.isPresent()) {
235 LOG.warn("Device object {} was not found", nodeId);
238 Map<CircuitPacksKey, CircuitPacks> circuitPacksMap = deviceObject.get().nonnullCircuitPacks();
239 LOG.info("Circuit pack size {}", circuitPacksMap.size());
241 try (Connection connection = requireNonNull(dataSource.getConnection())) {
242 for (Map.Entry<CircuitPacksKey, CircuitPacks> circuitPackEntry : circuitPacksMap.entrySet()) {
243 CircuitPacks cp = circuitPackEntry.getValue();
245 if (cp.getCpSlots() != null) {
246 persistCircuitPacksSlots(nodeId, cp, connection);
248 LOG.info("Everything {}", cp);
249 LOG.info("CP is {}", cp);
251 //persistPorts(cp, connection);
252 if (cp.getPorts() != null) {
253 persistCPPorts(nodeId, connection, cp);
255 persistCircuitPacks(nodeId, connection, cp);
257 } catch (SQLException e1) {
258 LOG.error("Something wrong when fetching Circuit Packs in DB", e1);
262 private void persistCircuitPacks(String nodeId, Connection connection, CircuitPacks cp) {
263 Object[] parameters = prepareCircuitPacksParameters(nodeId, cp);
264 String query = Queries.getQuery().deviceCircuitPackInsert().get();
265 LOG.info("Running {} query ", query);
266 try (PreparedStatement stmt = connection.prepareStatement(query)) {
267 for (int j = 0; j < parameters.length; j++) {
268 stmt.setObject(j + 1, parameters[j]);
271 stmt.clearParameters();
272 } catch (SQLException e) {
273 LOG.error("Something wrong when storing Circuit Packs in DB", e);
277 private void persistShelves(String nodeId, Connection connection, Shelves shelve) {
278 Object[] shelvesParameter = prepareShelvesParameters(nodeId, shelve);
279 String query = Queries.getQuery().deviceShelfInsert().get();
280 LOG.info("Running {} query ", query);
281 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
282 for (int j = 0; j < shelvesParameter.length; j++) {
283 preparedStmt.setObject(j + 1, shelvesParameter[j]);
285 preparedStmt.execute();
286 preparedStmt.clearParameters();
287 } catch (SQLException e) {
288 LOG.error("Something wrong when storing shelves in DB", e);
292 private void persistShelveSlots(String nodeId, Shelves shelves, Connection connection) {
293 String startTimetampStr = getCurrentTimestamp();
294 Map<SlotsKey, Slots> slotsMap = shelves.nonnullSlots();
295 for (Map.Entry<SlotsKey, Slots> slotEntry : slotsMap.entrySet()) {
296 Slots slot = slotEntry.getValue();
297 LOG.info("Getting Slot Details of {}", slot.getSlotName());
298 Object[] parameters = new Object[]{nodeId,
299 shelves.getShelfName(),
302 slot.getProvisionedCircuitPack(),
306 String query = Queries.getQuery().deviceShelfSlotInsert().get();
307 LOG.info("Running {} query ", query);
308 try (PreparedStatement stmt = connection.prepareStatement(query)) {
309 for (int j = 0; j < parameters.length; j++) {
310 stmt.setObject(j + 1, parameters[j]);
313 stmt.clearParameters();
314 } catch (SQLException e) {
315 LOG.error("Something wrong when storing shelves slots in DB", e);
321 private void persistCircuitPacksSlots(String nodeId, CircuitPacks circuitPacks, Connection connection) {
322 String startTimetampStr = getCurrentTimestamp();
323 Map<CpSlotsKey, CpSlots> cpSlotsMap = circuitPacks.nonnullCpSlots();
324 for (Map.Entry<CpSlotsKey, CpSlots> cpSlotEntry: cpSlotsMap.entrySet()) {
325 CpSlots cpSlot = cpSlotEntry.getValue();
327 Object[] parameters = new Object[]{nodeId,
328 circuitPacks.getCircuitPackName(),
329 cpSlot.getSlotName(),
331 cpSlot.getProvisionedCircuitPack(),
336 String query = Queries.getQuery().deviceCPSlotInsert().get();
337 LOG.info("Running {} query ", query);
338 try (PreparedStatement stmt = connection.prepareStatement(query)) {
339 for (int j = 0; j < parameters.length; j++) {
340 stmt.setObject(j + 1, parameters[j]);
343 stmt.clearParameters();
344 } catch (SQLException e) {
345 LOG.error("Something wrong when storing Cirtcuits Packs slots in DB", e);
351 * Prepares parameters for device insert query.
353 * @param deviceInfo device information
354 * @return Object an object
356 private static Object[] prepareDeviceInfoParameters(Info deviceInfo) {
357 String startTimetampStr = getCurrentTimestamp();
359 String nodeId = prepareDashString(deviceInfo.getNodeId());
360 Long nodeNumber = deviceInfo.getNodeNumber().toJava();
361 String nodeTypeEnu = deviceInfo.getNodeType().getName();
362 String clli = prepareDashString(deviceInfo.getClli());
363 String vendor = prepareDashString(deviceInfo.getVendor());
364 String model = prepareDashString(deviceInfo.getModel());
365 String serialId = prepareDashString(deviceInfo.getSerialId());
366 String ipAddress = prepareDashString(deviceInfo.getIpAddress().getIpv4Address().getValue());
367 String prefixLength = prepareDashString(deviceInfo.getPrefixLength());
368 String defaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
369 String sourceEnum = deviceInfo.getSource().getName();
370 String currentIpAddress = prepareDashString(deviceInfo.getCurrentIpAddress().getIpv4Address().getValue());
371 String currentPrefixLength = prepareDashString(deviceInfo.getCurrentPrefixLength());
372 String currentDefaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
373 String macAddress = prepareDashString(deviceInfo.getMacAddress().getValue());
374 String softwareVersion = prepareDashString(deviceInfo.getSoftwareVersion());
375 //String openroadmVersion = "1.2.1";
376 String template = prepareDashString(deviceInfo.getTemplate());
377 String currentDatetime = prepareDashString(deviceInfo.getCurrentDatetime().getValue());
378 String geoLatitude = (deviceInfo.getGeoLocation() != null
379 ? prepareDashString(deviceInfo.getGeoLocation().getLatitude()) : "");
380 String geoLongitude = (deviceInfo.getGeoLocation() != null
381 ? prepareDashString(deviceInfo.getGeoLocation().getLongitude()) : "");
382 String maxDegrees = (deviceInfo.getMaxDegrees() == null ? "-1" : prepareDashString(deviceInfo.getMaxDegrees()));
383 String maxSrgs = (deviceInfo.getMaxSrgs() == null ? "-1" : prepareDashString(deviceInfo.getMaxSrgs()));
384 String swVersion = prepareDashString(deviceInfo.getSoftwareVersion()); //sw_version
385 String swValidationTimer = prepareDashString(""); //sw_validation_timer
386 String activationDateTime = prepareDashString(""); //activation_date_time
387 //Integer maxNumBin15minHistoricalPm = null;
388 //Integer maxNumBin24hourHistoricalPm = null;
389 /*jsonDevInfo = JsonStringBuilder.getDevInfoJson().replace("$$NODE-ID$$",nodeId)
390 .replace("$$NODE-NUMBER$$", nodeNumber)
391 .replace("$$NODE-TYPE$$",nodeType)
392 .replace("$$CLLI$$",clli)
393 .replace("$$VENDOR$$",vendor)
394 .replace("$$MODEL$$",model)
395 .replace("$$SERIAL-ID$$",serialId)
396 .replace("$$IPADDRESS$$",ipAddress)
397 .replace("$$PREFIX-LENGTH$$",prefixLength)
398 .replace("$$DEFAULTGATEWAY$$",defaultGateway)
399 .replace("$$SOURCE$$",String.valueOf(source))
400 .replace("$$CURRENT-IPADDRESS$$",currentIpAddress)
401 .replace("$$CURRENT-PREFIX-LENGTH$$",currentPrefixLength)
402 .replace("$$CURRENT-DEFAULTGATEWAY$$",currentDefailtGateway)
403 .replace("$$MACADDRESS$$",macAddress)
404 .replace("$$SOFTWAREVERSION$$",softwareVersion)
405 .replace("$$OPENROADM-VERSION$$",openroadmVersion)
406 .replace("$$TEMPLATE$$",template)
407 .replace("$$CURRENT-DATETIME$$",currentDatetime)
408 .replace("$$LATITUDE$$",latitude)
409 .replace("$$LONGITUDE$$",longitude)
410 .replace("$$MAX-DEGREES$$",maxDegrees)
411 .replace("$$MAX-SRGS$$",maxSrgs)
412 .replace("$$MAX-NUM-BIN-15MIN-HISTORICAL-PM$$",prepareDashString(""))
413 .replace("$$MAX-NUM-BIN-24HOUR-HISTORICAL-PM$$",prepareDashString(""))
414 .replace("$$SW-VERSION$$",swVersion)
415 .replace("$$SW-VALIDATION-TIMER$$",swValidationTimer)
416 .replace("$$ACTIVATION-DATE-TIME$$",activationDateTime);*/
433 currentDefaultGateway,
444 //maxNumBin15minHistoricalPm,
445 //maxNumBin24hourHistoricalPm,
456 private static Object[] prepareShelvesParameters(String nodeId, Shelves shelve) {
457 String startTimestamp = getCurrentTimestamp();
459 return new Object[]{nodeId,
460 shelve.getShelfName(),
461 shelve.getShelfType(),
463 shelve.getShelfPosition(),
464 (shelve.getAdministrativeState() == null ? null : shelve.getAdministrativeState().getIntValue()),
467 shelve.getSerialId(),
469 shelve.getProductCode(),
470 (shelve.getManufactureDate() == null ? null : shelve.getManufactureDate().getValue()),
472 shelve.getHardwareVersion(),
473 (shelve.getOperationalState() == null ? null : shelve.getOperationalState().getIntValue()),
474 (shelve.getEquipmentState() == null ? null : shelve.getEquipmentState().getIntValue()),
475 (shelve.getDueDate() == null ? null : shelve.getDueDate().getValue()),
481 private static Object[] prepareCPPortsParameters(String nodeId, CircuitPacks circuitPacks, Ports cpPort) {
483 String circuitPackName = circuitPacks.getCircuitPackName();
484 String portName = cpPort.getPortName();
485 String portType = cpPort.getPortType();
486 String portQualEnu = String.valueOf((cpPort.getPortQual() == null ? "-1" : cpPort.getPortQual().getName()));
487 String portWavelengthTypeEnu = "-1"; //cpPort.getPortWavelengthType().getIntValue(); /* Check error*/
488 String portDirectionEnu = String.valueOf((cpPort.getPortDirection() == null ? "" :
489 cpPort.getPortDirection().getName()));
490 String label = cpPort.getLabel();
491 String circuitId = cpPort.getCircuitId();
492 String administrativeStateEnu = (cpPort.getAdministrativeState() == null ? "" :
493 cpPort.getAdministrativeState().getName());
494 String operationalStateEnu =
495 (cpPort.getOperationalState() == null ? "" : cpPort.getOperationalState().getName());
496 String logicalConnectionPoint = cpPort.getLogicalConnectionPoint();
497 String parentPortCircuitPackName = (cpPort.getPartnerPort() == null ? "" :
498 (cpPort.getPartnerPort().getCircuitPackName() == null ? "" : cpPort.getPartnerPort().getCircuitPackName()));
499 String partnerPortPortName = (cpPort.getPartnerPort() == null ? "" :
500 (cpPort.getPartnerPort().getPortName() == null ? "" : cpPort.getPartnerPort().getPortName().toString()));
501 String partnerPortCircuitPackName = (cpPort.getParentPort() == null ? "" :
502 (cpPort.getParentPort().getCircuitPackName() == null ? "" : cpPort.getParentPort().getCircuitPackName()));
503 String parentPortPortName = (cpPort.getParentPort() == null ? "" :
504 (cpPort.getParentPort().getPortName() == null ? "" : cpPort.getParentPort().toString()));
505 String roadmPortPortPowerCapabilityMinRx = (cpPort.getRoadmPort() == null ? "" :
506 (cpPort.getRoadmPort().getPortPowerCapabilityMinRx() == null ? "" :
507 cpPort.getRoadmPort().getPortPowerCapabilityMinRx().toString()));
508 String roadmPortPortPowerCapabilityMinTx = (cpPort.getRoadmPort() == null ? "" :
509 (cpPort.getRoadmPort().getPortPowerCapabilityMinTx() == null ? "" :
510 cpPort.getRoadmPort().getPortPowerCapabilityMinTx().toString()));
511 String roadmPortPortPowerCapabilityMaxRx = (cpPort.getRoadmPort() == null ? "" :
512 (cpPort.getRoadmPort().getPortPowerCapabilityMaxRx() == null ? "" :
513 cpPort.getRoadmPort().getPortPowerCapabilityMaxRx().toString()));
514 String roadmPortPortPowerCapabilityMaxTx = (cpPort.getRoadmPort() == null ? "" :
515 (cpPort.getRoadmPort().getPortPowerCapabilityMaxTx() == null ? "" :
516 cpPort.getRoadmPort().getPortPowerCapabilityMaxTx().toString()));
517 //String roadmPortCapableWavelengths = "";
518 //String roadmPortAvailableWavelengths = "";
519 //String roadmPortUsedWavelengths = "";
520 String transponderPortPortPowerCapabilityMinRx = (cpPort.getTransponderPort() == null ? "" :
521 (cpPort.getTransponderPort().getPortPowerCapabilityMinRx() == null ? "" :
522 cpPort.getTransponderPort().getPortPowerCapabilityMinRx().toString()));
523 String transponderPortPortPowerCapabilityMinTx = (cpPort.getTransponderPort() == null ? "" :
524 (cpPort.getTransponderPort().getPortPowerCapabilityMinTx() == null ? "" :
525 cpPort.getTransponderPort().getPortPowerCapabilityMinTx().toString()));
526 String transponderPortPortPowerCapabilityMaxRx = (cpPort.getTransponderPort() == null ? "" :
527 (cpPort.getTransponderPort().getPortPowerCapabilityMaxRx() == null ? "" :
528 cpPort.getTransponderPort().getPortPowerCapabilityMaxRx().toString()));
529 String transponderPortPortPowerCapabilityMaxTx = (cpPort.getTransponderPort() == null ? "" :
530 (cpPort.getTransponderPort().getPortPowerCapabilityMaxTx() == null ? "" :
531 cpPort.getTransponderPort().getPortPowerCapabilityMaxTx().toString()));
532 //String transponderPortCapableWavelengths = "";
533 String otdrPortLaunchCableLength = (cpPort.getOtdrPort() == null ? "" :
534 (cpPort.getOtdrPort().getLaunchCableLength() == null ? "" :
535 cpPort.getOtdrPort().getLaunchCableLength().toString()));
536 String otdrPortPortDirection = (cpPort.getOtdrPort() == null ? "-1" :
537 (cpPort.getOtdrPort().getPortDirection() == null ? "-1" :
538 Integer.toString(cpPort.getOtdrPort().getPortDirection().getIntValue())));
539 //String ilaPortPortPowerCapabilityMixRx = "";
540 //String ilaPortPortPowerCapabilityMixTx = "";
541 //String ilaPortPortPowerCapabilityMaxRx = "";
542 //String ilaPortPortPowerCapabilityMaxTx = "";
544 String startTimestamp = getCurrentTimestamp();
546 return new Object[]{nodeId,
551 portWavelengthTypeEnu,
555 administrativeStateEnu,
557 logicalConnectionPoint,
558 partnerPortCircuitPackName,
560 parentPortCircuitPackName,
562 roadmPortPortPowerCapabilityMinRx,
563 roadmPortPortPowerCapabilityMinTx,
564 roadmPortPortPowerCapabilityMaxRx,
565 roadmPortPortPowerCapabilityMaxTx,
566 //roadmPortCapableWavelengths,
567 //roadmPortAvailableWavelengths,
568 //roadmPortUsedWavelengths,
570 transponderPortPortPowerCapabilityMinRx,
571 transponderPortPortPowerCapabilityMinTx,
572 transponderPortPortPowerCapabilityMaxRx,
573 transponderPortPortPowerCapabilityMaxTx,
574 //transponderPortCapableWavelengths,
576 otdrPortLaunchCableLength,
577 otdrPortPortDirection,
578 //ilaPortPortPowerCapabilityMixRx,
579 //ilaPortPortPowerCapabilityMixTx,
580 //ilaPortPortPowerCapabilityMaxRx,
581 //ilaPortPortPowerCapabilityMaxTx,
589 private static Object[] prepareCircuitPacksParameters(String nodeId, CircuitPacks cpack) {
590 String startTimestamp = getCurrentTimestamp();
591 return new Object[]{nodeId,
592 cpack.getCircuitPackName(),
593 cpack.getCircuitPackType(),
594 cpack.getCircuitPackProductCode(),
595 (cpack.getAdministrativeState() == null ? "" : cpack.getAdministrativeState().getIntValue()),
600 cpack.getProductCode(),
601 (cpack.getManufactureDate() == null ? "" : cpack.getManufactureDate().getValue()),
603 cpack.getHardwareVersion(),
604 (cpack.getOperationalState() == null ? -1 : cpack.getOperationalState().getIntValue()),
605 cpack.getCircuitPackCategory().getType().getIntValue(),
606 cpack.getCircuitPackCategory().getExtension(),
607 (cpack.getEquipmentState() == null ? -1 : cpack.getEquipmentState().getIntValue()),
608 cpack.getCircuitPackMode(),
612 prepareEmptyString(cpack.getDueDate()),
613 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
614 ((cpack.getParentCircuitPack().getCircuitPackName() == null) ? "" :
615 cpack.getParentCircuitPack().getCircuitPackName())
617 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
618 ((cpack.getParentCircuitPack().getCpSlotName() == null) ? "" :
619 cpack.getParentCircuitPack().getCpSlotName())
626 private void persistCPPorts(String nodeId, Connection connection, CircuitPacks circuitPacks) {
628 Map<PortsKey, Ports> nonnullPorts = circuitPacks.nonnullPorts();
629 for (Map.Entry<PortsKey, Ports> entry : nonnullPorts.entrySet()) {
630 Object[] cpPortsParameters = prepareCPPortsParameters(nodeId, circuitPacks, entry.getValue());
631 String query = Queries.getQuery().deviceCPPortInsert().get();
632 LOG.info("Running {} query ", query);
633 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
634 for (int j = 0; j < cpPortsParameters.length; j++) {
635 preparedStmt.setObject(j + 1, cpPortsParameters[j]);
637 preparedStmt.execute();
638 preparedStmt.clearParameters();
639 } catch (SQLException e) {
640 LOG.error("Something wrong when storing Cirtcuits Packs Ports in DB", e);
646 private Object[] prepareDevInterfaceParameters(String nodeId, Interface deviceInterface, Connection connection) {
648 String ethernetDuplexEnu = "";
649 String ethernetAutoNegotiationEnu = "";
650 String maintTestsignalTestpatternEnu = "";
651 String maintTestsignalTypeEnu = "";
652 String otuFecEnu = "";
653 String otuMaintTypeEnu = "";
654 //String otsFiberTypeEnu = "";
655 String ethernetSpeed = "-1";
656 String ethernetFec = "";
657 String ethernetMtu = "-1";
658 String ethernetCurrSpeed = "";
659 String ethernetCurrDuplex = "-1";
660 //String mciMcttpMinFreq = "";
661 //String mciMcttpMaxFreq = "";
662 //String mciMcttpCenterFreq = "";
663 //String mciMcttpSlotWidth = "";
664 //String mciNmcCtpFrequency = "";
665 //String mciNmcCtpWidth = "";
667 //String ochFrequency = "";
668 //String ochWidth = "";
669 String ochWavelengthNumber = "";
670 String ochModulationFormat = "";
671 String ochTransmitPower = "";
672 String otsSpanLossReceive = "";
673 String otsSpanLossTransmit = "";
674 //String otsIngressSpanLossAgingMargin = "";
675 //String otsEolMaxLoadPin = "";
677 //String oduFunction = "";
678 String oduMonitoringMode = "";
679 //String oduNoOamFunction = "";
680 String oduProactiveDelayMeasurementEnabled = "";
681 //String oduPoaTribPortNumber = "-1";
682 //String oduTxSapi = "";
683 //String oduTxDapi = "";
684 //String oduTxOperator = "";
685 //String oduAcceptedSapi = "";
686 //String oduAcceptedDapi = "";
687 //String oduAcceptedOperator = "";
688 //String oduExpectedSapi = "";
689 //String oduExpectedDapi = "";
690 //String oduTimActEnabled = "";
691 //String oduTimDetectMode = "";
692 //String oduDegmIntervals = "-1";
693 //String oduDegthrPercentage = "-1";
694 String opuPayloadType = "";
695 String opuRxPayloadType = "";
696 String opuExpPayloadType = "";
697 String opuPayloadInterface = "";
698 String maintTestsignalEnabled = "";
699 String maintTestsignalBiterrors = "-1";
700 String maintTestsignalBiterrorsterminal = "-1";
701 String maintTestsignalSyncseconds = "-1";
702 String maintTestsignalSyncsecondsterminal = "-1";
704 //String otuTxSapi = "";
705 //String otuTxDapi = "";
706 //String otuTxOperator = "";
707 //String otuAcceptedSapi = "";
708 //String otuAcceptedDapi = "";
709 //String otuAcceptedOperator = "";
710 //String otuExpectedSapi = "";
711 //String otuExpectedDapi = "";
712 //String otuTimActEnabled = "";
713 //String otuTimDetectMode = "";
714 //String otuDegmIntervals = "-1";
715 //String otuDegthrPercentage = "-1";
716 String otuMaintLoopbackEnabled = "";
717 //String mtOtuRate = "";
718 //String mtOtuFec = "";
719 //String mtOtuMaintLoopback = "";
720 //String mtOtuEnabled = "";
721 //String mtOtuType = "";
723 String name = deviceInterface.getName();
724 String description = deviceInterface.getDescription();
725 String type = deviceInterface.getType().getTypeName();
726 String administrativeStateEnu = deviceInterface.getAdministrativeState().getName();
727 int operationalState = deviceInterface.getOperationalState().getIntValue();
728 String circuitId = deviceInterface.getCircuitId();
729 String supportingInterface = deviceInterface.getSupportingInterface();
730 String supportingCircuitPackName = deviceInterface.getSupportingCircuitPackName();
731 String supportingPort = deviceInterface.getSupportingPort().toString();
733 switch (deviceInterface.getType().toString()) {
736 //EthernetBuilder ethIfBuilder = new EthernetBuilder();
737 EthernetBuilder ethIfBuilder = new EthernetBuilder(deviceInterface.augmentation(Interface1.class)
739 ethernetSpeed = (ethIfBuilder.getSpeed() == null ? "-1" :
740 Integer.toString(ethIfBuilder.getSpeed().intValue()));
741 ethernetFec = ethIfBuilder.getFec().getName();
742 ethernetDuplexEnu = (ethIfBuilder.getDuplex() == null ? "" : ethIfBuilder.getDuplex().getName());
743 ethernetMtu = ethIfBuilder.getMtu().toString();
744 ethernetAutoNegotiationEnu = ethIfBuilder.getAutoNegotiation().getName();
745 ethernetCurrSpeed = ethIfBuilder.getCurrSpeed();
746 ethernetCurrDuplex = ethIfBuilder.getCurrDuplex();
750 OchBuilder ochIfBuilder = new OchBuilder(deviceInterface.augmentation(
751 org.opendaylight.yang.gen.v1
752 .http.org.openroadm.optical.channel.interfaces.rev161014.Interface1.class)
754 ochRate = ochIfBuilder.getRate().getName();
755 ochWavelengthNumber = ochIfBuilder.getWavelengthNumber().toString();
756 ochModulationFormat = ochIfBuilder.getModulationFormat().getName();
757 ochTransmitPower = ochIfBuilder.getTransmitPower().toString();
761 OtsBuilder otsIfBuilder = new OtsBuilder(deviceInterface.augmentation(
762 org.opendaylight.yang.gen.v1
763 .http.org.openroadm.optical.transport.interfaces.rev161014.Interface1.class)
765 //otsFiberTypeEnu = String.valueOf(otsIfBuilder.getFiberType().getIntValue());
766 otsSpanLossReceive = otsIfBuilder.getSpanLossReceive().toString();
767 otsSpanLossTransmit = otsIfBuilder.getSpanLossTransmit().toString();
771 OduBuilder oduIfBuilder = new OduBuilder(deviceInterface.augmentation(
772 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1.class)
774 oduRate = String.valueOf(oduIfBuilder.getRate());
775 oduMonitoringMode = oduIfBuilder.getMonitoringMode().getName();
776 oduProactiveDelayMeasurementEnabled = oduIfBuilder.isProactiveDelayMeasurementEnabled().toString();
778 persistDevInterfaceTcm(nodeId, name, oduIfBuilder, connection);
779 persistDevInterfaceOtnOduTxMsi(nodeId, name, oduIfBuilder, connection);
780 persistDevInterfaceOtnOduRxMsi(nodeId, name, oduIfBuilder, connection);
781 persistDevInterfaceOtnOduExpMsi(nodeId, name, oduIfBuilder, connection);
783 opuPayloadType = oduIfBuilder.getOpu().getPayloadType();
784 opuRxPayloadType = oduIfBuilder.getOpu().getRxPayloadType();
785 opuExpPayloadType = oduIfBuilder.getOpu().getExpPayloadType();
786 opuPayloadInterface = oduIfBuilder.getOpu().getPayloadInterface();
787 /*persistDevInterfaceOtnOduTxMsi(nodeId,name,oduIfBuilder,connection);
788 persistDevInterfaceOtnOduRxMsi(nodeId,name,oduIfBuilder,connection);
789 persistDevInterfaceOtnOduExpMsi(nodeId,name,oduIfBuilder,connection); */
790 maintTestsignalEnabled = oduIfBuilder.getMaintTestsignal().isEnabled().toString();
791 maintTestsignalTestpatternEnu = oduIfBuilder.getMaintTestsignal().getTestPattern().getName();
792 maintTestsignalTypeEnu = oduIfBuilder.getMaintTestsignal().getType().getName();
793 maintTestsignalBiterrors = Integer.toString(
794 oduIfBuilder.getMaintTestsignal().getBitErrors().intValue());
795 maintTestsignalBiterrorsterminal = oduIfBuilder.getMaintTestsignal().getBitErrorsTerminal().toString();
796 maintTestsignalSyncseconds = oduIfBuilder.getMaintTestsignal().getSyncSeconds();
797 maintTestsignalSyncsecondsterminal = oduIfBuilder.getMaintTestsignal().getSyncSecondsTerminal();
801 OtuBuilder otuIfBuilder =
802 new OtuBuilder(deviceInterface.augmentation(
803 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1.class)
805 otuRate = otuIfBuilder.getRate().getName();
806 otuFecEnu = otuIfBuilder.getFec().getName();
807 otuMaintLoopbackEnabled = otuIfBuilder.getMaintLoopback().isEnabled().toString();
808 otuMaintTypeEnu = otuIfBuilder.getMaintLoopback().getType().getName();
812 LOG.error("could not get interface type");
816 String startTimestamp = getCurrentTimestamp();
818 return new Object[]{nodeId,
822 administrativeStateEnu,
823 Integer.toString(operationalState),
826 supportingCircuitPackName,
832 ethernetAutoNegotiationEnu,
837 //mciMcttpCenterFreq,
839 //mciNmcCtpFrequency,
841 "", "", "", "", "", "",
852 //otsIngressSpanLossAgingMargin,
861 oduProactiveDelayMeasurementEnabled,
862 //oduPoaTribPortNumber,
868 //oduAcceptedOperator,
874 //oduDegthrPercentage,
875 "-1", "", "", "", "", "","", "", "", "", "", "-1", "-1",
880 maintTestsignalEnabled,
881 maintTestsignalTestpatternEnu,
882 maintTestsignalTypeEnu,
883 maintTestsignalBiterrors,
884 maintTestsignalBiterrorsterminal,
885 maintTestsignalSyncseconds,
886 maintTestsignalSyncsecondsterminal,
894 //otuAcceptedOperator,
900 //otuDegthrPercentage,
901 "", "", "", "", "", "","", "", "", "", "-1", "-1",
902 otuMaintLoopbackEnabled,
906 //mtOtuMaintLoopback,
916 private static Object[] prepareDevInterfaceTcmParameters(String nodeId, String interfaceName, Tcm tcm) {
918 String layer = tcm.getLayer().toString();
919 String monitoringModeEnu = tcm.getMonitoringMode().getName();
920 String ltcActEnabled = tcm.isLtcActEnabled().toString();
921 String proactiveDelayMeasurementEnabled = tcm.isProactiveDelayMeasurementEnabled().toString();
922 //String tcmDirectionEnu = "";
923 //String timDetectModeEnu = "";
924 //String txSapi = "";
925 //String txDapi = "";
926 //String txOperator = "";
927 //String acceptedSapi = "";
928 //String acceptedDapi = "";
929 //String acceptedOperator = "";
930 //String expectedSapi = "";
931 //String expectedDapi = "";
932 //String timActEnabled = "";
933 //String degmIntervals = "";
934 //String degthrPercentage = "";
935 String startTimestamp = getCurrentTimestamp();
937 return new Object[]{nodeId,
942 proactiveDelayMeasurementEnabled,
956 "", "", "", "", "", "", "", "", "", "", "", "", "",
962 private static Object[] prepareDevInterfaceOtnOduTxMsiParameters(String nodeId, String interfaceName, TxMsi txMsi) {
964 String tribSlot = txMsi.getTribSlot().toString();
965 String odtuType = txMsi.getOdtuType().getTypeName();
966 String tribPort = txMsi.getTribPort().toString();
967 String tribPortPayload = txMsi.getTribPortPayload();
969 String startTimestamp = getCurrentTimestamp();
971 return new Object[]{nodeId,
983 private static Object[] prepareDevInterfaceOtnOduRxMsiParameters(String nodeId, String interfaceName, RxMsi rxMsi) {
985 String tribSlot = rxMsi.getTribSlot().toString();
986 String odtuType = rxMsi.getOdtuType().getTypeName();
987 String tribPort = rxMsi.getTribPort().toString();
988 String tribPortPayload = rxMsi.getTribPortPayload();
990 String startTimestamp = getCurrentTimestamp();
992 return new Object[]{nodeId,
1005 private static Object[] prepareDevInterfaceOtnOduExpMsiParameters(String nodeId, String interfaceName,
1008 String tribSlot = expMsi.getTribSlot().toString();
1009 String odtuType = expMsi.getOdtuType().getTypeName();
1010 String tribPort = expMsi.getTribPort().toString();
1011 String tribPortPayload = expMsi.getTribPortPayload();
1013 String startTimestamp = getCurrentTimestamp();
1015 return new Object[]{nodeId,
1027 private void persistDevInterfaces(String nodeId, Connection connection) {
1029 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1030 Optional<OrgOpenroadmDevice> deviceObject =
1031 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1032 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1033 if (deviceObject.isPresent()) {
1034 Map<InterfaceKey, Interface> interfaceMap = deviceObject.get().nonnullInterface();
1035 for (Map.Entry<InterfaceKey, Interface> interfaceEntrySet : interfaceMap.entrySet()) {
1036 Interface deviceInterface = interfaceEntrySet.getValue();
1037 Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
1039 String query = Queries.getQuery().deviceInterfacesInsert().get();
1040 LOG.info("Running {} query ", query);
1041 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1042 for (int j = 0; j < parameters.length; j++) {
1043 stmt.setObject(j + 1, parameters[j]);
1046 stmt.clearParameters();
1047 } catch (SQLException e) {
1048 LOG.error("Something wrong when storing devices interfaces in DB", e);
1054 private void persistDevProtocols(String nodeId, Connection connection) {
1056 InstanceIdentifier<Protocols> protocolsIID =
1057 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1058 Optional<Protocols> protocolObject =
1059 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1060 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1061 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1062 LOG.error("LLDP subtree is missing");
1065 String adminstatusEnu = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1066 .getAdminStatus().getName();
1067 String msgTxtInterval = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1068 .getMsgTxInterval().toString();
1069 String mxgTxHoldMultiplier = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1070 .getMsgTxHoldMultiplier().toString();
1071 String startTimestamp = getCurrentTimestamp();
1072 persistDevProtocolLldpPortConfig(nodeId, connection);
1073 persistDevProtocolLldpNbrList(nodeId, connection);
1075 Object[] parameters = {nodeId,
1078 mxgTxHoldMultiplier,
1083 String query = Queries.getQuery().deviceProtocolInsert().get();
1084 LOG.info("Running {} query ", query);
1085 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1086 for (int j = 0; j < parameters.length; j++) {
1087 stmt.setObject(j + 1, parameters[j]);
1090 stmt.clearParameters();
1091 } catch (SQLException e) {
1092 LOG.error("Something wrong when storing devices protocols in DB", e);
1098 private void persistDevProtocolLldpPortConfig(String nodeId, Connection connection) {
1100 InstanceIdentifier<Protocols> protocolsIID =
1101 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1102 Optional<Protocols> protocolObject =
1103 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1104 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1105 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1106 LOG.error("LLDP subtree is missing");
1110 String startTimestamp = getCurrentTimestamp();
1112 Map<PortConfigKey, PortConfig> portConfigMap = protocolObject.get()
1113 .augmentation(Protocols1.class).getLldp().nonnullPortConfig();
1114 for (Map.Entry<PortConfigKey, PortConfig> entry : portConfigMap.entrySet()) {
1115 PortConfig portConfig = entry.getValue();
1116 String ifName = portConfig.getIfName();
1117 String adminStatusEnu = portConfig.getAdminStatus().getName();
1119 Object[] parameters = {nodeId,
1126 String query = Queries.getQuery().deviceProtocolPortConfigInsert().get();
1127 LOG.info("Running {} query ", query);
1128 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1129 for (int j = 0; j < parameters.length; j++) {
1130 stmt.setObject(j + 1, parameters[j]);
1133 stmt.clearParameters();
1134 } catch (SQLException e) {
1135 LOG.error("Something wrong when storing devices protocols LLDP Port config in DB", e);
1142 private void persistDevProtocolLldpNbrList(String nodeId, Connection connection) {
1144 InstanceIdentifier<Protocols> protocolsIID =
1145 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1146 Optional<Protocols> protocolObject =
1147 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1148 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1149 if (!protocolObject.isPresent()) {
1150 LOG.error("Protocols is missing");
1154 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1156 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, protocolsIID,
1157 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1160 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1161 LOG.error("LLDP nbrlist subtree is missing for {}", nodeId);
1164 String startTimestamp = getCurrentTimestamp();
1165 Map<IfNameKey, IfName> ifNameMap =
1166 protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().nonnullIfName();
1167 for (Map.Entry<IfNameKey, IfName> ifNameEntry : ifNameMap.entrySet()) {
1169 IfName ifNameObj = ifNameEntry.getValue();
1170 String ifName = ifNameObj.getIfName();
1171 String remotesysname = ifNameObj.getRemoteSysName();
1172 String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
1173 String remotemgmtaddress = ifNameObj.getRemoteMgmtAddress().getIpv4Address().toString();
1174 String remoteportidsubtypeEnu = ifNameObj.getRemotePortIdSubType().getName();
1175 String remoteportid = ifNameObj.getRemotePortId();
1176 String remotechassisidsubtypeEnu = ifNameObj.getRemoteChassisIdSubType().getName();
1177 String remotechassisid = ifNameObj.getRemoteChassisId();
1179 Object[] parameters = {nodeId,
1182 remotemgmtaddresssubtype,
1184 remoteportidsubtypeEnu,
1186 remotechassisidsubtypeEnu,
1192 String query = Queries.getQuery().deviceProtocolLldpNbrlistInsert().get();
1193 LOG.info("Running {} query ", query);
1194 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1195 for (int j = 0; j < parameters.length; j++) {
1196 stmt.setObject(j + 1, parameters[j]);
1199 stmt.clearParameters();
1200 } catch (SQLException e) {
1201 LOG.error("Something wrong when storing devices protocols LLDP list number in DB", e);
1208 private void persistDevInternalLinks(String nodeId, Connection connection) {
1210 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1211 Optional<OrgOpenroadmDevice> deviceObject =
1212 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1213 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1214 if (deviceObject.isPresent()) {
1215 if (deviceObject.get().getInternalLink() == null) {
1216 deviceObject = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION,
1217 deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1219 if (deviceObject.get().getInternalLink() == null) {
1220 LOG.info("External links not found for {}", nodeId);
1223 Map<InternalLinkKey, InternalLink> internalLinkMap = deviceObject.get().nonnullInternalLink();
1224 String startTimestamp = getCurrentTimestamp();
1225 for (Map.Entry<InternalLinkKey, InternalLink> internalLinkEntry: internalLinkMap.entrySet()) {
1226 InternalLink internalLink = internalLinkEntry.getValue();
1227 String internalLinkName = internalLink.getInternalLinkName();
1228 String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
1229 String sourcePortName = internalLink.getSource().getPortName().toString();
1230 String destinationCircuitPackName = internalLink.getDestination().getCircuitPackName();
1231 String destinationPortName = internalLink.getDestination().getPortName().toString();
1233 Object[] parameters = { nodeId, internalLinkName, sourceCircuitPackName, sourcePortName,
1234 destinationCircuitPackName, destinationPortName, startTimestamp, startTimestamp };
1235 String query = Queries.getQuery().deviceInternalLinkInsert().get();
1236 LOG.info("Running {} query ", query);
1237 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1238 for (int j = 0; j < parameters.length; j++) {
1239 stmt.setObject(j + 1, parameters[j]);
1242 stmt.clearParameters();
1243 } catch (SQLException e) {
1244 LOG.error("Something wrong when storing devices internal links", e);
1253 private void persistDevExternalLinks(String nodeId, Connection connection) {
1255 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1256 Optional<OrgOpenroadmDevice> deviceObject =
1257 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1258 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1259 if (deviceObject.isPresent()) {
1260 if (deviceObject.get().getExternalLink() == null) {
1261 deviceObject = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION,
1262 deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1264 if (deviceObject.get().getExternalLink() == null) {
1265 LOG.info("External links not found for {}", nodeId);
1267 String startTimestamp = getCurrentTimestamp();
1269 Map<ExternalLinkKey, ExternalLink> externalLinkMap = deviceObject.get().nonnullExternalLink();
1270 for (Map.Entry<ExternalLinkKey, ExternalLink> externalLinkEntry: externalLinkMap.entrySet()) {
1271 ExternalLink externalLink = externalLinkEntry.getValue();
1272 String externalLinkName = externalLink.getExternalLinkName();
1273 String sourceNodeId = externalLink.getSource().getNodeId();
1274 String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
1275 String sourcePortName = externalLink.getSource().getPortName();
1276 String destinationNodeId = externalLink.getDestination().getNodeId();
1277 String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
1278 String destinationPortName = externalLink.getDestination().getPortName();
1280 Object[] parameters = { nodeId, externalLinkName, sourceNodeId, sourceCircuitPackName,
1281 sourcePortName, destinationNodeId, destinationCircuitPackName, destinationPortName,
1282 startTimestamp, startTimestamp };
1284 String query = Queries.getQuery().deviceExternalLinkInsert().get();
1285 LOG.info("Running {} query ", query);
1286 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1287 for (int j = 0; j < parameters.length; j++) {
1288 stmt.setObject(j + 1, parameters[j]);
1291 stmt.clearParameters();
1292 } catch (SQLException e) {
1293 LOG.error("Something wrong when storing devices external links", e);
1301 private void persistDevPhysicalLinks(String nodeId, Connection connection) {
1303 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1304 Optional<OrgOpenroadmDevice> deviceObject =
1305 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1306 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1307 if (!deviceObject.isPresent()) {
1308 LOG.error("No device with node Id {}", nodeId);
1311 if (deviceObject.get().getPhysicalLink() == null) {
1313 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1314 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1316 if (!deviceObject.isPresent()) {
1317 LOG.error("No device with node Id {}", nodeId);
1320 if (deviceObject.get().getPhysicalLink() == null) {
1321 LOG.info("Physical links not found for {}", nodeId);
1324 String startTimestamp = getCurrentTimestamp();
1326 Map<PhysicalLinkKey, PhysicalLink> physicalLinkMap = deviceObject.get().nonnullPhysicalLink();
1327 for (Map.Entry<PhysicalLinkKey, PhysicalLink> physicalLinkEntry : physicalLinkMap.entrySet()) {
1328 PhysicalLink physicalLink = physicalLinkEntry.getValue();
1329 String physicalLinkName = physicalLink.getPhysicalLinkName();
1330 String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
1331 String sourcePortName = physicalLink.getSource().getPortName().toString();
1332 String destinationCircuitPackName = physicalLink.getDestination().getCircuitPackName();
1333 String destinationPortName = physicalLink.getDestination().getPortName().toString();
1335 Object[] parameters = {nodeId,
1337 sourceCircuitPackName,
1339 destinationCircuitPackName,
1340 destinationPortName,
1345 String query = Queries.getQuery().devicePhysicalLinkInsert().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("Something wrong when storing devices physical links", e);
1361 private void persistDevDegree(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);
1369 /*if (deviceObject.get().getDegree()==null){
1371 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1372 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1374 if (!deviceObject.isPresent()) {
1375 LOG.error("Cannot get device for node {}", nodeId);
1378 String startTimestamp = getCurrentTimestamp();
1380 Map<DegreeKey, Degree> degreeMap = deviceObject.get().nonnullDegree();
1381 for (Map.Entry<DegreeKey, Degree> degreeEntry : degreeMap.entrySet()) {
1382 Degree degree = degreeEntry.getValue();
1383 String degreeNumber = degree.getDegreeNumber().toString();
1384 String maxWavelengths = degree.getMaxWavelengths().toString();
1385 String otdrPortCircuitPackName =
1386 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getCircuitPackName());
1387 String otdrPortPortName =
1388 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getPortName().toString());
1389 // String mcCapabilitiesSlotWidthGranularity = "";
1390 // String mcCapabilitiesCenterFreqGranularity = "";
1391 // String mcCapabilitiesMinSlots = "-1";
1392 // String mcCapabilitiesMaxSlots = "-1";
1393 persistDevDegreeCircuitPack(nodeId, degree, degreeNumber, connection);
1394 persistDevDegreeConnectionPort(nodeId, degree, degreeNumber, connection);
1396 Object[] parameters = { nodeId, degreeNumber, maxWavelengths, otdrPortCircuitPackName, otdrPortPortName,
1397 // mcCapabilitiesSlotWidthGranularity,
1398 // mcCapabilitiesCenterFreqGranularity,
1399 // mcCapabilitiesMinSlots,
1400 // mcCapabilitiesMaxSlots,
1401 "", "", "-1", "-1", startTimestamp, startTimestamp };
1403 String query = Queries.getQuery().deviceDegreeInsert().get();
1404 LOG.info("Running {} query ", query);
1405 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1406 for (int j = 0; j < parameters.length; j++) {
1407 stmt.setObject(j + 1, parameters[j]);
1410 stmt.clearParameters();
1411 } catch (SQLException e) {
1412 LOG.error("Something wrong when storing devices degrees", e);
1419 private void persistDevDegreeCircuitPack(String nodeId, Degree degree, String degreeNumber, Connection connection) {
1421 String startTimestamp = getCurrentTimestamp();
1423 Map<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacksKey,
1424 org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks>
1425 circuitPacksMap = degree.nonnullCircuitPacks();
1426 for (Map.Entry<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacksKey,
1427 org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks> circuitPackEntry :
1428 circuitPacksMap.entrySet()) {
1430 String circuitPackIndex = circuitPackEntry.getValue().getIndex().toString();
1431 String circuitPackName = circuitPackEntry.getValue().getCircuitPackName();
1433 Object[] parameters = {nodeId,
1441 String query = Queries.getQuery().deviceDegreeCircuitPackInsert().get();
1442 LOG.info("Running {} query ", query);
1443 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1444 for (int j = 0; j < parameters.length; j++) {
1445 stmt.setObject(j + 1, parameters[j]);
1448 stmt.clearParameters();
1449 } catch (SQLException e) {
1450 LOG.error("Something wrong when storing devices degrees circuit packs", e);
1456 private void persistDevDegreeConnectionPort(String nodeId, Degree degree, String degreeNumber,
1457 Connection connection) {
1459 String startTimestamp = getCurrentTimestamp();
1461 Map<ConnectionPortsKey, ConnectionPorts> connectionPortsMap = degree.nonnullConnectionPorts();
1462 for (Map.Entry<ConnectionPortsKey, ConnectionPorts> portEntry : connectionPortsMap.entrySet()) {
1463 String connectionPortIndex = portEntry.getValue().getIndex().toString();
1464 String circuitPackName = portEntry.getValue().getCircuitPackName();
1465 String portName = portEntry.getValue().getPortName().toString();
1467 Object[] parameters = {nodeId,
1469 connectionPortIndex,
1476 String query = Queries.getQuery().deviceDegreeConnectionPortInsert().get();
1477 LOG.info("Running {} query ", query);
1478 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1479 for (int j = 0; j < parameters.length; j++) {
1480 stmt.setObject(j + 1, parameters[j]);
1483 stmt.clearParameters();
1484 } catch (SQLException e) {
1485 LOG.error("Something wrong when storing devices degrees connection ports", e);
1492 private void persistDevSrg(String nodeId, Connection connection) {
1494 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1495 Optional<OrgOpenroadmDevice> deviceObject =
1496 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1497 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1498 if (!deviceObject.isPresent()) {
1499 LOG.error("No device found in operational datastore for node {}", nodeId);
1503 if (deviceObject.get().getSharedRiskGroup() == null) {
1505 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1506 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1507 if (!deviceObject.isPresent()) {
1508 LOG.error("No device found in configuration datastore for node {}", nodeId);
1514 Map<SharedRiskGroupKey, SharedRiskGroup> sharedRiskGroupMap = deviceObject.get().nonnullSharedRiskGroup();
1515 if (sharedRiskGroupMap.isEmpty()) {
1516 LOG.info("no srg found for node {} ", nodeId);
1518 String startTimestamp = getCurrentTimestamp();
1519 for (Map.Entry<SharedRiskGroupKey, SharedRiskGroup> groupEntry : sharedRiskGroupMap.entrySet()) {
1520 SharedRiskGroup sharedRiskGroup = groupEntry.getValue();
1521 //String currentProvisionedAddDropPorts = "-1";
1522 //String mcCapSlotWidthGranularity = "";
1523 //String mcCapCenterFreqGranularity = "";
1524 //String mcCapMinSlots = "-1";
1525 //String mcCapMaxSlots = "-1";
1526 String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
1527 String srgNumber = sharedRiskGroup.getSrgNumber().toString();
1528 String wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getName();
1529 persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
1531 Object[] parameters = {nodeId,
1533 //currentProvisionedAddDropPorts,
1536 wavelengthDuplicationEnu,
1537 //mcCapSlotWidthGranularity,
1538 //mcCapCenterFreqGranularity,
1546 String query = Queries.getQuery().deviceSharedRiskGroupInsert().get();
1547 LOG.info("Running {} query ", query);
1548 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1549 for (int j = 0; j < parameters.length; j++) {
1550 stmt.setObject(j + 1, parameters[j]);
1553 stmt.clearParameters();
1554 } catch (SQLException e) {
1555 LOG.error("Something wrong when storing devices SRG", e);
1563 private void persistDevSrgCircuitPacks(String nodeId, SharedRiskGroup sharedRiskGroup, String srgNumber,
1564 Connection connection) {
1566 String startTimestamp = getCurrentTimestamp();
1568 Map<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksKey,
1569 org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks>
1570 circuitPacksMap = sharedRiskGroup.nonnullCircuitPacks();
1571 for (Map.Entry<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksKey,
1572 org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks> entry :
1573 circuitPacksMap.entrySet()) {
1575 String circuitPackindex = entry.getValue().getIndex().toString();
1576 String circuitPackName = entry.getValue().getCircuitPackName();
1578 Object[] parameters = {nodeId,
1586 String query = Queries.getQuery().deviceSrgCircuitPackInsert().get();
1587 LOG.info("Running {} query ", query);
1588 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1589 for (int j = 0; j < parameters.length; j++) {
1590 stmt.setObject(j + 1, parameters[j]);
1593 stmt.clearParameters();
1594 } catch (SQLException e) {
1595 LOG.error("Something wrong when storing devices SRG circuit packs", e);
1601 private void persistDevRoadmConnections(String nodeId, Connection connection) {
1603 //int opticalcontrolmodeEnu=-1;
1605 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1606 Optional<OrgOpenroadmDevice> deviceObject =
1607 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1608 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1609 if (!deviceObject.isPresent()) {
1610 LOG.error("No device found in operational datastore for node {}", nodeId);
1613 if (deviceObject.get().getRoadmConnections() == null) {
1615 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1616 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1617 if (!deviceObject.isPresent()) {
1618 LOG.error("No device found in configuration datastore for node {}", nodeId);
1624 Map<RoadmConnectionsKey, RoadmConnections> connectionsMap = deviceObject.get().nonnullRoadmConnections();
1625 if (!connectionsMap.isEmpty()) {
1626 String startTimestamp = getCurrentTimestamp();
1627 for (Map.Entry<RoadmConnectionsKey, RoadmConnections> entry : connectionsMap.entrySet()) {
1628 RoadmConnections roadmConnections = entry.getValue();
1629 String connectionNumber = roadmConnections.getConnectionNumber();
1630 //String connectionName = "";
1631 String wavelengthNumber = roadmConnections.getWavelengthNumber().toString();
1632 String opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getName();
1633 String targetOutputPower = roadmConnections.getTargetOutputPower().toString();
1634 String srcIf = roadmConnections.getSource().getSrcIf();
1635 String dstIf = roadmConnections.getDestination().getDstIf();
1637 Object[] parameters = {nodeId,
1642 opticalcontrolmodeEnu,
1650 String query = Queries.getQuery().deviceRoadmConnectionsInsert().get();
1651 LOG.info("Running {} query ", query);
1652 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1653 for (int j = 0; j < parameters.length; j++) {
1654 stmt.setObject(j + 1, parameters[j]);
1657 stmt.clearParameters();
1658 } catch (SQLException e) {
1659 LOG.error("Something wrong when storing devices ROADM connection ", e);
1664 LOG.info("ROADM Dev Connections not found!! for {}", nodeId);
1669 private void persistDevConnectionMap(String nodeId, Connection connection) {
1671 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1672 Optional<OrgOpenroadmDevice> deviceObject =
1673 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1674 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1675 if (!deviceObject.isPresent()) {
1676 LOG.error("No device found in operational datastore for node {}", nodeId);
1679 String startTimestamp = getCurrentTimestamp();
1681 Map<ConnectionMapKey, ConnectionMap> connectionsMap = deviceObject.get().nonnullConnectionMap();
1682 for (Map.Entry<ConnectionMapKey, ConnectionMap> entry : connectionsMap.entrySet()) {
1683 ConnectionMap connectionMap = entry.getValue();
1684 String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
1685 String sourceCircuitPackName = connectionMap.getSource().getCircuitPackName();
1686 String sourcePortName = connectionMap.getSource().getCircuitPackName();
1689 Object[] parameters = {nodeId,
1690 connectionMapNumber,
1691 sourceCircuitPackName,
1697 String query = Queries.getQuery().deviceConnectionMapInsert().get();
1698 LOG.info("Running {} query ", query);
1699 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1700 for (int j = 0; j < parameters.length; j++) {
1701 stmt.setObject(j + 1, parameters[j]);
1704 stmt.clearParameters();
1705 } catch (SQLException e) {
1706 LOG.error("Something wrong when storing devices connection map", e);
1712 private void persistDevWavelengthMap(String nodeId, Connection connection) {
1714 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1715 Optional<OrgOpenroadmDevice> deviceObject =
1716 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1717 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1718 if (!deviceObject.isPresent()) {
1719 LOG.error("No device found in operational datastore for node {}", nodeId);
1723 String startTimestamp = getCurrentTimestamp();
1725 Map<WavelengthsKey, Wavelengths> wavelengthsMap = deviceObject.get().getWavelengthMap().nonnullWavelengths();
1726 for (Map.Entry<WavelengthsKey, Wavelengths> entry : wavelengthsMap.entrySet()) {
1727 Wavelengths wavelengths = entry.getValue();
1728 String wavelengthNumber = wavelengths.getWavelengthNumber().toString();
1729 String centerFrequency = wavelengths.getCenterFrequency().toString();
1730 String wavelength = wavelengths.getWavelength().toString();
1733 Object[] parameters = {nodeId,
1741 String query = Queries.getQuery().deviceWavelengthInsert().get();
1742 LOG.info("Running {} query ", query);
1743 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1744 for (int j = 0; j < parameters.length; j++) {
1745 stmt.setObject(j + 1, parameters[j]);
1748 stmt.clearParameters();
1749 } catch (SQLException e) {
1750 LOG.error("Something wrong when storing devices wavelength map", e);
1757 private void persistDevInterfaceTcm(String nodeId, String interfaceName, OduBuilder oduBuilder,
1758 Connection connection) {
1760 Map<TcmKey, Tcm> tcmMap = oduBuilder.getTcm();
1761 for (Map.Entry<TcmKey, Tcm> entry : tcmMap.entrySet()) {
1762 Tcm tcm = entry.getValue();
1764 Object[] parameters = prepareDevInterfaceTcmParameters(nodeId, interfaceName, tcm);
1766 String query = Queries.getQuery().deviceInterfacesInsert().get();
1767 LOG.info("Running {} query ", query);
1768 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1769 for (int j = 0; j < parameters.length; j++) {
1770 stmt.setObject(j + 1, parameters[j]);
1773 stmt.clearParameters();
1774 } catch (SQLException e) {
1775 LOG.error("Something wrong when storing devices interface tcm", e);
1780 private void persistDevInterfaceOtnOduTxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1781 Connection connection) {
1783 Map<TxMsiKey, TxMsi> txMsiMap = oduBuilder.getOpu().getMsi().nonnullTxMsi();
1784 for (Map.Entry<TxMsiKey, TxMsi> entry : txMsiMap.entrySet()) {
1786 TxMsi txMsi = entry.getValue();
1788 Object[] parameters = prepareDevInterfaceOtnOduTxMsiParameters(nodeId, interfaceName, txMsi);
1790 String query = Queries.getQuery().deviceInterfaceOtnOduTxMsiInsert().get();
1791 LOG.info("Running {} query ", query);
1792 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1793 for (int j = 0; j < parameters.length; j++) {
1794 stmt.setObject(j + 1, parameters[j]);
1797 stmt.clearParameters();
1798 } catch (SQLException e) {
1799 LOG.error("Something wrong when storing devices interface OTN ODU Tx MSI", e);
1805 private void persistDevInterfaceOtnOduRxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1806 Connection connection) {
1807 Map<RxMsiKey, RxMsi> rxMsiMap = oduBuilder.getOpu().getMsi().nonnullRxMsi();
1808 for (Map.Entry<RxMsiKey, RxMsi> entry : rxMsiMap.entrySet()) {
1809 RxMsi rxMsi = entry.getValue();
1811 Object[] parameters = prepareDevInterfaceOtnOduRxMsiParameters(nodeId, interfaceName, rxMsi);
1813 String query = Queries.getQuery().deviceInterfaceOtnOduRxMsiInsert().get();
1814 LOG.info("Running {} query ", query);
1815 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1816 for (int j = 0; j < parameters.length; j++) {
1817 stmt.setObject(j + 1, parameters[j]);
1820 stmt.clearParameters();
1821 } catch (SQLException e) {
1822 LOG.error("Something wrong when storing devices interface OTN ODU Rx MSI", e);
1828 private void persistDevInterfaceOtnOduExpMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1829 Connection connection) {
1831 Map<ExpMsiKey, ExpMsi> expMsiMap = oduBuilder.getOpu().getMsi().nonnullExpMsi();
1832 for (Map.Entry<ExpMsiKey, ExpMsi> entry : expMsiMap.entrySet()) {
1833 ExpMsi expMsi = entry.getValue();
1835 Object[] parameters = prepareDevInterfaceOtnOduExpMsiParameters(nodeId, interfaceName, expMsi);
1837 String query = Queries.getQuery().deviceInterfaceOtnOduExpMsiInsert().get();
1838 LOG.info("Running {} query ", query);
1839 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1840 for (int j = 0; j < parameters.length; j++) {
1841 stmt.setObject(j + 1, parameters[j]);
1844 stmt.clearParameters();
1845 } catch (SQLException e) {
1846 LOG.error("Something wrong when storing devices interface OTN ODU Exp MSI", e);