Skip to content

Commit

Permalink
Merge pull request #3 from Akaizoku/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Akaizoku authored Feb 26, 2020
2 parents c8a95cd + e5fbb13 commit 9345e04
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 73 deletions.
16 changes: 3 additions & 13 deletions Private/Write-JBossClientCmd.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ function Write-JBossClientCmd {
File name: Write-JBossClientCmd.ps1
Author: Florian Carrier
Creation date: 21/10/2019
Last modified: 15/01/2020
Last modified: 28/01/2020
TODO: - Handle path with spaces with batch script
- Prevent pause with batch script
#>
[CmdletBinding (
SupportsShouldProcess = $true
)]
Param (
[Parameter (
Position = 1,
Mandatory = $false,
Mandatory = $true,
HelpMessage = "Path to JBoss client"
)]
[ValidateNotNUllOrEmpty ()]
Expand Down Expand Up @@ -74,13 +75,6 @@ function Write-JBossClientCmd {
Begin {
# Get global preference variables
Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState
# JBoss client path
if ($PSBoundParameters.ContainsKey('Path')) {
$JBossCliPath = $Path
} else {
# Use PATH environment variable
$JBossCliPath = 'jboss-cli.bat'
}
# Batch command error stream redirection
if ($Redirect) {
$Redirection = "2>&1"
Expand Down Expand Up @@ -113,10 +107,6 @@ function Write-JBossClientCmd {
$JBossCliCmd = "& ""$Path"" $CommandLine".Trim()
}
default {
# If path exists
if ($JBossClient) {
Write-Log -Type "ERROR" -Object "Unsupported JBoss client type ($Extension)"
}
Write-Log -Type "WARN" -Object "Defaulting to Windows Command line."
$JBossCliCmd = "cmd /c '""$Path"" $CommandLine $Redirection'".Trim()
}
Expand Down
25 changes: 21 additions & 4 deletions Public/Invoke-JBossClient.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ function Invoke-JBossClient {
File name: Invoke-JBossClient.ps1
Author: Florian Carrier
Creation date: 21/10/2019
Last modified: 22/01/2020
Last modified: 28/01/2020
#>
[CmdletBinding (
SupportsShouldProcess = $true
)]
Param (
[Parameter (
Position = 1,
Mandatory = $true,
Mandatory = $false,
HelpMessage = "Path to the JBoss client"
)]
[ValidateNotNUllOrEmpty ()]
Expand Down Expand Up @@ -75,6 +75,18 @@ function Invoke-JBossClient {
Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState
}
Process {
# JBoss client path
if ($PSBoundParameters.ContainsKey('Path')) {
# Check path
if (-Not (Test-Path -Path $Path)) {
return "Path not found $Path"
exit 1
}
} else {
# Use PATH environment variable
Write-Log -Type "WARN" -Object "No path was provided, using PATH environment variable"
$Path = 'jboss-cli.ps1'
}
# Check controller
if ($PSBoundParameters.ContainsKey("Controller")) {
# Remote controller
Expand All @@ -96,8 +108,13 @@ function Invoke-JBossClient {
}
}
# Execute command
$JBossCliLog = Invoke-Expression -Command $JBossCliCmd | Out-String
Write-Log -Type "DEBUG" -Object $JBossCliLog
try {
$JBossCliLog = Invoke-Expression -Command $JBossCliCmd | Out-String
Write-Log -Type "DEBUG" -Object $JBossCliLog
} catch {
return $Error[0].Exception
exit 1
}
# Return log
return $JBossCliLog
}
Expand Down
40 changes: 32 additions & 8 deletions Public/Invoke-ReloadServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Invoke-ReloadServer {
The path parameter corresponds to the path to the JBoss client.
.PARAMETER Controller
The controller parameter corresponds to the hostname and port of the JBoss host.
The optional controller parameter corresponds to the hostname and port of the JBoss host.
.PARAMETER Credentials
The optional credentials parameter correspond to the credentials of the account to use to connect to JBoss.
Expand All @@ -30,7 +30,7 @@ function Invoke-ReloadServer {
File name: Invoke-ReloadServer.ps1
Author: Florian Carrier
Creation date: 02/12/2019
Last modified: 10/01/2020
Last modified: 28/01/2020
.LINK
Invoke-JBossClient
Expand All @@ -41,15 +41,15 @@ function Invoke-ReloadServer {
Param (
[Parameter (
Position = 1,
Mandatory = $true,
Mandatory = $false,
HelpMessage = "Path to the JBoss client"
)]
[ValidateNotNUllOrEmpty ()]
[String]
$Path,
[Parameter (
Position = 2,
Mandatory = $true,
Mandatory = $false,
HelpMessage = "Controller"
)]
# TODO validate format
Expand All @@ -72,11 +72,35 @@ function Invoke-ReloadServer {
Process {
# Define command
$Command = ':reload()'
# Execute command
if ($PSBoundParameters.ContainsKey('Credentials')) {
Invoke-JBossClient -Path $Path -Controller $Controller -Command $Command -Credentials $Credentials -Redirect
# Run command
if ($PSBoundParameters.ContainsKey("Path")) {
if ($PSBoundParameters.ContainsKey("Controller")) {
if ($PSBoundParameters.ContainsKey("Credentials")) {
Invoke-JBossClient -Path $Path -Controller $Controller -Command $Command -Credentials $Credentials
} else {
Invoke-JBossClient -Path $Path -Controller $Controller -Command $Command
}
} else {
if ($PSBoundParameters.ContainsKey("Credentials")) {
Invoke-JBossClient -Path $Path -Command $Command -Credentials $Credentials
} else {
Invoke-JBossClient -Path $Path -Command $Command
}
}
} else {
Invoke-JBossClient -Path $Path -Controller $Controller -Command $Command -Redirect
if ($PSBoundParameters.ContainsKey("Controller")) {
if ($PSBoundParameters.ContainsKey("Credentials")) {
Invoke-JBossClient -Controller $Controller -Command $Command -Credentials $Credentials
} else {
Invoke-JBossClient -Controller $Controller -Command $Command
}
} else {
if ($PSBoundParameters.ContainsKey("Credentials")) {
Invoke-JBossClient -Command $Command -Credentials $Credentials
} else {
Invoke-JBossClient -Command $Command
}
}
}
}
}
23 changes: 14 additions & 9 deletions Public/Test-JBossClientOutcome.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Test-JBossClientOutcome {
File name: Test-JBossClientOutcome.ps1
Author: Florian Carrier
Creation date: 10/01/2020
Last modified: 10/01/2020
Last modified: 26/02/2020
#>
[CmdletBinding()]
Param (
Expand All @@ -24,22 +24,27 @@ function Test-JBossClientOutcome {
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true
)]
[ValidateNotNullOrEmpty()]
[Object]
# [ValidateNotNullOrEmpty()]
[System.Object]
$Log
)
Begin {
# Get global preference variables
Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState
}
Process {
# Check JBoss client operation outcome
if (Select-String -InputObject $Log -Pattern '"outcome" => "success"' -SimpleMatch -Quiet) {
# If outcome is successfull
return $true
} else {
# If outcome is failed or an error occured
# Check if log contains information
if (($Log -eq $null) -Or ($Log -eq "")) {
return $false
} else {
# Check JBoss client operation outcome
if (Select-String -InputObject $Log -Pattern '"outcome" => "success"' -SimpleMatch -Quiet) {
# If outcome is successfull
return $true
} else {
# If outcome is failed or an error occured
return $false
}
}
}
}
3 changes: 2 additions & 1 deletion Public/Test-Resource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ function Test-Resource {
File name: Test-Resource.ps1
Author: Florian Carrier
Creation date: 14/01/2020
Last modified: 14/01/2020
Last modified: 26/02/2020
TODO Wait for return from JBoss client to prevnt issue "Cannot validate argument on parameter 'Log'. The argument is null or empty."
.LINK
Invoke-JBossClient
Expand Down
89 changes: 51 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ WildFly PowerShell Module (PSWF) is a framework to manage WildFly using PowerShe
### Installation

There are two ways of setting up the WildFly PowerShell Module on your system:
1. Download the PSWF module from the [Github repository](https://github.com/Akaizoku/PSWF);
1. Install the PSWF module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/PSWF).
1. Download the PSWF module from the [Github repository](https://github.com/Akaizoku/PSWF);
2. Install the PSWF module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/PSWF).

```powershell
Install-Module -Name "PSWF" -Repository "PSGallery"
Expand All @@ -37,42 +37,55 @@ Import-Module -Name "PSWF"
Get-Command -Module "PSWF"
```

| CommandType | Name | Version | Source |
| ----------- | ---- | ------- | ------ |
| Function | Add-DataSource | 1.0.0 | PSWF |
| Function | Add-JDBCDriver | 1.0.0 | PSWF |
| Function | Add-Module | 1.0.0 | PSWF |
| Function | Add-SecurityRole | 1.0.0 | PSWF |
| Function | Add-User | 1.0.0 | PSWF |
| Function | Add-UserGroupRole | 1.0.0 | PSWF |
| Function | Disable-RBAC | 1.0.0 | PSWF |
| Function | Enable-RBAC | 1.0.0 | PSWF |
| Function | Grant-SecurityRole | 1.0.0 | PSWF |
| Function | Invoke-DeployWAR | 1.0.0 | PSWF |
| Function | Invoke-JBossClient | 1.0.0 | PSWF |
| Function | Invoke-ReloadServer | 1.0.0 | PSWF |
| Function | Invoke-UndeployWAR | 1.0.0 | PSWF |
| Function | Read-DeploymentStatus | 1.0.0 | PSWF |
| Function | Read-Resource | 1.0.0 | PSWF |
| Function | Read-ServerState | 1.0.0 | PSWF |
| Function | Remove-DataSource | 1.0.0 | PSWF |
| Function | Remove-JDBCDriver | 1.0.0 | PSWF |
| Function | Remove-Module | 1.0.0 | PSWF |
| Function | Remove-Resource | 1.0.0 | PSWF |
| Function | Remove-SecurityRole | 1.0.0 | PSWF |
| Function | Remove-User | 1.0.0 | PSWF |
| Function | Remove-UserGroupRole | 1.0.0 | PSWF |
| Function | Resolve-ServerState | 1.0.0 | PSWF |
| Function | Set-Interface | 1.0.0 | PSWF |
| Function | Set-JavaOptions | 1.0.0 | PSWF |
| Function | Set-PortNumber | 1.0.0 | PSWF |
| Function | Set-PortOffset | 1.0.0 | PSWF |
| Function | Test-JBossClientOutcome | 1.0.0 | PSWF |
| Function | Test-Module | 1.0.0 | PSWF |
| Function | Test-SecurityRole | 1.0.0 | PSWF |
| Function | Test-ServerState | 1.0.0 | PSWF |
| Function | Test-User | 1.0.0 | PSWF |
| Function | Test-UserGroupRole | 1.0.0 | PSWF |
| CommandType | Name | Version | Source |
| ----------- | -------------------------- | ------- | ------ |
| Function | Add-DataSource | 1.0.1 | PSWF |
| Function | Add-JDBCDriver | 1.0.1 | PSWF |
| Function | Add-Module | 1.0.1 | PSWF |
| Function | Add-Resource | 1.0.1 | PSWF |
| Function | Add-SecurityDomain | 1.0.1 | PSWF |
| Function | Add-SecurityRole | 1.0.1 | PSWF |
| Function | Add-User | 1.0.1 | PSWF |
| Function | Add-UserGroupRole | 1.0.1 | PSWF |
| Function | Disable-DataSource | 1.0.1 | PSWF |
| Function | Disable-Deployment | 1.0.1 | PSWF |
| Function | Disable-RBAC | 1.0.1 | PSWF |
| Function | Enable-DataSource | 1.0.1 | PSWF |
| Function | Enable-Deployment | 1.0.1 | PSWF |
| Function | Enable-RBAC | 1.0.1 | PSWF |
| Function | Get-DeploymentStatus | 1.0.1 | PSWF |
| Function | Grant-SecurityRole | 1.0.1 | PSWF |
| Function | Invoke-DeployApplication | 1.0.1 | PSWF |
| Function | Invoke-JBossClient | 1.0.1 | PSWF |
| Function | Invoke-ReloadServer | 1.0.1 | PSWF |
| Function | Invoke-UndeployApplication | 1.0.1 | PSWF |
| Function | Read-Attribute | 1.0.1 | PSWF |
| Function | Read-DeploymentStatus | 1.0.1 | PSWF |
| Function | Read-Resource | 1.0.1 | PSWF |
| Function | Read-SecurityDomain | 1.0.1 | PSWF |
| Function | Read-ServerState | 1.0.1 | PSWF |
| Function | Remove-Attribute | 1.0.1 | PSWF |
| Function | Remove-DataSource | 1.0.1 | PSWF |
| Function | Remove-JDBCDriver | 1.0.1 | PSWF |
| Function | Remove-Module | 1.0.1 | PSWF |
| Function | Remove-Resource | 1.0.1 | PSWF |
| Function | Remove-SecurityDomain | 1.0.1 | PSWF |
| Function | Remove-SecurityRole | 1.0.1 | PSWF |
| Function | Remove-User | 1.0.1 | PSWF |
| Function | Remove-UserGroupRole | 1.0.1 | PSWF |
| Function | Test-DataSource | 1.0.1 | PSWF |
| Function | Test-DataSourceConnection | 1.0.1 | PSWF |
| Function | Test-Deployment | 1.0.1 | PSWF |
| Function | Test-JBossClientOutcome | 1.0.1 | PSWF |
| Function | Test-JDBCDriver | 1.0.1 | PSWF |
| Function | Test-Module | 1.0.1 | PSWF |
| Function | Test-Resource | 1.0.1 | PSWF |
| Function | Test-SecurityDomain | 1.0.1 | PSWF |
| Function | Test-SecurityRole | 1.0.1 | PSWF |
| Function | Test-ServerState | 1.0.1 | PSWF |
| Function | Test-User | 1.0.1 | PSWF |
| Function | Test-UserGroupRole | 1.0.1 | PSWF |
| Function | Write-Attribute | 1.0.1 | PSWF |

## Dependencies

Expand Down

0 comments on commit 9345e04

Please sign in to comment.