Search in sources :

Example 1 with Utils

use of io.fabric8.kubernetes.client.utils.Utils in project fabric8 by jboss-fuse.

the class CloudContainerInstallationTask method uploadToNode.

private void uploadToNode(ComputeServiceContext context, NodeMetadata node, LoginCredentials credentials, URL url, String path) {
    Utils utils = context.utils();
    SshClient ssh = credentials != null ? utils.sshForNode().apply(NodeMetadataBuilder.fromNodeMetadata(nodeMetadata).credentials(credentials).build()) : utils.sshForNode().apply(node);
    try (InputStream is = url.openStream()) {
        ssh.connect();
        File distro = Files.createTempFile("/tmp");
        Files.copy(is, new FileOutputStream(distro));
        ssh.put(path, Payloads.newFilePayload(distro));
        distro.delete();
    } catch (IOException e) {
        LOGGER.warn("Failed to upload. Will attempt downloading distribution via maven.");
    } finally {
        if (ssh != null) {
            ssh.disconnect();
        }
    }
}
Also used : SshClient(org.jclouds.ssh.SshClient) Utils(org.jclouds.compute.Utils) ContainerProviderUtils(io.fabric8.internal.ContainerProviderUtils) InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File)

Aggregations

ContainerProviderUtils (io.fabric8.internal.ContainerProviderUtils)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Utils (org.jclouds.compute.Utils)1 SshClient (org.jclouds.ssh.SshClient)1