public Builder resetGlobalFiles() { defaultLocationMetadataUrl = "classpath://brooklyn/location-metadata.properties"; globalLocationMetadataFile = Os.mergePaths(Os.home(), ".brooklyn", "location-metadata.properties"); globalPropertiesFile = Os.mergePaths(Os.home(), ".brooklyn", "brooklyn.properties"); return this; }
/** * Adds the given file or directory to the archive, preserving its name but putting under the given directory in the archive (may be <code>""</code> or <code>"./"</code>). * See also {@link #addDirContentsAt(File, String)} and {@link #addFromLocalBaseDir(File, String)}. */ public ArchiveBuilder addAt(File file, String archiveParentDir) { checkNotNull(archiveParentDir, "archiveParentDir"); checkNotNull(file, "file"); return entry(Os.mergePaths(archiveParentDir, file.getName()), file); }
public Builder resetGlobalFiles() { defaultLocationMetadataUrl = "classpath://brooklyn/location-metadata.properties"; globalLocationMetadataFile = Os.mergePaths(Os.home(), ".brooklyn", "location-metadata.properties"); globalPropertiesFile = Os.mergePaths(Os.home(), ".brooklyn", "brooklyn.properties"); return this; }
/** {@inheritDoc} */ @Override public String layerSshableImageOn(String fullyQualifiedImageName) { checkNotNull(fullyQualifiedImageName, "fullyQualifiedImageName"); copyTemplate(DockerUtils.SSHD_DOCKERFILE, Os.mergePaths(fullyQualifiedImageName, "Sshd" + DockerUtils.DOCKERFILE), true, ImmutableMap.<String, Object>of("fullyQualifiedImageName", fullyQualifiedImageName)); String sshdImageId = buildDockerfile("Sshd" + DockerUtils.DOCKERFILE, fullyQualifiedImageName); log.info("Created SSH-based image from {} with ID {}", fullyQualifiedImageName, sshdImageId); return sshdImageId; }
public void testMergePaths() throws Exception { assertEquals(Os.mergePaths("a"), "a"); assertEquals(Os.mergePaths("a", "b"), "a/b"); assertEquals(Os.mergePaths("a/", "b"), "a/b"); assertEquals(Os.mergePaths("a", "b/"), "a/b/"); assertEquals(Os.mergePaths("/a", "b"), "/a/b"); }
/** allow the temp dir where ssh temporary files on the brooklyn server side are placed */ public static void setLocalTempDir(Map<String,?> source, ConfigBag target) { // TODO better would be to use BrooklynServerConfig, requiring management passed in String brooklynDataDir = (String) source.get(BrooklynServerConfig.getMgmtBaseDir(source)); if (brooklynDataDir != null && brooklynDataDir.length() > 0) { String tempDir = Os.mergePaths(brooklynDataDir, "tmp", "ssh"); target.putIfAbsentAndNotNull(SshTool.PROP_LOCAL_TEMP_DIR, tempDir); Os.deleteOnExitEmptyParentsUpTo(new File(tempDir), new File(brooklynDataDir)); } }
protected File getPersistanceFile(BrooklynObjectType type, String id) { String dir; switch (type) { case POLICY: dir = "policies"; break; default: throw new UnsupportedOperationException("type="+type); } return new File(mementoDir, Os.mergePaths(dir, id)); } }
@Override public StoreObjectAccessor newAccessor(String path) { if (!prepared) throw new IllegalStateException("Not yet prepared: "+this); String tmpExt = ".tmp"; if (mgmt!=null && mgmt.getManagementNodeId()!=null) tmpExt = "."+mgmt.getManagementNodeId()+tmpExt; return new FileBasedStoreObjectAccessor(new File(Os.mergePaths(getBaseDir().getAbsolutePath(), path)), tmpExt); }
@Override public String getAppDir() { return Os.mergePaths(getRunDir(), getEntity().getConfig(NodeJsWebAppService.APP_NAME)); }
@Test public void testCreateZipFromFilesWithBaseDir() throws Exception { ArchiveBuilder builder = ArchiveBuilder.zip(); String baseDir = tmpDir.getName(); for (String fileName : Arrays.asList("data01.txt", "data02.txt", "data03.txt")) { builder.addFromLocalBaseDir(parentDir, Os.mergePaths(baseDir, fileName)); } buildAndValidatePrefix(builder, Os.mergePaths(baseDir, "data")); }
@Override public void prepare() { resolver = Entities.newDownloader(this); setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("jboss-as-%s", getVersion())))); }
@Override public void prepare() { resolver = Entities.newDownloader(this, ImmutableMap.of("filename", getInstallFilename())); setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("mariadb-%s-%s", getVersion(), getOsTag())))); }
private File newZip(Map<String, String> files) throws Exception { File parentDir = Os.newTempDir(getClass().getSimpleName()+"-archive"); for (Map.Entry<String, String> entry : files.entrySet()) { File subFile = new File(Os.mergePaths(parentDir.getAbsolutePath(), entry.getKey())); subFile.getParentFile().mkdirs(); Files.write(entry.getValue(), subFile, Charsets.UTF_8); } return ArchiveBuilder.zip().addDirContentsAt(parentDir, ".").create(); }
private String buildDockerfile(String dockerfile, String name) { String build = format("build --rm -t %s - < %s", name, Os.mergePaths(getRunDir(), name, dockerfile)); String stdout = ((DockerHost) getEntity()).runDockerCommandTimeout(build, Duration.minutes(20)); String prefix = Strings.getFirstWordAfter(stdout, "Successfully built"); return getImageId(prefix, name); }
@Test(groups = {"Integration"}) public void testOutputAsExpected() throws Exception { final String CONTENTS = "hello world\n" + "bye bye\n"; execCommands("cat > "+Os.mergePaths(Os.tmp(), "test1")+" << X\n" + CONTENTS + "X\n"); String read = execCommands("echo START_FOO", "cat "+Os.mergePaths(Os.tmp(), "test1"), "echo END_FOO"); log.debug("read back data written, as:\n"+read); String contents = Strings.getFragmentBetween(read, "START_FOO", "END_FOO"); Assert.assertEquals(CONTENTS.trim(), contents.trim()); }
protected void doReadConfigInheritance(String label, String entityId) throws Exception { String mementoFilename = "config-inheritance-"+label+"-"+entityId; origMemento = Streams.readFullyString(getClass().getResourceAsStream(mementoFilename)); File persistedEntityFile = new File(mementoDir, Os.mergePaths("entities", entityId)); Files.write(origMemento.getBytes(), persistedEntityFile); // we'll make assertions on what we've loaded rebind(); rebindedApp = (Application) newManagementContext.lookup(entityId); // we'll also make assertions on the contents written out RebindTestUtils.waitForPersisted(mgmt()); newMemento = Joiner.on("\n").join(Files.readLines(persistedEntityFile, Charsets.UTF_8)); }
@Override public void prepare() { resolver = Entities.newDownloader(this); String unpackedDirectoryName = resolver.getUnpackedDirectoryName(getDefaultUnpackedDirectoryName()); setExpandedInstallDir(Os.mergePaths(getInstallDir(), unpackedDirectoryName)); }
@Test public void testDeleteRecursivelyNonExistantDir() throws Exception { DeletionResult result = Os.deleteRecursively(Os.mergePaths(Os.tmp(), Identifiers.makeRandomId(8))); assertTrue(result.wasSuccessful()); }
public void testResolvesLocalTempDir() throws Exception { String localTempDir = Os.mergePaths(Os.tmp(), "testResolvesUsernameAtHost"); brooklynProperties.put("brooklyn.location.byon.localTempDir", localTempDir); FixedListMachineProvisioningLocation<MachineLocation> byon = resolve("byon(hosts=\"1.1.1.1\",osFamily=\"windows\")"); MachineLocation machine = byon.obtain(); assertEquals(machine.getConfig(SshMachineLocation.LOCAL_TEMP_DIR), localTempDir); }
@Test(groups="Integration") public void testWebServerTempDirRespectsDataDirConfig() throws Exception { String dataDirName = ".brooklyn-foo"+Strings.makeRandomId(4); String dataDir = "~/"+dataDirName; launcher = newLauncherForTests(true) .brooklynProperties(BrooklynServerConfig.MGMT_BASE_DIR, dataDir) .start(); ManagementContext managementContext = launcher.getServerDetails().getManagementContext(); String expectedTempDir = Os.mergePaths(Os.home(), dataDirName, "planes", managementContext.getManagementNodeId(), "jetty"); File webappTempDir = launcher.getServerDetails().getWebServer().getWebappTempDir(); assertEquals(webappTempDir.getAbsolutePath(), expectedTempDir); }