joel74 / POSH-F5-BIGIP

A set of PowerShell modules for working with F5 BIGIP devices using the iControlREST API
14 stars 8 forks source link

Get-PoolsForMember requires custom object #4

Closed spuder closed 6 years ago

spuder commented 6 years ago

Most functions take an array or a string. The Get-PoolsForMember takes a custom powershell object.

https://github.com/joel74/POSH-F5-BIGIP/blob/master/F5-BIGIP/F5-LTM/Public/Get-PoolsForMember.ps1#L11

Are there any examples of what the attributes of this custom powershell object should be?

If you pass a string to this function, you get this error

Get-PoolsForMember -PoolMember 'foobar'
Exception calling "IsMatch" with "2" argument(s): "Object reference not set to an instance of an object."
At \\files\Users\sowen\My Documents\WindowsPowerShell\Modules\F5-LTM\Public\Get-PoolsForMember.ps1:25 char:94
+ ... | Where-Object { [PoshLTM.F5Address]::IsMatch($Address, $_.address) }
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceExceptio
joel74 commented 6 years ago

Hi, Spencer, I can add an example to that function to help with that. It's expecting to get a PoolMember object passed to it. I.e. Get-poolmember -Name 'member1' | Get-PoolsForMember

Cheers, Joel

spuder commented 6 years ago

Thank you.

There appears to be two issues with that

  1. Get-PoolMember requires that you know the port

This does not work

Get-PoolsForMember -Name 'foobar' 

This does work

Get-PoolsForMember -Name 'foobar:80'
  1. Get-PoolMember returns more than 1 result per server
Get-PoolMember -F5Session $global:f5session -Name 'foobar:80' -Partition Common

Name             Partition Address        Description Monitor Session         State
----             --------- -------        ----------- ------- -------         -----
foobar:80 Common    10.254.130.131             default monitor-enabled up
foobar:80 Common    10.254.130.131             default user-enabled    unchecked

The work around for number 2 is to pipe to Unique

joel74 commented 6 years ago

Hi, Spencer, as I mentioned in the other issue, my understanding is that pool members need to include port values in their names. That's an interesting point about multiple instances of the same pool member, if it's present in different pools. I think you're correct - if a name for a pool member is passed in, a unique result should be returned. I'm experimenting with having the results for Get-PoolMember be filtered for uniqueness before being returned.

joel74 commented 6 years ago

Pull request made. Please review when you get a chance. Thanks.