This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit 766f335c855d35499f130b9d760107e9bf5a0c79 Author: Juan Cabrerizo <j...@cloudsoft.io> AuthorDate: Fri Dec 4 14:14:01 2020 +0000 Managing the brooklyn.persistence.dir.required key, pending test --- .../localhost/LocalhostMachineProvisioningLocation.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocation.java b/core/src/main/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocation.java index 4ebeda6..b16a7df 100644 --- a/core/src/main/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocation.java +++ b/core/src/main/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocation.java @@ -42,6 +42,7 @@ import org.apache.brooklyn.core.location.geo.HostGeoInfo; import org.apache.brooklyn.core.mgmt.persist.FileBasedObjectStore; import org.apache.brooklyn.core.mgmt.persist.LocationWithObjectStore; import org.apache.brooklyn.core.mgmt.persist.PersistenceObjectStore; +import org.apache.brooklyn.core.server.BrooklynServerConfig; import org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation; import org.apache.brooklyn.location.ssh.SshMachineLocation; import org.apache.brooklyn.util.collections.MutableMap; @@ -50,6 +51,7 @@ import org.apache.brooklyn.util.core.flags.SetFromFlag; import org.apache.brooklyn.util.core.internal.ssh.process.ProcessTool; import org.apache.brooklyn.util.core.mutex.MutexSupport; import org.apache.brooklyn.util.core.mutex.WithMutexes; +import org.apache.brooklyn.util.exceptions.UserFacingException; import org.apache.brooklyn.util.net.Networking; import org.apache.brooklyn.util.os.Os; import org.apache.brooklyn.util.ssh.BashCommands; @@ -363,7 +365,14 @@ public class LocalhostMachineProvisioningLocation extends FixedListMachineProvis @Override public PersistenceObjectStore newPersistenceObjectStore(String container) { File basedir = new File(container); - if (basedir.isFile()) throw new IllegalArgumentException("Destination directory must not be a file"); + if (basedir.isFile()){ + throw new IllegalArgumentException("Destination directory must not be a file"); + } + Boolean persistence_dir_must_exist = getManagementContext().getConfig().getConfig(BrooklynServerConfig.PERSISTENCE_DIR_MUST_EXIST); + LOG.info("PERSISTENCE_DIR_MUST_EXIST {}", persistence_dir_must_exist); + if(persistence_dir_must_exist && !basedir.exists()) { + throw new UserFacingException("Destination directory '" + basedir + "' must exist"); + } return new FileBasedObjectStore(basedir); }