/** @deprecated since 0.5.0, destination should be a string not a File */ @Deprecated public void copyFile(File src, File destination) { getMachine().copyTo(src, destination); } /** @deprecated since 0.5.0, should use {@link copyResource(Map, String, String)}. */
/** @deprecated since 0.5.0, should use {@link copyResource(Map, String, String)}. */ @Deprecated @SuppressWarnings({ "unchecked", "rawtypes" }) public void copyFile(Map flags2, File src, String destination) { Map flags = new LinkedHashMap(); if (!flags2.containsKey(IGNORE_ENTITY_SSH_FLAGS)) flags.putAll(getSshFlags()); flags.putAll(flags2); getMachine().copyTo(flags, src, destination); }
public int copyTemplate(String template, String target, Map<String,? extends Object> extraSubstitutions) { // prefix with runDir if relative target String dest = target; if (!new File(target).isAbsolute()) { dest = getRunDir() + "/" + target; } String data = processTemplate(template, extraSubstitutions); int result = getMachine().copyTo(new StringReader(data), dest); if (log.isDebugEnabled()) log.debug("Copied filtered template for {}: {} to {} - result {}", new Object[] { entity, template, dest, result }); return result; }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public int execute(Map flags2, List<String> script, String summaryForLogging) { Map flags = new LinkedHashMap(); if (!flags2.containsKey(IGNORE_ENTITY_SSH_FLAGS)) flags.putAll(getSshFlags()); flags.putAll(flags2); Map<String, String> environment = (Map<String, String>) ((flags.get("env") != null) ? flags.get("env") : getShellEnvironment()); if (!flags.containsKey("logPrefix")) flags.put("logPrefix", ""+entity.getId()+"@"+getLocation().getDisplayName()); return getMachine().execScript(flags, summaryForLogging, script, environment); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public int copyResource(Map flags2, String resource, String target) { Map flags = Maps.newLinkedHashMap(); if (!flags2.containsKey(IGNORE_ENTITY_SSH_FLAGS)) flags.putAll(getSshFlags()); flags.putAll(flags2); // prefix with runDir if relative target String dest = target; if (!new File(target).isAbsolute()) { dest = getRunDir() + "/" + target; } int result = -1; // TODO allow s3://bucket/file URIs for AWS S3 resources // TODO use PAX-URL style URIs for maven artifacts if (resource.toLowerCase().matches("^https?://.*")) { // try resolving http resources remotely using curl result = getMachine().execCommands(flags, "download-resource", ImmutableList.of( BashCommands.INSTALL_CURL, String.format("curl -f --silent --insecure %s -o %s", resource, dest))); } // if not downloaded yet, retrieve locally and copy across if (result != 0) { result = getMachine().copyTo(flags, getResource(resource), dest); } if (log.isDebugEnabled()) log.debug("Copied file for {}: {} to {} - result {}", new Object[] { entity, resource, dest, result }); return result; }