I'm not sure if this is exactly what you are trying to do, but I was able to create a new group with two expressions using the NSX-T REST API. I'm using a direct rest call from vRO, but the principle...
See more...
I'm not sure if this is exactly what you are trying to do, but I was able to create a new group with two expressions using the NSX-T REST API. I'm using a direct rest call from vRO, but the principle should be the same for PowerCLI var expression = [];
expression.push({
"member_type": "VirtualMachine",
"value": "tag-1",
"key": "Tag",
"operator": "EQUALS",
"resource_type": "Condition"
})
// Not Adding a ConjunctionOperator to the expression list will make the API Call Fail
// The expression array index lenght must always be odd
expression.push({
"conjunction_operator": "AND",
"resource_type": "ConjunctionOperator"
});
expression.push({
"member_type": "VirtualMachine",
"value": "tag-2",
"key": "Tag",
"operator": "EQUALS",
"resource_type": "Condition"
})
// expression.length == 3
var group = {
"expression": expression,
"display_name": "NewGroup",
"description": "Testing Gropu Creation with multiple expressions"
};
var content = JSON.stringify(group);
System.log("Request Body is: " + content);
var restHost = System.getModule("com.domain.basic").getConfigurationElementAttributeValueWithPath("Domain", "NSXT", "restHost");
var restRequest = restHost.createRequest("PUT", "policy/api/v1/infra/domains/{yourdomain]/groups/NewGroup", content);
restRequest.contentType = "application/json";
var requestResponse = restRequest.execute(); Here is the result of the API Call in NSX-T