Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query group management #26

Open
WSLAB3D opened this issue Apr 19, 2024 · 3 comments
Open

Query group management #26

WSLAB3D opened this issue Apr 19, 2024 · 3 comments

Comments

@WSLAB3D
Copy link

WSLAB3D commented Apr 19, 2024

I can get the list of groups, and determine which devices are in the groups, but I cannot find the membership query or create a dynamic group.

we use this to create query groups based on ESXi version so that we can create firmware baselines using the ESXi catalogs matching the installed ESXi version. It would be great to be able to automate this

@TrevorSquillario
Copy link
Collaborator

TrevorSquillario commented Apr 19, 2024

What do you mean by "find the membership query"?

As far as creating a query group, I've looked into it before and I passed on it at the time. There's a lot to it. This is what I would need to put it together (thinking out loud). Seems doable but no promises on when I can deliver. This is a side project of mine and not my day job.

  1. Get ContextId from /api/QuerySupportService/QueryContexts which represents the Table
  2. Get FieldId from /api/QuerySupportService/QueryContexts(id) which represents the Field
  3. Get OperatorId from /api/QuerySupportService/OperatorInfo which represents the Operator

I could create commandlets for Get-QuerySupportContext, Get-QuerySupportField and Get-QuerySupportOperator. Then you'd have to save these into variables and input them into a New-OMEQueryGroup commandlet like:

$Context = Get-QuerySupportContext | Where-Object { $_.Name -eq "Devices" }
$Field1 = Get-QuerySupportField -Context $Context | Where-Object { $_.Name -eq "Operating System Name" }
$Operator1 = Get-QuerySupportOperator | Where-Object { $_.Name -eq "=" }
$Field2 = Get-QuerySupportField -Context $Context | Where-Object { $_.Name -eq "OS Version" }
$Operator2 = Get-QuerySupportOperator | Where-Object { $_.Name -eq "contains" }

New-OMEQueryGroup -Context $Context -Fields @($Field1, $Field2) -FieldValues @("VMware ESXi", "8.0") -Operators @($Operator1, $Operator2) -LogicalOperator "AND"

The payload would look similar to the following:

{
  "GroupModel" : {
    "Name" : "My Dynamic Test Group",
    "Description" : "This is a dynamic test group.",
    "MembershipTypeId" : 24,
    "ParentId" : 1022
  },
  "GroupModelExtension" : {
    "ContextId" : 2,
    "Conditions": [
      {
        "LogicalOperatorId": 1,
        "LeftParen": false,
        "FieldId": 56,
        "OperatorId": 1,
        "Value": "1000",
        "RightParen": false
      },
      {
        "LogicalOperatorId": 1,
        "LeftParen": false,
        "FieldId": 55,
        "OperatorId": 7,
        "Value": "poweredge",
        "RightParen": false
      }
    ]
  }
}

https://developer.dell.com/apis/5898/versions/4.0.1/docs/Tasks/QueryGroups.md

@WSLAB3D
Copy link
Author

WSLAB3D commented Apr 21, 2024

Thanks Trevor, what I mean is to see the query that determines membership of the query group. Is there a way to retrieve the query relating to an existing group

I'll have a look into this and see what I can pull together.

Cheers,

Will

@WSLAB3D
Copy link
Author

WSLAB3D commented Apr 29, 2024

I see that the Group Query is available at /api/GroupService/Groups(groupid)/GroupQuery - it would be great if the output from this could be included in the response from Get-OMEGroup. I'll have a go at this when I have some time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants