2 * Copyright © 2016 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
8 package org.opendaylight.transportpce.inventory;
10 import static java.util.Objects.requireNonNull;
11 import static org.opendaylight.transportpce.inventory.utils.StringUtils.getCurrentTimestamp;
12 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareDashString;
13 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareEmptyString;
15 import java.sql.Connection;
16 import java.sql.PreparedStatement;
17 import java.sql.ResultSet;
18 import java.sql.SQLException;
19 import java.util.Optional;
20 import java.util.concurrent.ExecutionException;
21 import javax.sql.DataSource;
22 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
23 import org.opendaylight.transportpce.common.Timeouts;
24 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
25 import org.opendaylight.transportpce.inventory.query.Queries;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.CpSlots;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.external.links.ExternalLink;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.internal.links.InternalLink;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.ConnectionMap;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Degree;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Info;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Protocols;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.physical.links.PhysicalLink;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelf.Slots;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.shelves.Shelves;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.Interface1;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.ethernet.container.EthernetBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.Protocols1;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.PortConfig;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.nbr.list.IfName;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.och.container.OchBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.ots.container.OtsBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.attributes.Tcm;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.odu.container.OduBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.ExpMsi;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.RxMsi;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.opu.opu.msi.TxMsi;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.otu.container.OtuBuilder;
54 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
55 import org.slf4j.Logger;
56 import org.slf4j.LoggerFactory;
58 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
59 value = "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING",
60 justification = "TODO review the SQL statement generation process")
61 public class INode221 {
62 private static final Logger LOG = LoggerFactory.getLogger(INode221.class);
64 private final DataSource dataSource;
65 private final DeviceTransactionManager deviceTransactionManager;
67 public INode221(DataSource dataSource, DeviceTransactionManager deviceTransactionManager) {
68 this.dataSource = dataSource;
69 this.deviceTransactionManager = deviceTransactionManager;
72 public boolean addNode(String deviceId) {
74 InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
75 Optional<Info> infoOpt =
76 deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, infoIID,
77 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
79 if (infoOpt.isPresent()) {
80 deviceInfo = infoOpt.get();
82 LOG.warn("Could not get device info from DataBroker");
85 boolean sqlResult = false;
86 String query = Queries.getQuery().deviceInfoInsert().get();
87 LOG.info("Running {} query ", query);
88 try (Connection connection = dataSource.getConnection();
89 PreparedStatement preparedStatement = connection.prepareStatement(query)) {
90 Object[] prepareParameters = prepareDeviceInfoParameters(deviceInfo);
91 for (int i = 0; i < prepareParameters.length; i++) {
92 LOG.debug("Parameter {} has value {}", i + 1, prepareParameters[i]);
93 preparedStatement.setObject(i + 1, prepareParameters[i]);
96 int executeUpdate = preparedStatement.executeUpdate();
97 LOG.info("{} entries were added", executeUpdate);
100 LOG.info("iNode AddNode call complete");
101 getRoadmShelves(deviceId);
102 LOG.info("iNode getRoadmShelves call complete");
103 getCircuitPacks(deviceId);
104 LOG.debug("iNode getCircuitPacks call complete");
106 LOG.debug("iNode persist interfaces call");
107 persistDevInterfaces(deviceId, connection);
108 LOG.debug("iNode persist interfaces call complete");
110 LOG.debug("iNode persist interfaces call");
111 persistDevInterfaces(deviceId, connection);
112 LOG.debug("iNode persist interfaces call complete");
114 LOG.debug("iNode persist protocols call");
115 persistDevProtocols(deviceId, connection);
116 LOG.debug("iNode persist protocols call complete");
118 // LOG.debug("iNode persist wavelength map call");
119 // persistDevWavelengthMap(deviceId, connection);
120 // LOG.debug("iNode persist wavelength map call complete");
122 LOG.debug("iNode persist internal links map call");
123 persistDevInternalLinks(deviceId, connection);
124 LOG.debug("iNode persist internal links map call complete");
126 LOG.debug("iNode persist Physical links map call");
127 persistDevPhysicalLinks(deviceId, connection);
128 LOG.debug("iNode persist Physical links map call complete");
130 LOG.debug("iNode persist External links map call");
131 persistDevExternalLinks(deviceId, connection);
132 LOG.debug("iNode persist External links map call complete");
134 LOG.debug("iNode persist degree map call");
135 persistDevDegree(deviceId, connection);
136 LOG.debug("iNode persist degree map call complete");
138 LOG.debug("iNode persist srg map call");
139 persistDevSrg(deviceId, connection);
140 LOG.debug("iNode persist srg map call complete");
142 LOG.debug("iNode persist Roadm Connections call");
143 persistDevRoadmConnections(deviceId, connection);
144 LOG.debug("iNode persist Roadm Connections call complete");
146 LOG.debug("iNode persist Connection Map call");
147 persistDevConnectionMap(deviceId, connection);
148 LOG.debug("iNode persist Connection Map call complete");
150 } catch (SQLException | InterruptedException | ExecutionException e) {
151 LOG.error("Something wrong when storing node into DB", e);
156 public boolean nodeExists(String nodeId) {
157 String selectTableSQL = "select count(*) node_exists from inv_dev_info where node_id = ?";
159 LOG.info("Checking if {} exists in DB", nodeId);
160 try (Connection connection = dataSource.getConnection();
161 PreparedStatement preparedStmt = connection.prepareStatement(selectTableSQL)) {
162 preparedStmt.setString(1, nodeId);
163 try (ResultSet rs = preparedStmt.executeQuery()) {
165 nodeExists = rs.getInt("node_exists");
166 LOG.debug("Found {} devices matching {}", nodeExists, nodeId);
169 } catch (SQLException e) {
170 LOG.error("Something wrong when fetching node in DB", e);
172 return nodeExists == 0 ? false : true;
175 public void getRoadmShelves(String nodeId) throws InterruptedException, ExecutionException {
176 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
177 Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
178 LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT,
179 Timeouts.DEVICE_READ_TIMEOUT_UNIT);
181 LOG.info("Shelves size {}", deviceObject.get().getShelves().size());
182 try (Connection connection = requireNonNull(dataSource.getConnection())) {
183 for (int i = 0; i < deviceObject.get().getShelves().size(); i++) {
184 Shelves shelve = deviceObject.get().getShelves().get(i);
185 String shelfName = shelve.getShelfName();
187 LOG.info("Getting Shelve Details of {}", shelfName);
188 if (shelve.getSlots() != null) {
189 LOG.info("Slot Size {} ", shelve.getSlots().size());
190 persistShelveSlots(nodeId, shelve, connection);
192 LOG.info("No Slots for shelf {}", shelfName);
196 persistShelves(nodeId, connection, shelve);
198 } catch (SQLException e1) {
199 LOG.error("Something wrong when fetching ROADM shelves in DB", e1);
203 public void getCircuitPacks(String nodeId) throws InterruptedException, ExecutionException {
204 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
205 Optional<OrgOpenroadmDevice> deviceObject =
206 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
207 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
208 if (!deviceObject.isPresent()) {
209 LOG.warn("Device object {} was not found", nodeId);
212 LOG.info("Circuit pack size {}", deviceObject.get().getCircuitPacks().size());
214 try (Connection connection = requireNonNull(dataSource.getConnection())) {
215 for (int i = 0; i < deviceObject.get().getCircuitPacks().size(); i++) {
216 CircuitPacks cp = deviceObject.get().getCircuitPacks().get(i);
218 if (cp.getCpSlots() != null) {
219 persistCircuitPacksSlots(nodeId, cp, connection);
221 LOG.info("Everything {}", cp);
222 LOG.info("CP is {}", cp);
224 persistPorts(cp, connection);
226 persistCircuitPacks(nodeId, connection, cp);
228 } catch (SQLException e1) {
229 LOG.error("Something wrong when fetching Circuit Packs in DB", e1);
233 private void persistCircuitPacks(String nodeId, Connection connection, CircuitPacks cp) {
234 Object[] parameters = prepareCircuitPacksParameters(nodeId, cp);
235 String query = Queries.getQuery().deviceCircuitPackInsert().get();
236 LOG.info("Running {} query ", query);
237 try (PreparedStatement stmt = connection.prepareStatement(query)) {
238 for (int j = 0; j < parameters.length; j++) {
239 stmt.setObject(j + 1, parameters[j]);
242 stmt.clearParameters();
243 } catch (SQLException e) {
244 LOG.error("Something wrong when storing Circuit Packs in DB", e);
248 private void persistShelves(String nodeId, Connection connection, Shelves shelve) {
249 Object[] shelvesParameter = prepareShelvesParameters(nodeId, shelve);
250 String query = Queries.getQuery().deviceShelfInsert().get();
251 LOG.info("Running {} query ", query);
252 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
253 for (int j = 0; j < shelvesParameter.length; j++) {
254 preparedStmt.setObject(j + 1, shelvesParameter[j]);
256 preparedStmt.execute();
257 preparedStmt.clearParameters();
258 } catch (SQLException e) {
259 LOG.error("Something wrong when storing shelves in DB", e);
263 private void persistShelveSlots(String nodeId, Shelves shelves, Connection connection) {
264 String startTimetampStr = getCurrentTimestamp();
265 for (int i = 0; i < shelves.getSlots().size(); i++) {
266 Slots slot = shelves.getSlots().get(i);
267 LOG.info("Getting Slot Details of {}", slot.getSlotName());
268 Object[] parameters = new Object[]{nodeId,
269 shelves.getShelfName(),
272 slot.getProvisionedCircuitPack(),
276 String query = Queries.getQuery().deviceShelfSlotInsert().get();
277 LOG.info("Running {} query ", query);
278 try (PreparedStatement stmt = connection.prepareStatement(query)) {
279 for (int j = 0; j < parameters.length; j++) {
280 stmt.setObject(j + 1, parameters[j]);
283 stmt.clearParameters();
284 } catch (SQLException e) {
285 LOG.error("Something wrong when storing shelves slots in DB", e);
291 private void persistCircuitPacksSlots(String nodeId, CircuitPacks circuitPacks, Connection connection) {
292 String startTimetampStr = getCurrentTimestamp();
293 for (int i = 0; i < circuitPacks.getCpSlots().size(); i++) {
294 CpSlots cpSlot = circuitPacks.getCpSlots().get(i);
296 Object[] parameters = new Object[]{nodeId,
297 circuitPacks.getCircuitPackName(),
298 cpSlot.getSlotName(),
300 cpSlot.getProvisionedCircuitPack(),
304 String query = Queries.getQuery().deviceCPSlotInsert().get();
305 LOG.info("Running {} query ", query);
306 try (PreparedStatement stmt = connection.prepareStatement(query)) {
307 for (int j = 0; j < parameters.length; j++) {
308 stmt.setObject(j + 1, parameters[j]);
311 stmt.clearParameters();
312 } catch (SQLException e) {
313 LOG.error("Something wrong when storing Cirtcuits Packs slots in DB", e);
318 private void persistPorts(CircuitPacks circuitPacks, Connection connection) {
319 LOG.warn("Ports are not persisted yet");
324 * Prepares parameters for device insert query.
326 * @param deviceInfo device info
327 * @return Object Object
329 private static Object[] prepareDeviceInfoParameters(Info deviceInfo) {
330 String startTimetampStr = getCurrentTimestamp();
331 //Integer maxNumBin15minHistoricalPm = null;
332 //Integer maxNumBin24hourHistoricalPm = null;
333 //String serialId = "";
335 String nodeId = prepareDashString(deviceInfo.getNodeId());
336 Long nodeNumber = deviceInfo.getNodeNumber().toJava();
337 Integer nodeTypeEnu = deviceInfo.getNodeType().getIntValue();
338 String clli = prepareDashString(deviceInfo.getClli());
339 String vendor = prepareDashString(deviceInfo.getVendor());
340 String model = prepareDashString(deviceInfo.getModel());
341 String ipAddress = prepareDashString(deviceInfo.getIpAddress().getIpv4Address().getValue());
342 String prefixLength = prepareDashString(deviceInfo.getPrefixLength());
343 String defaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
344 Integer sourceEnum = deviceInfo.getSource().getIntValue();
345 String currentIpAddress = prepareDashString(deviceInfo.getCurrentIpAddress().getIpv4Address().getValue());
346 String currentPrefixLength = prepareDashString(deviceInfo.getCurrentPrefixLength());
347 String currentDefaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
348 String macAddress = prepareDashString(deviceInfo.getMacAddress().getValue());
349 String softwareVersion = prepareDashString(deviceInfo.getSoftwareVersion());
350 String openroadmVersion = "2.2.1";
351 String template = prepareDashString(deviceInfo.getTemplate());
352 String currentDatetime = prepareDashString(deviceInfo.getCurrentDatetime().getValue());
354 (deviceInfo.getGeoLocation() != null ? prepareDashString(deviceInfo.getGeoLocation().getLatitude()) : "");
355 String geoLongitude =
356 (deviceInfo.getGeoLocation() != null ? prepareDashString(deviceInfo.getGeoLocation().getLongitude()) : "");
357 String maxDegrees = prepareDashString(deviceInfo.getMaxDegrees()); // max_degrees
358 String maxSrgs = prepareDashString(deviceInfo.getMaxSrgs()); //max_srgs
359 String swVersion = prepareDashString(deviceInfo.getSoftwareVersion()); //sw_version
360 String swValidationTimer = prepareDashString(""); //sw_validation_timer
361 String activationDateTime = prepareDashString(""); //activation_date_time
362 /*jsonDevInfo = JsonStringBuilder.getDevInfoJson().replace("$$NODE-ID$$",nodeId)
363 .replace("$$NODE-NUMBER$$", nodeNumber)
364 .replace("$$NODE-TYPE$$",nodeType)
365 .replace("$$CLLI$$",clli)
366 .replace("$$VENDOR$$",vendor)
367 .replace("$$MODEL$$",model)
368 .replace("$$SERIAL-ID$$",serialId)
369 .replace("$$IPADDRESS$$",ipAddress)
370 .replace("$$PREFIX-LENGTH$$",prefixLength)
371 .replace("$$DEFAULTGATEWAY$$",defaultGateway)
372 .replace("$$SOURCE$$",String.valueOf(source))
373 .replace("$$CURRENT-IPADDRESS$$",currentIpAddress)
374 .replace("$$CURRENT-PREFIX-LENGTH$$",currentPrefixLength)
375 .replace("$$CURRENT-DEFAULTGATEWAY$$",currentDefailtGateway)
376 .replace("$$MACADDRESS$$",macAddress)
377 .replace("$$SOFTWAREVERSION$$",softwareVersion)
378 .replace("$$OPENROADM-VERSION$$",openroadmVersion)
379 .replace("$$TEMPLATE$$",template)
380 .replace("$$CURRENT-DATETIME$$",currentDatetime)
381 .replace("$$LATITUDE$$",latitude)
382 .replace("$$LONGITUDE$$",longitude)
383 .replace("$$MAX-DEGREES$$",maxDegrees)
384 .replace("$$MAX-SRGS$$",maxSrgs)
385 .replace("$$MAX-NUM-BIN-15MIN-HISTORICAL-PM$$",prepareDashString(""))
386 .replace("$$MAX-NUM-BIN-24HOUR-HISTORICAL-PM$$",prepareDashString(""))
387 .replace("$$SW-VERSION$$",swVersion)
388 .replace("$$SW-VALIDATION-TIMER$$",swValidationTimer)
389 .replace("$$ACTIVATION-DATE-TIME$$",activationDateTime);*/
407 currentDefaultGateway,
417 //maxNumBin15minHistoricalPm,
418 //maxNumBin24hourHistoricalPm,
429 private static Object[] prepareShelvesParameters(String nodeId, Shelves shelve) {
430 String startTimestamp = getCurrentTimestamp();
432 return new Object[]{nodeId,
433 shelve.getShelfName(),
434 shelve.getShelfType(),
436 shelve.getShelfPosition(),
437 (shelve.getAdministrativeState() == null ? null : shelve.getAdministrativeState().getIntValue()),
440 shelve.getSerialId(),
442 shelve.getProductCode(),
443 (shelve.getManufactureDate() == null ? null : shelve.getManufactureDate().getValue()),
445 shelve.getHardwareVersion(),
446 (shelve.getOperationalState() == null ? null : shelve.getOperationalState().getIntValue()),
447 (shelve.getEquipmentState() == null ? null : shelve.getEquipmentState().getIntValue()),
448 (shelve.getDueDate() == null ? null : shelve.getDueDate().getValue()),
453 private static Object[] prepareCircuitPacksParameters(String nodeId, CircuitPacks cpack) {
454 String startTimestamp = getCurrentTimestamp();
455 return new Object[]{nodeId,
456 cpack.getCircuitPackName(),
457 cpack.getCircuitPackType(),
458 cpack.getCircuitPackProductCode(),
459 (cpack.getAdministrativeState() == null ? "" : cpack.getAdministrativeState().getIntValue()),
464 cpack.getProductCode(),
465 (cpack.getManufactureDate() == null ? "" : cpack.getManufactureDate().getValue()),
467 cpack.getHardwareVersion(),
468 prepareEmptyString(cpack.getOperationalState().getIntValue()),
469 cpack.getCircuitPackCategory().getType().getName(),
470 cpack.getCircuitPackCategory().getExtension(),
471 (cpack.getEquipmentState() == null ? "" : cpack.getEquipmentState().getIntValue()),
472 cpack.getCircuitPackMode(),
476 prepareEmptyString(cpack.getDueDate()),
477 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
478 ((cpack.getParentCircuitPack().getCircuitPackName() == null) ? "" :
479 cpack.getParentCircuitPack().getCircuitPackName())
481 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
482 ((cpack.getParentCircuitPack().getCpSlotName() == null) ? "" :
483 cpack.getParentCircuitPack().getCpSlotName())
489 private Object[] prepareDevInterfaceParameters(String nodeId, Interface deviceInterface, Connection connection) {
491 int administrativeStateEnu = deviceInterface.getAdministrativeState().getIntValue();
492 int operationalState = deviceInterface.getOperationalState().getIntValue();
493 int ethernetDuplexEnu = -1;
494 int ethernetAutoNegotiationEnu = -1;
495 int maintTestsignalTestpatternEnu = -1;
496 int maintTestsignalTypeEnu = -1;
498 int otuMaintTypeEnu = -1;
499 //int otsFiberTypeEnu = -1;
500 String name = deviceInterface.getName();
501 String description = deviceInterface.getDescription();
502 String type = deviceInterface.getType().getTypeName();
503 String circuitId = deviceInterface.getCircuitId();
504 String supportingInterface = deviceInterface.getSupportingInterface();
505 String supportingCircuitPackName = deviceInterface.getSupportingCircuitPackName();
506 String supportingPort = deviceInterface.getSupportingPort().toString();
507 String ethernetSpeed = "";
508 String ethernetFec = "";
509 String ethernetMtu = "";
510 String ethernetCurrSpeed = "";
511 String ethernetCurrDuplex = "";
512 //String mciMcttpMinFreq = "";
513 //String mciMcttpMaxFreq = "";
514 //String mciMcttpCenterFreq = "";
515 //String mciMcttpSlotWidth = "";
516 //String mciNmcCtpFrequency = "";
517 //String mciNmcCtpWidth = "";
519 //String ochFrequency = "";
520 //String ochWidth = "";
521 //String ochWavelengthNumber = "";
522 String ochModulationFormat = "";
523 String ochTransmitPower = "";
524 String otsSpanLossReceive = "";
525 String otsSpanLossTransmit = "";
526 //String otsIngressSpanLossAgingMargin = "";
527 //String otsEolMaxLoadPin = "";
528 String oduRate = ""; //BUG in following case switch statement ???
529 //String oduFunction = "";
530 String oduMonitoringMode = "";
531 //String oduNoOamFunction = "";
532 String oduProactiveDelayMeasurementEnabled = "";
533 //String oduPoaTribPortNumber = "";
534 //String oduTxSapi = "";
535 //String oduTxDapi = "";
536 //String oduTxOperator = "";
537 //String oduAcceptedSapi = "";
538 //String oduAcceptedDapi = "";
539 //String oduAcceptedOperator = "";
540 //String oduExpectedSapi = "";
541 //String oduExpectedDapi = "";
542 //String oduTimActEnabled = "";
543 //String oduTimDetectMode = "";
544 //String oduDegmIntervals = "";
545 //String oduDegthrPercentage = "";
546 String opuPayloadType = "";
547 String opuRxPayloadType = "";
548 String opuExpPayloadType = "";
549 String opuPayloadInterface = "";
550 String maintTestsignalEnabled = "";
551 String maintTestsignalBiterrors = "";
552 String maintTestsignalBiterrorsterminal = "";
553 String maintTestsignalSyncseconds = "";
554 String maintTestsignalSyncsecondsterminal = "";
556 //String otuTxSapi = "";
557 //String otuTxDapi = "";
558 //String otuTxOperator = "";
559 //String otuAcceptedSapi = "";
560 //String otuAcceptedDapi = "";
561 //String otuAcceptedOperator = "";
562 //String otuExpectedSapi = "";
563 //String otuExpectedDapi = "";
564 //String otuTimActEnabled = "";
565 //String otuTimDetectMode = "";
566 //String otuDegmIntervals = "";
567 //String otuDegthrPercentage = "";
568 String otuMaintLoopbackEnabled = "";
569 //String mtOtuRate = "";
570 //String mtOtuFec = "";
571 //String mtOtuMaintLoopback = "";
572 //String mtOtuEnabled = "";
573 //String mtOtuType = "";
575 switch (deviceInterface.getType().toString()) {
578 //EthernetBuilder ethIfBuilder = new EthernetBuilder();
579 EthernetBuilder ethIfBuilder =
580 new EthernetBuilder(deviceInterface.augmentation(Interface1.class).getEthernet());
581 ethernetSpeed = ethIfBuilder.getSpeed().toString();
582 ethernetFec = ethIfBuilder.getFec().getName();
583 ethernetDuplexEnu = ethIfBuilder.getDuplex().getIntValue();
584 ethernetMtu = ethIfBuilder.getMtu().toString();
585 ethernetAutoNegotiationEnu = ethIfBuilder.getAutoNegotiation().getIntValue();
586 ethernetCurrSpeed = ethIfBuilder.getCurrSpeed();
587 ethernetCurrDuplex = ethIfBuilder.getCurrDuplex();
591 OchBuilder ochIfBuilder = new OchBuilder(deviceInterface.augmentation(
592 org.opendaylight.yang.gen.v1
593 .http.org.openroadm.optical.channel.interfaces.rev161014.Interface1.class)
595 ochRate = ochIfBuilder.getRate().getName();
596 //ochWavelengthNumber = ochIfBuilder.getWavelengthNumber().toString();
597 ochModulationFormat = ochIfBuilder.getModulationFormat().getName();
598 ochTransmitPower = ochIfBuilder.getTransmitPower().toString();
602 OtsBuilder otsIfBuilder = new OtsBuilder(deviceInterface.augmentation(
603 org.opendaylight.yang.gen.v1
604 .http.org.openroadm.optical.transport.interfaces.rev161014.Interface1.class)
606 //otsFiberTypeEnu = otsIfBuilder.getFiberType().getIntValue();
607 otsSpanLossReceive = otsIfBuilder.getSpanLossReceive().toString();
608 otsSpanLossTransmit = otsIfBuilder.getSpanLossTransmit().toString();
612 OduBuilder oduIfBuilder = new OduBuilder(deviceInterface.augmentation(
613 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1.class)
615 oduRate = String.valueOf(oduIfBuilder.getRate());
616 oduMonitoringMode = oduIfBuilder.getMonitoringMode().getName();
617 oduProactiveDelayMeasurementEnabled = oduIfBuilder.isProactiveDelayMeasurementEnabled().toString();
619 persistDevInterfaceTcm(nodeId, name, oduIfBuilder, connection);
620 persistDevInterfaceOtnOduTxMsi(nodeId, name, oduIfBuilder, connection);
621 persistDevInterfaceOtnOduRxMsi(nodeId, name, oduIfBuilder, connection);
622 persistDevInterfaceOtnOduExpMsi(nodeId, name, oduIfBuilder, connection);
624 opuPayloadType = oduIfBuilder.getOpu().getPayloadType();
625 opuRxPayloadType = oduIfBuilder.getOpu().getRxPayloadType();
626 opuExpPayloadType = oduIfBuilder.getOpu().getExpPayloadType();
627 opuPayloadInterface = oduIfBuilder.getOpu().getPayloadInterface();
628 /*persistDevInterfaceOtnOduTxMsi(nodeId,name,oduIfBuilder,connection);
629 persistDevInterfaceOtnOduRxMsi(nodeId,name,oduIfBuilder,connection);
630 persistDevInterfaceOtnOduExpMsi(nodeId,name,oduIfBuilder,connection); */
631 maintTestsignalEnabled = oduIfBuilder.getMaintTestsignal().isEnabled().toString();
632 maintTestsignalTestpatternEnu = oduIfBuilder.getMaintTestsignal().getTestPattern().getIntValue();
633 maintTestsignalTypeEnu = oduIfBuilder.getMaintTestsignal().getType().getIntValue();
634 maintTestsignalBiterrors = oduIfBuilder.getMaintTestsignal().getBitErrors().toString();
635 maintTestsignalBiterrorsterminal = oduIfBuilder.getMaintTestsignal().getBitErrorsTerminal().toString();
636 maintTestsignalSyncseconds = oduIfBuilder.getMaintTestsignal().getSyncSeconds();
637 maintTestsignalSyncsecondsterminal = oduIfBuilder.getMaintTestsignal().getSyncSecondsTerminal();
641 OtuBuilder otuIfBuilder = new OtuBuilder(deviceInterface.augmentation(
642 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1.class)
644 otuRate = otuIfBuilder.getRate().getName();
645 otuFecEnu = otuIfBuilder.getFec().getIntValue();
646 otuMaintLoopbackEnabled = otuIfBuilder.getMaintLoopback().isEnabled().toString();
647 otuMaintTypeEnu = otuIfBuilder.getMaintLoopback().getType().getIntValue();
651 LOG.error("Could not get interface type");
654 String startTimestamp = getCurrentTimestamp();
656 return new Object[]{nodeId,
660 Integer.toString(administrativeStateEnu),
661 Integer.toString(operationalState),
664 supportingCircuitPackName,
668 Integer.toString(ethernetDuplexEnu),
670 Integer.toString(ethernetAutoNegotiationEnu),
675 //mciMcttpCenterFreq,
677 //mciNmcCtpFrequency,
679 "", "", "", "", "", "",
683 //ochWavelengthNumber,
687 //Integer.toString(otsFiberTypeEnu),
691 //otsIngressSpanLossAgingMargin,
700 oduProactiveDelayMeasurementEnabled,
701 //oduPoaTribPortNumber,
707 //oduAcceptedOperator,
713 //oduDegthrPercentage,
714 "", "", "", "", "", "", "", "", "", "", "", "", "",
719 maintTestsignalEnabled,
720 Integer.toString(maintTestsignalTestpatternEnu),
721 Integer.toString(maintTestsignalTypeEnu),
722 maintTestsignalBiterrors,
723 maintTestsignalBiterrorsterminal,
724 maintTestsignalSyncseconds,
725 maintTestsignalSyncsecondsterminal,
727 Integer.toString(otuFecEnu),
733 //otuAcceptedOperator,
739 //otuDegthrPercentage,
740 "", "", "", "", "", "", "", "", "", "", "", "",
741 otuMaintLoopbackEnabled,
742 Integer.toString(otuMaintTypeEnu),
745 //mtOtuMaintLoopback,
755 private static Object[] prepareDevInterfaceTcmParameters(String nodeId, String interfaceName, Tcm tcm) {
758 String layer = tcm.getLayer().toString();
759 int monitoringModeEnu = tcm.getMonitoringMode().getIntValue();
760 String ltcActEnabled = tcm.isLtcActEnabled().toString();
761 String proactiveDelayMeasurementEnabled = tcm.isProactiveDelayMeasurementEnabled().toString();
762 //int tcmDirectionEnu = -1;
763 //int timDetectModeEnu = -1;
764 //String txSapi = "";
765 //String txDapi = "";
766 //String txOperator = "";
767 //String acceptedSapi = "";
768 //String acceptedDapi = "";
769 //String acceptedOperator = "";
770 //String expectedSapi = "";
771 //String expectedDapi = "";
772 //String timActEnabled = "";
773 //String degmIntervals = "";
774 //String degthrPercentage = "";
776 String startTimestamp = getCurrentTimestamp();
778 return new Object[]{nodeId,
781 Integer.toString(monitoringModeEnu),
783 proactiveDelayMeasurementEnabled,
784 //Integer.toString(tcmDirectionEnu),
795 "", "", "", "", "", "", "", "", "",
796 //Integer.toString(timDetectModeEnu),
806 private static Object[] prepareDevInterfaceOtnOduTxMsiParameters(String nodeId, String interfaceName, TxMsi txMsi) {
808 String tribSlot = txMsi.getTribSlot().toString();
809 String odtuType = txMsi.getOdtuType().getTypeName();
810 String tribPort = txMsi.getTribPort().toString();
811 String tribPortPayload = txMsi.getTribPortPayload();
813 String startTimestamp = getCurrentTimestamp();
815 return new Object[]{nodeId,
827 private static Object[] prepareDevInterfaceOtnOduRxMsiParameters(String nodeId, String interfaceName, RxMsi rxMsi) {
829 String tribSlot = rxMsi.getTribSlot().toString();
830 String odtuType = rxMsi.getOdtuType().getTypeName();
831 String tribPort = rxMsi.getTribPort().toString();
832 String tribPortPayload = rxMsi.getTribPortPayload();
834 String startTimestamp = getCurrentTimestamp();
836 return new Object[]{nodeId,
849 private static Object[] prepareDevInterfaceOtnOduExpMsiParameters(String nodeId, String interfaceName,
852 String tribSlot = expMsi.getTribSlot().toString();
853 String odtuType = expMsi.getOdtuType().getTypeName();
854 String tribPort = expMsi.getTribPort().toString();
855 String tribPortPayload = expMsi.getTribPortPayload();
857 String startTimestamp = getCurrentTimestamp();
859 return new Object[]{nodeId,
871 private void persistDevInterfaces(String nodeId, Connection connection) {
873 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
874 Optional<OrgOpenroadmDevice> deviceObject =
875 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
876 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
878 /*InstanceIdentifier<Interface> interfaceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
879 .child(Interface.class);
880 Optional<Interface> interfaceOpt =
881 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, interfaceIID,
882 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); */
884 for (int i = 0; i < deviceObject.get().getInterface().size(); i++) {
885 Interface deviceInterface;
887 deviceInterface = deviceObject.get().getInterface().get(i);
888 /*if (interfaceOpt.isPresent()) {
889 deviceInterface = interfaceOpt.get();
891 LOG.warn("Could not get interface info");
894 Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
896 String query = Queries.getQuery().deviceInterfacesInsert().get();
897 LOG.info("Running {} query ", query);
898 try (PreparedStatement stmt = connection.prepareStatement(query)) {
899 for (int j = 0; j < parameters.length; j++) {
900 stmt.setObject(j + 1, parameters[j]);
903 stmt.clearParameters();
904 } catch (SQLException e) {
905 LOG.error("Something wrong when storing devices interfaces in DB", e);
910 private void persistDevProtocols(String nodeId, Connection connection) {
912 InstanceIdentifier<Protocols> protocolsIID =
913 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
914 Optional<Protocols> protocolObject =
915 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
916 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
917 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
918 LOG.error("LLDP subtree is missing");
922 protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getAdminStatus()
924 String msgTxtInterval =
925 protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getMsgTxInterval()
927 String mxgTxHoldMultiplier =
928 protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getMsgTxHoldMultiplier()
930 String startTimestamp = getCurrentTimestamp();
931 persistDevProtocolLldpPortConfig(nodeId, connection);
932 persistDevProtocolLldpNbrList(nodeId, connection);
934 Object[] parameters = {nodeId,
935 Integer.toString(adminstatusEnu),
942 String query = Queries.getQuery().deviceProtocolInsert().get();
943 LOG.info("Running {} query ", query);
944 try (PreparedStatement stmt = connection.prepareStatement(query)) {
945 for (int j = 0; j < parameters.length; j++) {
946 stmt.setObject(j + 1, parameters[j]);
949 stmt.clearParameters();
950 } catch (SQLException e) {
951 LOG.error("Something wrong when storing devices protocols in DB", e);
957 private void persistDevProtocolLldpPortConfig(String nodeId, Connection connection) {
959 InstanceIdentifier<Protocols> protocolsIID =
960 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
961 Optional<Protocols> protocolObject =
962 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
963 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
964 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
965 LOG.error("LLDP subtree is missing");
968 String startTimestamp = getCurrentTimestamp();
969 for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().size(); i++) {
971 PortConfig portConfig =
972 protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().get(i);
973 String ifName = portConfig.getIfName();
974 int adminStatusEnu = portConfig.getAdminStatus().getIntValue();
976 Object[] parameters = {nodeId,
978 Integer.toString(adminStatusEnu),
983 String query = Queries.getQuery().deviceProtocolPortConfigInsert().get();
984 LOG.info("Running {} query ", query);
985 try (PreparedStatement stmt = connection.prepareStatement(query)) {
986 for (int j = 0; j < parameters.length; j++) {
987 stmt.setObject(j + 1, parameters[j]);
990 stmt.clearParameters();
991 } catch (SQLException e) {
992 LOG.error("Something wrong when storing devices protocols LLDP Port config in DB", e);
999 private void persistDevProtocolLldpNbrList(String nodeId, Connection connection) {
1001 InstanceIdentifier<Protocols> protocolsIID =
1002 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1003 Optional<Protocols> protocolObject =
1004 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1005 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1006 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1007 LOG.error("LLDP subtree is missing");
1010 String startTimestamp = getCurrentTimestamp();
1011 for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().getIfName()
1015 protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().getIfName().get(i);
1016 String ifName = ifNameObj.getIfName();
1017 String remotesysname = ifNameObj.getRemoteSysName();
1018 String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
1019 String remotemgmtaddress = ifNameObj.getRemoteMgmtAddress().getIpv4Address().toString();
1020 int remoteportidsubtypeEnu = ifNameObj.getRemotePortIdSubType().getIntValue();
1021 String remoteportid = ifNameObj.getRemotePortId();
1022 int remotechassisidsubtypeEnu = ifNameObj.getRemoteChassisIdSubType().getIntValue();
1023 String remotechassisid = ifNameObj.getRemoteChassisId();
1025 Object[] parameters = {nodeId,
1028 remotemgmtaddresssubtype,
1030 Integer.toString(remoteportidsubtypeEnu),
1032 Integer.toString(remotechassisidsubtypeEnu),
1038 String query = Queries.getQuery().deviceProtocolLldpNbrlistInsert().get();
1039 LOG.info("Running {} query ", query);
1040 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1041 for (int j = 0; j < parameters.length; j++) {
1042 stmt.setObject(j + 1, parameters[j]);
1045 stmt.clearParameters();
1046 } catch (SQLException e) {
1047 LOG.error("Something wrong when storing devices protocols LLDP list number in DB", e);
1053 private void persistDevInternalLinks(String nodeId, Connection connection) {
1055 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1056 Optional<OrgOpenroadmDevice> deviceObject =
1057 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1058 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1060 String startTimestamp = getCurrentTimestamp();
1061 for (int i = 0; i < deviceObject.get().getInternalLink().size(); i++) {
1062 InternalLink internalLink = deviceObject.get().getInternalLink().get(i);
1063 String internalLinkName = internalLink.getInternalLinkName();
1064 String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
1065 String sourcePortName = internalLink.getSource().getPortName().toString();
1066 String destinationCircuitPackName = internalLink.getDestination().getCircuitPackName();
1067 String destinationPortName = internalLink.getDestination().getPortName().toString();
1069 Object[] parameters = {nodeId,
1071 sourceCircuitPackName,
1073 destinationCircuitPackName,
1074 destinationPortName,
1079 String query = Queries.getQuery().deviceInternalLinkInsert().get();
1080 LOG.info("Running {} query ", query);
1081 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1082 for (int j = 0; j < parameters.length; j++) {
1083 stmt.setObject(j + 1, parameters[j]);
1086 stmt.clearParameters();
1087 } catch (SQLException e) {
1088 LOG.error("Something wrong when storing devices internal links", e);
1095 private void persistDevExternalLinks(String nodeId, Connection connection) {
1097 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1098 Optional<OrgOpenroadmDevice> deviceObject =
1099 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1100 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1102 String startTimestamp = getCurrentTimestamp();
1103 for (int i = 0; i < deviceObject.get().getExternalLink().size(); i++) {
1104 ExternalLink externalLink = deviceObject.get().getExternalLink().get(i);
1105 String externalLinkName = externalLink.getExternalLinkName();
1106 String sourceNodeId = externalLink.getSource().getNodeId();
1107 String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
1108 String sourcePortName = externalLink.getSource().getPortName();
1109 String destinationNodeId = externalLink.getDestination().getNodeId();
1110 String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
1111 String destinationPortName = externalLink.getDestination().getPortName();
1113 Object[] parameters = {nodeId,
1116 sourceCircuitPackName,
1119 destinationCircuitPackName,
1120 destinationPortName,
1125 String query = Queries.getQuery().deviceExternalLinkInsert().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 external links", e);
1140 private void persistDevPhysicalLinks(String nodeId, Connection connection) {
1142 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1143 Optional<OrgOpenroadmDevice> deviceObject =
1144 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1145 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1147 String startTimestamp = getCurrentTimestamp();
1148 for (int i = 0; i < deviceObject.get().getPhysicalLink().size(); i++) {
1149 PhysicalLink physicalLink = deviceObject.get().getPhysicalLink().get(i);
1150 String physicalLinkName = physicalLink.getPhysicalLinkName();
1151 String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
1152 String sourcePortName = physicalLink.getSource().getPortName().toString();
1153 String destinationCircuitPackName = physicalLink.getDestination().getCircuitPackName();
1154 String destinationPortName = physicalLink.getDestination().getPortName().toString();
1156 Object[] parameters = {nodeId,
1158 sourceCircuitPackName,
1160 destinationCircuitPackName,
1161 destinationPortName,
1166 String query = Queries.getQuery().devicePhysicalLinkInsert().get();
1167 LOG.info("Running {} query ", query);
1168 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1169 for (int j = 0; j < parameters.length; j++) {
1170 stmt.setObject(j + 1, parameters[j]);
1173 stmt.clearParameters();
1174 } catch (SQLException e) {
1175 LOG.error("Something wrong when storing devices physical links", e);
1181 private void persistDevDegree(String nodeId, Connection connection) {
1183 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1184 Optional<OrgOpenroadmDevice> deviceObject =
1185 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1186 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1188 String startTimestamp = getCurrentTimestamp();
1189 for (int i = 0; i < deviceObject.get().getDegree().size(); i++) {
1190 Degree degree = deviceObject.get().getDegree().get(i);
1191 String degreeNumber = degree.getDegreeNumber().toString();
1192 String maxWavelengths = degree.getMaxWavelengths().toString();
1193 String otdrPortCircuitPackName = degree.getOtdrPort().getCircuitPackName();
1194 String otdrPortPortName = degree.getOtdrPort().getPortName().toString();
1195 persistDevDegreeCircuitPack(nodeId, degree, degreeNumber, connection);
1196 persistDevDegreeConnectionPort(nodeId, degree, degreeNumber, connection);
1197 //String mcCapabilitiesSlotWidthGranularity = "";
1198 //String mcCapabilitiesCenterFreqGranularity = "";
1199 //String mcCapabilitiesMinSlots = "";
1200 //String mcCapabilitiesMaxSlots = "";
1202 Object[] parameters = {nodeId,
1205 otdrPortCircuitPackName,
1207 //mcCapabilitiesSlotWidthGranularity,
1208 //mcCapabilitiesCenterFreqGranularity,
1209 //mcCapabilitiesMinSlots,
1210 //mcCapabilitiesMaxSlots,
1216 String query = Queries.getQuery().deviceDegreeInsert().get();
1217 LOG.info("Running {} query ", query);
1218 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1219 for (int j = 0; j < parameters.length; j++) {
1220 stmt.setObject(j + 1, parameters[j]);
1223 stmt.clearParameters();
1224 } catch (SQLException e) {
1225 LOG.error("Something wrong when storing devices degrees", e);
1232 private void persistDevDegreeCircuitPack(String nodeId, Degree degree, String degreeNumber, Connection connection) {
1234 String startTimestamp = getCurrentTimestamp();
1235 for (int i = 0; i < degree.getCircuitPacks().size(); i++) {
1237 String circuitPackIndex = degree.getCircuitPacks().get(i).getIndex().toString();
1238 String circuitPackName = degree.getCircuitPacks().get(i).getCircuitPackName();
1240 Object[] parameters = {nodeId,
1248 String query = Queries.getQuery().deviceDegreeCircuitPackInsert().get();
1249 LOG.info("Running {} query ", query);
1250 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1251 for (int j = 0; j < parameters.length; j++) {
1252 stmt.setObject(j + 1, parameters[j]);
1255 stmt.clearParameters();
1256 } catch (SQLException e) {
1257 LOG.error("Something wrong when storing devices degrees circuit packs", e);
1263 private void persistDevDegreeConnectionPort(String nodeId, Degree degree, String degreeNumber,
1264 Connection connection) {
1266 String startTimestamp = getCurrentTimestamp();
1267 for (int i = 0; i < degree.getConnectionPorts().size(); i++) {
1269 String connectionPortIndex = degree.getConnectionPorts().get(i).getIndex().toString();
1270 String circuitPackName = degree.getConnectionPorts().get(i).getCircuitPackName();
1271 String portName = degree.getConnectionPorts().get(i).getPortName().toString();
1273 Object[] parameters = {nodeId,
1275 connectionPortIndex,
1282 String query = Queries.getQuery().deviceDegreeConnectionPortInsert().get();
1283 LOG.info("Running {} query ", query);
1284 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1285 for (int j = 0; j < parameters.length; j++) {
1286 stmt.setObject(j + 1, parameters[j]);
1289 stmt.clearParameters();
1290 } catch (SQLException e) {
1291 LOG.error("Something wrong when storing devices degrees connection ports", e);
1298 private void persistDevSrg(String nodeId, Connection connection) {
1300 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1301 Optional<OrgOpenroadmDevice> deviceObject =
1302 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1303 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1305 String startTimestamp = getCurrentTimestamp();
1306 for (int i = 0; i < deviceObject.get().getSharedRiskGroup().size(); i++) {
1307 SharedRiskGroup sharedRiskGroup = deviceObject.get().getSharedRiskGroup().get(i);
1308 String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
1309 String srgNumber = sharedRiskGroup.getSrgNumber().toString();
1310 //int wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getIntValue();
1311 persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
1312 //String currentProvisionedAddDropPorts = "";
1313 //String mcCapSlotWidthGranularity = "";
1314 //String mcCapCenterFreqGranularity = "";
1315 //String mcCapMinSlots = "";
1316 //String mcCapMaxSlots = "";
1318 Object[] parameters = {nodeId,
1320 //currentProvisionedAddDropPorts,
1323 //mcCapSlotWidthGranularity,
1324 //mcCapCenterFreqGranularity,
1332 String query = Queries.getQuery().deviceSharedRiskGroupInsert().get();
1333 LOG.info("Running {} query ", query);
1334 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1335 for (int j = 0; j < parameters.length; j++) {
1336 stmt.setObject(j + 1, parameters[j]);
1339 stmt.clearParameters();
1340 } catch (SQLException e) {
1341 LOG.error("Something wrong when storing devices SRG", e);
1347 private void persistDevSrgCircuitPacks(String nodeId, SharedRiskGroup sharedRiskGroup, String srgNumber,
1348 Connection connection) {
1350 String startTimestamp = getCurrentTimestamp();
1351 for (int i = 0; i < sharedRiskGroup.getCircuitPacks().size(); i++) {
1353 String circuitPackindex = sharedRiskGroup.getCircuitPacks().get(i).getIndex().toString();
1354 String circuitPackName = sharedRiskGroup.getCircuitPacks().get(i).getCircuitPackName();
1356 Object[] parameters = {nodeId,
1364 String query = Queries.getQuery().deviceSrgCircuitPackInsert().get();
1365 LOG.info("Running {} query ", query);
1366 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1367 for (int j = 0; j < parameters.length; j++) {
1368 stmt.setObject(j + 1, parameters[j]);
1371 stmt.clearParameters();
1372 } catch (SQLException e) {
1373 LOG.error("Something wrong when storing devices SRG circuit packs", e);
1379 private void persistDevRoadmConnections(String nodeId, Connection connection) {
1381 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1382 Optional<OrgOpenroadmDevice> deviceObject =
1383 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1384 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1386 String startTimestamp = getCurrentTimestamp();
1387 for (int i = 0; i < deviceObject.get().getRoadmConnections().size(); i++) {
1388 RoadmConnections roadmConnections = deviceObject.get().getRoadmConnections().get(i);
1389 int opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getIntValue();
1390 //String connectionName = "";
1391 //String connectionNumber = "";
1392 //String wavelengthNumber = "";
1393 String targetOutputPower = roadmConnections.getTargetOutputPower().toString();
1394 String srcIf = roadmConnections.getSource().getSrcIf();
1395 String dstIf = roadmConnections.getDestination().getDstIf();
1397 Object[] parameters = {nodeId,
1402 Integer.toString(opticalcontrolmodeEnu),
1411 String query = Queries.getQuery().deviceRoadmConnectionsInsert().get();
1412 LOG.info("Running {} query ", query);
1413 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1414 for (int j = 0; j < parameters.length; j++) {
1415 stmt.setObject(j + 1, parameters[j]);
1418 stmt.clearParameters();
1419 } catch (SQLException e) {
1420 LOG.error("Something wrong when storing devices ROADM connection ", e);
1427 private void persistDevConnectionMap(String nodeId, Connection connection) {
1429 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1430 Optional<OrgOpenroadmDevice> deviceObject =
1431 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1432 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1434 String startTimestamp = getCurrentTimestamp();
1435 for (int i = 0; i < deviceObject.get().getConnectionMap().size(); i++) {
1436 ConnectionMap connectionMap = deviceObject.get().getConnectionMap().get(i);
1437 String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
1438 String sourceCircuitPackName = connectionMap.getSource().getCircuitPackName();
1439 String sourcePortName = connectionMap.getSource().getCircuitPackName();
1442 Object[] parameters = {nodeId,
1443 connectionMapNumber,
1444 sourceCircuitPackName,
1450 String query = Queries.getQuery().deviceConnectionMapInsert().get();
1451 LOG.info("Running {} query ", query);
1452 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1453 for (int j = 0; j < parameters.length; j++) {
1454 stmt.setObject(j + 1, parameters[j]);
1457 stmt.clearParameters();
1458 } catch (SQLException e) {
1459 LOG.error("Something wrong when storing devices connection map", e);
1465 private void persistDevWavelengthMap(String nodeId, Connection connection) {
1468 String wavelengthNumber="", centerFrequency="", wavelength="";;
1470 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1471 Optional<OrgOpenroadmDevice> deviceObject =
1472 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1473 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1476 String startTimestamp = getCurrentTimestamp();
1477 for (int i = 0; i<deviceObject.get().getWavelengthMap().getWavelengths().size(); i++) {
1478 Wavelengths wavelengths = deviceObject.get().getWavelengthMap().getWavelengths().get(i);
1479 wavelengthNumber=wavelengths.getWavelengthNumber().toString();
1480 centerFrequency=wavelengths.getCenterFrequency().toString();
1481 wavelength=wavelengths.getWavelength().toString();
1484 Object[] parameters = {nodeId,
1492 String query = Queries.getQuery().deviceWavelengthInsert().get();
1493 LOG.info("Running {} query ", query);
1494 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1495 for (int j = 0; j < parameters.length; j++) {
1496 stmt.setObject(j + 1, parameters[j]);
1499 stmt.clearParameters();
1500 } catch (SQLException e) {
1501 LOG.error("Something wrong when storing devices wavelength map", e);
1509 private void persistDevInterfaceTcm(String nodeId, String interfaceName, OduBuilder oduBuilder,
1510 Connection connection) {
1512 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1515 tcm = oduBuilder.getTcm().get(i);
1517 Object[] parameters = prepareDevInterfaceTcmParameters(nodeId, interfaceName, tcm);
1519 String query = Queries.getQuery().deviceInterfacesInsert().get();
1520 LOG.info("Running {} query ", query);
1521 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1522 for (int j = 0; j < parameters.length; j++) {
1523 stmt.setObject(j + 1, parameters[j]);
1526 stmt.clearParameters();
1527 } catch (SQLException e) {
1528 LOG.error("Something wrong when storing devices interface tcm", e);
1533 private void persistDevInterfaceOtnOduTxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1534 Connection connection) {
1536 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1539 txMsi = oduBuilder.getOpu().getMsi().getTxMsi().get(i);
1541 Object[] parameters = prepareDevInterfaceOtnOduTxMsiParameters(nodeId, interfaceName, txMsi);
1543 String query = Queries.getQuery().deviceInterfaceOtnOduTxMsiInsert().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 interface OTN ODU Tx MSI", e);
1558 private void persistDevInterfaceOtnOduRxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1559 Connection connection) {
1561 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1564 rxMsi = oduBuilder.getOpu().getMsi().getRxMsi().get(i);
1566 Object[] parameters = prepareDevInterfaceOtnOduRxMsiParameters(nodeId, interfaceName, rxMsi);
1568 String query = Queries.getQuery().deviceInterfaceOtnOduRxMsiInsert().get();
1569 LOG.info("Running {} query ", query);
1570 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1571 for (int j = 0; j < parameters.length; j++) {
1572 stmt.setObject(j + 1, parameters[j]);
1575 stmt.clearParameters();
1576 } catch (SQLException e) {
1577 LOG.error("Something wrong when storing devices interface OTN ODU Rx MSI", e);
1583 private void persistDevInterfaceOtnOduExpMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1584 Connection connection) {
1586 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1589 expMsi = oduBuilder.getOpu().getMsi().getExpMsi().get(i);
1591 Object[] parameters = prepareDevInterfaceOtnOduExpMsiParameters(nodeId, interfaceName, expMsi);
1593 String query = Queries.getQuery().deviceInterfaceOtnOduExpMsiInsert().get();
1594 LOG.info("Running {} query ", query);
1595 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1596 for (int j = 0; j < parameters.length; j++) {
1597 stmt.setObject(j + 1, parameters[j]);
1600 stmt.clearParameters();
1601 } catch (SQLException e) {
1602 LOG.error("Something wrong when storing devices interface OTN ODU Exp MSI", e);