Skip to content

Commit

Permalink
Release 3.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
U-AMERICAS\Trevor_Squillario authored and U-AMERICAS\Trevor_Squillario committed Feb 23, 2024
1 parent 1a26275 commit 3602e5b
Show file tree
Hide file tree
Showing 17 changed files with 334 additions and 130 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions DellOpenManage/DellOpenManage.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Trevor Squillario <[email protected]>
#
# Generated on: 10/27/2023
# Generated on: 2/23/2024
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'DellOpenManage.psm1'

# Version number of this module.
ModuleVersion = '3.7.0'
ModuleVersion = '3.8.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
115 changes: 115 additions & 0 deletions DellOpenManage/Private/Get-DiscoveryProtocolPayload.ps1
Original file line number Diff line number Diff line change
@@ -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
}
89 changes: 46 additions & 43 deletions DellOpenManage/Public/OME/Edit-OMEDiscovery.ps1
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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":{
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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 + ")"
Expand All @@ -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 $_
}
}

Expand Down
4 changes: 3 additions & 1 deletion DellOpenManage/Public/OME/Invoke-OMEProfileUnassign.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit 3602e5b

Please sign in to comment.