@Override public Utils getUtils() { return delegate().getUtils(); }
public WindowsInstanceStarter(Arguments arguments, ComputeServiceContext context) { this.arguments = arguments; this.context = context; logger = context.getUtils().getLoggerFactory().getLogger(WindowsInstanceStarter.class.getName()); ec2Client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()); computeService = context.getComputeService(); }
/** * Upload a file on a selected node * @param sourcePath path to the file to be uploaded * @param destinationPath path to the file to be created * @param nodeId Id of a node * @param login user login * @param key key to connect */ public void uploadFile(String sourcePath, String destinationPath, String nodeId, String login, String key){ try { String contentKey=FileUtils.readFileToString(new File(key)); SshClient ssh = compute.getContext().getUtils().sshForNode().apply(NodeMetadataBuilder.fromNodeMetadata(getNodeById(nodeId)).credentials(new LoginCredentials(login, null, contentKey, true)).build()); try { ssh.connect(); ssh.put(destinationPath, Payloads.newPayload(new File(sourcePath))); } finally { if (ssh != null) ssh.disconnect(); journal.log(Level.INFO, ">> File uploaded!"); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
WindowsLoginCredentialsFromEncryptedData f = computeServiceContext.getUtils().getInjector().getInstance(WindowsLoginCredentialsFromEncryptedData.class); LoginCredentials credentials = f.apply(dataAndKey);
ec2Client.getWindowsServices().getPasswordDataInRegion(region, node.getProviderId()), node.getCredentials().getPrivateKey()); WindowsLoginCredentialsFromEncryptedData f = context.getUtils().getInjector().getInstance(WindowsLoginCredentialsFromEncryptedData.class); LoginCredentials credentials = f.apply(dataAndKey);