HewlettPackard / HPEDSCC-PowerShell-Toolkit

A PowerShell Toolkit that enables management of a HPE GreenLake DSCC (Data Storage Cloud Console) environment via easy to use PowerShell commands which interface with the publically available RestAPI.
BSD 3-Clause "New" or "Revised" License
9 stars 5 forks source link

Set-DSCCHost is not working #7

Open tbeha opened 1 year ago

tbeha commented 1 year ago

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.

tbeha commented 1 year ago

I did find the root cause why the Set-DSCCHost function is not working:

in line 337 of the host.ps1 you do have the following assignment: $MyAdd = 'host-initiator/' + $hostID

The correct assignment is: $MyAdd = 'host-initiators/' + $hostID

the s in 'host-initiators' was missing.

atkinsroy commented 1 year ago

You're right, Thomas - thanks. I'll add it to my next pull request. host.ps1 needs work, evidently. To be honest the API is a bit challenging with the different device types. I've been focusing on the "get" commands for now as I don't have a demo environment to play with.