public AbstractSoftwareProcessSshDriver(EntityLocal entity, SshMachineLocation machine) { super(entity, machine); // FIXME this assumes we own the location, and causes warnings about configuring location after deployment; // better would be to wrap the ssh-execution-provider to supply these flags if (getSshFlags()!=null && !getSshFlags().isEmpty()) machine.configure(getSshFlags()); }
/** @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); }
@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; }