-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It's [`RemoteLocation`] from aws-infrastructure, but without the AWS bits. [`RemoteLocation`]: https://github.com/atlassian/aws-infrastructure/blob/release-2.22.2/src/main/kotlin/com/atlassian/performance/tools/awsinfrastructure/api/RemoteLocation.kt
- Loading branch information
Showing
7 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/kotlin/com/atlassian/performance/tools/infrastructure/RemotePathExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.atlassian.performance.tools.infrastructure | ||
|
||
import com.atlassian.performance.tools.infrastructure.api.distribution.ProductDistribution | ||
import com.atlassian.performance.tools.infrastructure.api.jira.JiraHomeSource | ||
import com.atlassian.performance.tools.infrastructure.api.os.RemotePath | ||
import com.atlassian.performance.tools.ssh.api.SshConnection | ||
|
||
fun JiraHomeSource.downloadRemotely( | ||
ssh: SshConnection | ||
) = RemotePath(ssh.getHost(), this.download(ssh)) | ||
|
||
fun ProductDistribution.installRemotely( | ||
ssh: SshConnection, | ||
destination: String | ||
) = RemotePath(ssh.getHost(), this.install(ssh, destination)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/kotlin/com/atlassian/performance/tools/infrastructure/api/os/RemotePath.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.atlassian.performance.tools.infrastructure.api.os | ||
|
||
import com.atlassian.performance.tools.infrastructure.api.dataset.FileArchiver | ||
import com.atlassian.performance.tools.ssh.api.Ssh | ||
import com.atlassian.performance.tools.ssh.api.SshHost | ||
import java.nio.file.Path | ||
import java.time.Duration | ||
import javax.json.Json | ||
import javax.json.JsonObject | ||
|
||
/** | ||
* @since 4.18.0 | ||
*/ | ||
class RemotePath( | ||
val host: SshHost, | ||
val path: String | ||
) { | ||
|
||
constructor(json: JsonObject) : this( | ||
host = SshHost(json.getJsonObject("host")), | ||
path = json.getString("path") | ||
) | ||
|
||
fun toJson(): JsonObject = Json.createObjectBuilder() | ||
.add("host", host.toJson()) | ||
.add("path", path) | ||
.build() | ||
|
||
fun resolve(other: String): RemotePath = RemotePath(host, "$path/$other") | ||
|
||
fun move(destination: String, timeout: Duration): RemotePath { | ||
if (path != destination) { | ||
Ssh(host, connectivityPatience = 4).newConnection().use { ssh -> | ||
ssh.execute("sudo mv $path $destination", timeout) | ||
} | ||
} | ||
return RemotePath(host, destination) | ||
} | ||
|
||
fun archive(timeout: Duration): RemotePath { | ||
val destination = Ssh(host, connectivityPatience = 4).newConnection().use { ssh -> | ||
FileArchiver().zip(ssh, path, timeout) | ||
} | ||
return RemotePath(host, destination) | ||
} | ||
|
||
fun download( | ||
localDestination: Path | ||
) { | ||
Ssh(host, connectivityPatience = 4).newConnection().use { ssh -> | ||
ssh.download(path, localDestination) | ||
} | ||
} | ||
|
||
override fun toString(): String { | ||
return "RemotePath(host=$host, path='$path')" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters