Question

Nutanix Rest API v3 FIQL Filtering

  • 29 September 2021
  • 11 replies
  • 2990 views

I’m looking for more details regarding the use of the “filter” attribute and getting a list of VMs.

https://www.nutanix.dev/reference/prism_central/v3/api/vms/postvmslist/ 

 

I've been able to filter down VMs returned using the filter = “vm_name==my-vm-name” in my Rest API quiries but I was looking for some more examples.

In particular it would be great if I could find VMs by IP address or MAC address to try and hunt down VMs without doing a full VM list query.

Is there additional documentation on the FIQL filtering options in the REST api?


11 replies

I’m looking for the same information.

I can’t seem to find any documentation on this.

Are there any wildcards that can be used? * doesn’t seem to work.

I did figure out that if you include .*VMNAME.* it appears that wildcards do work. However this appears to switch the API to a case sensitive regex.
I found that if I encoded my queries like:
.*[Vv][Mm][Nn][Aa][Mm][Ee].* that it would return any VMs that contained the word “VMNAME” in either letter case. 
I then did some manual filtering if I wanted to get an exact match.

This was over all still much faster than dumping the entire list of VMs and filtering it down.

Cool, this is usefull information. Thanks!

I didn’t expect that the API would require me to handle the regex part, but on the other hand it allows for most flexibility ofcourse.

 

@Nutanix, I still could use some more documentation on this though :blush:

Userlevel 2
Badge +2

I’m going to continue this thread instead of creating my own to keep the rest of the posters in the loop.

@Jon - the last I read from you on this topic was that you hadn’t productized the filtering in the V3 API, but that was 2 years ago. Any updates on the filter functionality?

In my specific case I want to filter VMs on a category value and I can’t find any proper reference or documentation on how to do this in the Prism Central V3 API.

It’d be extremely convenient to filter directly in the API call instead of grabbing all VMs and then filter in my code.

Userlevel 6
Badge +29

@Martin Edelius - What version of PC are you trying to use in this case? Just want to make sure I get my ducks in the right order when I respond

Userlevel 2
Badge +2

Hi @Jon.

Sorry for the delayed reply, time is in short supply. :)

We’re using pc.2021.9.0.3.

What I’m actually looking for is proper documentation on how I can use filters in general when using Nutanix API’s. The FIQL standard/syntax is in itself relatively poorly documented and I can’t find any examples relating to JSON, only XML.

I can get my search to work for simple things like name but categories or similar “arrays” of values is a complete mystery.

Userlevel 1

Any update on this? I am trying to explore REST APIs to filter Vms, Hosts

  • Get VMs under a particular host
  • Get Hosts under a particular Cluster

Hoping this filtering is possible with FIQL. If we can get some documentation around this will be useful

 

Still no word on this?

Hello everyone,

It is possible to get the list of available attributes running the following command on a CVM:
arithmos_cli list_attributes_and_stats entity_type=<ENTITY_TYPE> | grep attribute_name

Where ENTITY_TYPE can be: cluster, disk, vdisk, vm, protection_domain, remote_site, storage_pool.

Complete attribute list for “entity_type=vm” is as follows:
  attribute_name: "memory_overcommit"
  attribute_name: "source_vm_uuid"
  attribute_name: "disable_update_white_list"
  attribute_name: "enable_cpu_passthrough"
  attribute_name: "disable_branding"
  attribute_name: "is_agent_vm"
  attribute_name: "protection_type"
  attribute_name: "vm_annotation"
  attribute_name: "gpu_console"
  attribute_name: "tools_version_status"
  attribute_name: "is_control_domain"
  attribute_name: "tools_running_status"
  attribute_name: "boot.uefi_firmware"
  attribute_name: "config_nutanix_nfs_file_path"
  attribute_name: "ngt_fail_on_script_failure"
  attribute_name: "is_virtual_disk_uuid_reporting_enabled"
  attribute_name: "has_virtual_disk_chains"
  attribute_name: "capacity_bytes"
  attribute_name: "machine_type"
  attribute_name: "ngt.multipathing_enabled_for_devices"
  attribute_name: "ngt.kvm_drivers_installed"
  attribute_name: "ngt.esx_drivers_installed"
  attribute_name: "ngt.is_deleted"
  attribute_name: "vm_type"
  attribute_name: "ngt.vm_vss_enabled"
  attribute_name: "ngt.iscsi_iqn"
  attribute_name: "ngt.guest_os"
  attribute_name: "ngt.cluster_version"
  attribute_name: "ngt.installed_version"
  attribute_name: "vm_uuid"
  attribute_name: "cbr_not_capable_reason"
  attribute_name: "frodo_enabled"
  attribute_name: "ngt.network_interfaces"
  attribute_name: "empty_cdrom_disk_addresses"
  attribute_name: "category_host_affinity_list"
  attribute_name: "auto_stop_action"
  attribute_name: "node_uuid"
  attribute_name: "ngt_enable_script_exec"
  attribute_name: "nutanix_iscsi_based_virtual_disk_uuids"
  attribute_name: "display_address"
  attribute_name: "is_cbr_capable"
  attribute_name: "container_ids"
  attribute_name: "id"
  attribute_name: "num_threads_per_core"
  attribute_name: "configured_gpu_list"
  attribute_name: "gpus_in_use"
  attribute_name: "host_uuid"
  attribute_name: "memory_reserved_bytes"
  attribute_name: "last_published_timestamp_usecs"
  attribute_name: "guest_os_name"
  attribute_name: "ngt.communication_over_serial_port_active"
  attribute_name: "vm_name"
  attribute_name: "num_vcpus"
  attribute_name: "empty_cdrom_device_uuid_list"
  attribute_name: "controller.storage_tier.das-sata.configured_pinned_bytes"
  attribute_name: "guest_driver_version"
  attribute_name: "ngt.metrics_enabled"
  attribute_name: "node_id"
  attribute_name: "memory_size_bytes"
  attribute_name: "num_network_adapters"
  attribute_name: "protection_domain_name"
  attribute_name: "tools_installer_mounted"
  attribute_name: "node_name"
  attribute_name: "hardware_clock_timezone"
  attribute_name: "nutanix_iscsi_based_virtual_disks"
  attribute_name: "storage_committed"
  attribute_name: "ip_addresses"
  attribute_name: "hypervisor_type"
  attribute_name: "nutanix_nfs_based_virtual_disks"
  attribute_name: "boot_device_order"
  attribute_name: "gpu_type"
  attribute_name: "controller.total_pinned_vdisks"
  attribute_name: "serial_port_types"
  attribute_name: "is_acropolis_vm"
  attribute_name: "node_ipv4_address"
  attribute_name: "power_state"
  attribute_name: "power_state_mechanism"
  attribute_name: "virtual_nic_ids"
  attribute_name: "is_live_migratable"
  attribute_name: "num_vnuma_nodes"
  attribute_name: "virtual_gpu_device_uuids"
  attribute_name: "num_cores_per_socket"
  attribute_name: "cluster_name"
  attribute_name: "vm_snapshot"
  attribute_name: "vm_create_timestamp_usecs"
  attribute_name: "vga_console_enabled"
  attribute_name: "legacy_host_affinity_list"
  attribute_name: "logical_timestamp"
  attribute_name: "volume_group"
  attribute_name: "consistency_group_name"
  attribute_name: "ngt.communication_active"
  attribute_name: "flash_mode_enabled"
  attribute_name: "virtual_gpu_uuids"
  attribute_name: "virtual_nic_uuids"
  attribute_name: "bios_uuid"
  attribute_name: "cpu_ready_time_ppm"
  attribute_name: "nutanix_nfs_based_virtual_disk_uuids"
  attribute_name: "generation_uuid"
  attribute_name: "guest_os_id"
  attribute_name: "serial_ports"
  attribute_name: "controller.storage_tier.ssd.configured_pinned_bytes"
  attribute_name: "is_cvm"
  attribute_name: "cpu_reservation_hz"
  attribute_name: "ngt.flr_enabled"
  attribute_name: "controller.storage_tier.cloud.configured_pinned_bytes"
  attribute_name: "cluster_uuid"
  attribute_name: "ngt.enabled_applications"
  attribute_name: "ngt.communication_type"
  attribute_name: "controller.storage_tier.ssd-mem-nvme.configured_pinned_bytes"
  attribute_name: "vcpu_hard_pin"
  attribute_name: "serial_port_device_uuids"
  attribute_name: "ngt.iso_mounted"
  attribute_name: "ngt.enabled"
  attribute_name: "storage_unshared"
  attribute_name: "virtual_hardware_version"
  attribute_name: "serial_port_urls"
  attribute_name: "ha_priority"
  attribute_name: "boot_device_config"

Regards!

Hello, @Jon, any update on a proper documentation for how we can use filters in v3?

I want to filter out a list of HOSTS for a specific cluster using v3 API. I’m using the following dictionary but it returns the hosts for all the clusters

 

{
  "kind": "host",
  "filter": “cluster=in=randomplaceholderclusterid",
  "length": 1,
  "offset": 0
}

Any help on this would be appreciated. 

Thanks!

Reply