ome_groupdevices_info (Data Source)

This Terraform DataSource is used to query groups and their devices from OME. The information fetched from this data source can be used for getting the details / for further processing in resource block.

Example Usage

/*
Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.
Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://mozilla.org/MPL/2.0/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

# Get Group Info, Deviceids and servicetags of all devices that belong to a specified list of groups
data "ome_groupdevices_info" "gd" {
  device_group_names = ["WINDOWS", "WINDOWS-10"]
}

output "out" {
  value = {
    "common_device_ids"            = data.ome_groupdevices_info.gd.device_ids,
    "common_device_scvtags"        = data.ome_groupdevices_info.gd.device_servicetags,
    "group_windows"                = data.ome_groupdevices_info.gd.device_groups["WINDOWS"],
    "group_windows_subgroup_names" = data.ome_groupdevices_info.gd.device_groups["WINDOWS"].sub_groups[*].name,
    "group_windows_device_ids"     = data.ome_groupdevices_info.gd.device_groups["WINDOWS"].devices[*].id,
  }
}

# Get Sub Group Info of all specified groups
locals {
  # gd_names_with_non_zero_children is the subset of the specified list of group names where the group
  # has one or more child groups.
  # In the below code, we iterate over the specified list of groups and check if the sub_groups
  # field for that group in the ome_groupdevices_info data source has any entries. If it does, then that name is added
  # to a list. Then we use the to_set function to convert the list of names to a set to ensure that there is no 
  # duplication of names. Then that set is assigned to gd_names_with_non_zero_children.
  gd_names_with_non_zero_children = toset([for i in data.ome_groupdevices_info.gd.device_group_names : i if
  length(data.ome_groupdevices_info.gd.device_groups[i].sub_groups) > 0])
}

data "ome_groupdevices_info" "gd_children" {
  id                 = "1"
  device_group_names = data.ome_groupdevices_info.gd.device_groups[each.key].sub_groups[*].name
  for_each           = local.gd_names_with_non_zero_children
}

After the successful execution of above said block, We can see the output value by executing terraform output command. Also, we can use the fetched information by the variable data.ome_groupdevices_info.gd

Schema

Required

  • device_group_names (Set of String) List of the device group names.

Optional

  • id (String) ID for group devices data source.

Read-Only

  • device_groups (Attributes Map) Map of the groups fetched keyed by its name. (see below for nested schema)
  • device_ids (List of Number) List of the device id(s) associated with any of the groups.
  • device_servicetags (List of String) List of the device servicetags associated with any of the groups.

Nested Schema for device_groups

Read-Only:

  • created_by (String) The user who created the group.
  • creation_time (String) Creation time of the group.
  • definition_description (String) Definition description of the group.
  • definition_id (Number) Definition ID of the group.
  • description (String) Description of the group.
  • devices (Attributes Set) Devices of the group. (see below for nested schema)
  • global_status (Number) global_status of the group.
  • has_attributes (Boolean) If the group has attributes.
  • id (Number) ID of the group.
  • id_owner (Number) ID Owner of the group.
  • is_access_allowed (Boolean) If access of this group is allowed.
  • membership_type_id (Number) Membership Type ID of the group.
  • name (String) Name of the group.
  • parent_id (Number) Parent ID of the group.
  • sub_groups (Attributes Set) Sub Groups of the group. (see below for nested schema)
  • type_id (Number) Type ID of the group.
  • updated_by (String) The user who updated the group.
  • updated_time (String) Last updation time of the group.
  • visible (Boolean) If the group is visible or not.

Nested Schema for device_groups.devices

Read-Only:

  • id (Number) ID of the device.
  • servicetag (String) Service Tag of the device

Nested Schema for device_groups.sub_groups

Read-Only:

  • id (Number) ID of the sub group.
  • name (String) Name of the sub group.