+ Element xmlToBePersisted;
+ try {
+ xmlToBePersisted = XmlUtil.readXmlToElement(configSnapshotHolder.getConfigSnapshot());
+ } catch (SAXException | IOException e) {
+ throw new IllegalStateException("Cannot parse " + configSnapshotHolder);
+ }
+ logger.trace("Pushing last configuration to netconf: {}", configSnapshotHolder);
+ Stopwatch stopwatch = new Stopwatch().start();
+ NetconfMessage editConfigMessage = createEditConfigMessage(xmlToBePersisted);
+
+ Document editResponseMessage = sendRequestGetResponseCheckIsOK(editConfigMessage, operationService,
+ "edit-config", configSnapshotHolder.toString());
+
+ Document commitResponseMessage = sendRequestGetResponseCheckIsOK(getCommitMessage(), operationService,
+ "commit", configSnapshotHolder.toString());
+
+ if (logger.isTraceEnabled()) {
+ StringBuilder response = new StringBuilder("editConfig response = {");
+ response.append(XmlUtil.toString(editResponseMessage));
+ response.append("}");
+ response.append("commit response = {");
+ response.append(XmlUtil.toString(commitResponseMessage));
+ response.append("}");
+ logger.trace("Last configuration loaded successfully");
+ logger.trace("Detailed message {}", response);
+ logger.trace("Total time spent {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
+ }
+ return new EditAndCommitResponse(editResponseMessage, commitResponseMessage);
+ }