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 LOG.warn("Could not get device info from DataBroker");
111 deviceInfo = infoOpt.get();
112 boolean sqlResult = false;
113 String query = Queries.getQuery().deviceInfoInsert().get();
114 LOG.info("Running {} query ", query);
115 try (Connection connection = dataSource.getConnection();
116 PreparedStatement preparedStatement = connection.prepareStatement(query)) {
117 Object[] prepareParameters = prepareDeviceInfoParameters(deviceInfo);
118 for (int i = 0; i < prepareParameters.length; i++) {
119 LOG.debug("Parameter {} has value {}", i + 1, prepareParameters[i]);
120 preparedStatement.setObject(i + 1, prepareParameters[i]);
123 int executeUpdate = preparedStatement.executeUpdate();
124 LOG.info("{} entries were added", executeUpdate);
127 LOG.debug("iNode AddNode call complete");
128 getRoadmShelves(deviceId);
129 LOG.debug("iNode getRoadmShelves call complete");
130 getCircuitPacks(deviceId);
131 LOG.debug("iNode getCircuitPacks call complete");
133 LOG.debug("iNode persist interfaces call");
134 persistDevInterfaces(deviceId, connection);
135 LOG.debug("iNode persist interfaces call complete");
138 LOG.debug("iNode persist protocols call");
139 persistDevProtocols(deviceId, connection);
140 LOG.debug("iNode persist protocols call complete");
143 LOG.debug("iNode persist wavelength map call");
144 persistDevWavelengthMap(deviceId, connection);
145 LOG.debug("iNode persist wavelength map call complete");
147 LOG.debug("iNode persist internal links map call");
148 persistDevInternalLinks(deviceId, connection);
149 LOG.debug("iNode persist internal links map call complete");
151 LOG.debug("iNode persist Physical links map call");
152 persistDevPhysicalLinks(deviceId, connection);
153 LOG.debug("iNode persist Physical links map call complete");
155 LOG.debug("iNode persist External links map call");
156 persistDevExternalLinks(deviceId, connection);
157 LOG.debug("iNode persist External links map call complete");
159 LOG.debug("iNode persist degree map call");
160 persistDevDegree(deviceId, connection);
161 LOG.debug("iNode persist degree map call complete");
163 LOG.debug("iNode persist srg map call");
164 persistDevSrg(deviceId, connection);
165 LOG.debug("iNode persist srg map call complete");
167 LOG.debug("iNode persist Roadm Connections call");
168 persistDevRoadmConnections(deviceId, connection);
169 LOG.debug("iNode persist Roadm Connections call complete");
171 LOG.debug("iNode persist Connection Map call");
172 persistDevConnectionMap(deviceId, connection);
173 LOG.debug("iNode persist Connection Map call complete");
175 } catch (SQLException | InterruptedException | ExecutionException e) {
176 LOG.error("Something wrong when storing node into DB", e);
181 public boolean nodeExists(String nodeId) {
182 String selectTableSQL = "select count(*) node_exists from inv_dev_info where node_id = ?";
184 LOG.info("Checking if {} exists in DB", nodeId);
185 try (Connection connection = dataSource.getConnection();
186 PreparedStatement preparedStmt = connection.prepareStatement(selectTableSQL)) {
187 preparedStmt.setString(1, nodeId);
188 try (ResultSet rs = preparedStmt.executeQuery()) {
190 nodeExists = rs.getInt("node_exists");
191 LOG.debug("Found {} devices matching {}", nodeExists, nodeId);
194 } catch (SQLException e) {
195 LOG.error("Something wrong when fetching node in DB", e);
197 return nodeExists == 0 ? false : true;
200 public void getRoadmShelves(String nodeId) throws InterruptedException, ExecutionException {
201 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
202 Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
203 LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT,
204 Timeouts.DEVICE_READ_TIMEOUT_UNIT);
205 if (!deviceObject.isPresent()) {
208 Map<ShelvesKey, Shelves> shelvesMap = deviceObject.get().nonnullShelves();
209 LOG.info("Shelves size {}", shelvesMap.size());
210 try (Connection connection = requireNonNull(dataSource.getConnection())) {
211 for (Map.Entry<ShelvesKey, Shelves> shelveEntry : shelvesMap.entrySet()) {
212 Shelves shelve = shelveEntry.getValue();
213 String shelfName = shelve.getShelfName();
214 LOG.info("Getting Shelve Details of {}", shelfName);
215 if (shelve.getSlots() != null) {
216 LOG.info("Slot Size {} ", shelve.getSlots().size());
217 persistShelveSlots(nodeId, shelve, connection);
219 LOG.info("No Slots for shelf {}", shelfName);
222 persistShelves(nodeId, connection, shelve);
224 } catch (SQLException e1) {
225 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()));
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();
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.getProactiveDelayMeasurementEnabled().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().getEnabled().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().getEnabled().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.getLtcActEnabled().toString();
921 String proactiveDelayMeasurementEnabled = tcm.getProactiveDelayMeasurementEnabled().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()) {
1036 Map<InterfaceKey, Interface> interfaceMap = deviceObject.get().nonnullInterface();
1037 for (Map.Entry<InterfaceKey, Interface> interfaceEntrySet : interfaceMap.entrySet()) {
1038 Interface deviceInterface = interfaceEntrySet.getValue();
1039 Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
1041 String query = Queries.getQuery().deviceInterfacesInsert().get();
1042 LOG.info("Running {} query ", query);
1043 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1044 for (int j = 0; j < parameters.length; j++) {
1045 stmt.setObject(j + 1, parameters[j]);
1048 stmt.clearParameters();
1049 } catch (SQLException e) {
1050 LOG.error("Something wrong when storing devices interfaces in DB", e);
1055 private void persistDevProtocols(String nodeId, Connection connection) {
1057 InstanceIdentifier<Protocols> protocolsIID =
1058 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1059 Optional<Protocols> protocolObject =
1060 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1061 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1062 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1063 LOG.error("LLDP subtree is missing");
1066 String adminstatusEnu = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1067 .getAdminStatus().getName();
1068 String msgTxtInterval = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1069 .getMsgTxInterval().toString();
1070 String mxgTxHoldMultiplier = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
1071 .getMsgTxHoldMultiplier().toString();
1072 String startTimestamp = getCurrentTimestamp();
1073 persistDevProtocolLldpPortConfig(nodeId, connection);
1074 persistDevProtocolLldpNbrList(nodeId, connection);
1076 Object[] parameters = {nodeId,
1079 mxgTxHoldMultiplier,
1084 String query = Queries.getQuery().deviceProtocolInsert().get();
1085 LOG.info("Running {} query ", query);
1086 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1087 for (int j = 0; j < parameters.length; j++) {
1088 stmt.setObject(j + 1, parameters[j]);
1091 stmt.clearParameters();
1092 } catch (SQLException e) {
1093 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");
1109 String startTimestamp = getCurrentTimestamp();
1111 Map<PortConfigKey, PortConfig> portConfigMap = protocolObject.get()
1112 .augmentation(Protocols1.class).getLldp().nonnullPortConfig();
1113 for (Map.Entry<PortConfigKey, PortConfig> entry : portConfigMap.entrySet()) {
1114 PortConfig portConfig = entry.getValue();
1115 String ifName = portConfig.getIfName();
1116 String adminStatusEnu = portConfig.getAdminStatus().getName();
1118 Object[] parameters = {nodeId,
1125 String query = Queries.getQuery().deviceProtocolPortConfigInsert().get();
1126 LOG.info("Running {} query ", query);
1127 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1128 for (int j = 0; j < parameters.length; j++) {
1129 stmt.setObject(j + 1, parameters[j]);
1132 stmt.clearParameters();
1133 } catch (SQLException e) {
1134 LOG.error("Something wrong when storing devices protocols LLDP Port config in DB", e);
1141 private void persistDevProtocolLldpNbrList(String nodeId, Connection connection) {
1143 InstanceIdentifier<Protocols> protocolsIID =
1144 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1145 Optional<Protocols> protocolObject =
1146 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1147 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1148 if (!protocolObject.isPresent()) {
1149 LOG.error("Protocols is missing");
1152 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1154 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, protocolsIID,
1155 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1156 if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
1157 LOG.error("LLDP nbrlist subtree is missing for {}", nodeId);
1161 String startTimestamp = getCurrentTimestamp();
1162 Map<IfNameKey, IfName> ifNameMap =
1163 protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().nonnullIfName();
1164 for (Map.Entry<IfNameKey, IfName> ifNameEntry : ifNameMap.entrySet()) {
1166 IfName ifNameObj = ifNameEntry.getValue();
1167 String ifName = ifNameObj.getIfName();
1168 String remotesysname = ifNameObj.getRemoteSysName();
1169 String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
1170 String remotemgmtaddress = ifNameObj.getRemoteMgmtAddress().getIpv4Address().toString();
1171 String remoteportidsubtypeEnu = ifNameObj.getRemotePortIdSubType().getName();
1172 String remoteportid = ifNameObj.getRemotePortId();
1173 String remotechassisidsubtypeEnu = ifNameObj.getRemoteChassisIdSubType().getName();
1174 String remotechassisid = ifNameObj.getRemoteChassisId();
1176 Object[] parameters = {nodeId,
1179 remotemgmtaddresssubtype,
1181 remoteportidsubtypeEnu,
1183 remotechassisidsubtypeEnu,
1189 String query = Queries.getQuery().deviceProtocolLldpNbrlistInsert().get();
1190 LOG.info("Running {} query ", query);
1191 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1192 for (int j = 0; j < parameters.length; j++) {
1193 stmt.setObject(j + 1, parameters[j]);
1196 stmt.clearParameters();
1197 } catch (SQLException e) {
1198 LOG.error("Something wrong when storing devices protocols LLDP list number in DB", e);
1204 private void persistDevInternalLinks(String nodeId, Connection connection) {
1206 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1207 Optional<OrgOpenroadmDevice> deviceObject =
1208 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1209 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1210 if (!deviceObject.isPresent()) {
1213 if (deviceObject.get().getInternalLink() == null) {
1214 deviceObject = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION,
1215 deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1216 if (deviceObject.get().getInternalLink() == null) {
1217 LOG.info("External links not found for {}", nodeId);
1222 Map<InternalLinkKey, InternalLink> internalLinkMap = deviceObject.get().nonnullInternalLink();
1223 String startTimestamp = getCurrentTimestamp();
1224 for (Map.Entry<InternalLinkKey, InternalLink> internalLinkEntry: internalLinkMap.entrySet()) {
1225 InternalLink internalLink = internalLinkEntry.getValue();
1226 String internalLinkName = internalLink.getInternalLinkName();
1227 String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
1228 String sourcePortName = internalLink.getSource().getPortName();
1229 String destinationCircuitPackName = internalLink.getDestination().getCircuitPackName();
1230 String destinationPortName = internalLink.getDestination().getPortName();
1232 Object[] parameters = { nodeId, internalLinkName, sourceCircuitPackName, sourcePortName,
1233 destinationCircuitPackName, destinationPortName, startTimestamp, startTimestamp };
1234 String query = Queries.getQuery().deviceInternalLinkInsert().get();
1235 LOG.info("Running {} query ", query);
1236 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1237 for (int j = 0; j < parameters.length; j++) {
1238 stmt.setObject(j + 1, parameters[j]);
1241 stmt.clearParameters();
1242 } catch (SQLException e) {
1243 LOG.error("Something wrong when storing devices internal links", e);
1249 private void persistDevExternalLinks(String nodeId, Connection connection) {
1251 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1252 Optional<OrgOpenroadmDevice> deviceObject =
1253 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1254 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1255 if (!deviceObject.isPresent()) {
1258 if (deviceObject.get().getExternalLink() == null) {
1259 deviceObject = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION,
1260 deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1261 if (deviceObject.get().getExternalLink() == null) {
1262 LOG.info("External links not found for {}", nodeId);
1266 String startTimestamp = getCurrentTimestamp();
1268 Map<ExternalLinkKey, ExternalLink> externalLinkMap = deviceObject.get().nonnullExternalLink();
1269 for (Map.Entry<ExternalLinkKey, ExternalLink> externalLinkEntry: externalLinkMap.entrySet()) {
1270 ExternalLink externalLink = externalLinkEntry.getValue();
1271 String externalLinkName = externalLink.getExternalLinkName();
1272 String sourceNodeId = externalLink.getSource().getNodeId();
1273 String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
1274 String sourcePortName = externalLink.getSource().getPortName();
1275 String destinationNodeId = externalLink.getDestination().getNodeId();
1276 String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
1277 String destinationPortName = externalLink.getDestination().getPortName();
1279 Object[] parameters = { nodeId, externalLinkName, sourceNodeId, sourceCircuitPackName,
1280 sourcePortName, destinationNodeId, destinationCircuitPackName, destinationPortName,
1281 startTimestamp, startTimestamp };
1283 String query = Queries.getQuery().deviceExternalLinkInsert().get();
1284 LOG.info("Running {} query ", query);
1285 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1286 for (int j = 0; j < parameters.length; j++) {
1287 stmt.setObject(j + 1, parameters[j]);
1290 stmt.clearParameters();
1291 } catch (SQLException e) {
1292 LOG.error("Something wrong when storing devices external links", e);
1297 private void persistDevPhysicalLinks(String nodeId, Connection connection) {
1299 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1300 Optional<OrgOpenroadmDevice> deviceObject =
1301 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1302 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1303 if (!deviceObject.isPresent()) {
1304 LOG.error("No device with node Id {}", nodeId);
1307 if (deviceObject.get().getPhysicalLink() == null) {
1309 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1310 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1311 if (!deviceObject.isPresent()) {
1312 LOG.error("No device with node Id {}", nodeId);
1315 if (deviceObject.get().getPhysicalLink() == null) {
1316 LOG.info("Physical links not found for {}", nodeId);
1321 String startTimestamp = getCurrentTimestamp();
1323 Map<PhysicalLinkKey, PhysicalLink> physicalLinkMap = deviceObject.get().nonnullPhysicalLink();
1324 for (Map.Entry<PhysicalLinkKey, PhysicalLink> physicalLinkEntry : physicalLinkMap.entrySet()) {
1325 PhysicalLink physicalLink = physicalLinkEntry.getValue();
1326 String physicalLinkName = physicalLink.getPhysicalLinkName();
1327 String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
1328 String sourcePortName = physicalLink.getSource().getPortName();
1329 String destinationCircuitPackName = physicalLink.getDestination().getCircuitPackName();
1330 String destinationPortName = physicalLink.getDestination().getPortName();
1332 Object[] parameters = {nodeId,
1334 sourceCircuitPackName,
1336 destinationCircuitPackName,
1337 destinationPortName,
1342 String query = Queries.getQuery().devicePhysicalLinkInsert().get();
1343 LOG.info("Running {} query ", query);
1344 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1345 for (int j = 0; j < parameters.length; j++) {
1346 stmt.setObject(j + 1, parameters[j]);
1349 stmt.clearParameters();
1350 } catch (SQLException e) {
1351 LOG.error("Something wrong when storing devices physical links", e);
1357 private void persistDevDegree(String nodeId, Connection connection) {
1359 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1360 Optional<OrgOpenroadmDevice> deviceObject =
1361 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1362 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1365 /*if (deviceObject.get().getDegree()==null){
1367 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1368 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1370 if (!deviceObject.isPresent()) {
1371 LOG.error("Cannot get device for node {}", nodeId);
1374 String startTimestamp = getCurrentTimestamp();
1376 Map<DegreeKey, Degree> degreeMap = deviceObject.get().nonnullDegree();
1377 for (Map.Entry<DegreeKey, Degree> degreeEntry : degreeMap.entrySet()) {
1378 Degree degree = degreeEntry.getValue();
1379 String degreeNumber = degree.getDegreeNumber().toString();
1380 String maxWavelengths = degree.getMaxWavelengths().toString();
1381 String otdrPortCircuitPackName =
1382 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getCircuitPackName());
1383 String otdrPortPortName =
1384 (degree.getOtdrPort() == null ? "" : degree.getOtdrPort().getPortName());
1385 // String mcCapabilitiesSlotWidthGranularity = "";
1386 // String mcCapabilitiesCenterFreqGranularity = "";
1387 // String mcCapabilitiesMinSlots = "-1";
1388 // String mcCapabilitiesMaxSlots = "-1";
1389 persistDevDegreeCircuitPack(nodeId, degree, degreeNumber, connection);
1390 persistDevDegreeConnectionPort(nodeId, degree, degreeNumber, connection);
1392 Object[] parameters = { nodeId, degreeNumber, maxWavelengths, otdrPortCircuitPackName, otdrPortPortName,
1393 // mcCapabilitiesSlotWidthGranularity,
1394 // mcCapabilitiesCenterFreqGranularity,
1395 // mcCapabilitiesMinSlots,
1396 // mcCapabilitiesMaxSlots,
1397 "", "", "-1", "-1", startTimestamp, startTimestamp };
1399 String query = Queries.getQuery().deviceDegreeInsert().get();
1400 LOG.info("Running {} query ", query);
1401 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1402 for (int j = 0; j < parameters.length; j++) {
1403 stmt.setObject(j + 1, parameters[j]);
1406 stmt.clearParameters();
1407 } catch (SQLException e) {
1408 LOG.error("Something wrong when storing devices degrees", e);
1415 private void persistDevDegreeCircuitPack(String nodeId, Degree degree, String degreeNumber, Connection connection) {
1417 String startTimestamp = getCurrentTimestamp();
1419 Map<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacksKey,
1420 org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks>
1421 circuitPacksMap = degree.nonnullCircuitPacks();
1422 for (Map.Entry<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacksKey,
1423 org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks> circuitPackEntry :
1424 circuitPacksMap.entrySet()) {
1426 String circuitPackIndex = circuitPackEntry.getValue().getIndex().toString();
1427 String circuitPackName = circuitPackEntry.getValue().getCircuitPackName();
1429 Object[] parameters = {nodeId,
1437 String query = Queries.getQuery().deviceDegreeCircuitPackInsert().get();
1438 LOG.info("Running {} query ", query);
1439 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1440 for (int j = 0; j < parameters.length; j++) {
1441 stmt.setObject(j + 1, parameters[j]);
1444 stmt.clearParameters();
1445 } catch (SQLException e) {
1446 LOG.error("Something wrong when storing devices degrees circuit packs", e);
1452 private void persistDevDegreeConnectionPort(String nodeId, Degree degree, String degreeNumber,
1453 Connection connection) {
1455 String startTimestamp = getCurrentTimestamp();
1457 Map<ConnectionPortsKey, ConnectionPorts> connectionPortsMap = degree.nonnullConnectionPorts();
1458 for (Map.Entry<ConnectionPortsKey, ConnectionPorts> portEntry : connectionPortsMap.entrySet()) {
1459 String connectionPortIndex = portEntry.getValue().getIndex().toString();
1460 String circuitPackName = portEntry.getValue().getCircuitPackName();
1461 String portName = portEntry.getValue().getPortName();
1463 Object[] parameters = {nodeId,
1465 connectionPortIndex,
1472 String query = Queries.getQuery().deviceDegreeConnectionPortInsert().get();
1473 LOG.info("Running {} query ", query);
1474 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1475 for (int j = 0; j < parameters.length; j++) {
1476 stmt.setObject(j + 1, parameters[j]);
1479 stmt.clearParameters();
1480 } catch (SQLException e) {
1481 LOG.error("Something wrong when storing devices degrees connection ports", e);
1488 private void persistDevSrg(String nodeId, Connection connection) {
1490 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1491 Optional<OrgOpenroadmDevice> deviceObject =
1492 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1493 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1494 if (!deviceObject.isPresent()) {
1495 LOG.error("No device found in operational datastore for node {}", nodeId);
1499 if (deviceObject.get().getSharedRiskGroup() == null) {
1501 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1502 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1503 if (!deviceObject.isPresent()) {
1504 LOG.error("No device found in configuration datastore for node {}", nodeId);
1510 Map<SharedRiskGroupKey, SharedRiskGroup> sharedRiskGroupMap = deviceObject.get().nonnullSharedRiskGroup();
1511 if (sharedRiskGroupMap.isEmpty()) {
1512 LOG.info("no srg found for node {} ", nodeId);
1515 String startTimestamp = getCurrentTimestamp();
1516 for (Map.Entry<SharedRiskGroupKey, SharedRiskGroup> groupEntry : sharedRiskGroupMap.entrySet()) {
1517 SharedRiskGroup sharedRiskGroup = groupEntry.getValue();
1518 //String currentProvisionedAddDropPorts = "-1";
1519 //String mcCapSlotWidthGranularity = "";
1520 //String mcCapCenterFreqGranularity = "";
1521 //String mcCapMinSlots = "-1";
1522 //String mcCapMaxSlots = "-1";
1523 String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
1524 String srgNumber = sharedRiskGroup.getSrgNumber().toString();
1525 String wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getName();
1526 persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
1528 Object[] parameters = {nodeId,
1530 //currentProvisionedAddDropPorts,
1533 wavelengthDuplicationEnu,
1534 //mcCapSlotWidthGranularity,
1535 //mcCapCenterFreqGranularity,
1543 String query = Queries.getQuery().deviceSharedRiskGroupInsert().get();
1544 LOG.info("Running {} query ", query);
1545 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1546 for (int j = 0; j < parameters.length; j++) {
1547 stmt.setObject(j + 1, parameters[j]);
1550 stmt.clearParameters();
1551 } catch (SQLException e) {
1552 LOG.error("Something wrong when storing devices SRG", e);
1559 private void persistDevSrgCircuitPacks(String nodeId, SharedRiskGroup sharedRiskGroup, String srgNumber,
1560 Connection connection) {
1562 String startTimestamp = getCurrentTimestamp();
1564 Map<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksKey,
1565 org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks>
1566 circuitPacksMap = sharedRiskGroup.nonnullCircuitPacks();
1567 for (Map.Entry<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksKey,
1568 org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks> entry :
1569 circuitPacksMap.entrySet()) {
1571 String circuitPackindex = entry.getValue().getIndex().toString();
1572 String circuitPackName = entry.getValue().getCircuitPackName();
1574 Object[] parameters = {nodeId,
1582 String query = Queries.getQuery().deviceSrgCircuitPackInsert().get();
1583 LOG.info("Running {} query ", query);
1584 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1585 for (int j = 0; j < parameters.length; j++) {
1586 stmt.setObject(j + 1, parameters[j]);
1589 stmt.clearParameters();
1590 } catch (SQLException e) {
1591 LOG.error("Something wrong when storing devices SRG circuit packs", e);
1597 private void persistDevRoadmConnections(String nodeId, Connection connection) {
1599 //int opticalcontrolmodeEnu=-1;
1601 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1602 Optional<OrgOpenroadmDevice> deviceObject =
1603 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1604 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1605 if (!deviceObject.isPresent()) {
1606 LOG.error("No device found in operational datastore for node {}", nodeId);
1609 if (deviceObject.get().getRoadmConnections() == null) {
1611 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
1612 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1613 if (!deviceObject.isPresent()) {
1614 LOG.error("No device found in configuration datastore for node {}", nodeId);
1620 Map<RoadmConnectionsKey, RoadmConnections> connectionsMap = deviceObject.get().nonnullRoadmConnections();
1621 if (connectionsMap.isEmpty()) {
1622 LOG.info("ROADM Dev Connections not found!! for {}", nodeId);
1625 String startTimestamp = getCurrentTimestamp();
1626 for (Map.Entry<RoadmConnectionsKey, RoadmConnections> entry : connectionsMap.entrySet()) {
1627 RoadmConnections roadmConnections = entry.getValue();
1628 String connectionNumber = roadmConnections.getConnectionNumber();
1629 //String connectionName = "";
1630 String wavelengthNumber = roadmConnections.getWavelengthNumber().toString();
1631 String opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getName();
1632 String targetOutputPower = roadmConnections.getTargetOutputPower().toString();
1633 String srcIf = roadmConnections.getSource().getSrcIf();
1634 String dstIf = roadmConnections.getDestination().getDstIf();
1636 Object[] parameters = {nodeId,
1641 opticalcontrolmodeEnu,
1649 String query = Queries.getQuery().deviceRoadmConnectionsInsert().get();
1650 LOG.info("Running {} query ", query);
1651 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1652 for (int j = 0; j < parameters.length; j++) {
1653 stmt.setObject(j + 1, parameters[j]);
1656 stmt.clearParameters();
1657 } catch (SQLException e) {
1658 LOG.error("Something wrong when storing devices ROADM connection ", e);
1664 private void persistDevConnectionMap(String nodeId, Connection connection) {
1666 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1667 Optional<OrgOpenroadmDevice> deviceObject =
1668 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1669 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1670 if (!deviceObject.isPresent()) {
1671 LOG.error("No device found in operational datastore for node {}", nodeId);
1674 String startTimestamp = getCurrentTimestamp();
1676 Map<ConnectionMapKey, ConnectionMap> connectionsMap = deviceObject.get().nonnullConnectionMap();
1677 for (Map.Entry<ConnectionMapKey, ConnectionMap> entry : connectionsMap.entrySet()) {
1678 ConnectionMap connectionMap = entry.getValue();
1679 String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
1680 String sourceCircuitPackName = connectionMap.getSource().getCircuitPackName();
1681 String sourcePortName = connectionMap.getSource().getCircuitPackName();
1684 Object[] parameters = {nodeId,
1685 connectionMapNumber,
1686 sourceCircuitPackName,
1692 String query = Queries.getQuery().deviceConnectionMapInsert().get();
1693 LOG.info("Running {} query ", query);
1694 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1695 for (int j = 0; j < parameters.length; j++) {
1696 stmt.setObject(j + 1, parameters[j]);
1699 stmt.clearParameters();
1700 } catch (SQLException e) {
1701 LOG.error("Something wrong when storing devices connection map", e);
1707 private void persistDevWavelengthMap(String nodeId, Connection connection) {
1709 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1710 Optional<OrgOpenroadmDevice> deviceObject =
1711 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1712 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1713 if (!deviceObject.isPresent()) {
1714 LOG.error("No device found in operational datastore for node {}", nodeId);
1718 String startTimestamp = getCurrentTimestamp();
1720 Map<WavelengthsKey, Wavelengths> wavelengthsMap = deviceObject.get().getWavelengthMap().nonnullWavelengths();
1721 for (Map.Entry<WavelengthsKey, Wavelengths> entry : wavelengthsMap.entrySet()) {
1722 Wavelengths wavelengths = entry.getValue();
1723 String wavelengthNumber = wavelengths.getWavelengthNumber().toString();
1724 String centerFrequency = wavelengths.getCenterFrequency().toString();
1725 String wavelength = wavelengths.getWavelength().toString();
1728 Object[] parameters = {nodeId,
1736 String query = Queries.getQuery().deviceWavelengthInsert().get();
1737 LOG.info("Running {} query ", query);
1738 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1739 for (int j = 0; j < parameters.length; j++) {
1740 stmt.setObject(j + 1, parameters[j]);
1743 stmt.clearParameters();
1744 } catch (SQLException e) {
1745 LOG.error("Something wrong when storing devices wavelength map", e);
1752 private void persistDevInterfaceTcm(String nodeId, String interfaceName, OduBuilder oduBuilder,
1753 Connection connection) {
1755 Map<TcmKey, Tcm> tcmMap = oduBuilder.getTcm();
1756 for (Map.Entry<TcmKey, Tcm> entry : tcmMap.entrySet()) {
1757 Tcm tcm = entry.getValue();
1759 Object[] parameters = prepareDevInterfaceTcmParameters(nodeId, interfaceName, tcm);
1761 String query = Queries.getQuery().deviceInterfacesInsert().get();
1762 LOG.info("Running {} query ", query);
1763 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1764 for (int j = 0; j < parameters.length; j++) {
1765 stmt.setObject(j + 1, parameters[j]);
1768 stmt.clearParameters();
1769 } catch (SQLException e) {
1770 LOG.error("Something wrong when storing devices interface tcm", e);
1775 private void persistDevInterfaceOtnOduTxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1776 Connection connection) {
1778 Map<TxMsiKey, TxMsi> txMsiMap = oduBuilder.getOpu().getMsi().nonnullTxMsi();
1779 for (Map.Entry<TxMsiKey, TxMsi> entry : txMsiMap.entrySet()) {
1781 TxMsi txMsi = entry.getValue();
1783 Object[] parameters = prepareDevInterfaceOtnOduTxMsiParameters(nodeId, interfaceName, txMsi);
1785 String query = Queries.getQuery().deviceInterfaceOtnOduTxMsiInsert().get();
1786 LOG.info("Running {} query ", query);
1787 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1788 for (int j = 0; j < parameters.length; j++) {
1789 stmt.setObject(j + 1, parameters[j]);
1792 stmt.clearParameters();
1793 } catch (SQLException e) {
1794 LOG.error("Something wrong when storing devices interface OTN ODU Tx MSI", e);
1800 private void persistDevInterfaceOtnOduRxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1801 Connection connection) {
1802 Map<RxMsiKey, RxMsi> rxMsiMap = oduBuilder.getOpu().getMsi().nonnullRxMsi();
1803 for (Map.Entry<RxMsiKey, RxMsi> entry : rxMsiMap.entrySet()) {
1804 RxMsi rxMsi = entry.getValue();
1806 Object[] parameters = prepareDevInterfaceOtnOduRxMsiParameters(nodeId, interfaceName, rxMsi);
1808 String query = Queries.getQuery().deviceInterfaceOtnOduRxMsiInsert().get();
1809 LOG.info("Running {} query ", query);
1810 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1811 for (int j = 0; j < parameters.length; j++) {
1812 stmt.setObject(j + 1, parameters[j]);
1815 stmt.clearParameters();
1816 } catch (SQLException e) {
1817 LOG.error("Something wrong when storing devices interface OTN ODU Rx MSI", e);
1823 private void persistDevInterfaceOtnOduExpMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1824 Connection connection) {
1826 Map<ExpMsiKey, ExpMsi> expMsiMap = oduBuilder.getOpu().getMsi().nonnullExpMsi();
1827 for (Map.Entry<ExpMsiKey, ExpMsi> entry : expMsiMap.entrySet()) {
1828 ExpMsi expMsi = entry.getValue();
1830 Object[] parameters = prepareDevInterfaceOtnOduExpMsiParameters(nodeId, interfaceName, expMsi);
1832 String query = Queries.getQuery().deviceInterfaceOtnOduExpMsiInsert().get();
1833 LOG.info("Running {} query ", query);
1834 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1835 for (int j = 0; j < parameters.length; j++) {
1836 stmt.setObject(j + 1, parameters[j]);
1839 stmt.clearParameters();
1840 } catch (SQLException e) {
1841 LOG.error("Something wrong when storing devices interface OTN ODU Exp MSI", e);