VMware Cloud Community
s7464dghd
Contributor
Contributor
Jump to solution

Powercli NSX module not loading expression for a group?

I am trying to modify objects in NSXT using the newer VMware.Sdk.Nsx.Policy from Powercli. I am on v13 and when loading a group either via Invoke-ListGroupForDomain or Invoke-ReadGroupForDomain, the Expression is not fully shown/pulled down and thus I can't actually modify group properties and push it back up. For example, below is the condition seen from the REST API:

{
    "expression": [
        {
            "member_type": "VirtualMachine",
            "key": "ComputerName",
            "operator": "STARTSWITH",
            "value": "adtest1",
            "resource_type": "Condition",
            "id": "steven-test-2",
            "path": "/infra/domains/default/groups/test-steven/condition-expressions/steven-test-2",
            "relative_path": "steven-test-2",
            "parent_path": "/infra/domains/default/groups/test-steven",
            "marked_for_delete": false,
            "overridden": false,
            "_protection": "NOT_PROTECTED"
        }
    ],
    "extended_expression": [],
    "reference": false,

 

Now., using the Powershell cmdlets, the expression is only partially loaded it seems:

$g = Invoke-ReadGroupForDomain -DomainId default -GroupId "test-steven"
$g


GroupType          :
State              :
Expression         : {steven-test-2}
ExtendedExpression : {}
Reference          : False
Children           :
MarkedForDelete    : False
Overridden         : False
ParentPath         : /infra/domains/default
Path               : /infra/domains/default/groups/test-steven
RealizationId      :
RelativePath       : test-steven
UniqueId           : 0c1301c2-d842-4bc6-bc05-17342591e035
CreateTime         : 1675273711221
CreateUser         : SANITIZED
LastModifiedTime   : 1675281827900
LastModifiedUser   : SANITIZED
Protection         : NOT_PROTECTED
SystemOwned        : False
Description        :
DisplayName        : test-steven3
Id                 : test-steven
ResourceType       : Group
Tags               : {VMware.Bindings.Nsx.Policy.Model.Tag}
Revision           : 4
Links              :
Schema             :
Self               :

$g.Expression

ResourceType     : Condition
Children         :
MarkedForDelete  : False
Overridden       : False
ParentPath       : /infra/domains/default/groups/test-steven
Path             : /infra/domains/default/groups/test-steven/condition-expressions/steven-test-2
RealizationId    :
RelativePath     : steven-test-2
UniqueId         :
CreateTime       : 0
CreateUser       :
LastModifiedTime : 0
LastModifiedUser :
Protection       : NOT_PROTECTED
SystemOwned      : False
Description      :
DisplayName      :
Id               : steven-test-2
Tags             :
Revision         : 0
Links            :
Schema           :

 

Any ideas what's going on? This is making editing groups kind of worthless for this project.

0 Kudos
1 Solution

Accepted Solutions
knikolov
VMware Employee
VMware Employee
Jump to solution

What GSS have told you is not true. Here is the PowerCLI support information from the current PowerCLI user guide: https://developer.vmware.com/docs/15315//GUID-0F835722-E667-4177-A8EF-51AB15FA837E.html. Can you please PM me the GSS rep details and the SR number, so that I can update them on the PowerCLI support policy?

As far as the issue itself is concerned this is a known issue and is due to the fact that NSX supports different expression types, but at the API level only the base type is defined as a return type. As a result PowerCLI tries to deserialize the information in this base type and is losing some of the properties. We're still considering how to fix this polymorphism issue. 

View solution in original post

9 Replies
LucD
Leadership
Leadership
Jump to solution

Does using the -IncludedFields parameter on the Invoke-ListGroupForDomain cmdlet make any difference?

Instead of using these from a Swagger file generated cmdlets you could try calling the REST API directly with for example Invoke-RestMethod.
See if that makes a difference.
At least you will know if it is a cmdlet issue or an API issue.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
s7464dghd
Contributor
Contributor
Jump to solution

I did the invoke-rest method and it correctly retrieves expression, just like postman did. Definitely a cmdlet/powershell specific issue.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Then an SR might be the best way to proceed (although it will not solve your immediate problem).

If GSS claims PowerCLI is not supported without a Developer Support contract, point them to Online Documentation - PowerCLI 12.3.0 User’s Guide - VMware {code}

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
s7464dghd
Contributor
Contributor
Jump to solution

Appreciate the quick reply and will do that.

 

As a sidenote, even their doc generation is a bit broken...if you notice the latest docs have random instances of "null" before the command names 🙂

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, that caused me a serious headache yesterday evening 😂

Perhaps something the UX Team is cooking up.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
s7464dghd
Contributor
Contributor
Jump to solution

So contacted support and VMWare doesn't seem to actually care that their PowerCLI functions don't work.

the rep said I needed to submit a ticket against SDK and not NSX (and couldn't automatically do that for me either 😒) and VMWARE SDK isn't an option in the product list. I sent them the link you sent and they mentioned that didnt apply to 13.

So, whatever...

Tags (1)
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is (again) the same BS you get from GSS.
Did you point the GSS person to the document I referred to earlier?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
s7464dghd
Contributor
Contributor
Jump to solution

Yeah they said that’s for 12.6 and they’re on v13 now. And those details seem to be gone from the v13 page. 

0 Kudos
knikolov
VMware Employee
VMware Employee
Jump to solution

What GSS have told you is not true. Here is the PowerCLI support information from the current PowerCLI user guide: https://developer.vmware.com/docs/15315//GUID-0F835722-E667-4177-A8EF-51AB15FA837E.html. Can you please PM me the GSS rep details and the SR number, so that I can update them on the PowerCLI support policy?

As far as the issue itself is concerned this is a known issue and is due to the fact that NSX supports different expression types, but at the API level only the base type is defined as a return type. As a result PowerCLI tries to deserialize the information in this base type and is losing some of the properties. We're still considering how to fix this polymorphism issue.