public static void deploy(Map<String, ?> props, String archiveUrl, SshMachineLocation machine, String destDir, String destFile) { deploy(props, archiveUrl, machine, destDir, destDir, destFile); } public static void deploy(Map<String, ?> props, String archiveUrl, SshMachineLocation machine, String tmpDir, String destDir, String destFile) {
public static void deploy(Map<String, ?> props, String archiveUrl, SshMachineLocation machine, String tmpDir, String destDir, String destFile) { deploy(null, props, archiveUrl, machine, destDir, true, tmpDir, destFile); }
/** * Deploys an archive file to a remote machine and extracts the contents. */ public static void deploy(String archiveUrl, SshMachineLocation machine, String destDir) { deploy(MutableMap.<String, Object>of(), archiveUrl, machine, destDir); }
/** * Deploys an archive file to a remote machine and extracts the contents. * <p> * Copies the archive file from the given URL to a file in the destination directory and extracts * the contents. * * @see #deploy(String, SshMachineLocation, String) * @see #deploy(Map, String, SshMachineLocation, String, String, String) */ public static void deploy(String archiveUrl, SshMachineLocation machine, String destDir, String destFile) { deploy(MutableMap.<String, Object>of(), archiveUrl, machine, destDir, destDir, destFile); } public static void deploy(Map<String, ?> props, String archiveUrl, SshMachineLocation machine, String destDir, String destFile) {
/** * Deploys an archive file to a remote machine and extracts the contents. * <p> * Copies the archive file from the given URL to the destination directory and extracts * the contents. If the URL is a local directory, the contents are packaged as a Zip archive first. * * @see #deploy(String, SshMachineLocation, String, String) * @see #deploy(Map, String, SshMachineLocation, String, String, String) */ public static void deploy(Map<String, ?> props, String archiveUrl, SshMachineLocation machine, String destDir) { if (Urls.isDirectory(archiveUrl)) { File zipFile = ArchiveBuilder.zip().entry(".", Urls.toFile(archiveUrl)).create(); archiveUrl = zipFile.getAbsolutePath(); } // Determine filename String destFile = archiveUrl.contains("?") ? archiveUrl.substring(0, archiveUrl.indexOf('?')) : archiveUrl; destFile = destFile.substring(destFile.lastIndexOf('/') + 1); deploy(props, archiveUrl, machine, destDir, destFile); }
@Test(groups="Integration") public void testDeployZipDeletingArchiveAfterUnpack() throws Exception { boolean result = ArchiveUtils.deploy(resourceUtils, ImmutableMap.<String, Object>of(), origZip.getAbsolutePath(), machine, destDir.getAbsolutePath(), false, null, null); assertTrue(result); assertFalse(new File(destDir, origZip.getName()).exists()); assertSubFilesEqual(destDir, archiveContents); }
@Override public String deployArchive(String url) { String volumeId = Identifiers.makeIdFromHash(url.hashCode()); String path = Os.mergePaths(getRunDir(), volumeId); ArchiveUtils.deploy(url, getMachine(), path); return path; }
@Test(groups="Integration") public void testDeployJarNotUnpacked() throws Exception { ArchiveUtils.deploy(origJar.getAbsolutePath(), machine, destDir.getAbsolutePath()); assertFilesEqual(new File(destDir, origJar.getName()), origJar); }
@Test(groups="Integration") public void testDeployExplicitDestFile() throws Exception { String destFile = "custom-destFile.jar"; ArchiveUtils.deploy(origJar.getAbsolutePath(), machine, destDir.getAbsolutePath(), destFile); assertFilesEqual(new File(destDir, destFile), origJar); }
@Override @Effector(description="Deploys an archive of static content to the server") public void deploy(String archiveUrl) { NginxSshDriver driver = (NginxSshDriver) getDriver(); if (driver==null) { if (LOG.isDebugEnabled()) LOG.debug("No driver for {}, so not deploying archive (is entity stopping? state={})", this, getAttribute(NginxController.SERVICE_STATE_ACTUAL)); return; } // Copy to the destination machine and extract contents ArchiveUtils.deploy(archiveUrl, driver.getMachine(), driver.getRunDir()); }
@Test(groups="Integration") public void testDeployZipWithNoOptionalArgsSupplied() throws Exception { boolean result = ArchiveUtils.deploy(resourceUtils, ImmutableMap.<String, Object>of(), origZip.getAbsolutePath(), machine, destDir.getAbsolutePath(), true, null, null); assertTrue(result); assertFilesEqual(new File(destDir, origZip.getName()), origZip); assertSubFilesEqual(destDir, archiveContents); }
@Override public void customize() { List<String> commands = Lists.newLinkedList(); String gitRepoUrl = getEntity().getConfig(NodeJsWebAppService.APP_GIT_REPOSITORY_URL); String archiveUrl = getEntity().getConfig(NodeJsWebAppService.APP_ARCHIVE_URL); String appName = getEntity().getConfig(NodeJsWebAppService.APP_NAME); if (Strings.isNonBlank(gitRepoUrl) && Strings.isNonBlank(archiveUrl)) { throw new IllegalStateException("Only one of Git or archive URL must be set for " + getEntity()); } else if (Strings.isNonBlank(gitRepoUrl)) { commands.add(String.format("git clone %s %s", gitRepoUrl, appName)); commands.add(String.format("cd %s", appName)); } else if (Strings.isNonBlank(archiveUrl)) { ArchiveUtils.deploy(archiveUrl, getMachine(), getRunDir()); } else { throw new IllegalStateException("At least one of Git or archive URL must be set for " + getEntity()); } commands.add(BashCommands.ifFileExistsElse1("package.json", "npm install")); List<String> packages = getEntity().getConfig(NodeJsWebAppService.NODE_PACKAGE_LIST); if (packages != null && packages.size() > 0) { commands.add(BashCommands.sudo("npm install -g " + Joiner.on(' ').join(packages))); } newScript(CUSTOMIZING) .body.append(commands) .execute(); }
String imageDir = Os.mergePaths(getRunDir(), name); if (!ArchiveType.UNKNOWN.equals(ArchiveType.of(dockerfile)) || Urls.isDirectory(dockerfile)) { ArchiveUtils.deploy(dockerfile, getMachine(), imageDir); imageId = buildDockerfileDirectory(name); log.info("Created base Dockerfile image with ID {}", imageId); } else { if (contextArchive.isPresent()) { ArchiveUtils.deploy(contextArchive.get(), getMachine(), imageDir); } else { ProcessTaskWrapper<Integer> task = SshEffectorTasks.ssh(format("mkdir -p %s", imageDir))
destFile = destFile.substring(destFile.lastIndexOf('/') + 1); ArchiveUtils.deploy(MutableMap.<String, Object>of(), entry, machine, getRunDir(), Os.mergePaths(getRunDir(), "lib"), destFile);
ArchiveUtils.deploy(MutableMap.<String, Object>of(), url, machine, getRunDir(), Os.mergePaths(getRunDir(), "lib", "dropins"), filename);