diff --git a/CHANGELOG.md b/CHANGELOG.md index c80746d..3dc072f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.8.0]() - 2024-02-23 +### Fixed +- Support 200 and 201 status codes in all commandlets from PR #18 +- Tested against OME 4.0, no code changes required + +### Changed +- New-OMEDiscovery to support all Protocol types supported in OME +- Edit-OMEDiscovery to support all Protocol types supported in OME. Closes #19 + ## [3.7.0]() - 2023-10-27 ### Added - Get-OMEProfile diff --git a/DellOpenManage/DellOpenManage.psd1 b/DellOpenManage/DellOpenManage.psd1 index 43a7b73..b0e5902 100644 --- a/DellOpenManage/DellOpenManage.psd1 +++ b/DellOpenManage/DellOpenManage.psd1 @@ -3,7 +3,7 @@ # # Generated by: Trevor Squillario # -# Generated on: 10/27/2023 +# Generated on: 2/23/2024 # @{ @@ -12,7 +12,7 @@ RootModule = 'DellOpenManage.psm1' # Version number of this module. -ModuleVersion = '3.7.0' +ModuleVersion = '3.8.0' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/DellOpenManage/Private/Get-DiscoveryProtocolPayload.ps1 b/DellOpenManage/Private/Get-DiscoveryProtocolPayload.ps1 new file mode 100755 index 0000000..ebe89f4 --- /dev/null +++ b/DellOpenManage/Private/Get-DiscoveryProtocolPayload.ps1 @@ -0,0 +1,115 @@ +<# +.SYNOPSIS +Generate JSON object to be used when submitting Jobs to the DiscoveryConfigService + +.DESCRIPTION + +.PARAMETER $Protocol +String containing protocol + +.OUTPUTS +PCCustomObject +#> +function Get-DiscoveryProtocolPayload($Protocol) { + + $WSManProtocolPayload = '{ + "type":"WSMAN", + "authType":"Basic", + "modified":false, + "credentials": { + "username":"", + "password":"", + "caCheck":false, + "cnCheck":false, + "port":443, + "retries":3, + "timeout": 60 + } + }' | ConvertFrom-Json + + $RedfishProtocolPayload = '{ + "type":"REDFISH", + "authType":"Basic", + "modified":false, + "credentials": { + "username":"", + "password":"", + "caCheck":false, + "cnCheck":false, + "port":443, + "retries":3, + "timeout": 60 + } + }' | ConvertFrom-Json + + $VMwareProtocolPayload = '{ + "type":"VMWARE", + "authType":"Basic", + "modified":false, + "credentials":{ + "username":"", + "password":"", + "caCheck":false, + "cnCheck":false, + "port":443, + "retries":3, + "timeout":60, + "isHttp":false, + "keepAlive":false} + }' | ConvertFrom-Json + + $SNMPProtocolPayload = '{ + "type":"SNMP", + "authType":"Basic", + "modified":false, + "credentials":{ + "community":"public", + "enableV1V2":true, + "port":161, + "retries":3, + "timeout":3} + }' | ConvertFrom-Json + + $IPMIProtocolPayload = '{ + "type":"IPMI", + "authType":"Basic", + "modified":false, + "credentials":{ + "username":"", + "password":"", + "privilege":2, + "retries":3, + "timeout":59} + }' | ConvertFrom-Json + + $SSHProtocolPayload = '{ + "type":"SSH", + "authType":"Basic", + "modified":false, + "credentials":{ + "username":"", + "isSudoUser":false, + "password":"", + "port":22, + "useKey":false, + "retries":1, + "timeout":59, + "checkKnownHosts":false} + }' | ConvertFrom-Json + + $Payload = $null + if ($Protocol -eq "WSMAN") { + $Payload = $WSManProtocolPayload + } elseif ($Protocol -eq "REDFISH") { + $Payload = $RedfishProtocolPayload + } elseif ($Protocol -eq "VMWARE") { + $Payload = $VMwareProtocolPayload + } elseif ($Protocol -eq "SNMP") { + $Payload = $SNMPProtocolPayload + } elseif ($Protocol -eq "IPMI") { + $Payload = $IPMIProtocolPayload + } elseif ($Protocol -eq "SSH") { + $Payload = $SSHProtocolPayload + } + return $Payload +} \ No newline at end of file diff --git a/DellOpenManage/Public/OME/Edit-OMEDiscovery.ps1 b/DellOpenManage/Public/OME/Edit-OMEDiscovery.ps1 index f99aa0c..d84e172 100644 --- a/DellOpenManage/Public/OME/Edit-OMEDiscovery.ps1 +++ b/DellOpenManage/Public/OME/Edit-OMEDiscovery.ps1 @@ -1,6 +1,6 @@ using module ..\..\Classes\Discovery.psm1 -function Update-DiscoverDevicePayload($HostList, $DiscoveryJob, $Mode, $DiscoveryUserName, [SecureString] $DiscoveryPassword, $Email, $Schedule, $ScheduleCron) { +function Update-DiscoverDevicePayload($HostList, $DiscoveryJob, $Protocol, $Mode, $DiscoveryUserName, [SecureString] $DiscoveryPassword, $Email, $Schedule, $ScheduleCron) { $DiscoveryConfigPayload = '{ "DiscoveryConfigGroupId":11, "DiscoveryConfigGroupName":"Server Discovery", @@ -13,39 +13,12 @@ function Update-DiscoverDevicePayload($HostList, $DiscoveryJob, $Mode, $Discover "AddressType": 30 } ], - "ConnectionProfile":"{ - \"profileName\":\"\", - \"profileDescription\":\"\", - \"type\":\"DISCOVERY\", - \"credentials\":[{ - \"type\":\"WSMAN\", - \"authType\":\"Basic\", - \"modified\":false, - \"credentials\": { - \"username\":\"\", - \"password\":\"\", - \"caCheck\":false, - \"cnCheck\":false, - \"port\":443, - \"retries\":3, - \"timeout\": 60 - } - }, - { - \"type\":\"REDFISH\", - \"authType\":\"Basic\", - \"modified\":false, - \"credentials\": { - \"username\":\"\", - \"password\":\"\", - \"caCheck\":false, - \"cnCheck\":false, - \"port\":443, - \"retries\":3, - \"timeout\": 60 - } - }] - }", + "ConnectionProfile":{ + "profileName":"", + "profileDescription":"", + "type":"DISCOVERY", + "credentials":[] + }, "DeviceType":[1000] }], "Schedule":{ @@ -72,11 +45,37 @@ function Update-DiscoverDevicePayload($HostList, $DiscoveryJob, $Mode, $Discover $DiscoveryConfigPayload.CommunityString = $DiscoveryJob.CommunityString # Update credentials - $ConnectionProfile = $DiscoveryConfigPayload.DiscoveryConfigModels[0].ConnectionProfile | ConvertFrom-Json - $ConnectionProfile.credentials[0].credentials.'username' = $DiscoveryUserName - $ConnectionProfile.credentials[0].credentials.'password' = $DiscoveryPasswordText - $ConnectionProfile.credentials[1].credentials.'username' = $DiscoveryUserName - $ConnectionProfile.credentials[1].credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile = $DiscoveryConfigPayload.DiscoveryConfigModels[0].ConnectionProfile + if ($Protocol -eq "iDRAC") { + $WSManProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "WSMAN" + $RedfishProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "REDFISH" + $WSManProtocolPayload.credentials.'username' = $DiscoveryUserName + $WSManProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $RedfishProtocolPayload.credentials.'username' = $DiscoveryUserName + $RedfishProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile.credentials += $WSManProtocolPayload + $ConnectionProfile.credentials += $RedfishProtocolPayload + } elseif ($Protocol -eq "VMWARE") { + $VMwareProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "VMWARE" + $VMwareProtocolPayload.credentials.'username' = $DiscoveryUserName + $VMwareProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile.credentials += $VMwareProtocolPayload + } elseif ($Protocol -eq "SNMP") { + $SNMPProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "SNMP" + $SNMPProtocolPayload.credentials.'username' = $DiscoveryUserName + $SNMPProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile.credentials += $SNMPProtocolPayload + } elseif ($Protocol -eq "IPMI") { + $IPMIProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "IPMI" + $IPMIProtocolPayload.credentials.'username' = $DiscoveryUserName + $IPMIProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile.credentials += $IPMIProtocolPayload + } elseif ($Protocol -eq "SSH") { + $SSHProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "SSH" + $SSHProtocolPayload.credentials.'username' = $DiscoveryUserName + $SSHProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile.credentials += $SSHProtocolPayload + } $DiscoveryConfigPayload.DiscoveryConfigModels[0].ConnectionProfile = $ConnectionProfile | ConvertTo-Json -Depth 6 # Update target hosts @@ -186,6 +185,8 @@ limitations under the License. 10.35.0.* 10.36.0.0-255 10.35.0.0/255.255.255.0 +.PARAMETER Protocol + Protocol to use for discovery (Default="iDRAC", "SNMP", "IPMI", "SSH", "VMWARE") .PARAMETER DiscoveryUserName Discovery user name. The iDRAC user for server discovery. .PARAMETER DiscoveryPassword @@ -238,6 +239,10 @@ param( [parameter(Mandatory=$false)] [String[]]$Hosts, + [Parameter(Mandatory=$false)] + [ValidateSet("iDRAC", "SNMP", "IPMI", "SSH", "VMWARE")] + [String] $Protocol = "iDRAC", + [Parameter(Mandatory)] [String]$DiscoveryUserName, @@ -277,7 +282,7 @@ Process { $Headers = @{} $Headers."X-Auth-Token" = $SessionAuth.Token - $Payload = Update-DiscoverDevicePayload -Name $Name -HostList $Hosts -Mode $Mode -DiscoveryJob $Discovery -DiscoveryUserName $DiscoveryUserName -DiscoveryPassword $DiscoveryPassword -Email $Email -Schedule $Schedule -ScheduleCron $ScheduleCron + $Payload = Update-DiscoverDevicePayload -Name $Name -HostList $Hosts -Protocol $Protocol -Mode $Mode -DiscoveryJob $Discovery -DiscoveryUserName $DiscoveryUserName -DiscoveryPassword $DiscoveryPassword -Email $Email -Schedule $Schedule -ScheduleCron $ScheduleCron $Payload = $Payload | ConvertTo-Json -Depth 6 $DiscoveryId = $Discovery.Id $DiscoverUrl = $BaseUri + "/api/DiscoveryConfigService/DiscoveryConfigGroups(" + $DiscoveryId + ")" @@ -301,9 +306,7 @@ Process { } Catch { - Write-Error ($_.ErrorDetails) - Write-Error ($_.Exception | Format-List -Force | Out-String) - Write-Error ($_.InvocationInfo | Format-List -Force | Out-String) + Resolve-Error $_ } } diff --git a/DellOpenManage/Public/OME/Invoke-OMEProfileUnassign.ps1 b/DellOpenManage/Public/OME/Invoke-OMEProfileUnassign.ps1 index 6a242bf..cfdc972 100644 --- a/DellOpenManage/Public/OME/Invoke-OMEProfileUnassign.ps1 +++ b/DellOpenManage/Public/OME/Invoke-OMEProfileUnassign.ps1 @@ -104,7 +104,9 @@ Process { } elseif ($ProfileName) { $ProfileUnassignPayload.Filters = "=contains(ProfileName, '$($ProfileName)')" } else { - throw [System.Exception] "You must specify one of the following parameters: -Device -Template -ProfileName" + Write-Verbose "You must specify one of the following parameters: -Device -Template -ProfileName" + # This seems to be thrown without ever going into this else statement. Not sure why. Need to look into. + # throw [System.Exception]::new("You must specify one of the following parameters: -Device -Template -ProfileName") } if ($ForceReclaim) { diff --git a/DellOpenManage/Public/OME/New-OMEDiscovery.ps1 b/DellOpenManage/Public/OME/New-OMEDiscovery.ps1 index e3dc159..d943406 100644 --- a/DellOpenManage/Public/OME/New-OMEDiscovery.ps1 +++ b/DellOpenManage/Public/OME/New-OMEDiscovery.ps1 @@ -1,5 +1,5 @@  -function Get-DiscoverDevicePayload($Name, $HostList, $DeviceType, $DiscoveryUserName, [SecureString] $DiscoveryPassword, $Email, $SetTrapDestination, $SetCommunityString, $UseAllProtocols, $Schedule, $ScheduleCron) { +function Get-DiscoverDevicePayload($Name, $HostList, $DeviceType, $Protocol, $DiscoveryUserName, [SecureString] $DiscoveryPassword, $Email, $SetTrapDestination, $SetCommunityString, $UseAllProtocols, $Schedule, $ScheduleCron) { $DiscoveryConfigPayload = '{ "DiscoveryConfigGroupName":"Server Discovery", "DiscoveryStatusEmailRecipient":"", @@ -11,39 +11,12 @@ function Get-DiscoverDevicePayload($Name, $HostList, $DeviceType, $DiscoveryUser "AddressType": 30 } ], - "ConnectionProfile":"{ - \"profileName\":\"\", - \"profileDescription\":\"\", - \"type\":\"DISCOVERY\", - \"credentials\":[{ - \"type\":\"WSMAN\", - \"authType\":\"Basic\", - \"modified\":false, - \"credentials\": { - \"username\":\"\", - \"password\":\"\", - \"caCheck\":false, - \"cnCheck\":false, - \"port\":443, - \"retries\":3, - \"timeout\": 60 - } - }, - { - \"type\":\"REDFISH\", - \"authType\":\"Basic\", - \"modified\":false, - \"credentials\": { - \"username\":\"\", - \"password\":\"\", - \"caCheck\":false, - \"cnCheck\":false, - \"port\":443, - \"retries\":3, - \"timeout\": 60 - } - }] - }", + "ConnectionProfile":{ + "profileName":"", + "profileDescription":"", + "type":"DISCOVERY", + "credentials":[] + }, "DeviceType":[1000] }], "Schedule":{ @@ -92,11 +65,38 @@ function Get-DiscoverDevicePayload($Name, $HostList, $DeviceType, $DiscoveryUser } if ($DeviceType.ToLower() -eq 'server' -or $DeviceType.ToLower() -eq 'chassis') { $DiscoveryConfigPayload.DiscoveryConfigModels[0].DeviceType = @($DeviceMap[$DeviceType.ToLower()]) - $ConnectionProfile = $DiscoveryConfigPayload.DiscoveryConfigModels[0].ConnectionProfile | ConvertFrom-Json - $ConnectionProfile.credentials[0].credentials.'username' = $DiscoveryUserName - $ConnectionProfile.credentials[0].credentials.'password' = $DiscoveryPasswordText - $ConnectionProfile.credentials[1].credentials.'username' = $DiscoveryUserName - $ConnectionProfile.credentials[1].credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile = $DiscoveryConfigPayload.DiscoveryConfigModels[0].ConnectionProfile + if ($Protocol -eq "iDRAC") { + $WSManProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "WSMAN" + $RedfishProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "REDFISH" + $WSManProtocolPayload.credentials.'username' = $DiscoveryUserName + $WSManProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $RedfishProtocolPayload.credentials.'username' = $DiscoveryUserName + $RedfishProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile.credentials += $WSManProtocolPayload + $ConnectionProfile.credentials += $RedfishProtocolPayload + } elseif ($Protocol -eq "VMWARE") { + $VMwareProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "VMWARE" + $VMwareProtocolPayload.credentials.'username' = $DiscoveryUserName + $VMwareProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile.credentials += $VMwareProtocolPayload + } elseif ($Protocol -eq "SNMP") { + $SNMPProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "SNMP" + $SNMPProtocolPayload.credentials.'username' = $DiscoveryUserName + $SNMPProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile.credentials += $SNMPProtocolPayload + } elseif ($Protocol -eq "IPMI") { + $IPMIProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "IPMI" + $IPMIProtocolPayload.credentials.'username' = $DiscoveryUserName + $IPMIProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile.credentials += $IPMIProtocolPayload + } elseif ($Protocol -eq "SSH") { + $SSHProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "SSH" + $SSHProtocolPayload.credentials.'username' = $DiscoveryUserName + $SSHProtocolPayload.credentials.'password' = $DiscoveryPasswordText + $ConnectionProfile.credentials += $SSHProtocolPayload + } + $DiscoveryConfigPayload.DiscoveryConfigModels[0].ConnectionProfile = $ConnectionProfile | ConvertTo-Json -Depth 6 } if ($Schedule.ToLower() -eq "runlater") { @@ -153,7 +153,7 @@ limitations under the License. .PARAMETER Name Name of the discovery job .PARAMETER DeviceType - Type of device ("Server", "Chassis", "Storage", "Network") + Type of device (Default="Server", "Chassis", "Storage", "Network") .PARAMETER Hosts Array of IP Addresses, Subnets or Hosts Valid Format: @@ -169,6 +169,8 @@ limitations under the License. 10.35.0.* 10.36.0.0-255 10.35.0.0/255.255.255.0 +.PARAMETER Protocol + Protocol to use for discovery (Default="iDRAC", "SNMP", "IPMI", "SSH", "VMWARE") .PARAMETER DiscoveryUserName Discovery user name. The iDRAC user for server discovery. .PARAMETER DiscoveryPassword @@ -222,6 +224,10 @@ param( [parameter(Mandatory)] [String[]]$Hosts, + [Parameter(Mandatory=$false)] + [ValidateSet("iDRAC", "SNMP", "IPMI", "SSH", "VMWARE")] + [String] $Protocol = "iDRAC", + [Parameter(Mandatory)] [String]$DiscoveryUserName, @@ -244,12 +250,6 @@ param( [Parameter(Mandatory=$false)] [String]$ScheduleCron = "0 0 0 ? * sun *", - <# - [Parameter(Mandatory=$false)] - [ValidateSet("vmware", "wsman", "snmp", "ipmi", "redfish", "ssh" )] - [String[]] $Protocol = @("wsman", "redfish"), - #> - [Parameter(Mandatory=$false)] [Switch]$UseAllProtocols, @@ -274,7 +274,7 @@ Process { $DiscoverUrl = $BaseUri + "/api/DiscoveryConfigService/DiscoveryConfigGroups" if ($Hosts.Count -gt 0) { - $Payload = Get-DiscoverDevicePayload -Name $Name -HostList $Hosts -DeviceType $DeviceType -DiscoveryUserName $DiscoveryUserName -DiscoveryPassword $DiscoveryPassword -Email $Email -SetTrapDestination $SetTrapDestination -SetCommunityString $SetCommunityString -UseAllProtocols $UseAllProtocols -Schedule $Schedule -ScheduleCron $ScheduleCron + $Payload = Get-DiscoverDevicePayload -Name $Name -HostList $Hosts -DeviceType $DeviceType -Protocol $Protocol -DiscoveryUserName $DiscoveryUserName -DiscoveryPassword $DiscoveryPassword -Email $Email -SetTrapDestination $SetTrapDestination -SetCommunityString $SetCommunityString -UseAllProtocols $UseAllProtocols -Schedule $Schedule -ScheduleCron $ScheduleCron $Payload = $Payload | ConvertTo-Json -Depth 6 $DiscoverResponse = Invoke-WebRequest -Uri $DiscoverUrl -UseBasicParsing -Method Post -Body $Payload -Headers $Headers -ContentType $Type if ($DiscoverResponse.StatusCode -eq 201) { diff --git a/Documentation/Functions/Edit-OMEDiscovery.md b/Documentation/Functions/Edit-OMEDiscovery.md index 8bad1d4..e2e280f 100644 --- a/Documentation/Functions/Edit-OMEDiscovery.md +++ b/Documentation/Functions/Edit-OMEDiscovery.md @@ -13,7 +13,7 @@ Edit device discovery job in OpenManage Enterprise ## SYNTAX ``` -Edit-OMEDiscovery [-Discovery] [[-Name] ] [[-Hosts] ] +Edit-OMEDiscovery [-Discovery] [[-Name] ] [[-Hosts] ] [[-Protocol] ] [-DiscoveryUserName] [-DiscoveryPassword] [[-Email] ] [[-Schedule] ] [[-ScheduleCron] ] [[-Mode] ] [-Wait] [[-WaitTime] ] [] ``` @@ -121,6 +121,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Protocol +Protocol to use for discovery (Default="iDRAC", "SNMP", "IPMI", "SSH", "VMWARE") + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: IDRAC +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -DiscoveryUserName Discovery user name. The iDRAC user for server discovery. @@ -131,7 +146,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 4 +Position: 5 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -147,7 +162,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 5 +Position: 6 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -162,7 +177,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 6 +Position: 7 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -178,7 +193,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 7 +Position: 8 Default value: RunNow Accept pipeline input: False Accept wildcard characters: False @@ -197,7 +212,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 8 +Position: 9 Default value: 0 0 0 ? * sun * Accept pipeline input: False Accept wildcard characters: False @@ -212,7 +227,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 9 +Position: 10 Default value: Replace Accept pipeline input: False Accept wildcard characters: False @@ -242,7 +257,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 10 +Position: 11 Default value: 3600 Accept pipeline input: False Accept wildcard characters: False diff --git a/Documentation/Functions/New-OMEDiscovery.md b/Documentation/Functions/New-OMEDiscovery.md index 305b905..57b6087 100644 --- a/Documentation/Functions/New-OMEDiscovery.md +++ b/Documentation/Functions/New-OMEDiscovery.md @@ -13,10 +13,10 @@ Create new device discovery job in OpenManage Enterprise ## SYNTAX ``` -New-OMEDiscovery [[-Name] ] [[-DeviceType] ] [-Hosts] [-DiscoveryUserName] - [-DiscoveryPassword] [[-Email] ] [-SetTrapDestination] [-SetCommunityString] - [[-Schedule] ] [[-ScheduleCron] ] [-UseAllProtocols] [-Wait] [[-WaitTime] ] - [] +New-OMEDiscovery [[-Name] ] [[-DeviceType] ] [-Hosts] [[-Protocol] ] + [-DiscoveryUserName] [-DiscoveryPassword] [[-Email] ] [-SetTrapDestination] + [-SetCommunityString] [[-Schedule] ] [[-ScheduleCron] ] [-UseAllProtocols] [-Wait] + [[-WaitTime] ] [] ``` ## DESCRIPTION @@ -75,7 +75,7 @@ Accept wildcard characters: False ``` ### -DeviceType -Type of device ("Server", "Chassis", "Storage", "Network") +Type of device (Default="Server", "Chassis", "Storage", "Network") ```yaml Type: String @@ -117,6 +117,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Protocol +Protocol to use for discovery (Default="iDRAC", "SNMP", "IPMI", "SSH", "VMWARE") + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: IDRAC +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -DiscoveryUserName Discovery user name. The iDRAC user for server discovery. @@ -127,7 +142,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 4 +Position: 5 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -143,7 +158,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 5 +Position: 6 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -158,7 +173,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 6 +Position: 7 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -204,7 +219,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 7 +Position: 8 Default value: RunNow Accept pipeline input: False Accept wildcard characters: False @@ -223,7 +238,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 8 +Position: 9 Default value: 0 0 0 ? * sun * Accept pipeline input: False Accept wildcard characters: False @@ -269,7 +284,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 9 +Position: 10 Default value: 3600 Accept pipeline input: False Accept wildcard characters: False diff --git a/README.md b/README.md index d54bedc..e3af623 100644 --- a/README.md +++ b/README.md @@ -460,9 +460,9 @@ Unassign Profile by template ``` Invoke-OMEProfileUnassign -Template $("TestTemplate01" | Get-OMETemplate) -Wait -Verbose ``` -Unassign Profile by profile name +Unassign Profile by profile name and force reclaim identities ``` -Invoke-OMEProfileUnassign -ProfileName "Profile from template 'TestTemplate01' 00001" -Wait -Verbose +Invoke-OMEProfileUnassign -ProfileName "Profile from template 'TestTemplate01' 00001" -ForceReclaim -Wait -Verbose ``` Remove Profile ``` diff --git a/Tests/Device.Tests.ps1 b/Tests/Device.Tests.ps1 index 4710ca4..9dd979d 100644 --- a/Tests/Device.Tests.ps1 +++ b/Tests/Device.Tests.ps1 @@ -2,8 +2,8 @@ $credentials = New-Object -TypeName System.Management.Automation.PSCredential -A Connect-OMEServer -Name $Global:OMEServer -Credentials $credentials -IgnoreCertificateWarning Describe "Device Tests" { BeforeEach { - $TestDeviceServiceTags = @("C86D0Q2") - $TestDeviceModel = "PowerEdge R740" + $TestDeviceServiceTags = @("9Z39MH3") + $TestDeviceModel = "PowerEdge R650" } Context "Device Checks" { It "Should return ALL Devices" { @@ -31,7 +31,7 @@ Describe "Device Tests" { } It "Should submit job to power on device" { - $TestDeviceServiceTags | Get-OMEDevice | Set-OMEPowerState -State "On" | Should -Be "Completed" + $TestDeviceServiceTags | Get-OMEDevice | Set-OMEPowerState -State "On" -Wait | Should -Be "Completed" } } } \ No newline at end of file diff --git a/Tests/Discovery.Tests.ps1 b/Tests/Discovery.Tests.ps1 index 9eed07e..b6b467a 100644 --- a/Tests/Discovery.Tests.ps1 +++ b/Tests/Discovery.Tests.ps1 @@ -2,17 +2,29 @@ $credentials = New-Object -TypeName System.Management.Automation.PSCredential -A Connect-OMEServer -Name $Global:OMEServer -Credentials $credentials -IgnoreCertificateWarning Describe "Device Tests" { BeforeAll { - $Script:TestDeviceHosts = @("100.77.14.129", "100.77.14.34", "100.77.14.172") - $Script:TestDeviceHostsNew = @("100.77.14.13") + $Script:TestDeviceHosts = @("100.77.14.41", "100.77.14.42", "100.77.14.55") + $Script:TestDeviceHostsNew = @("100.77.14.62") + $Script:TestDeviceHostsSSH = @("100.77.18.47") $Script:TestDiscoveryJobName = "TestDiscovery_$((Get-Date).ToString('yyyyMMddHHmmss'))" + $Script:TestDiscoveryJobNameSSH = "$($Script:TestDiscoveryJobName)_SSH" $Script:TestiDRACUsername = $Global:iDRACUsername $Script:TestiDRACPassword = $Global:iDRACPassword + $Script:TestSSHUsername = $Global:SSHUsername + $Script:TestSSHPassword = $Global:SSHPassword } Context "Discovery Job Checks" { It "NewDiscoveryJob > Should return a discovery job id" { New-OMEDiscovery -Name $Script:TestDiscoveryJobName -Hosts $Script:TestDeviceHosts -DiscoveryUserName $Script:TestiDRACUsername -DiscoveryPassword $(ConvertTo-SecureString $Script:TestiDRACPassword -AsPlainText -Force) -Wait | Should -BeGreaterThan 0 } + It "NewDiscoveryJobSSH > Should return a discovery job id" -Tag "SSH" { + New-OMEDiscovery -Name $Script:TestDiscoveryJobNameSSH -Hosts $Script:TestDeviceHostsSSH ` + -Protocol "SSH" ` + -DiscoveryUserName $Script:TestSSHUsername ` + -DiscoveryPassword $(ConvertTo-SecureString $Script:TestSSHPassword -AsPlainText -Force) ` + -Wait | Should -BeGreaterThan 0 + } + It "GetDiscoveryJob > Should return 1 discovery job" { $Script:TestDiscoveryJobName | Get-OMEDiscovery | Measure-Object | Select-Object -ExpandProperty Count | Should -Be 1 } diff --git a/Tests/Firmware.Tests.ps1 b/Tests/Firmware.Tests.ps1 index ca9e05a..fa8c4c3 100644 --- a/Tests/Firmware.Tests.ps1 +++ b/Tests/Firmware.Tests.ps1 @@ -4,7 +4,7 @@ Describe "Firmware Tests" { BeforeAll { $CatalogName = "Test01" $BaselineName = "TestBaseline01" - $DeviceServiceTag = "C86D0Q2" + $DeviceServiceTag = "9Z39MH3" } Context "Firmware" { It "Should export at least one function" { @@ -14,7 +14,7 @@ Describe "Firmware Tests" { It "Should create and return a new Catalog object" { # Need to implement Delete-Catalog to cleanup for subsequent runs #New-OMECatalog -Name $CatalogName -Wait - New-OMECatalog -Name $CatalogName -RepositoryType "NFS" -Source "100.79.7.16" -SourcePath "/mnt/data/drm/OSELabAll" -CatalogFile "OSELabAll_1.00_Catalog.xml" -Wait + New-OMECatalog -Name $CatalogName -RepositoryType "NFS" -Source "100.77.18.27" -SourcePath "/home/nfs/drm/R650" -CatalogFile "R650_Catalog.xml" -Wait $CatalogName | Get-OMECatalog | Measure-Object | Select-Object -ExpandProperty Count | Should -BeGreaterThan 0 } diff --git a/Tests/Group.Tests.ps1 b/Tests/Group.Tests.ps1 index 502e12a..5fd74ca 100644 --- a/Tests/Group.Tests.ps1 +++ b/Tests/Group.Tests.ps1 @@ -2,7 +2,7 @@ $credentials = New-Object -TypeName System.Management.Automation.PSCredential -A Connect-OMEServer -Name $Global:OMEServer -Credentials $credentials -IgnoreCertificateWarning Describe "Group Tests" { BeforeEach { - $TestDeviceModel = "PowerEdge R640" + $TestDeviceModel = "PowerEdge R650" $TestGroup = "Dell iDRAC Servers" $TestNewGroup = "TestGroup01" $TestNewGroupEdit = "TestGroup02" diff --git a/Tests/Main.Tests.ps1 b/Tests/Main.Tests.ps1 index 9e2ed87..8ea44b3 100644 --- a/Tests/Main.Tests.ps1 +++ b/Tests/Main.Tests.ps1 @@ -11,6 +11,8 @@ param( ) . .\Credentials.ps1 +& .\Install-Module.ps1 + Import-Module Pester Remove-Module DellOpenManage @@ -25,6 +27,8 @@ $Global:OMEUsername = $OMEUsername $Global:OMEPassword = $OMEPassword $Global:iDRACUsername = $iDRACUsername $Global:iDRACPassword = $iDRACPassword +$Global:SSHUsername = $SSHUsername +$Global:SSHPassword = $SSHPassword $PesterPreference = [PesterConfiguration]::Default $PesterPreference.Output.Verbosity = 'Detailed' diff --git a/Tests/Misc.Tests.ps1 b/Tests/Misc.Tests.ps1 index 4c5fc48..69e5ff1 100644 --- a/Tests/Misc.Tests.ps1 +++ b/Tests/Misc.Tests.ps1 @@ -75,4 +75,15 @@ Describe "Misc Tests" { #$Script:TestIdentityPoolName | Get-OMEIdentityPool | Get-OMEIdentityPoolUsage | Measure-Object | Select-Object -ExpandProperty Count | Should -BeGreaterThan 0 } } + + Context "Cleanup" -Tag "Cleanup" { + It "Should remove Network" { + $TestNetwork.Name | Get-OMENetwork | Remove-OMENetwork + $TestNetwork.Name | Get-OMENetwork | Measure-Object | Select-Object -ExpandProperty Count | Should -Be 0 + } + <# NOT IMPLEMENTED YET + It "Should remove Identity Pool" { + } + #> + } } \ No newline at end of file diff --git a/Tests/SupportAssist.Tests.ps1 b/Tests/SupportAssist.Tests.ps1 index 67415ca..fec8a89 100644 --- a/Tests/SupportAssist.Tests.ps1 +++ b/Tests/SupportAssist.Tests.ps1 @@ -4,7 +4,7 @@ Describe "Support Assist Tests" { BeforeAll { $Script:TestSupportAssistGroupName = "TestSAGroup_$((Get-Date).ToString('yyyyMMddHHmmss'))" $Script:TestSupportAssistGroupEdit = "TestSAGroup2_$((Get-Date).ToString('yyyyMMddHHmmss'))" - $Script:DeviceServiceTag = "GV6V673" + $Script:DeviceServiceTag = "9Z39MH3" $Script:TestSupportAssistGroup = '{ "MyAccountId": "", "Name": "Support Assist Group 1", diff --git a/Tests/Template.Tests.ps1 b/Tests/Template.Tests.ps1 index 021685f..c432e00 100644 --- a/Tests/Template.Tests.ps1 +++ b/Tests/Template.Tests.ps1 @@ -2,12 +2,16 @@ $credentials = New-Object -TypeName System.Management.Automation.PSCredential -A Connect-OMEServer -Name $Global:OMEServer -Credentials $credentials -IgnoreCertificateWarning Describe "Template Tests" { BeforeAll { - $Script:DeviceServiceTag1 = "C86D0Q2" - $Script:DeviceServiceTag2 = "C86F0Q2" - $Script:DeviceServiceTag3 = "47BXBM2" + $Script:DeviceServiceTag1 = "9Z39MH3" + $Script:DeviceServiceTag2 = "9Z38MH3" + $Script:DeviceServiceTag3 = "6VQS5X3" $Script:ConfigurationBaselineName = "TestConfigurationBaseline_$((Get-Date).ToString('yyyyMMddHHmmss'))" + $Script:DeploymentTemplateNameFromDevice = "TestDeploymentTemplate_FromDevice_$((Get-Date).ToString('yyyyMMddHHmmss'))" + $Script:DeploymentTemplateNameFromFile = "TestDeploymentTemplate_FromFile_$((Get-Date).ToString('yyyyMMddHHmmss'))" $Script:DeploymentTemplateNameFromString = "TestDeploymentTemplate_FromString_$((Get-Date).ToString('yyyyMMddHHmmss'))" $Script:DeploymentTemplateNameFromStringClone = "$($Script:DeploymentTemplateNameFromString) - Clone" + $Script:ConfigurationTemplateNameFromDevice = "TestComplianceTemplate_FromDevice_$((Get-Date).ToString('yyyyMMddHHmmss'))" + $Script:ConfigurationTemplateNameFromFile = "TestComplianceTemplate_FromFile_$((Get-Date).ToString('yyyyMMddHHmmss'))" $Script:ConfigurationTemplateNameFromString = "TestConfigurationTemplate_FromString_$((Get-Date).ToString('yyyyMMddHHmmss'))" } Context "General" { @@ -17,13 +21,13 @@ Describe "Template Tests" { } Context "Deployment" -Tag "Deployment" { It ("Should create a deployment template from source device and return JobId"){ - $TemplateName = "TestDeploymentTemplate_FromDevice_$((Get-Date).ToString('yyyyMMddHHmmss'))" + $TemplateName = $Script:DeploymentTemplateNameFromDevice New-OMETemplateFromDevice -Name $TemplateName -Device $($Script:DeviceServiceTag1 | Get-OMEDevice -FilterBy "ServiceTag") -Component "All" | Should -BeGreaterThan 0 } It ("Should create a new deployment template from XML string located in a file") { $xml = Get-Content -Path .\Tests\Data\Test01.xml | Out-String - $TemplateNameFromFile = "TestDeploymentTemplate_FromFile_$((Get-Date).ToString('yyyyMMddHHmmss'))" + $TemplateNameFromFile = $Script:DeploymentTemplateNameFromFile New-OMETemplateFromFile -Name $TemplateNameFromFile -Content $xml -Wait $TemplateNameFromFile | Get-OMETemplate -FilterBy "Name" | Select-Object -ExpandProperty Name | Should -Be $TemplateNameFromFile $TemplateNameFromFile | Get-OMETemplate -FilterBy "Name" | Select-Object -ExpandProperty ViewTypeId | Should -Be 2 @@ -63,6 +67,10 @@ Describe "Template Tests" { } It "Should remove deploy templates" { + Get-OMETemplate | Where-Object -Property "Name" -EQ $Script:DeploymentTemplateNameFromDevice | Remove-OMETemplate + $Script:DeploymentTemplateNameFromDevice | Get-OMETemplate | Measure-Object | Select-Object -ExpandProperty Count | Should -Be 0 + Get-OMETemplate | Where-Object -Property "Name" -EQ $Script:DeploymentTemplateNameFromFile | Remove-OMETemplate + $Script:DeploymentTemplateNameFromFile | Get-OMETemplate | Measure-Object | Select-Object -ExpandProperty Count | Should -Be 0 Get-OMETemplate | Where-Object -Property "Name" -EQ $Script:DeploymentTemplateNameFromString | Remove-OMETemplate Get-OMETemplate | Where-Object -Property "Name" -EQ $Script:DeploymentTemplateNameFromStringClone | Remove-OMETemplate $Script:DeploymentTemplateNameFromString | Get-OMETemplate | Measure-Object | Select-Object -ExpandProperty Count | Should -Be 0 @@ -70,13 +78,13 @@ Describe "Template Tests" { } Context "Configuration" -Tag "Configuration" { It ("Should create a compliance template from source device and return JobId"){ - $TemplateName = "TestComplianceTemplate_FromDevice_$((Get-Date).ToString('yyyyMMddHHmmss'))" + $TemplateName = $Script:ConfigurationTemplateNameFromDevice New-OMETemplateFromDevice -Name $TemplateName -TemplateType "Configuration" -Device $($Script:DeviceServiceTag2 | Get-OMEDevice -FilterBy "ServiceTag") -Component "All" | Should -BeGreaterThan 0 } It ("Should create a new compliance template from XML string located in a file") { $xml = Get-Content -Path .\Tests\Data\Test01.xml | Out-String - $TemplateNameFromFile = "TestComplianceTemplate_FromFile_$((Get-Date).ToString('yyyyMMddHHmmss'))" + $TemplateNameFromFile = $Script:ConfigurationTemplateNameFromFile New-OMETemplateFromFile -Name $TemplateNameFromFile -TemplateType "Configuration" -Content $xml -Wait $TemplateNameFromFile | Get-OMETemplate -FilterBy "Name" | Select-Object -ExpandProperty Name | Should -Be $TemplateNameFromFile $TemplateNameFromFile | Get-OMETemplate -FilterBy "Name" | Select-Object -ExpandProperty ViewTypeId | Should -Be 1 @@ -119,6 +127,16 @@ Describe "Template Tests" { $baseline = $Script:ConfigurationBaselineName | Get-OMEConfigurationBaseline $baseline | Invoke-OMEConfigurationBaselineRefresh | Should -BeGreaterThan 0 } + It "Should remove configuration template from device" { + $template = $($Script:ConfigurationTemplateNameFromDevice | Get-OMETemplate) + $template | Remove-OMETemplate + $Script:ConfigurationTemplateNameFromDevice | Get-OMETemplate | Measure-Object | Select-Object -ExpandProperty Count | Should -Be 0 + } + It "Should remove configuration template from file" { + $template = $($Script:ConfigurationTemplateNameFromFile | Get-OMETemplate) + $template | Remove-OMETemplate + $Script:ConfigurationTemplateNameFromFile | Get-OMETemplate | Measure-Object | Select-Object -ExpandProperty Count | Should -Be 0 + } It "Should remove configuration template" { $template = $($Script:ConfigurationTemplateNameFromString | Get-OMETemplate) $template | Remove-OMETemplate