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;
59 public class INode221 {
60 private static final Logger LOG = LoggerFactory.getLogger(INode221.class);
62 private final DataSource dataSource;
63 private final DeviceTransactionManager deviceTransactionManager;
65 public INode221(DataSource dataSource, DeviceTransactionManager deviceTransactionManager) {
66 this.dataSource = dataSource;
67 this.deviceTransactionManager = deviceTransactionManager;
70 public boolean addNode(String deviceId) {
72 InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
73 Optional<Info> infoOpt =
74 deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, infoIID,
75 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
77 if (infoOpt.isPresent()) {
78 deviceInfo = infoOpt.get();
80 LOG.warn("Could not get device info from DataBroker");
83 boolean sqlResult = false;
84 String query = Queries.getQuery().deviceInfoInsert().get();
85 LOG.info("Running {} query ", query);
86 try (Connection connection = dataSource.getConnection();
87 PreparedStatement preparedStatement = connection.prepareStatement(query)) {
88 Object[] prepareParameters = prepareDeviceInfoParameters(deviceInfo);
89 for (int i = 0; i < prepareParameters.length; i++) {
90 LOG.debug("Parameter {} has value {}", i + 1, prepareParameters[i]);
91 preparedStatement.setObject(i + 1, prepareParameters[i]);
94 int executeUpdate = preparedStatement.executeUpdate();
95 LOG.info("{} entries were added", executeUpdate);
98 LOG.info("iNode AddNode call complete");
99 getRoadmShelves(deviceId);
100 LOG.info("iNode getRoadmShelves call complete");
101 getCircuitPacks(deviceId);
102 LOG.debug("iNode getCircuitPacks call complete");
104 LOG.debug("iNode persist interfaces call");
105 persistDevInterfaces(deviceId, connection);
106 LOG.debug("iNode persist interfaces call complete");
108 LOG.debug("iNode persist interfaces call");
109 persistDevInterfaces(deviceId, connection);
110 LOG.debug("iNode persist interfaces call complete");
112 LOG.debug("iNode persist protocols call");
113 persistDevProtocols(deviceId, connection);
114 LOG.debug("iNode persist protocols call complete");
116 // LOG.debug("iNode persist wavelength map call");
117 // persistDevWavelengthMap(deviceId, connection);
118 // LOG.debug("iNode persist wavelength map call complete");
120 LOG.debug("iNode persist internal links map call");
121 persistDevInternalLinks(deviceId, connection);
122 LOG.debug("iNode persist internal links map call complete");
124 LOG.debug("iNode persist Physical links map call");
125 persistDevPhysicalLinks(deviceId, connection);
126 LOG.debug("iNode persist Physical links map call complete");
128 LOG.debug("iNode persist External links map call");
129 persistDevExternalLinks(deviceId, connection);
130 LOG.debug("iNode persist External links map call complete");
132 LOG.debug("iNode persist degree map call");
133 persistDevDegree(deviceId, connection);
134 LOG.debug("iNode persist degree map call complete");
136 LOG.debug("iNode persist srg map call");
137 persistDevSrg(deviceId, connection);
138 LOG.debug("iNode persist srg map call complete");
140 LOG.debug("iNode persist Roadm Connections call");
141 persistDevRoadmConnections(deviceId, connection);
142 LOG.debug("iNode persist Roadm Connections call complete");
144 LOG.debug("iNode persist Connection Map call");
145 persistDevConnectionMap(deviceId, connection);
146 LOG.debug("iNode persist Connection Map call complete");
148 } catch (SQLException | InterruptedException | ExecutionException e) {
149 LOG.error("Something wrong when storing node into DB", e);
154 public boolean nodeExists(String nodeId) {
155 String selectTableSQL = "select count(*) node_exists from inv_dev_info where node_id = ?";
157 LOG.info("Checking if {} exists in DB", nodeId);
158 try (Connection connection = dataSource.getConnection();
159 PreparedStatement preparedStmt = connection.prepareStatement(selectTableSQL)) {
160 preparedStmt.setString(1, nodeId);
161 try (ResultSet rs = preparedStmt.executeQuery()) {
163 nodeExists = rs.getInt("node_exists");
164 LOG.debug("Found {} devices matching {}", nodeExists, nodeId);
167 } catch (SQLException e) {
168 LOG.error("Something wrong when fetching node in DB", e);
170 return nodeExists == 0 ? false : true;
173 public void getRoadmShelves(String nodeId) throws InterruptedException, ExecutionException {
174 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
175 Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
176 LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT,
177 Timeouts.DEVICE_READ_TIMEOUT_UNIT);
179 LOG.info("Shelves size {}", deviceObject.get().getShelves().size());
180 try (Connection connection = requireNonNull(dataSource.getConnection())) {
181 for (int i = 0; i < deviceObject.get().getShelves().size(); i++) {
182 Shelves shelve = deviceObject.get().getShelves().get(i);
183 String shelfName = shelve.getShelfName();
185 LOG.info("Getting Shelve Details of {}", shelfName);
186 if (shelve.getSlots() != null) {
187 LOG.info("Slot Size {} ", shelve.getSlots().size());
188 persistShelveSlots(nodeId, shelve, connection);
190 LOG.info("No Slots for shelf {}", shelfName);
194 persistShelves(nodeId, connection, shelve);
196 } catch (SQLException e1) {
197 LOG.error("Something wrong when fetching ROADM shelves in DB", e1);
201 public void getCircuitPacks(String nodeId) throws InterruptedException, ExecutionException {
202 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
203 Optional<OrgOpenroadmDevice> deviceObject =
204 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
205 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
206 if (!deviceObject.isPresent()) {
207 LOG.warn("Device object {} was not found", nodeId);
210 LOG.info("Circuit pack size {}", deviceObject.get().getCircuitPacks().size());
212 try (Connection connection = requireNonNull(dataSource.getConnection())) {
213 for (int i = 0; i < deviceObject.get().getCircuitPacks().size(); i++) {
214 CircuitPacks cp = deviceObject.get().getCircuitPacks().get(i);
216 if (cp.getCpSlots() != null) {
217 persistCircuitPacksSlots(nodeId, cp, connection);
219 LOG.info("Everything {}", cp);
220 LOG.info("CP is {}", cp);
222 persistPorts(cp, connection);
224 persistCircuitPacks(nodeId, connection, cp);
226 } catch (SQLException e1) {
227 LOG.error("Something wrong when fetching Circuit Packs in DB", e1);
231 private void persistCircuitPacks(String nodeId, Connection connection, CircuitPacks cp) {
232 Object[] parameters = prepareCircuitPacksParameters(nodeId, cp);
233 String query = Queries.getQuery().deviceCircuitPackInsert().get();
234 LOG.info("Running {} query ", query);
235 try (PreparedStatement stmt = connection.prepareStatement(query)) {
236 for (int j = 0; j < parameters.length; j++) {
237 stmt.setObject(j + 1, parameters[j]);
240 stmt.clearParameters();
241 } catch (SQLException e) {
242 LOG.error("Something wrong when storing Circuit Packs in DB", e);
246 private void persistShelves(String nodeId, Connection connection, Shelves shelve) {
247 Object[] shelvesParameter = prepareShelvesParameters(nodeId, shelve);
248 String query = Queries.getQuery().deviceShelfInsert().get();
249 LOG.info("Running {} query ", query);
250 try (PreparedStatement preparedStmt = connection.prepareStatement(query)) {
251 for (int j = 0; j < shelvesParameter.length; j++) {
252 preparedStmt.setObject(j + 1, shelvesParameter[j]);
254 preparedStmt.execute();
255 preparedStmt.clearParameters();
256 } catch (SQLException e) {
257 LOG.error("Something wrong when storing shelves in DB", e);
261 private void persistShelveSlots(String nodeId, Shelves shelves, Connection connection) {
262 String startTimetampStr = getCurrentTimestamp();
263 for (int i = 0; i < shelves.getSlots().size(); i++) {
264 Slots slot = shelves.getSlots().get(i);
265 LOG.info("Getting Slot Details of {}", slot.getSlotName());
266 Object[] parameters = new Object[]{nodeId,
267 shelves.getShelfName(),
270 slot.getProvisionedCircuitPack(),
274 String query = Queries.getQuery().deviceShelfSlotInsert().get();
275 LOG.info("Running {} query ", query);
276 try (PreparedStatement stmt = connection.prepareStatement(query)) {
277 for (int j = 0; j < parameters.length; j++) {
278 stmt.setObject(j + 1, parameters[j]);
281 stmt.clearParameters();
282 } catch (SQLException e) {
283 LOG.error("Something wrong when storing shelves slots in DB", e);
289 private void persistCircuitPacksSlots(String nodeId, CircuitPacks circuitPacks, Connection connection) {
290 String startTimetampStr = getCurrentTimestamp();
291 for (int i = 0; i < circuitPacks.getCpSlots().size(); i++) {
292 CpSlots cpSlot = circuitPacks.getCpSlots().get(i);
294 Object[] parameters = new Object[]{nodeId,
295 circuitPacks.getCircuitPackName(),
296 cpSlot.getSlotName(),
298 cpSlot.getProvisionedCircuitPack(),
302 String query = Queries.getQuery().deviceCPSlotInsert().get();
303 LOG.info("Running {} query ", query);
304 try (PreparedStatement stmt = connection.prepareStatement(query)) {
305 for (int j = 0; j < parameters.length; j++) {
306 stmt.setObject(j + 1, parameters[j]);
309 stmt.clearParameters();
310 } catch (SQLException e) {
311 LOG.error("Something wrong when storing Cirtcuits Packs slots in DB", e);
316 private void persistPorts(CircuitPacks circuitPacks, Connection connection) {
317 LOG.warn("Ports are not persisted yet");
322 * Prepares parameters for device insert query.
324 * @param deviceInfo device info
325 * @return Object Object
327 private static Object[] prepareDeviceInfoParameters(Info deviceInfo) {
328 String startTimetampStr = getCurrentTimestamp();
329 //Integer maxNumBin15minHistoricalPm = null;
330 //Integer maxNumBin24hourHistoricalPm = null;
331 //String serialId = "";
333 String nodeId = prepareDashString(deviceInfo.getNodeId());
334 Long nodeNumber = deviceInfo.getNodeNumber().toJava();
335 Integer nodeTypeEnu = deviceInfo.getNodeType().getIntValue();
336 String clli = prepareDashString(deviceInfo.getClli());
337 String vendor = prepareDashString(deviceInfo.getVendor());
338 String model = prepareDashString(deviceInfo.getModel());
339 String ipAddress = prepareDashString(deviceInfo.getIpAddress().getIpv4Address().getValue());
340 String prefixLength = prepareDashString(deviceInfo.getPrefixLength());
341 String defaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
342 Integer sourceEnum = deviceInfo.getSource().getIntValue();
343 String currentIpAddress = prepareDashString(deviceInfo.getCurrentIpAddress().getIpv4Address().getValue());
344 String currentPrefixLength = prepareDashString(deviceInfo.getCurrentPrefixLength());
345 String currentDefaultGateway = prepareDashString(deviceInfo.getDefaultGateway().getIpv4Address().getValue());
346 String macAddress = prepareDashString(deviceInfo.getMacAddress().getValue());
347 String softwareVersion = prepareDashString(deviceInfo.getSoftwareVersion());
348 String openroadmVersion = "2.2.1";
349 String template = prepareDashString(deviceInfo.getTemplate());
350 String currentDatetime = prepareDashString(deviceInfo.getCurrentDatetime().getValue());
352 (deviceInfo.getGeoLocation() != null ? prepareDashString(deviceInfo.getGeoLocation().getLatitude()) : "");
353 String geoLongitude =
354 (deviceInfo.getGeoLocation() != null ? prepareDashString(deviceInfo.getGeoLocation().getLongitude()) : "");
355 String maxDegrees = prepareDashString(deviceInfo.getMaxDegrees()); // max_degrees
356 String maxSrgs = prepareDashString(deviceInfo.getMaxSrgs()); //max_srgs
357 String swVersion = prepareDashString(deviceInfo.getSoftwareVersion()); //sw_version
358 String swValidationTimer = prepareDashString(""); //sw_validation_timer
359 String activationDateTime = prepareDashString(""); //activation_date_time
360 /*jsonDevInfo = JsonStringBuilder.getDevInfoJson().replace("$$NODE-ID$$",nodeId)
361 .replace("$$NODE-NUMBER$$", nodeNumber)
362 .replace("$$NODE-TYPE$$",nodeType)
363 .replace("$$CLLI$$",clli)
364 .replace("$$VENDOR$$",vendor)
365 .replace("$$MODEL$$",model)
366 .replace("$$SERIAL-ID$$",serialId)
367 .replace("$$IPADDRESS$$",ipAddress)
368 .replace("$$PREFIX-LENGTH$$",prefixLength)
369 .replace("$$DEFAULTGATEWAY$$",defaultGateway)
370 .replace("$$SOURCE$$",String.valueOf(source))
371 .replace("$$CURRENT-IPADDRESS$$",currentIpAddress)
372 .replace("$$CURRENT-PREFIX-LENGTH$$",currentPrefixLength)
373 .replace("$$CURRENT-DEFAULTGATEWAY$$",currentDefailtGateway)
374 .replace("$$MACADDRESS$$",macAddress)
375 .replace("$$SOFTWAREVERSION$$",softwareVersion)
376 .replace("$$OPENROADM-VERSION$$",openroadmVersion)
377 .replace("$$TEMPLATE$$",template)
378 .replace("$$CURRENT-DATETIME$$",currentDatetime)
379 .replace("$$LATITUDE$$",latitude)
380 .replace("$$LONGITUDE$$",longitude)
381 .replace("$$MAX-DEGREES$$",maxDegrees)
382 .replace("$$MAX-SRGS$$",maxSrgs)
383 .replace("$$MAX-NUM-BIN-15MIN-HISTORICAL-PM$$",prepareDashString(""))
384 .replace("$$MAX-NUM-BIN-24HOUR-HISTORICAL-PM$$",prepareDashString(""))
385 .replace("$$SW-VERSION$$",swVersion)
386 .replace("$$SW-VALIDATION-TIMER$$",swValidationTimer)
387 .replace("$$ACTIVATION-DATE-TIME$$",activationDateTime);*/
405 currentDefaultGateway,
415 //maxNumBin15minHistoricalPm,
416 //maxNumBin24hourHistoricalPm,
427 private static Object[] prepareShelvesParameters(String nodeId, Shelves shelve) {
428 String startTimestamp = getCurrentTimestamp();
430 return new Object[]{nodeId,
431 shelve.getShelfName(),
432 shelve.getShelfType(),
434 shelve.getShelfPosition(),
435 (shelve.getAdministrativeState() == null ? null : shelve.getAdministrativeState().getIntValue()),
438 shelve.getSerialId(),
440 shelve.getProductCode(),
441 (shelve.getManufactureDate() == null ? null : shelve.getManufactureDate().getValue()),
443 shelve.getHardwareVersion(),
444 (shelve.getOperationalState() == null ? null : shelve.getOperationalState().getIntValue()),
445 (shelve.getEquipmentState() == null ? null : shelve.getEquipmentState().getIntValue()),
446 (shelve.getDueDate() == null ? null : shelve.getDueDate().getValue()),
451 private static Object[] prepareCircuitPacksParameters(String nodeId, CircuitPacks cpack) {
452 String startTimestamp = getCurrentTimestamp();
453 return new Object[]{nodeId,
454 cpack.getCircuitPackName(),
455 cpack.getCircuitPackType(),
456 cpack.getCircuitPackProductCode(),
457 (cpack.getAdministrativeState() == null ? "" : cpack.getAdministrativeState().getIntValue()),
462 cpack.getProductCode(),
463 (cpack.getManufactureDate() == null ? "" : cpack.getManufactureDate().getValue()),
465 cpack.getHardwareVersion(),
466 prepareEmptyString(cpack.getOperationalState().getIntValue()),
467 cpack.getCircuitPackCategory().getType().getName(),
468 cpack.getCircuitPackCategory().getExtension(),
469 (cpack.getEquipmentState() == null ? "" : cpack.getEquipmentState().getIntValue()),
470 cpack.getCircuitPackMode(),
474 prepareEmptyString(cpack.getDueDate()),
475 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
476 ((cpack.getParentCircuitPack().getCircuitPackName() == null) ? "" :
477 cpack.getParentCircuitPack().getCircuitPackName())
479 prepareEmptyString((cpack.getParentCircuitPack() == null) ? "" :
480 ((cpack.getParentCircuitPack().getCpSlotName() == null) ? "" :
481 cpack.getParentCircuitPack().getCpSlotName())
487 private Object[] prepareDevInterfaceParameters(String nodeId, Interface deviceInterface, Connection connection) {
489 int administrativeStateEnu = deviceInterface.getAdministrativeState().getIntValue();
490 int operationalState = deviceInterface.getOperationalState().getIntValue();
491 int ethernetDuplexEnu = -1;
492 int ethernetAutoNegotiationEnu = -1;
493 int maintTestsignalTestpatternEnu = -1;
494 int maintTestsignalTypeEnu = -1;
496 int otuMaintTypeEnu = -1;
497 //int otsFiberTypeEnu = -1;
498 String name = deviceInterface.getName();
499 String description = deviceInterface.getDescription();
500 String type = deviceInterface.getType().getTypeName();
501 String circuitId = deviceInterface.getCircuitId();
502 String supportingInterface = deviceInterface.getSupportingInterface();
503 String supportingCircuitPackName = deviceInterface.getSupportingCircuitPackName();
504 String supportingPort = deviceInterface.getSupportingPort().toString();
505 String ethernetSpeed = "";
506 String ethernetFec = "";
507 String ethernetMtu = "";
508 String ethernetCurrSpeed = "";
509 String ethernetCurrDuplex = "";
510 //String mciMcttpMinFreq = "";
511 //String mciMcttpMaxFreq = "";
512 //String mciMcttpCenterFreq = "";
513 //String mciMcttpSlotWidth = "";
514 //String mciNmcCtpFrequency = "";
515 //String mciNmcCtpWidth = "";
517 //String ochFrequency = "";
518 //String ochWidth = "";
519 //String ochWavelengthNumber = "";
520 String ochModulationFormat = "";
521 String ochTransmitPower = "";
522 String otsSpanLossReceive = "";
523 String otsSpanLossTransmit = "";
524 //String otsIngressSpanLossAgingMargin = "";
525 //String otsEolMaxLoadPin = "";
526 String oduRate = ""; //BUG in following case switch statement ???
527 //String oduFunction = "";
528 String oduMonitoringMode = "";
529 //String oduNoOamFunction = "";
530 String oduProactiveDelayMeasurementEnabled = "";
531 //String oduPoaTribPortNumber = "";
532 //String oduTxSapi = "";
533 //String oduTxDapi = "";
534 //String oduTxOperator = "";
535 //String oduAcceptedSapi = "";
536 //String oduAcceptedDapi = "";
537 //String oduAcceptedOperator = "";
538 //String oduExpectedSapi = "";
539 //String oduExpectedDapi = "";
540 //String oduTimActEnabled = "";
541 //String oduTimDetectMode = "";
542 //String oduDegmIntervals = "";
543 //String oduDegthrPercentage = "";
544 String opuPayloadType = "";
545 String opuRxPayloadType = "";
546 String opuExpPayloadType = "";
547 String opuPayloadInterface = "";
548 String maintTestsignalEnabled = "";
549 String maintTestsignalBiterrors = "";
550 String maintTestsignalBiterrorsterminal = "";
551 String maintTestsignalSyncseconds = "";
552 String maintTestsignalSyncsecondsterminal = "";
554 //String otuTxSapi = "";
555 //String otuTxDapi = "";
556 //String otuTxOperator = "";
557 //String otuAcceptedSapi = "";
558 //String otuAcceptedDapi = "";
559 //String otuAcceptedOperator = "";
560 //String otuExpectedSapi = "";
561 //String otuExpectedDapi = "";
562 //String otuTimActEnabled = "";
563 //String otuTimDetectMode = "";
564 //String otuDegmIntervals = "";
565 //String otuDegthrPercentage = "";
566 String otuMaintLoopbackEnabled = "";
567 //String mtOtuRate = "";
568 //String mtOtuFec = "";
569 //String mtOtuMaintLoopback = "";
570 //String mtOtuEnabled = "";
571 //String mtOtuType = "";
573 switch (deviceInterface.getType().toString()) {
576 //EthernetBuilder ethIfBuilder = new EthernetBuilder();
577 EthernetBuilder ethIfBuilder =
578 new EthernetBuilder(deviceInterface.augmentation(Interface1.class).getEthernet());
579 ethernetSpeed = ethIfBuilder.getSpeed().toString();
580 ethernetFec = ethIfBuilder.getFec().getName();
581 ethernetDuplexEnu = ethIfBuilder.getDuplex().getIntValue();
582 ethernetMtu = ethIfBuilder.getMtu().toString();
583 ethernetAutoNegotiationEnu = ethIfBuilder.getAutoNegotiation().getIntValue();
584 ethernetCurrSpeed = ethIfBuilder.getCurrSpeed();
585 ethernetCurrDuplex = ethIfBuilder.getCurrDuplex();
589 OchBuilder ochIfBuilder = new OchBuilder(deviceInterface.augmentation(
590 org.opendaylight.yang.gen.v1
591 .http.org.openroadm.optical.channel.interfaces.rev161014.Interface1.class)
593 ochRate = ochIfBuilder.getRate().getName();
594 //ochWavelengthNumber = ochIfBuilder.getWavelengthNumber().toString();
595 ochModulationFormat = ochIfBuilder.getModulationFormat().getName();
596 ochTransmitPower = ochIfBuilder.getTransmitPower().toString();
600 OtsBuilder otsIfBuilder = new OtsBuilder(deviceInterface.augmentation(
601 org.opendaylight.yang.gen.v1
602 .http.org.openroadm.optical.transport.interfaces.rev161014.Interface1.class)
604 int otsFiberTypeEnu = otsIfBuilder.getFiberType().getIntValue();
605 otsSpanLossReceive = otsIfBuilder.getSpanLossReceive().toString();
606 otsSpanLossTransmit = otsIfBuilder.getSpanLossTransmit().toString();
610 OduBuilder oduIfBuilder = new OduBuilder(deviceInterface.augmentation(
611 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1.class)
613 oduRate = String.valueOf(oduIfBuilder.getRate());
614 oduMonitoringMode = oduIfBuilder.getMonitoringMode().getName();
615 oduProactiveDelayMeasurementEnabled = oduIfBuilder.isProactiveDelayMeasurementEnabled().toString();
617 persistDevInterfaceTcm(nodeId, name, oduIfBuilder, connection);
618 persistDevInterfaceOtnOduTxMsi(nodeId, name, oduIfBuilder, connection);
619 persistDevInterfaceOtnOduRxMsi(nodeId, name, oduIfBuilder, connection);
620 persistDevInterfaceOtnOduExpMsi(nodeId, name, oduIfBuilder, connection);
622 opuPayloadType = oduIfBuilder.getOpu().getPayloadType();
623 opuRxPayloadType = oduIfBuilder.getOpu().getRxPayloadType();
624 opuExpPayloadType = oduIfBuilder.getOpu().getExpPayloadType();
625 opuPayloadInterface = oduIfBuilder.getOpu().getPayloadInterface();
626 /*persistDevInterfaceOtnOduTxMsi(nodeId,name,oduIfBuilder,connection);
627 persistDevInterfaceOtnOduRxMsi(nodeId,name,oduIfBuilder,connection);
628 persistDevInterfaceOtnOduExpMsi(nodeId,name,oduIfBuilder,connection); */
629 maintTestsignalEnabled = oduIfBuilder.getMaintTestsignal().isEnabled().toString();
630 maintTestsignalTestpatternEnu = oduIfBuilder.getMaintTestsignal().getTestPattern().getIntValue();
631 maintTestsignalTypeEnu = oduIfBuilder.getMaintTestsignal().getType().getIntValue();
632 maintTestsignalBiterrors = oduIfBuilder.getMaintTestsignal().getBitErrors().toString();
633 maintTestsignalBiterrorsterminal = oduIfBuilder.getMaintTestsignal().getBitErrorsTerminal().toString();
634 maintTestsignalSyncseconds = oduIfBuilder.getMaintTestsignal().getSyncSeconds();
635 maintTestsignalSyncsecondsterminal = oduIfBuilder.getMaintTestsignal().getSyncSecondsTerminal();
639 OtuBuilder otuIfBuilder = new OtuBuilder(deviceInterface.augmentation(
640 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1.class)
642 otuRate = otuIfBuilder.getRate().getName();
643 otuFecEnu = otuIfBuilder.getFec().getIntValue();
644 otuMaintLoopbackEnabled = otuIfBuilder.getMaintLoopback().isEnabled().toString();
645 otuMaintTypeEnu = otuIfBuilder.getMaintLoopback().getType().getIntValue();
649 LOG.error("Could not get interface type");
652 String startTimestamp = getCurrentTimestamp();
654 return new Object[]{nodeId,
658 Integer.toString(administrativeStateEnu),
659 Integer.toString(operationalState),
662 supportingCircuitPackName,
666 Integer.toString(ethernetDuplexEnu),
668 Integer.toString(ethernetAutoNegotiationEnu),
673 //mciMcttpCenterFreq,
675 //mciNmcCtpFrequency,
677 "", "", "", "", "", "",
681 //ochWavelengthNumber,
685 //Integer.toString(otsFiberTypeEnu),
689 //otsIngressSpanLossAgingMargin,
698 oduProactiveDelayMeasurementEnabled,
699 //oduPoaTribPortNumber,
705 //oduAcceptedOperator,
711 //oduDegthrPercentage,
712 "", "", "", "", "", "", "", "", "", "", "", "", "",
717 maintTestsignalEnabled,
718 Integer.toString(maintTestsignalTestpatternEnu),
719 Integer.toString(maintTestsignalTypeEnu),
720 maintTestsignalBiterrors,
721 maintTestsignalBiterrorsterminal,
722 maintTestsignalSyncseconds,
723 maintTestsignalSyncsecondsterminal,
725 Integer.toString(otuFecEnu),
731 //otuAcceptedOperator,
737 //otuDegthrPercentage,
738 "", "", "", "", "", "", "", "", "", "", "", "",
739 otuMaintLoopbackEnabled,
740 Integer.toString(otuMaintTypeEnu),
743 //mtOtuMaintLoopback,
753 private static Object[] prepareDevInterfaceTcmParameters(String nodeId, String interfaceName, Tcm tcm) {
756 String layer = tcm.getLayer().toString();
757 int monitoringModeEnu = tcm.getMonitoringMode().getIntValue();
758 String ltcActEnabled = tcm.isLtcActEnabled().toString();
759 String proactiveDelayMeasurementEnabled = tcm.isProactiveDelayMeasurementEnabled().toString();
760 //int tcmDirectionEnu = -1;
761 //int timDetectModeEnu = -1;
762 //String txSapi = "";
763 //String txDapi = "";
764 //String txOperator = "";
765 //String acceptedSapi = "";
766 //String acceptedDapi = "";
767 //String acceptedOperator = "";
768 //String expectedSapi = "";
769 //String expectedDapi = "";
770 //String timActEnabled = "";
771 //String degmIntervals = "";
772 //String degthrPercentage = "";
774 String startTimestamp = getCurrentTimestamp();
776 return new Object[]{nodeId,
779 Integer.toString(monitoringModeEnu),
781 proactiveDelayMeasurementEnabled,
782 //Integer.toString(tcmDirectionEnu),
793 "", "", "", "", "", "", "", "", "",
794 //Integer.toString(timDetectModeEnu),
804 private static Object[] prepareDevInterfaceOtnOduTxMsiParameters(String nodeId, String interfaceName, TxMsi txMsi) {
806 String tribSlot = txMsi.getTribSlot().toString();
807 String odtuType = txMsi.getOdtuType().getTypeName();
808 String tribPort = txMsi.getTribPort().toString();
809 String tribPortPayload = txMsi.getTribPortPayload();
811 String startTimestamp = getCurrentTimestamp();
813 return new Object[]{nodeId,
825 private static Object[] prepareDevInterfaceOtnOduRxMsiParameters(String nodeId, String interfaceName, RxMsi rxMsi) {
827 String tribSlot = rxMsi.getTribSlot().toString();
828 String odtuType = rxMsi.getOdtuType().getTypeName();
829 String tribPort = rxMsi.getTribPort().toString();
830 String tribPortPayload = rxMsi.getTribPortPayload();
832 String startTimestamp = getCurrentTimestamp();
834 return new Object[]{nodeId,
847 private static Object[] prepareDevInterfaceOtnOduExpMsiParameters(String nodeId, String interfaceName,
850 String tribSlot = expMsi.getTribSlot().toString();
851 String odtuType = expMsi.getOdtuType().getTypeName();
852 String tribPort = expMsi.getTribPort().toString();
853 String tribPortPayload = expMsi.getTribPortPayload();
855 String startTimestamp = getCurrentTimestamp();
857 return new Object[]{nodeId,
869 private void persistDevInterfaces(String nodeId, Connection connection) {
871 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
872 Optional<OrgOpenroadmDevice> deviceObject =
873 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
874 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
876 /*InstanceIdentifier<Interface> interfaceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
877 .child(Interface.class);
878 Optional<Interface> interfaceOpt =
879 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, interfaceIID,
880 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); */
882 for (int i = 0; i < deviceObject.get().getInterface().size(); i++) {
883 Interface deviceInterface;
885 deviceInterface = deviceObject.get().getInterface().get(i);
886 /*if (interfaceOpt.isPresent()) {
887 deviceInterface = interfaceOpt.get();
889 LOG.warn("Could not get interface info");
892 Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
894 String query = Queries.getQuery().deviceInterfacesInsert().get();
895 LOG.info("Running {} query ", query);
896 try (PreparedStatement stmt = connection.prepareStatement(query)) {
897 for (int j = 0; j < parameters.length; j++) {
898 stmt.setObject(j + 1, parameters[j]);
901 stmt.clearParameters();
902 } catch (SQLException e) {
903 LOG.error("Something wrong when storing devices interfaces in DB", e);
908 private void persistDevProtocols(String nodeId, Connection connection) {
910 InstanceIdentifier<Protocols> protocolsIID =
911 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
912 Optional<Protocols> protocolObject =
913 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
914 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
915 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
916 LOG.error("LLDP subtree is missing");
920 protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getAdminStatus()
922 String msgTxtInterval =
923 protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getMsgTxInterval()
925 String mxgTxHoldMultiplier =
926 protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig().getMsgTxHoldMultiplier()
928 String startTimestamp = getCurrentTimestamp();
929 persistDevProtocolLldpPortConfig(nodeId, connection);
930 persistDevProtocolLldpNbrList(nodeId, connection);
932 Object[] parameters = {nodeId,
933 Integer.toString(adminstatusEnu),
940 String query = Queries.getQuery().deviceProtocolInsert().get();
941 LOG.info("Running {} query ", query);
942 try (PreparedStatement stmt = connection.prepareStatement(query)) {
943 for (int j = 0; j < parameters.length; j++) {
944 stmt.setObject(j + 1, parameters[j]);
947 stmt.clearParameters();
948 } catch (SQLException e) {
949 LOG.error("Something wrong when storing devices protocols in DB", e);
955 private void persistDevProtocolLldpPortConfig(String nodeId, Connection connection) {
957 InstanceIdentifier<Protocols> protocolsIID =
958 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
959 Optional<Protocols> protocolObject =
960 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
961 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
962 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
963 LOG.error("LLDP subtree is missing");
966 String startTimestamp = getCurrentTimestamp();
967 for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().size(); i++) {
969 PortConfig portConfig =
970 protocolObject.get().augmentation(Protocols1.class).getLldp().getPortConfig().get(i);
971 String ifName = portConfig.getIfName();
972 int adminStatusEnu = portConfig.getAdminStatus().getIntValue();
974 Object[] parameters = {nodeId,
976 Integer.toString(adminStatusEnu),
981 String query = Queries.getQuery().deviceProtocolPortConfigInsert().get();
982 LOG.info("Running {} query ", query);
983 try (PreparedStatement stmt = connection.prepareStatement(query)) {
984 for (int j = 0; j < parameters.length; j++) {
985 stmt.setObject(j + 1, parameters[j]);
988 stmt.clearParameters();
989 } catch (SQLException e) {
990 LOG.error("Something wrong when storing devices protocols LLDP Port config in DB", e);
997 private void persistDevProtocolLldpNbrList(String nodeId, Connection connection) {
999 InstanceIdentifier<Protocols> protocolsIID =
1000 InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
1001 Optional<Protocols> protocolObject =
1002 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
1003 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1004 if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
1005 LOG.error("LLDP subtree is missing");
1008 String startTimestamp = getCurrentTimestamp();
1009 for (int i = 0; i < protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().getIfName()
1013 protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().getIfName().get(i);
1014 String ifName = ifNameObj.getIfName();
1015 String remotesysname = ifNameObj.getRemoteSysName();
1016 String remotemgmtaddresssubtype = ifNameObj.getRemoteMgmtAddressSubType().getName();
1017 String remotemgmtaddress = ifNameObj.getRemoteMgmtAddress().getIpv4Address().toString();
1018 int remoteportidsubtypeEnu = ifNameObj.getRemotePortIdSubType().getIntValue();
1019 String remoteportid = ifNameObj.getRemotePortId();
1020 int remotechassisidsubtypeEnu = ifNameObj.getRemoteChassisIdSubType().getIntValue();
1021 String remotechassisid = ifNameObj.getRemoteChassisId();
1023 Object[] parameters = {nodeId,
1026 remotemgmtaddresssubtype,
1028 Integer.toString(remoteportidsubtypeEnu),
1030 Integer.toString(remotechassisidsubtypeEnu),
1036 String query = Queries.getQuery().deviceProtocolLldpNbrlistInsert().get();
1037 LOG.info("Running {} query ", query);
1038 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1039 for (int j = 0; j < parameters.length; j++) {
1040 stmt.setObject(j + 1, parameters[j]);
1043 stmt.clearParameters();
1044 } catch (SQLException e) {
1045 LOG.error("Something wrong when storing devices protocols LLDP list number in DB", e);
1051 private void persistDevInternalLinks(String nodeId, Connection connection) {
1053 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1054 Optional<OrgOpenroadmDevice> deviceObject =
1055 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1056 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1058 String startTimestamp = getCurrentTimestamp();
1059 for (int i = 0; i < deviceObject.get().getInternalLink().size(); i++) {
1060 InternalLink internalLink = deviceObject.get().getInternalLink().get(i);
1061 String internalLinkName = internalLink.getInternalLinkName();
1062 String sourceCircuitPackName = internalLink.getSource().getCircuitPackName();
1063 String sourcePortName = internalLink.getSource().getPortName().toString();
1064 String destinationCircuitPackName = internalLink.getDestination().getCircuitPackName();
1065 String destinationPortName = internalLink.getDestination().getPortName().toString();
1067 Object[] parameters = {nodeId,
1069 sourceCircuitPackName,
1071 destinationCircuitPackName,
1072 destinationPortName,
1077 String query = Queries.getQuery().deviceInternalLinkInsert().get();
1078 LOG.info("Running {} query ", query);
1079 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1080 for (int j = 0; j < parameters.length; j++) {
1081 stmt.setObject(j + 1, parameters[j]);
1084 stmt.clearParameters();
1085 } catch (SQLException e) {
1086 LOG.error("Something wrong when storing devices internal links", e);
1093 private void persistDevExternalLinks(String nodeId, Connection connection) {
1095 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1096 Optional<OrgOpenroadmDevice> deviceObject =
1097 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1098 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1100 String startTimestamp = getCurrentTimestamp();
1101 for (int i = 0; i < deviceObject.get().getExternalLink().size(); i++) {
1102 ExternalLink externalLink = deviceObject.get().getExternalLink().get(i);
1103 String externalLinkName = externalLink.getExternalLinkName();
1104 String sourceNodeId = externalLink.getSource().getNodeId();
1105 String sourceCircuitPackName = externalLink.getSource().getCircuitPackName();
1106 String sourcePortName = externalLink.getSource().getPortName();
1107 String destinationNodeId = externalLink.getDestination().getNodeId();
1108 String destinationCircuitPackName = externalLink.getDestination().getCircuitPackName();
1109 String destinationPortName = externalLink.getDestination().getPortName();
1111 Object[] parameters = {nodeId,
1114 sourceCircuitPackName,
1117 destinationCircuitPackName,
1118 destinationPortName,
1123 String query = Queries.getQuery().deviceExternalLinkInsert().get();
1124 LOG.info("Running {} query ", query);
1125 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1126 for (int j = 0; j < parameters.length; j++) {
1127 stmt.setObject(j + 1, parameters[j]);
1130 stmt.clearParameters();
1131 } catch (SQLException e) {
1132 LOG.error("Something wrong when storing devices external links", e);
1138 private void persistDevPhysicalLinks(String nodeId, Connection connection) {
1140 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1141 Optional<OrgOpenroadmDevice> deviceObject =
1142 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1143 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1145 String startTimestamp = getCurrentTimestamp();
1146 for (int i = 0; i < deviceObject.get().getPhysicalLink().size(); i++) {
1147 PhysicalLink physicalLink = deviceObject.get().getPhysicalLink().get(i);
1148 String physicalLinkName = physicalLink.getPhysicalLinkName();
1149 String sourceCircuitPackName = physicalLink.getSource().getCircuitPackName();
1150 String sourcePortName = physicalLink.getSource().getPortName().toString();
1151 String destinationCircuitPackName = physicalLink.getDestination().getCircuitPackName();
1152 String destinationPortName = physicalLink.getDestination().getPortName().toString();
1154 Object[] parameters = {nodeId,
1156 sourceCircuitPackName,
1158 destinationCircuitPackName,
1159 destinationPortName,
1164 String query = Queries.getQuery().devicePhysicalLinkInsert().get();
1165 LOG.info("Running {} query ", query);
1166 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1167 for (int j = 0; j < parameters.length; j++) {
1168 stmt.setObject(j + 1, parameters[j]);
1171 stmt.clearParameters();
1172 } catch (SQLException e) {
1173 LOG.error("Something wrong when storing devices physical links", e);
1179 private void persistDevDegree(String nodeId, Connection connection) {
1181 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1182 Optional<OrgOpenroadmDevice> deviceObject =
1183 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1184 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1186 String startTimestamp = getCurrentTimestamp();
1187 for (int i = 0; i < deviceObject.get().getDegree().size(); i++) {
1188 Degree degree = deviceObject.get().getDegree().get(i);
1189 String degreeNumber = degree.getDegreeNumber().toString();
1190 String maxWavelengths = degree.getMaxWavelengths().toString();
1191 String otdrPortCircuitPackName = degree.getOtdrPort().getCircuitPackName();
1192 String otdrPortPortName = degree.getOtdrPort().getPortName().toString();
1193 persistDevDegreeCircuitPack(nodeId, degree, degreeNumber, connection);
1194 persistDevDegreeConnectionPort(nodeId, degree, degreeNumber, connection);
1195 //String mcCapabilitiesSlotWidthGranularity = "";
1196 //String mcCapabilitiesCenterFreqGranularity = "";
1197 //String mcCapabilitiesMinSlots = "";
1198 //String mcCapabilitiesMaxSlots = "";
1200 Object[] parameters = {nodeId,
1203 otdrPortCircuitPackName,
1205 //mcCapabilitiesSlotWidthGranularity,
1206 //mcCapabilitiesCenterFreqGranularity,
1207 //mcCapabilitiesMinSlots,
1208 //mcCapabilitiesMaxSlots,
1214 String query = Queries.getQuery().deviceDegreeInsert().get();
1215 LOG.info("Running {} query ", query);
1216 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1217 for (int j = 0; j < parameters.length; j++) {
1218 stmt.setObject(j + 1, parameters[j]);
1221 stmt.clearParameters();
1222 } catch (SQLException e) {
1223 LOG.error("Something wrong when storing devices degrees", e);
1230 private void persistDevDegreeCircuitPack(String nodeId, Degree degree, String degreeNumber, Connection connection) {
1232 String startTimestamp = getCurrentTimestamp();
1233 for (int i = 0; i < degree.getCircuitPacks().size(); i++) {
1235 String circuitPackIndex = degree.getCircuitPacks().get(i).getIndex().toString();
1236 String circuitPackName = degree.getCircuitPacks().get(i).getCircuitPackName();
1238 Object[] parameters = {nodeId,
1246 String query = Queries.getQuery().deviceDegreeCircuitPackInsert().get();
1247 LOG.info("Running {} query ", query);
1248 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1249 for (int j = 0; j < parameters.length; j++) {
1250 stmt.setObject(j + 1, parameters[j]);
1253 stmt.clearParameters();
1254 } catch (SQLException e) {
1255 LOG.error("Something wrong when storing devices degrees circuit packs", e);
1261 private void persistDevDegreeConnectionPort(String nodeId, Degree degree, String degreeNumber,
1262 Connection connection) {
1264 String startTimestamp = getCurrentTimestamp();
1265 for (int i = 0; i < degree.getConnectionPorts().size(); i++) {
1267 String connectionPortIndex = degree.getConnectionPorts().get(i).getIndex().toString();
1268 String circuitPackName = degree.getConnectionPorts().get(i).getCircuitPackName();
1269 String portName = degree.getConnectionPorts().get(i).getPortName().toString();
1271 Object[] parameters = {nodeId,
1273 connectionPortIndex,
1280 String query = Queries.getQuery().deviceDegreeConnectionPortInsert().get();
1281 LOG.info("Running {} query ", query);
1282 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1283 for (int j = 0; j < parameters.length; j++) {
1284 stmt.setObject(j + 1, parameters[j]);
1287 stmt.clearParameters();
1288 } catch (SQLException e) {
1289 LOG.error("Something wrong when storing devices degrees connection ports", e);
1296 private void persistDevSrg(String nodeId, Connection connection) {
1298 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1299 Optional<OrgOpenroadmDevice> deviceObject =
1300 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1301 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1303 String startTimestamp = getCurrentTimestamp();
1304 for (int i = 0; i < deviceObject.get().getSharedRiskGroup().size(); i++) {
1305 SharedRiskGroup sharedRiskGroup = deviceObject.get().getSharedRiskGroup().get(i);
1306 String maxAddDropPorts = sharedRiskGroup.getMaxAddDropPorts().toString();
1307 String srgNumber = sharedRiskGroup.getSrgNumber().toString();
1308 int wavelengthDuplicationEnu = sharedRiskGroup.getWavelengthDuplication().getIntValue();
1309 persistDevSrgCircuitPacks(nodeId, sharedRiskGroup, srgNumber, connection);
1310 //String currentProvisionedAddDropPorts = "";
1311 //String mcCapSlotWidthGranularity = "";
1312 //String mcCapCenterFreqGranularity = "";
1313 //String mcCapMinSlots = "";
1314 //String mcCapMaxSlots = "";
1316 Object[] parameters = {nodeId,
1318 //currentProvisionedAddDropPorts,
1321 //mcCapSlotWidthGranularity,
1322 //mcCapCenterFreqGranularity,
1330 String query = Queries.getQuery().deviceSharedRiskGroupInsert().get();
1331 LOG.info("Running {} query ", query);
1332 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1333 for (int j = 0; j < parameters.length; j++) {
1334 stmt.setObject(j + 1, parameters[j]);
1337 stmt.clearParameters();
1338 } catch (SQLException e) {
1339 LOG.error("Something wrong when storing devices SRG", e);
1345 private void persistDevSrgCircuitPacks(String nodeId, SharedRiskGroup sharedRiskGroup, String srgNumber,
1346 Connection connection) {
1348 String startTimestamp = getCurrentTimestamp();
1349 for (int i = 0; i < sharedRiskGroup.getCircuitPacks().size(); i++) {
1351 String circuitPackindex = sharedRiskGroup.getCircuitPacks().get(i).getIndex().toString();
1352 String circuitPackName = sharedRiskGroup.getCircuitPacks().get(i).getCircuitPackName();
1354 Object[] parameters = {nodeId,
1362 String query = Queries.getQuery().deviceSrgCircuitPackInsert().get();
1363 LOG.info("Running {} query ", query);
1364 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1365 for (int j = 0; j < parameters.length; j++) {
1366 stmt.setObject(j + 1, parameters[j]);
1369 stmt.clearParameters();
1370 } catch (SQLException e) {
1371 LOG.error("Something wrong when storing devices SRG circuit packs", e);
1377 private void persistDevRoadmConnections(String nodeId, Connection connection) {
1379 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1380 Optional<OrgOpenroadmDevice> deviceObject =
1381 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1382 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1384 String startTimestamp = getCurrentTimestamp();
1385 for (int i = 0; i < deviceObject.get().getRoadmConnections().size(); i++) {
1386 RoadmConnections roadmConnections = deviceObject.get().getRoadmConnections().get(i);
1387 int opticalcontrolmodeEnu = roadmConnections.getOpticalControlMode().getIntValue();
1388 //String connectionName = "";
1389 //String connectionNumber = "";
1390 //String wavelengthNumber = "";
1391 String targetOutputPower = roadmConnections.getTargetOutputPower().toString();
1392 String srcIf = roadmConnections.getSource().getSrcIf();
1393 String dstIf = roadmConnections.getDestination().getDstIf();
1395 Object[] parameters = {nodeId,
1400 Integer.toString(opticalcontrolmodeEnu),
1409 String query = Queries.getQuery().deviceRoadmConnectionsInsert().get();
1410 LOG.info("Running {} query ", query);
1411 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1412 for (int j = 0; j < parameters.length; j++) {
1413 stmt.setObject(j + 1, parameters[j]);
1416 stmt.clearParameters();
1417 } catch (SQLException e) {
1418 LOG.error("Something wrong when storing devices ROADM connection ", e);
1425 private void persistDevConnectionMap(String nodeId, Connection connection) {
1427 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1428 Optional<OrgOpenroadmDevice> deviceObject =
1429 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1430 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1432 String startTimestamp = getCurrentTimestamp();
1433 for (int i = 0; i < deviceObject.get().getConnectionMap().size(); i++) {
1434 ConnectionMap connectionMap = deviceObject.get().getConnectionMap().get(i);
1435 String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
1436 String sourceCircuitPackName = connectionMap.getSource().getCircuitPackName();
1437 String sourcePortName = connectionMap.getSource().getCircuitPackName();
1440 Object[] parameters = {nodeId,
1441 connectionMapNumber,
1442 sourceCircuitPackName,
1448 String query = Queries.getQuery().deviceConnectionMapInsert().get();
1449 LOG.info("Running {} query ", query);
1450 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1451 for (int j = 0; j < parameters.length; j++) {
1452 stmt.setObject(j + 1, parameters[j]);
1455 stmt.clearParameters();
1456 } catch (SQLException e) {
1457 LOG.error("Something wrong when storing devices connection map", e);
1463 private void persistDevWavelengthMap(String nodeId, Connection connection) {
1466 String wavelengthNumber="", centerFrequency="", wavelength="";;
1468 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
1469 Optional<OrgOpenroadmDevice> deviceObject =
1470 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
1471 Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
1474 String startTimestamp = getCurrentTimestamp();
1475 for (int i = 0; i<deviceObject.get().getWavelengthMap().getWavelengths().size(); i++) {
1476 Wavelengths wavelengths = deviceObject.get().getWavelengthMap().getWavelengths().get(i);
1477 wavelengthNumber=wavelengths.getWavelengthNumber().toString();
1478 centerFrequency=wavelengths.getCenterFrequency().toString();
1479 wavelength=wavelengths.getWavelength().toString();
1482 Object[] parameters = {nodeId,
1490 String query = Queries.getQuery().deviceWavelengthInsert().get();
1491 LOG.info("Running {} query ", query);
1492 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1493 for (int j = 0; j < parameters.length; j++) {
1494 stmt.setObject(j + 1, parameters[j]);
1497 stmt.clearParameters();
1498 } catch (SQLException e) {
1499 LOG.error("Something wrong when storing devices wavelength map", e);
1507 private void persistDevInterfaceTcm(String nodeId, String interfaceName, OduBuilder oduBuilder,
1508 Connection connection) {
1510 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1513 tcm = oduBuilder.getTcm().get(i);
1515 Object[] parameters = prepareDevInterfaceTcmParameters(nodeId, interfaceName, tcm);
1517 String query = Queries.getQuery().deviceInterfacesInsert().get();
1518 LOG.info("Running {} query ", query);
1519 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1520 for (int j = 0; j < parameters.length; j++) {
1521 stmt.setObject(j + 1, parameters[j]);
1524 stmt.clearParameters();
1525 } catch (SQLException e) {
1526 LOG.error("Something wrong when storing devices interface tcm", e);
1531 private void persistDevInterfaceOtnOduTxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1532 Connection connection) {
1534 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1537 txMsi = oduBuilder.getOpu().getMsi().getTxMsi().get(i);
1539 Object[] parameters = prepareDevInterfaceOtnOduTxMsiParameters(nodeId, interfaceName, txMsi);
1541 String query = Queries.getQuery().deviceInterfaceOtnOduTxMsiInsert().get();
1542 LOG.info("Running {} query ", query);
1543 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1544 for (int j = 0; j < parameters.length; j++) {
1545 stmt.setObject(j + 1, parameters[j]);
1548 stmt.clearParameters();
1549 } catch (SQLException e) {
1550 LOG.error("Something wrong when storing devices interface OTN ODU Tx MSI", e);
1556 private void persistDevInterfaceOtnOduRxMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1557 Connection connection) {
1559 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1562 rxMsi = oduBuilder.getOpu().getMsi().getRxMsi().get(i);
1564 Object[] parameters = prepareDevInterfaceOtnOduRxMsiParameters(nodeId, interfaceName, rxMsi);
1566 String query = Queries.getQuery().deviceInterfaceOtnOduRxMsiInsert().get();
1567 LOG.info("Running {} query ", query);
1568 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1569 for (int j = 0; j < parameters.length; j++) {
1570 stmt.setObject(j + 1, parameters[j]);
1573 stmt.clearParameters();
1574 } catch (SQLException e) {
1575 LOG.error("Something wrong when storing devices interface OTN ODU Rx MSI", e);
1581 private void persistDevInterfaceOtnOduExpMsi(String nodeId, String interfaceName, OduBuilder oduBuilder,
1582 Connection connection) {
1584 for (int i = 0; i < oduBuilder.getTcm().size(); i++) {
1587 expMsi = oduBuilder.getOpu().getMsi().getExpMsi().get(i);
1589 Object[] parameters = prepareDevInterfaceOtnOduExpMsiParameters(nodeId, interfaceName, expMsi);
1591 String query = Queries.getQuery().deviceInterfaceOtnOduExpMsiInsert().get();
1592 LOG.info("Running {} query ", query);
1593 try (PreparedStatement stmt = connection.prepareStatement(query)) {
1594 for (int j = 0; j < parameters.length; j++) {
1595 stmt.setObject(j + 1, parameters[j]);
1598 stmt.clearParameters();
1599 } catch (SQLException e) {
1600 LOG.error("Something wrong when storing devices interface OTN ODU Exp MSI", e);