HewlettPackard / hpe3par_pstoolkit

The HPE Alletra 9000 and Primera and 3PAR PowerShell Toolkit supports cmdlets, which are wrappers around the native HPE Alletra 9000 or HPE Primera or HPE 3PAR storage CLI commands and Web Services API (WSAPI).
Other
12 stars 13 forks source link

No way of getting Add-VvToRCopyGroup_WSAPI to work #53

Open apol76 opened 2 years ago

apol76 commented 2 years ago

Hi, I can't find a way to use Add-VvToRCopyGroup_WSAPI: Add-VvToRCopyGroup_WSAPI -GroupName mygroupname -VolumeName myvolumeonprimaryname -VolumeAutoCreation 1 -TargetName rcopytargetname -SecVolumeName myvolumeonprimaryname

and

Add-VvToRCopyGroup_WSAPI -GroupName mygroupname -VolumeName myvolumeonprimaryname -VolumeAutoCreation $true -TargetName rcopytargetname -SecVolumeName myvolumeonprimaryname

and, with a secondary volume with the same name as on primary created on my own,

Add-VvToRCopyGroup_WSAPI -GroupName mygroupname -VolumeName myvolumeonprimaryname -TargetName rcopytargetname -SecVolumeName myvolumeonprimaryname

all return

 The array sends an error message: invalid input: some or all required parameters are missing.

 Status: ProtocolError
 Error code: 40
 HTTP Error code: 400
 Message: invalid input: some or all required parameters are missing

 FAILURE : While Admitting a volume into a Remote Copy group : myvolumeonprimaryname

If I really omit a parameter, it does not return this error but asks for the missing parameter.

The RCGroup is stopped.

Does anybody know what's wrong here, or does anybody use this command successfully?

I'm using PSToolkit 3.1.

apol76 commented 2 years ago

PSToolkit DebugLog in X-Logs does non contain any additional information (I think):

05/18/2022 06:48:23 DEBUG: Request: Test-WSAPIConnection to Test if the session key exists. 05/18/2022 06:48:23 DEBUG: Running: Validate the session key 05/18/2022 06:48:23 INFO: End: Connected 05/18/2022 06:48:23 DEBUG: End: Test-WSAPIConnection 05/18/2022 06:48:23 DEBUG: Running: Creation of the body hash 05/18/2022 06:48:23 DEBUG: Request: Request to Add-VvToRCopyGroup_WSAPI : myvolumeonprimaryname (Invoke-WSAPI). 05/18/2022 06:48:23 DEBUG: Request: Request Invoke-WSAPI URL : /remotecopygroups/mygroupname/volumes TYPE : POST 05/18/2022 06:48:23 DEBUG: Running: Constructing header. 05/18/2022 06:48:23 DEBUG: Request: Invoke-WebRequest for Data, Request Type : POST 05/18/2022 06:48:24 DEBUG: Stop: Exception Occurs 05/18/2022 06:48:24 DEBUG: Stop:The array sends an error message: Der Remoteserver hat einen Fehler zurückgegeben: (400) Ungültige Anforderung.. 05/18/2022 06:48:24 DEBUG: Stop: Status: ProtocolError 05/18/2022 06:48:24 DEBUG: Stop: Error code: 40 05/18/2022 06:48:24 DEBUG: Stop: HTTP Error code: 400 05/18/2022 06:48:24 DEBUG: Stop: Message: invalid input: some or all required parameters are missing 05/18/2022 06:48:24 INFO: FAILURE : While Admitting a volume into a Remote Copy group : myvolumeonprimaryname

apol76 commented 2 years ago

I tried a somewhat crude debug idea and added

Write-Host ($body | Out-String)
Write-Host ($($body.targets) | Out-String)

to remotecopy.psm1 to see the actual body that was passed to the API.

Result: body:

 Name                           Value
 ----                           -----
 volumeAutoCreation             True
 targets                        {targetName, secVolumeName}
 action                         1
 volumeName                     myvolumeonprimaryname 

body.targets:

 Name                           Value
 ----                           -----
 targetName                     rcopytargetname 
 secVolumeName                  myvolumeonprimaryname 

According to the api guide, Action 1 is ADMIT_VV - looks good. So I still have no idea what's going wrong.

Btw, PrimeraOS 4.3.5

apol76 commented 2 years ago

mygroupname is not included in the body, but is part of the uri. It does in my usecase contain a "." - does this need to be replaced by %2E in the uri?

apol76 commented 2 years ago

On a 3PAR with InformOS 3.3.1 MU5 P172, it does not work, too. The error is different:

Show-RequestException : Das Argument kann nicht an den Parameter "InputObject" gebunden werden, da es NULL ist.
In C:\Program Files\WindowsPowerShell\Modules\HPEStoragePowerShellToolkit\GLOBAL\VS-Functions.psm1:672 Zeichen:4
+             Show-RequestException -Exception $_
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Show-RequestException], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Show-RequestException

The first line says "The argument could not be bound to parameter "InputObject", because it is NULL"

apol76 commented 1 year ago

just for the record, I managed to find the bug that cause this function to fail. 1) $body["action"] = 1 is wrong, it is no longer necessary for the POST variant of Add-VvToRCopyGroup_WSAPI 2) a part of the body is assembled wrong. $body["targets"] = $TargetsBody needs to be changed to $body["targets"] = @() $body["targets"] += $TargetsBody