Skip to content

Commit 3602e5b

Browse files
U-AMERICAS\Trevor_SquillarioU-AMERICAS\Trevor_Squillario
U-AMERICAS\Trevor_Squillario
authored and
U-AMERICAS\Trevor_Squillario
committed
Release 3.8.0
1 parent 1a26275 commit 3602e5b

17 files changed

+334
-130
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [3.8.0]() - 2024-02-23
8+
### Fixed
9+
- Support 200 and 201 status codes in all commandlets from PR #18
10+
- Tested against OME 4.0, no code changes required
11+
12+
### Changed
13+
- New-OMEDiscovery to support all Protocol types supported in OME
14+
- Edit-OMEDiscovery to support all Protocol types supported in OME. Closes #19
15+
716
## [3.7.0]() - 2023-10-27
817
### Added
918
- Get-OMEProfile

DellOpenManage/DellOpenManage.psd1

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Trevor Squillario <Trevor.Squillario@Dell.com>
55
#
6-
# Generated on: 10/27/2023
6+
# Generated on: 2/23/2024
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'DellOpenManage.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '3.7.0'
15+
ModuleVersion = '3.8.0'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<#
2+
.SYNOPSIS
3+
Generate JSON object to be used when submitting Jobs to the DiscoveryConfigService
4+
5+
.DESCRIPTION
6+
7+
.PARAMETER $Protocol
8+
String containing protocol
9+
10+
.OUTPUTS
11+
PCCustomObject
12+
#>
13+
function Get-DiscoveryProtocolPayload($Protocol) {
14+
15+
$WSManProtocolPayload = '{
16+
"type":"WSMAN",
17+
"authType":"Basic",
18+
"modified":false,
19+
"credentials": {
20+
"username":"",
21+
"password":"",
22+
"caCheck":false,
23+
"cnCheck":false,
24+
"port":443,
25+
"retries":3,
26+
"timeout": 60
27+
}
28+
}' | ConvertFrom-Json
29+
30+
$RedfishProtocolPayload = '{
31+
"type":"REDFISH",
32+
"authType":"Basic",
33+
"modified":false,
34+
"credentials": {
35+
"username":"",
36+
"password":"",
37+
"caCheck":false,
38+
"cnCheck":false,
39+
"port":443,
40+
"retries":3,
41+
"timeout": 60
42+
}
43+
}' | ConvertFrom-Json
44+
45+
$VMwareProtocolPayload = '{
46+
"type":"VMWARE",
47+
"authType":"Basic",
48+
"modified":false,
49+
"credentials":{
50+
"username":"",
51+
"password":"",
52+
"caCheck":false,
53+
"cnCheck":false,
54+
"port":443,
55+
"retries":3,
56+
"timeout":60,
57+
"isHttp":false,
58+
"keepAlive":false}
59+
}' | ConvertFrom-Json
60+
61+
$SNMPProtocolPayload = '{
62+
"type":"SNMP",
63+
"authType":"Basic",
64+
"modified":false,
65+
"credentials":{
66+
"community":"public",
67+
"enableV1V2":true,
68+
"port":161,
69+
"retries":3,
70+
"timeout":3}
71+
}' | ConvertFrom-Json
72+
73+
$IPMIProtocolPayload = '{
74+
"type":"IPMI",
75+
"authType":"Basic",
76+
"modified":false,
77+
"credentials":{
78+
"username":"",
79+
"password":"",
80+
"privilege":2,
81+
"retries":3,
82+
"timeout":59}
83+
}' | ConvertFrom-Json
84+
85+
$SSHProtocolPayload = '{
86+
"type":"SSH",
87+
"authType":"Basic",
88+
"modified":false,
89+
"credentials":{
90+
"username":"",
91+
"isSudoUser":false,
92+
"password":"",
93+
"port":22,
94+
"useKey":false,
95+
"retries":1,
96+
"timeout":59,
97+
"checkKnownHosts":false}
98+
}' | ConvertFrom-Json
99+
100+
$Payload = $null
101+
if ($Protocol -eq "WSMAN") {
102+
$Payload = $WSManProtocolPayload
103+
} elseif ($Protocol -eq "REDFISH") {
104+
$Payload = $RedfishProtocolPayload
105+
} elseif ($Protocol -eq "VMWARE") {
106+
$Payload = $VMwareProtocolPayload
107+
} elseif ($Protocol -eq "SNMP") {
108+
$Payload = $SNMPProtocolPayload
109+
} elseif ($Protocol -eq "IPMI") {
110+
$Payload = $IPMIProtocolPayload
111+
} elseif ($Protocol -eq "SSH") {
112+
$Payload = $SSHProtocolPayload
113+
}
114+
return $Payload
115+
}

DellOpenManage/Public/OME/Edit-OMEDiscovery.ps1

+46-43
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using module ..\..\Classes\Discovery.psm1
22

3-
function Update-DiscoverDevicePayload($HostList, $DiscoveryJob, $Mode, $DiscoveryUserName, [SecureString] $DiscoveryPassword, $Email, $Schedule, $ScheduleCron) {
3+
function Update-DiscoverDevicePayload($HostList, $DiscoveryJob, $Protocol, $Mode, $DiscoveryUserName, [SecureString] $DiscoveryPassword, $Email, $Schedule, $ScheduleCron) {
44
$DiscoveryConfigPayload = '{
55
"DiscoveryConfigGroupId":11,
66
"DiscoveryConfigGroupName":"Server Discovery",
@@ -13,39 +13,12 @@ function Update-DiscoverDevicePayload($HostList, $DiscoveryJob, $Mode, $Discover
1313
"AddressType": 30
1414
}
1515
],
16-
"ConnectionProfile":"{
17-
\"profileName\":\"\",
18-
\"profileDescription\":\"\",
19-
\"type\":\"DISCOVERY\",
20-
\"credentials\":[{
21-
\"type\":\"WSMAN\",
22-
\"authType\":\"Basic\",
23-
\"modified\":false,
24-
\"credentials\": {
25-
\"username\":\"\",
26-
\"password\":\"\",
27-
\"caCheck\":false,
28-
\"cnCheck\":false,
29-
\"port\":443,
30-
\"retries\":3,
31-
\"timeout\": 60
32-
}
33-
},
34-
{
35-
\"type\":\"REDFISH\",
36-
\"authType\":\"Basic\",
37-
\"modified\":false,
38-
\"credentials\": {
39-
\"username\":\"\",
40-
\"password\":\"\",
41-
\"caCheck\":false,
42-
\"cnCheck\":false,
43-
\"port\":443,
44-
\"retries\":3,
45-
\"timeout\": 60
46-
}
47-
}]
48-
}",
16+
"ConnectionProfile":{
17+
"profileName":"",
18+
"profileDescription":"",
19+
"type":"DISCOVERY",
20+
"credentials":[]
21+
},
4922
"DeviceType":[1000]
5023
}],
5124
"Schedule":{
@@ -72,11 +45,37 @@ function Update-DiscoverDevicePayload($HostList, $DiscoveryJob, $Mode, $Discover
7245
$DiscoveryConfigPayload.CommunityString = $DiscoveryJob.CommunityString
7346

7447
# Update credentials
75-
$ConnectionProfile = $DiscoveryConfigPayload.DiscoveryConfigModels[0].ConnectionProfile | ConvertFrom-Json
76-
$ConnectionProfile.credentials[0].credentials.'username' = $DiscoveryUserName
77-
$ConnectionProfile.credentials[0].credentials.'password' = $DiscoveryPasswordText
78-
$ConnectionProfile.credentials[1].credentials.'username' = $DiscoveryUserName
79-
$ConnectionProfile.credentials[1].credentials.'password' = $DiscoveryPasswordText
48+
$ConnectionProfile = $DiscoveryConfigPayload.DiscoveryConfigModels[0].ConnectionProfile
49+
if ($Protocol -eq "iDRAC") {
50+
$WSManProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "WSMAN"
51+
$RedfishProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "REDFISH"
52+
$WSManProtocolPayload.credentials.'username' = $DiscoveryUserName
53+
$WSManProtocolPayload.credentials.'password' = $DiscoveryPasswordText
54+
$RedfishProtocolPayload.credentials.'username' = $DiscoveryUserName
55+
$RedfishProtocolPayload.credentials.'password' = $DiscoveryPasswordText
56+
$ConnectionProfile.credentials += $WSManProtocolPayload
57+
$ConnectionProfile.credentials += $RedfishProtocolPayload
58+
} elseif ($Protocol -eq "VMWARE") {
59+
$VMwareProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "VMWARE"
60+
$VMwareProtocolPayload.credentials.'username' = $DiscoveryUserName
61+
$VMwareProtocolPayload.credentials.'password' = $DiscoveryPasswordText
62+
$ConnectionProfile.credentials += $VMwareProtocolPayload
63+
} elseif ($Protocol -eq "SNMP") {
64+
$SNMPProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "SNMP"
65+
$SNMPProtocolPayload.credentials.'username' = $DiscoveryUserName
66+
$SNMPProtocolPayload.credentials.'password' = $DiscoveryPasswordText
67+
$ConnectionProfile.credentials += $SNMPProtocolPayload
68+
} elseif ($Protocol -eq "IPMI") {
69+
$IPMIProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "IPMI"
70+
$IPMIProtocolPayload.credentials.'username' = $DiscoveryUserName
71+
$IPMIProtocolPayload.credentials.'password' = $DiscoveryPasswordText
72+
$ConnectionProfile.credentials += $IPMIProtocolPayload
73+
} elseif ($Protocol -eq "SSH") {
74+
$SSHProtocolPayload = Get-DiscoveryProtocolPayload -Protocol "SSH"
75+
$SSHProtocolPayload.credentials.'username' = $DiscoveryUserName
76+
$SSHProtocolPayload.credentials.'password' = $DiscoveryPasswordText
77+
$ConnectionProfile.credentials += $SSHProtocolPayload
78+
}
8079
$DiscoveryConfigPayload.DiscoveryConfigModels[0].ConnectionProfile = $ConnectionProfile | ConvertTo-Json -Depth 6
8180

8281
# Update target hosts
@@ -186,6 +185,8 @@ limitations under the License.
186185
10.35.0.*
187186
10.36.0.0-255
188187
10.35.0.0/255.255.255.0
188+
.PARAMETER Protocol
189+
Protocol to use for discovery (Default="iDRAC", "SNMP", "IPMI", "SSH", "VMWARE")
189190
.PARAMETER DiscoveryUserName
190191
Discovery user name. The iDRAC user for server discovery.
191192
.PARAMETER DiscoveryPassword
@@ -238,6 +239,10 @@ param(
238239
[parameter(Mandatory=$false)]
239240
[String[]]$Hosts,
240241

242+
[Parameter(Mandatory=$false)]
243+
[ValidateSet("iDRAC", "SNMP", "IPMI", "SSH", "VMWARE")]
244+
[String] $Protocol = "iDRAC",
245+
241246
[Parameter(Mandatory)]
242247
[String]$DiscoveryUserName,
243248

@@ -277,7 +282,7 @@ Process {
277282
$Headers = @{}
278283
$Headers."X-Auth-Token" = $SessionAuth.Token
279284

280-
$Payload = Update-DiscoverDevicePayload -Name $Name -HostList $Hosts -Mode $Mode -DiscoveryJob $Discovery -DiscoveryUserName $DiscoveryUserName -DiscoveryPassword $DiscoveryPassword -Email $Email -Schedule $Schedule -ScheduleCron $ScheduleCron
285+
$Payload = Update-DiscoverDevicePayload -Name $Name -HostList $Hosts -Protocol $Protocol -Mode $Mode -DiscoveryJob $Discovery -DiscoveryUserName $DiscoveryUserName -DiscoveryPassword $DiscoveryPassword -Email $Email -Schedule $Schedule -ScheduleCron $ScheduleCron
281286
$Payload = $Payload | ConvertTo-Json -Depth 6
282287
$DiscoveryId = $Discovery.Id
283288
$DiscoverUrl = $BaseUri + "/api/DiscoveryConfigService/DiscoveryConfigGroups(" + $DiscoveryId + ")"
@@ -301,9 +306,7 @@ Process {
301306

302307
}
303308
Catch {
304-
Write-Error ($_.ErrorDetails)
305-
Write-Error ($_.Exception | Format-List -Force | Out-String)
306-
Write-Error ($_.InvocationInfo | Format-List -Force | Out-String)
309+
Resolve-Error $_
307310
}
308311
}
309312

DellOpenManage/Public/OME/Invoke-OMEProfileUnassign.ps1

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ Process {
104104
} elseif ($ProfileName) {
105105
$ProfileUnassignPayload.Filters = "=contains(ProfileName, '$($ProfileName)')"
106106
} else {
107-
throw [System.Exception] "You must specify one of the following parameters: -Device -Template -ProfileName"
107+
Write-Verbose "You must specify one of the following parameters: -Device -Template -ProfileName"
108+
# This seems to be thrown without ever going into this else statement. Not sure why. Need to look into.
109+
# throw [System.Exception]::new("You must specify one of the following parameters: -Device -Template -ProfileName")
108110
}
109111

110112
if ($ForceReclaim) {

0 commit comments

Comments
 (0)