HewlettPackard / HewlettPackard/HPEDSCC-PowerShell-Toolkit

Set-DSCCHost is not working

Open
#7 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PowerShell
Stars
9
Forks
5
PR merge metrics
No merged PRs in 30d

Description

There are a few coding errors in the Set-DSSCHost function:

$MyAdd = 'host-initiator/' + $hostID
$MyBody += @{}
if ($name) { $MyBody += @{ name = $name } }
if ($updatedInitiators) { $MyBody += @{ updatedInitiators = $updatedInitiators } }
if ($initiatorsToCreate) { $MyBody += @{ initiatorsToCreate = $initiatorsToCreate } }
return (Invoke-DSCCRestMethod -uri $MyUri -body ( $MyBody | convertto-json) -Method 'PUT' -WhatIfBoolean $WhatIf )

You use the Invoke-DSCCRestMethod with -uri $MyUri, but you should use: -uriAdd $MyBody since Invoke-DSCCRestMethod does use uriAdd as a parameter, and you use $MyAdd instead of $MyUri in the Set-DSCCHost function.

But even if do change this, the Set-DSCCHost -hostID $hostid -name $name is not working for me. Drilling down into it,
I do see in the Invoke-DSCCRestMethod the following:
$MyUri "https://eu1.data.cloud.hpe.com/api/v1/host-initiator/f6b1593e566a4d70a10c9be2a85ae333"
$MyBody {
"name": "dscc-api-01"
}
that look o.k. for me (the hostId in the $MyUri is correct).
And the final invoke-restmethod produces an error with the following response:

Response: StatusCode: 503, ReasonPhrase: 'Service Unavailable', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Date: Thu, 15 Jun 2023 15:40:15 GMT
Server: istio-envoy
Connection: close
Content-Length: 0
}, Trailing Headers:
{
}

Being primarily a Python coder, I did cross check the same operation (i.e. with the same hostid and name) with my own Python class library for the DSCC. And that worked without any issue. Hence, the DSCC API itself doesn't seem to have an issue. It is something weird within the DSCC Powershell Toolkit as far as I can see it.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.