HewlettPackard / POSH-HPEOneView

PowerShell language bindings library for HPE OneView.
http://hewlettpackard.github.io/POSH-HPEOneView/
126 stars 52 forks source link

No Valid session ID with connected sessions #119

Closed wingZero21 closed 8 years ago

wingZero21 commented 8 years ago

Hi,

When trying to test taking a backup or running other commands I am getting the below error. I currently have details in connected sessions. Can you advise what might be causing this to occur.

Details:

PS C:\Users\vagrant> $ConnectedSessions

ConnectionID Name                  UserName AuthLoginDomain
------------ ----                  -------- ---------------
1            ovdc1.domain.com      api      LOCAL
2            ovdc2.domain.com      api      LOCAL

Error:

PS C:\Users\vagrant> Get-HPOVHealthStatus
Send-HPOVRequest : No valid session ID found for 'ovdc1.domain.com'.  The call to '/rest/appliance/health-status'
requires authentication.  Please use Connect-HPOVMgmt to connect and authenticate to an appliance.
At C:\Users\vagrant\Documents\WindowsPowerShell\Modules\HPOneView.200\HPOneView.200.psm1:9710 char:20
+             $healthStatus = Send-HPOVRequest $applHealthStatus -Hostname $_connection
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : AuthenticationError: (Send-HPOVRequest:String) [Send-HPOVRequest], AuthSessionException
    + FullyQualifiedErrorId : NoAuthSession,Send-HPOVRequest

You cannot call a method on a null-valued expression.
At C:\Users\vagrant\Documents\WindowsPowerShell\Modules\HPOneView.200\HPOneView.200.psm1:9714 char:5
+                 $_.PSObject.TypeNames.Insert(0,"HPOneView.Appliance.HealthStatus")
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Version Information

HPE OneView PowerShell Library Version (Get-HPOVVersion):

PowerShell Library Version : 2.0.430.0
Library Path               : C:\Users\vagrant\Documents\WindowsPowerShell\Modules\HPOneView.200

HPE OneView Appliance Version:

2.00

Output from $PSVersionTable on your Windows Host:

PS C:\Users\vagrant> $PSVersionTable

Name  : PSVersion
Value : 4.0

Name  : WSManStackVersion
Value : 3.0

Name  : SerializationVersion
Value : 1.1.0.1

Name  : CLRVersion
Value : 4.0.30319.34209

Name  : BuildVersion
Value : 6.3.9600.17400

Name  : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0}

Name  : PSRemotingProtocolVersion
Value : 2.2
wingZero21 commented 8 years ago

Oddly I have noticed that if I use a dns entry without a dash or numbers this does seem to work fine.

Is there any strangeness with this when using a - or numbers within the hostname?

PS C:\Users\vagrant> Connect-HPOVMgmt -appliance "ov.domain.com" -Username api -Password "z8eYWasa12bhu5"
WARNING: You are already connected to ov.domain.com
PS C:\Users\vagrant> Connect-HPOVMgmt -appliance "ovdc1.domain.com" -Username api -Password "z8eYWasa12bhu5"
Exception calling "RemoveAt" with "1" argument(s): "Index was out of range. Must be non-negative and less than the
size of the collection.
Parameter name: index"
At C:\Users\vagrant\Documents\WindowsPowerShell\Modules\HPOneView.200\HPOneView.200.psm1:6589 char:5
+                 [void]${Global:ConnectedSessions}.RemoveAt($_ndx)
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentOutOfRangeException

Connect-HPOVMgmt : Cannot process argument transformation on parameter 'Appliance'. Cannot convert value to type
System.String.
At line:1 char:1
+ Connect-HPOVMgmt -appliance "ovdc1.domain.com" -Username api -Password "z8eY ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Connect-HPOVMgmt], ParameterBindingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Connect-HPOVMgmt
ChrisLynchHPE commented 8 years ago

Your first example does not show any hyphens in the FQDN, which does not matter. When we look in the $Global:ConnectionSessions variable, we look to see if the Hostname or ApplianceConnection parameter value equals (using the -eq comparison operator), and then get the correct ApplianceConnection object. I use numbers in my FQDN's all of the time, and have not seen this behavior during any form of testing. Can you provide an example of the FQDN's you are trying to use?

ChrisLynchHPE commented 8 years ago

I believe I found the problem and fixed it. Please try Release 2.0.436.0.

wingZero21 commented 8 years ago

Hey,

Cheers for taking a look at this. I will try the latest version and let you know if it sorts it.

Cheers Mark

wingZero21 commented 8 years ago

Hi,

When attempting to connect with the new version it mentions the appliance version. Does the OneView appliance need to be updated to use this new client?

Cheers Mark

Details:

Connect-HPOVMgmt : The appliance you are connecting to supports an older version of this library.  Please visit
https://github.com/HewlettPackard/POSH-HPOneView for a supported version of the library.
At line:1 char:1
+ Connect-HPOVMgmt -appliance "ovdc1.domain.com" -Username user -Password " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (ovdc1.domain.com:String) [Connect-HPOVMgmt], NotImplementedExce
   ption
    + FullyQualifiedErrorId : LibraryTooNew,Connect-HPOVMgmt
wingZero21 commented 8 years ago

Just to confirm it looks like after getting the certificate this has fixed the issue though.

After importing the cert however it does indeed seem to be taking the backup as expected.

Thanks very much for sorting that.

Cheers Mark

ChrisLynchHPE commented 8 years ago

When attempting to connect with the new version it mentions the appliance version. Does the OneView appliance need to be updated to use this new client?

Can you tell me what version of the appliance you were attempting to connect to? If the appliance is older than 2.00, the library is incompatible with the library version you are trying to use. Essentially, you need the Major.Minor library version to match that of the HPE OneView appliance's Major.Minor version. The exception is when you have a newer appliance and you wish to use an older library version for script backwards compatibility purposes. The library keys off of the appliances supported API versions.