summaryrefslogtreecommitdiffstats
path: root/v3po/vpp-cfg-init
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-05-23 09:26:27 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-05-24 12:53:23 +0200
commitd70f76a3626eb1b3786a5cfac4528a449b476583 (patch)
tree661742089f924c8bdda61c391917de85333b7708 /v3po/vpp-cfg-init
parent3af5cb9926238ba0fa802e0e067451a8e19f1c6a (diff)
HONEYCOMB-61: Fix outstanding issues
Change-Id: I2dec6bbd8db656663029ad0f59da1b583c890565 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/vpp-cfg-init')
-rw-r--r--v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java21
-rw-r--r--v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang2
2 files changed, 14 insertions, 9 deletions
diff --git a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java
index eed22313c..ff3dc1087 100644
--- a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java
+++ b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java
@@ -33,9 +33,13 @@ import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.vpp.data.in
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RestoringInitializer implements DataTreeInitializer {
+ private static final Logger LOG = LoggerFactory.getLogger(InitializerRegistryImpl.class);
+
private final SchemaService schemaService;
private final Path path;
private final DOMDataBroker dataTree;
@@ -55,15 +59,9 @@ public class RestoringInitializer implements DataTreeInitializer {
}
private Path checkStorage(final Path path) {
- try {
- if(Files.exists(path)) {
- checkArgument(!Files.isDirectory(path), "File %s is a directory", path);
- checkArgument(Files.isReadable(path), "File %s is not readable", path);
- } else {
- return checkStorage(Files.createFile(path));
- }
- } catch (IOException e) {
- throw new IllegalArgumentException("Cannot use " + path + " for restoring data", e);
+ if (Files.exists(path)) {
+ checkArgument(!Files.isDirectory(path), "File %s is a directory", path);
+ checkArgument(Files.isReadable(path), "File %s is not readable", path);
}
return path;
@@ -71,7 +69,9 @@ public class RestoringInitializer implements DataTreeInitializer {
@Override
public void initialize() throws InitializeException {
+ LOG.debug("Starting restoration of {} from {} using {}", dataTree, path, restorationType);
if(!Files.exists(path)) {
+ LOG.debug("Persist file {} does not exist. Skipping restoration", path);
return;
}
@@ -83,6 +83,8 @@ public class RestoringInitializer implements DataTreeInitializer {
for (DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> dataContainerChild : containerNode
.getValue()) {
final YangInstanceIdentifier iid = YangInstanceIdentifier.create(dataContainerChild.getIdentifier());
+ LOG.trace("Restoring {} from {}", iid, path);
+
switch (restorationType) {
case Merge:
domDataWriteTransaction.merge(datastoreType, iid, dataContainerChild);
@@ -98,6 +100,7 @@ public class RestoringInitializer implements DataTreeInitializer {
// Block here to prevent subsequent initializers processing before context is fully restored
domDataWriteTransaction.submit().checkedGet();
+ LOG.debug("Data from {} restored successfully", path);
} catch (IOException | TransactionCommitFailedException e) {
throw new InitializeException("Unable to restore data from " + path, e);
diff --git a/v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang b/v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang
index 8d305685e..52750d926 100644
--- a/v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang
+++ b/v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang
@@ -98,6 +98,7 @@ module vpp-cfg-init {
leaf persist-file-path {
type string;
+ mandatory true;
}
leaf restoration-type {
@@ -108,6 +109,7 @@ module vpp-cfg-init {
leaf datastore-type {
type dapi:datatree-type;
+ mandatory true;
}
}
}