Nutanix Hypervisor
Nutanix Hypervisor abstracts and isolates the VMs and their programs from the underlying server hardware, enabling a more efficient use of physical resources, simpler maintenance and operations, and reduced costs.
IT Services · Nutanix Hypervisor
Details
| ID | Nutanix Hypervisor |
|---|---|
| Provider | Nutanix |
| Category | IT Services |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Supported Modules | Agentix XSIAM |
README
Nutanix Hypervisor abstracts and isolates the VMs and their programs from the underlying server hardware, enabling a
more efficient use of physical resources, simpler maintenance and operations, and reduced costs. This integration was
integrated and tested with version v2 of Nutanix.
Configure Nutanix Hypervisor on Cortex XSOAR
- Navigate to Settings > Integrations > Servers & Services.
- Search for Nutanix Hypervisor.
-
Click Add instance to create and configure a new integration instance.
Parameter Description Required Server URL (e.g., https://192.168.0.1:57261) True Fetch incidents False Incident type False Username True Incidents Fetch Interval False Maximum number of incidents per fetch The maximum number of incidents to fetch each time. False Alert Status Filters Fetches incidents by the status filters given. For example, if acknowledged is true, then only alerts that have been acknowledged will be fetched. If ‘Auto Resolved’ or ‘Not Auto Resolved’ is selected, then by default also ‘Resolved’ will be set. False Alert type IDs Comma-separated list of alert type IDs. Fetches alerts whose type ID matches an alert_type_id in the alert_type_ids list. For example, alert ‘Alert E-mail Failure’ has type ID A111066. If alert_type_ids = ‘A111066’, only alerts of ‘Alert E-mail Failure’ will be displayed. False Impact Types Comma-separated list of impact types. Fetch alerts whose impact type matches an impact type in Impact Types list. For example, alert ‘Incorrect NTP Configuration’ has impact type ‘SystemIndicator’. If Impact Types = ‘SystemIndicator’, only alerts with impact type ‘SystemIndicator’, such as ‘Incorrect NTP Configuration’ will be displayed. False First fetch timestamp format: <number><time unit>, e.g., 12 hours, 7 days.False Trust any certificate (not secure) False Use system proxy settings False - Click Test to validate the URLs, token, and connection.
Available Alert Type IDs, Impact Types, and Entity Types
Alert Policies contains the list of all possible alerts in the system,
and their ID, impact type, and entity type. In order to check the optional values for these entities:
- Go to your Nutanix UI and navigate to the Alerts screen. (Can be found under the second tab in the top left corner, see image below)
- Navigate to the Alert Policies tab on the left sidebar.
You should see the following screen:

- ID is the alert type ID filter parameter for fetching alerts, or the argument for the nutanix-hypervisor-alerts-list command.
- Impact Type is the impact type filter parameter for fetching alerts, or the argument for the nutanix-hypervisor-alerts-list command.
Permissions
The following commands require cluster admin or higher permissions.
(Found in Nutanix Settings in the Users And Roles category.)
- nutanix-hypervisor-vm-powerstatus-change
- nutanix-hypervisor-alert-acknowledge
- nutanix-hypervisor-alert-resolve
- nutanix-hypervisor-alerts-acknowledge-by-filter
- nutanix-hypervisor-alerts-resolve-by-filter
Commands
You can execute these commands from the Cortex XSOAR CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.
nutanix-hypervisor-hosts-list
Gets the list of physical hosts configured in the cluster.
Base Command
nutanix-hypervisor-hosts-list
Input
| Argument Name | Description | Required |
|---|---|---|
| filter | The filters used to define the hosts to retrieve. Nutanix filters can be one of the fields returned in the response by the Nutanix GET hosts API call. Some of the fields in the response are not supported. Known filters that the Nutanix service supports are: host_nic_ids, host_gpus, storage_tier, das-sata.usage_bytes, storage.capacity_bytes, storage.logical_usage_bytes, storage_tier.das-sata.capacity_bytes, storage.usage_bytes. You can try to enter your own filters, but if Nutanix does not support the filter, an error will be thrown specifying that the filter is invalid. Each filter is written in the following format: filter_name==filter_value or filter_name!=filter_value. Possible combinations of OR (using comma ‘,’) and AND (using semicolon ‘;’), for example, storage.capacity_bytes==2;host_nic_ids!=35,host_gpus==x, are parsed by Nutanix as follows: Return all hosts s.t (storage.capacity_bytes == 2 AND host_nic_ids != 35) OR host_gpus == x. | Optional |
| page | Page number in the query response. Default is 1. | Optional |
| limit | Maximum number of physical hosts to retrieve. Possible values are 1-1000. Default is 50. | Optional |
| verbose | Receive extended information from Nutanix about hosts. Possible values are: true, false. Default is false. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| NutanixHypervisor.Host.service_vmid | String | Service virtual machine ID. |
| NutanixHypervisor.Host.uuid | String | Host UUID. |
| NutanixHypervisor.Host.name | String | Host name. |
| NutanixHypervisor.Host.service_vmexternal_ip | String | Service virtual machine external IP. |
| NutanixHypervisor.Host.service_vmnat_ip | String | Service virtual machine network address translation IP. |
| NutanixHypervisor.Host.service_vmnat_port | Number | Service virtual machine network address translation port. |
| NutanixHypervisor.Host.oplog_disk_pct | Number | Oplog disk pct. |
| NutanixHypervisor.Host.oplog_disk_size | Date | Oplog disk size. |
| NutanixHypervisor.Host.hypervisor_key | String | Hypervisor key. |
| NutanixHypervisor.Host.hypervisor_address | String | Hypervisor address. |
| NutanixHypervisor.Host.hypervisor_username | String | Hypervisor username. |
| NutanixHypervisor.Host.hypervisor_password | String | Hypervisor password. |
| NutanixHypervisor.Host.backplane_ip | String | Backplane IP. |
| NutanixHypervisor.Host.controller_vm_backplane_ip | String | Controller virtual machine backplane IP. |
| NutanixHypervisor.Host.rdma_backplane_ips | Unknown | Remote directory memory access backplane IPs. |
| NutanixHypervisor.Host.management_server_name | String | Management server name. |
| NutanixHypervisor.Host.ipmi_address | String | Intelligent platform management interface address. |
| NutanixHypervisor.Host.ipmi_username | String | Intelligent platform management interface username. |
| NutanixHypervisor.Host.ipmi_password | String | Intelligent platform management interface password. |
| NutanixHypervisor.Host.monitored | Boolean | Whether the host is monitored. |
| NutanixHypervisor.Host.position.ordinal | Number | Host ordinal position. |
| NutanixHypervisor.Host.position.name | String | Host’s position name. |
| NutanixHypervisor.Host.position.physical_position | String | Physical position. Allowed values are [C, L, R, TL, TR, BL, BR]. Values are abbreviations for [Center, Left, Right, Top Left, Top Right, Bottom Left, Bottom Right]. |
| NutanixHypervisor.Host.serial | String | Host serial ID. |
| NutanixHypervisor.Host.block_serial | String | Host block serial ID. |
| NutanixHypervisor.Host.block_model | String | Host block model. |
| NutanixHypervisor.Host.block_model_name | String | Block model name. |
| NutanixHypervisor.Host.block_location | String | Block location. |
| NutanixHypervisor.Host.host_maintenance_mode_reason | String | Host maintenance reason, if host is in maintenance. |
| NutanixHypervisor.Host.hypervisor_state | String | Host’s hypervisor state. |
| NutanixHypervisor.Host.acropolis_connection_state | String | Acropolis connection status. |
| NutanixHypervisor.Host.metadata_store_status | String | Metadata store status. |
| NutanixHypervisor.Host.metadata_store_status_message | String | Metadata store status message. |
| NutanixHypervisor.Host.state | String | Host state. |
| NutanixHypervisor.Host.removal_status | String | Host removal status. |
| NutanixHypervisor.Host.vzone_name | String | Virtual zone name. |
| NutanixHypervisor.Host.cpu_model | String | CPU model. |
| NutanixHypervisor.Host.num_cpu_cores | Number | Number of CPU cores. |
| NutanixHypervisor.Host.num_cpu_threads | Number | Number of CPU threads. |
| NutanixHypervisor.Host.num_cpu_sockets | Number | Number of CPU sockets. |
| NutanixHypervisor.Host.hypervisor_full_name | String | Host’s hypervisor full name. |
| NutanixHypervisor.Host.hypervisor_type | String | Hypervisor’s type. |
| NutanixHypervisor.Host.num_vms | Number | Host number of virtual machines. |
| NutanixHypervisor.Host.boot_time_in_usecs | Number | Boot time in epoch time. |
| NutanixHypervisor.Host.boot_time | date | Boot time in epoch time. |
| NutanixHypervisor.Host.is_degraded | Boolean | Whether the host is degraded. |
| NutanixHypervisor.Host.is_secure_booted | Boolean | Whether the host is secure booted. |
| NutanixHypervisor.Host.is_hardware_virtualized | Boolean | Whether the hardware is virtualized. |
| NutanixHypervisor.Host.failover_cluster_fqdn | String | Failover cluster fully qualified domain name. |
| NutanixHypervisor.Host.failover_cluster_node_state | String | Failover cluster node state. |
| NutanixHypervisor.Host.reboot_pending | Boolean | Whether reboot is pending. |
| NutanixHypervisor.Host.default_vm_location | String | Default virtual machine location. |
| NutanixHypervisor.Host.default_vm_storage_container_id | String | Default virtual machine storage container ID. |
| NutanixHypervisor.Host.default_vm_storage_container_uuid | String | Default virtual machine storage container UUID. |
| NutanixHypervisor.Host.default_vhd_location | String | Default virtual hard disk location. |
| NutanixHypervisor.Host.default_vhd_storage_container_id | String | Default virtual hard disk storage container ID. |
| NutanixHypervisor.Host.default_vhd_storage_container_uuid | String | Default virtual hard disk storage container UUID. |
| NutanixHypervisor.Host.bios_version | String | BIOS version. |
| NutanixHypervisor.Host.bios_model | String | BIOS model. |
| NutanixHypervisor.Host.bmc_version | String | BMC version. |
| NutanixHypervisor.Host.bmc_model | String | BMC model. |
| NutanixHypervisor.Host.hba_firmwares_list | Unknown | Host bus adapter firmware list. |
| NutanixHypervisor.Host.cluster_uuid | String | Host’s cluster UUID. |
| NutanixHypervisor.Host.has_csr | Boolean | Whether the host has a certificate signing request. |
| NutanixHypervisor.Host.host_gpus | Unknown | Host’s GPUs. |
| NutanixHypervisor.Host.gpu_driver_version | String | Host GPU driver version. |
| NutanixHypervisor.Host.host_type | String | Host type. |
| NutanixHypervisor.Host.host_in_maintenance_mode | Boolean | Whether the host is in maintenance mode. |
Command Example
!nutanix-hypervisor-hosts-list filter="num_vms==2" limit=3 page=1
Context Example
{
"NutanixHypervisor": {
"Host": {
"boot_time": "2020-11-22T14:13:52.399817+00:00",
"boot_time_in_usecs": 1606054432399817,
"cluster_uuid": "asra1631-a234-zxd1-aa23-azxr124z23aq",
"controller_vm_backplane_ip": "192.168.1.111",
"cpu_model": "Intel(R) Xeon(R) Silver 4216 CPU @ 2.10GHz",
"has_csr": false,
"host_type": "HYPER_CONVERGED",
"hypervisor_address": "192.168.1.111",
"hypervisor_full_name": "Nutanix 20190916.321",
"hypervisor_key": "192.168.1.111",
"hypervisor_type": "kKvm",
"hypervisor_username": "root",
"is_degraded": false,
"is_hardware_virtualized": false,
"is_secure_booted": false,
"management_server_name": "192.168.1.111",
"monitored": true,
"name": "NTNX-386a5fb4-A",
"num_cpu_cores": 8,
"num_cpu_sockets": 2,
"num_cpu_threads": 8,
"num_vms": 2,
"reboot_pending": false,
"serial": "59bc015e-a22d-41ab-9ce2-a96164955e9q",
"service_vmexternal_ip": "192.168.1.111",
"service_vmid": "asra1631-a234-zxd1-aa23-azxr124z23aq::2",
"state": "NORMAL",
"uuid": "59bc015e-a22d-41ab-9ce2-a96164955e9q",
"vzone_name": ""
}
}
}
Human Readable Output
Nutanix Hosts List
is_hardware_virtualized host_type serial boot_time hypervisor_type num_cpu_sockets hypervisor_full_name hypervisor_username uuid vzone_name hypervisor_address num_vms is_secure_booted management_server_name monitored is_degraded state num_cpu_cores name service_vmid service_vmexternal_ip reboot_pending cluster_uuid has_csr hypervisor_key cpu_model num_cpu_threads controller_vm_backplane_ip boot_time_in_usecs false HYPER_CONVERGED 59bc015e-a22d-41ab-9ce2-a96164955e9q 2020-11-22T14:13:52.399817+00:00 kKvm 2 Nutanix 20190916.321 root 59bc015e-a22d-41ab-9ce2-a96164955e9q 192.168.1.111 2 false 192.168.1.111 true false NORMAL 8 NTNX-386a5fb4-A asra1631-a234-zxd1-aa23-azxr124z23aq::2 192.168.1.111 false asra1631-a234-zxd1-aa23-azxr124z23aq false 192.168.1.111 Intel(R) Xeon(R) Silver 4216 CPU @ 2.10GHz 8 192.168.1.111 1606054432399817
nutanix-hypervisor-vms-list
Gets a list of virtual machines.
Base Command
nutanix-hypervisor-vms-list
Input
| Argument Name | Description | Required |
|---|---|---|
| filter | Retrieve virtual machines that matches the filters given. . Nutanix filters can be one of the field returned in the response by nutanix GET VMs API call. Some of the fields in the response are not supported. Known filters Nutanix service supports are: machine_type, power_state, ha_priority, uefi_boot. You can try to enter your own filter, but if Nutanix does not support the filter, an error will be thrown specifying the filter is invalid. Each filter is written in the following way: filter_name==filter_value or filter_name!=filter_value. Possible combinations of OR (using comma ‘,’) and AND (using semicolon ‘;’), for Example: machine_type==pc;power_state!=off,ha_priority==0 is parsed by Nutanix the following way: Return all virtual machines s.t (machine type == pc AND power_state != off) OR ha_priority == 0. | Optional |
| limit | Maximum number of virtual machines to retrieve. Default is 50. | Optional |
| offset | The offset to start retrieving virtual machines. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| NutanixHypervisor.VM.affinity.policy | String | Affinity policy. |
| NutanixHypervisor.VM.affinity.host_uuids | String | List of host UUIDs of the affinity. |
| NutanixHypervisor.VM.allow_live_migrate | Boolean | Whether the virtual machine allows live migration. |
| NutanixHypervisor.VM.gpus_assigned | Boolean | Whether the virtual machine has GPUs assigned. |
| NutanixHypervisor.VM.boot.uefi_boot | Boolean | Whether the Unified Extensible Firmware Interface boots. |
| NutanixHypervisor.VM.ha_priority | Number | High availability priority. |
| NutanixHypervisor.VM.host_uuid | String | Host UUID of the virtual machine. |
| NutanixHypervisor.VM.memory_mb | Number | The memory size in megabytes. |
| NutanixHypervisor.VM.name | String | The name of the virtual machine. |
| NutanixHypervisor.VM.num_cores_per_vcpu | Number | Number of cores per vCPU. |
| NutanixHypervisor.VM.num_vcpus | Number | Number of vCPUs. |
| NutanixHypervisor.VM.power_state | String | The virtual machine current power state. |
| NutanixHypervisor.VM.timezone | String | The virtual machine time zone. |
| NutanixHypervisor.VM.uuid | String | The UUID of the virtual machine. |
| NutanixHypervisor.VM.vm_features.AGENT_VM | Boolean | Whether the virtual machine has the AGENT VM feature. |
| NutanixHypervisor.VM.vm_features.VGA_CONSOLE | Boolean | Whether the virtual machine has the VGA CONSOLE feature. |
| NutanixHypervisor.VM.vm_logical_timestamp | Number | The logical timestamp of the virtual machine. |
| NutanixHypervisor.VM.machine_type | String | The machine type of the virtual machine. |
Command Example
!nutanix-hypervisor-vms-list filter="machine_type==pc,power_state!=off" length=3 offset=0
Context Example
{
"NutanixHypervisor": {
"VM": {
"affinity": {
"host_uuids": [
"59bc015e-a22d-41ab-9ce2-a96164955e9q"
],
"policy": "AFFINITY"
},
"allow_live_migrate": false,
"boot": {
"uefi_boot": false
},
"gpus_assigned": false,
"ha_priority": 0,
"host_uuid": "59bc015e-a22d-41ab-9ce2-a96164955e9q",
"machine_type": "pc",
"memory_mb": 4096,
"name": "CentOS7_Test",
"num_cores_per_vcpu": 2,
"num_vcpus": 2,
"power_state": "on",
"timezone": "UTC",
"uuid": "16c3d845-dc54-4fb1-bfc8-7671dd230967",
"vm_features": {
"AGENT_VM": false,
"VGA_CONSOLE": true
},
"vm_logical_timestamp": 243
}
}
}
Human Readable Output
Nutanix Virtual Machines List
timezone allow_live_migrate name ha_priority machine_type memory_mb uuid power_state num_cores_per_vcpu vm_logical_timestamp gpus_assigned host_uuid num_vcpus UTC false CentOS7_Test 0 pc 4096 16c3d845-dc54-4fb1-bfc8-7671dd230967 on 2 243 false 59bc015e-a22d-41ab-9ce2-a96164955e9q 2
nutanix-hypervisor-vm-powerstatus-change
Sets the power state of a virtual machine. If the virtual machine is being powered on and no host is specified, the host with
the most available CPU and memory will be chosen. Note that such a host may not be available. If the virtual machine is
being power cycled, a different host can be specified to start it on. The command returns a task UUID that can be
monitored by the nutanix-hypervisor-task-results-get command.
Base Command
nutanix-hypervisor-vm-powerstatus-change
Input
| Argument Name | Description | Required |
|---|---|---|
| vm_uuid | ID of the virtual machine to change its power status. Virtual machine ID is the ‘uuid’ field returned for by command ‘nutanix-hypervisor-vms-list’. | Required |
| host_uuid | The UUID of the host to be used to run the virtual machine if the virtual machine is transitioned with ‘ON’ or ‘POWERCYCLE’. Host ID is the ‘uuid’ field returned for by command ‘nutanix-hypervisor-hosts-list’. | Optional |
| transition | The new power state to which you want to transfer the virtual machine to. Possible values are: ON, OFF, POWERCYCLE, RESET, PAUSE, SUSPEND, RESUME, SAVE, ACPI_SHUTDOWN, ACPI_REBOOT. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| NutanixHypervisor.VMPowerStatus.task_uuid | String | The task UUID returned by Nutanix service for the power status change request. With this task UUID the task status can be monitored by using the nutanix-hypervisor-task-results-get command. |
Command Example
!nutanix-hypervisor-vm-powerstatus-change vm_uuid=16c3d845-dc54-4fb1-bfc8-7671dd230967 transition=ON
Context Example
{
"NutanixHypervisor": {
"VMPowerStatus": {
"task_uuid": "7f522fb2-1b19-491a-ab49-763f48be8712"
}
}
}
Human Readable Output
Results
task_uuid 7f522fb2-1b19-491a-ab49-763f48be8712
nutanix-hypervisor-task-results-get
Returns the results of given tasks. If a task is not ready, its status will be returned.
Base Command
nutanix-hypervisor-task-results-get
Input
| Argument Name | Description | Required |
|---|---|---|
| task_ids | Comma-separated list of the task IDs to get results to. Task ID is the ‘task_uuid’ field returned for by command ‘nutanix-hypervisor-vm-powerstatus-change’. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| NutanixHypervisor.Task.timed_out | Boolean | Indicates if a timeout occurred during the poll request from Nutanix. |
| NutanixHypervisor.Task.uuid | String | The task UUID. |
| NutanixHypervisor.Task.meta_request.method_name | String | The name of the method performed for this task. |
| NutanixHypervisor.Task.meta_response.error_code | Number | The error code returned for the task. |
| NutanixHypervisor.Task.meta_response.error_detail | String | The error details if the error code was not 0. |
| NutanixHypervisor.Task.create_time_usecs | Number | The time the task was created in epoch time. |
| NutanixHypervisor.Task.create_time | date | The time task was created in epoch. |
| NutanixHypervisor.Task.start_time_usecs | Number | The start time of the task in epoch time. |
| NutanixHypervisor.Task.start_time | date | The start time of the task in epoch time. |
| NutanixHypervisor.Task.complete_time_usecs | Number | The completion time of the task in epoch time. |
| NutanixHypervisor.Task.complete_time | date | The completion time of the task in epoch time. |
| NutanixHypervisor.Task.last_updated_time_usecs | Number | The last update of the task in epoch time. |
| NutanixHypervisor.Task.last_updated | date | The last update of the task in epoch time. |
| NutanixHypervisor.Task.entity_list.entity_id | String | ID of the entity. |
| NutanixHypervisor.Task.entity_list.entity_type | String | Type of the entity. |
| NutanixHypervisor.Task.entity_list.entity_name | String | The name of the entity. |
| NutanixHypervisor.Task.operation_type | String | Operation type of the task. |
| NutanixHypervisor.Task.message | String | Task message. |
| NutanixHypervisor.Task.percentage_complete | Number | Completion percentage of the task. |
| NutanixHypervisor.Task.progress_status | String | Progress status of the task, for example, Succeeded, Failed, etc. |
| NutanixHypervisor.Task.subtask_uuid_list | String | The list of the UUIDs of the subtasks for this task. |
| NutanixHypervisor.Task.cluster_uuid | String | The UUID of the cluster. |
Command Example
!nutanix-hypervisor-task-results-get task_ids=072f64d8-c737-4230-a1ec-199b449b9795
Context Example
{
"NutanixHypervisor": {
"Task": {
"cluster_uuid": "asra1631-a234-zxd1-aa23-azxr124z23aq",
"complete_time": "2021-02-03T15:51:26.579757+00:00",
"complete_time_usecs": 1612367486579757,
"create_time": "2021-02-03T15:51:26.346257+00:00",
"create_time_usecs": 1612367486346257,
"entity_list": [
{
"entity_id": "16c3d845-dc54-4fb1-bfc8-7671dd230967",
"entity_type": "VM"
}
],
"last_updated": "2021-02-03T15:51:26.579757+00:00",
"last_updated_time_usecs": 1612367486579757,
"message": "",
"meta_request": {
"method_name": "VmChangePowerState"
},
"meta_response": {
"error_code": 0
},
"operation_type": "VmChangePowerState",
"percentage_complete": 100,
"progress_status": "Succeeded",
"start_time": "2021-02-03T15:51:26.376685+00:00",
"start_time_usecs": 1612367486376685,
"subtask_uuid_list": [
"6f90a15d-ad76-4782-89bd-80811f162543"
],
"uuid": "072f64d8-c737-4230-a1ec-199b449b9795"
}
}
}
Human Readable Output
Nutanix Hypervisor Tasks Status
cluster_uuid complete_time complete_time_usecs create_time create_time_usecs entity_list last_updated last_updated_time_usecs message meta_request meta_response operation_type percentage_complete progress_status start_time start_time_usecs subtask_uuid_list uuid asra1631-a234-zxd1-aa23-azxr124z23aq 2021-02-03T15:51:26.579757+00:00 1612367486579757 2021-02-03T15:51:26.346257+00:00 1612367486346257 {‘entity_id’: ‘16c3d845-dc54-4fb1-bfc8-7671dd230967’, ‘entity_type’: ‘VM’} 2021-02-03T15:51:26.579757+00:00 1612367486579757 method_name: VmChangePowerState error_code: 17
error_detail: Cannot complete request in state InvalidVmState: Cannot complete request in state OnVmChangePowerState 100 Failed 2021-02-03T15:51:26.376685+00:00 1612367486376685 6f90a15d-ad76-4782-89bd-80811f162543 072f64d8-c737-4230-a1ec-199b449b9795
nutanix-hypervisor-alerts-list
Gets the list of alerts generated in the cluster that matches the filters. Nutanix fetches the latest alerts created if there are more than the defined maximum number of alerts.
Base Command
nutanix-hypervisor-alerts-list
Input
| Argument Name | Description | Required |
|---|---|---|
| start_time | The start date in ISO date format, epoch time or time range(<number> <time unit>, e.g., 12 hours, 7 days). Only alerts that were created on or after the specified date/time will be retrieved. If no time zone is specified, UTC time zone will be used. |
Optional |
| end_time | The end date in ISO date format, epoch time or time range(<number&> <time unit>, e.g., 12 hours, 7 days). Only alerts that were created on or before the specified date/time will be retrieved. If no time zone is specified, UTC time zone will be used. |
Optional |
| resolved | If true, retrieves alerts that have been resolved. If false, retrieves alerts that have not been resolved. Possible values are: true, false. | Optional |
| auto_resolved | If true, retrieves alerts that have been resolved, and were auto_resolved. If false, retrieves alerts that have been resolved, and were not auto_resolved. Possible values are: true, false. | Optional |
| acknowledged | If true, retrieves alerts that have been acknowledged. If false, retrieves alerts that have not been acknowledged. Possible values are: true, false. | Optional |
| severity | Comma-separated list of the severity levels of the alerts to retrieve. Possible values are: CRITICAL, WARNING, INFO, AUDIT. | Optional |
| alert_type_ids | Comma-separated list of alert type IDs. Will retrieve alerts whose type ID matches an alert_type_id in the alert_type_ids list. For example, alert ‘Alert E-mail Failure’ has type id of A111066. Given alert_type_ids= ‘A111066’, only alerts of ‘Alert E-mail Failure’ will be retrieved. | Optional |
| impact_types | Comma-separated list of impact types. Possible values: Availability, Capacity, Configuration, Performance, and System Indicator. Will retrieve alerts whose impact type matches an impact types in the impact_types list. For example, alert ‘Incorrect NTP Configuration’ has impact type ‘SystemIndicator’. Given impact_types =’SystemIndicator’,only alerts with impact type ‘SystemIndicator’, such as ‘Incorrect NTP Configuration’ will be retrieved. Possible values are: Availability, Capacity, Configuration, Performance, System Indicator. | Optional |
| entity_types | Comma-separated list of entity types. Will retrieve alerts whose entity_type matches an entity_type in the entity_types list. For details, see the Nutanix README. If the Nutanix service cannot recognize the entity type, it returns a 404 error. | Optional |
| page | Page number in the query response. Default is 1. | Optional |
| limit | Maximum number of physical hosts to retrieve. Possible values are 1-1000. Default is 50. | Optional |
| verbose | Receive extended information from Nutanix about alerts. Possible values are: true, false. Default is false. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| NutanixHypervisor.Alerts.id | String | ID of the alert. |
| NutanixHypervisor.Alerts.alert_type_uuid | String | UUID of the type of the alert. |
| NutanixHypervisor.Alerts.check_id | String | The check ID of the alert. |
| NutanixHypervisor.Alerts.resolved | Boolean | Whether the alert was resolved. |
| NutanixHypervisor.Alerts.auto_resolved | Boolean | Whether the alert was auto resolved. |
| NutanixHypervisor.Alerts.acknowledged | Boolean | Whether the alert was acknowledged. |
| NutanixHypervisor.Alerts.service_vmid | String | Service virtual machine ID of the alert. |
| NutanixHypervisor.Alerts.node_uuid | String | Node UUID. |
| NutanixHypervisor.Alerts.created_time_stamp_in_usecs | Number | The time the alert was created in epoch time. |
| NutanixHypervisor.Alerts.created_time | date | The time alert was created in epoch time. |
| NutanixHypervisor.Alerts.last_occurrence_time_stamp_in_usecs | Number | The time of the last occurrence of the alert in epoch time. |
| NutanixHypervisor.Alerts.last_occurrence | date | The time of the last occurrence of the alert in epoch time. |
| NutanixHypervisor.Alerts.cluster_uuid | String | The cluster UUID of the alert. |
| NutanixHypervisor.Alerts.originating_cluster_uuid | String | The originating cluster UUID of the alert. |
| NutanixHypervisor.Alerts.severity | String | The severity of the alert. |
| NutanixHypervisor.Alerts.impact_types | String | The impact types of the alert. |
| NutanixHypervisor.Alerts.classifications | String | The classifications of the alert. |
| NutanixHypervisor.Alerts.acknowledged_by_username | String | The username of whom acknowledged the alert, if the alert was acknowledged by a user. |
| NutanixHypervisor.Alerts.message | String | Alert message. |
| NutanixHypervisor.Alerts.detailed_message | String | Alert detailed message. |
| NutanixHypervisor.Alerts.alert_title | String | Alert title. |
| NutanixHypervisor.Alerts.operation_type | String | Alert operation type. |
| NutanixHypervisor.Alerts.acknowledged_time_stamp_in_usecs | Number | The time the alert was acknowledged in epoch time. |
| NutanixHypervisor.Alerts.acknowledged_time | date | The time the alert was acknowledged in epoch time. |
| NutanixHypervisor.Alerts.resolved_time_stamp_in_usecs | Number | The time the alert was resolved in epoch time. |
| NutanixHypervisor.Alerts.resolved_time | date | The time alert was resolved in epoch time. |
| NutanixHypervisor.Alerts.resolved_by_username | String | The username whom resolved the alert, if the alert was resolved by a user. |
| NutanixHypervisor.Alerts.user_defined | Boolean | Whether the alert user was defined. |
| NutanixHypervisor.Alerts.affected_entities.entity_type | String | Affected entity type. |
| NutanixHypervisor.Alerts.affected_entities.entity_type_display_name | String | The entity type display name of the affected entities. |
| NutanixHypervisor.Alerts.affected_entities.entity_name | String | The entity display name of the affected entities. |
| NutanixHypervisor.Alerts.affected_entities.uuid | String | The affected entity UUID. |
| NutanixHypervisor.Alerts.affected_entities.id | String | The affected entity ID. |
| NutanixHypervisor.Alerts.context_types | String | Alert context types. |
| NutanixHypervisor.Alerts.context_values | String | Alert context values. |
| NutanixHypervisor.Alerts.alert_details.metric_details.comparison_operator | String | Comparison operator used in the metric. |
| NutanixHypervisor.Alerts.alert_details.metric_details.condition_type | String | Condition type of the alert by metric. Can be: STATIC, THRESHOLD, ANOMALY, SAFETY_ZONE. |
| NutanixHypervisor.Alerts.alert_details.metric_details.data_type | String | Data type used in the metric. Can be: LONG, DOUBLE, BOOLEAN, STRING. |
| NutanixHypervisor.Alerts.alert_details.metric_details.metric_category | String | Metric category. |
| NutanixHypervisor.Alerts.alert_details.metric_details.metric_display_name | String | Metric display name. |
| NutanixHypervisor.Alerts.alert_details.metric_details.metric_name | String | Metric name. |
| NutanixHypervisor.Alerts.alert_details.metric_details.metric_value_details | Unknown | Metric value details. |
Command Example
!nutanix-hypervisor-alerts-list acknowledged=true auto_resolved=true resolved=true start_time=2018-12-31T21:34:54 limit=4
Context Example
{
"NutanixHypervisor": {
"Alerts": [
{
"acknowledged": true,
"acknowledged_by_username": "N/A",
"acknowledged_time": "2020-11-25T15:28:02.804764+00:00",
"acknowledged_time_stamp_in_usecs": 1606318082804764,
"affected_entities": [
{
"entity_type": "host",
"id": "2",
"uuid": "59bc015e-a22d-41ab-9ce2-a96164955e9q"
}
],
"alert_title": "{vm_type} time not synchronized with any external servers.",
"alert_type_uuid": "A3026",
"auto_resolved": true,
"check_id": "asra1631-a234-zxd1-aa23-azxr124z23aq::3026",
"classifications": [
"ControllerVM"
],
"cluster_uuid": "asra1631-a234-zxd1-aa23-azxr124z23aq",
"created_time": "2020-11-22T14:31:14.675609+00:00",
"created_time_stamp_in_usecs": 1606055474675609,
"detailed_message": "",
"id": "4b12dc84-2a77-4b3a-a40a-2dc47c919caa",
"impact_types": [
"Configuration"
],
"last_occurrence": "2020-11-22T14:31:14.675609+00:00",
"last_occurrence_time_stamp_in_usecs": 1606055474675609,
"message": "The {vm_type} is not synchronizing time with any external servers. {alert_msg}",
"node_uuid": "59bc015e-a22d-41ab-9ce2-a96164955e9q",
"operation_type": "kCreate",
"originating_cluster_uuid": "asra1631-a234-zxd1-aa23-azxr124z23aq",
"resolved": true,
"resolved_by_username": "N/A",
"resolved_time": "2020-11-25T15:28:02.804758+00:00",
"resolved_time_stamp_in_usecs": 1606318082804758,
"service_vmid": "asra1631-a234-zxd1-aa23-azxr124z23aq::2",
"severity": "kWarning",
"user_defined": false
},
{
"acknowledged": true,
"acknowledged_by_username": "N/A",
"acknowledged_time": "2020-11-25T15:28:02.851718+00:00",
"acknowledged_time_stamp_in_usecs": 1606318082851718,
"affected_entities": [
{
"entity_type": "host",
"id": "2",
"uuid": "59bc015e-a22d-41ab-9ce2-a96164955e9q"
}
],
"alert_title": "Incorrect NTP Configuration",
"alert_type_uuid": "A103076",
"auto_resolved": true,
"check_id": "asra1631-a234-zxd1-aa23-azxr124z23aq::103076",
"classifications": [
"Cluster"
],
"cluster_uuid": "asra1631-a234-zxd1-aa23-azxr124z23aq",
"created_time": "2020-11-22T14:31:14.619018+00:00",
"created_time_stamp_in_usecs": 1606055474619018,
"detailed_message": "",
"id": "1c63dcd9-3b36-45a6-8991-d28cc661c861",
"impact_types": [
"SystemIndicator"
],
"last_occurrence": "2020-11-22T14:31:14.619018+00:00",
"last_occurrence_time_stamp_in_usecs": 1606055474619018,
"message": "{alert_msg}",
"node_uuid": "59bc015e-a22d-41ab-9ce2-a96164955e9q",
"operation_type": "kCreate",
"originating_cluster_uuid": "asra1631-a234-zxd1-aa23-azxr124z23aq",
"resolved": true,
"resolved_by_username": "N/A",
"resolved_time": "2020-11-25T15:28:02.851706+00:00",
"resolved_time_stamp_in_usecs": 1606318082851706,
"service_vmid": "asra1631-a234-zxd1-aa23-azxr124z23aq::2",
"severity": "kWarning",
"user_defined": false
}
]
}
}
Human Readable Output
Nutanix Alert List
impact_types created_time_stamp_in_usecs created_time severity acknowledged_time_stamp_in_usecs resolved acknowledged_by_username resolved_by_username last_occurrence_time_stamp_in_usecs acknowledged_time check_id alert_title service_vmid id classifications acknowledged resolved_time last_occurrence alert_type_uuid detailed_message operation_type originating_cluster_uuid message node_uuid user_defined cluster_uuid auto_resolved resolved_time_stamp_in_usecs Configuration 1606055474675609 2020-11-22T14:31:14.675609+00:00 kWarning 1606318082804764 true N/A N/A 1606055474675609 2020-11-25T15:28:02.804764+00:00 asra1631-a234-zxd1-aa23-azxr124z23aq::3026 {vm_type} time not synchronized with any external servers. asra1631-a234-zxd1-aa23-azxr124z23aq::2 4b12dc84-2a77-4b3a-a40a-2dc47c919caa ControllerVM true 2020-11-25T15:28:02.804758+00:00 2020-11-22T14:31:14.675609+00:00 A3026 kCreate asra1631-a234-zxd1-aa23-azxr124z23aq The {vm_type} is not synchronizing time with any external servers. {alert_msg} 59bc015e-a22d-41ab-9ce2-a96164955e9q false asra1631-a234-zxd1-aa23-azxr124z23aq true 1606318082804758 SystemIndicator 1606055474619018 2020-11-22T14:31:14.619018+00:00 kWarning 1606318082851718 true N/A N/A 1606055474619018 2020-11-25T15:28:02.851718+00:00 asra1631-a234-zxd1-aa23-azxr124z23aq::103076 Incorrect NTP Configuration asra1631-a234-zxd1-aa23-azxr124z23aq::2 1c63dcd9-3b36-45a6-8991-d28cc661c861 Cluster true 2020-11-25T15:28:02.851706+00:00 2020-11-22T14:31:14.619018+00:00 A103076 kCreate asra1631-a234-zxd1-aa23-azxr124z23aq {alert_msg} 59bc015e-a22d-41ab-9ce2-a96164955e9q false asra1631-a234-zxd1-aa23-azxr124z23aq true 1606318082851706
nutanix-hypervisor-alert-acknowledge
Acknowledges the alert with the specified alert_id.
Base Command
nutanix-hypervisor-alert-acknowledge
Input
| Argument Name | Description | Required |
|---|---|---|
| alert_id | The ID of the alert to acknowledge. Alert ID is the ‘id’ field returned for alerts by command ‘nutanix-hypervisor-alerts-list’. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| NutanixHypervisor.AcknowledgedAlerts.id | String | ID of the alert to be acknowledged. |
| NutanixHypervisor.AcknowledgedAlerts.successful | Boolean | Whether the alert was acknowledged successfully. |
| NutanixHypervisor.AcknowledgedAlerts.message | String | The message returned by the acknowledge task. |
Command Example
!nutanix-hypervisor-alert-acknowledge alert_id=da53aaa3-8c29-4b68-9f27-e0927ca694ce
Context Example
{
"NutanixHypervisor": {
"AcknowledgedAlerts": {
"id": "da53aaa3-8c29-4b68-9f27-e0927ca694ce",
"message": null,
"successful": true
}
}
}
Human Readable Output
Results
id message successful da53aaa3-8c29-4b68-9f27-e0927ca694ce true
nutanix-hypervisor-alert-resolve
Resolves the alert with the specified alert_id. Alert ID is the ‘id’ field returned for alerts by command ‘nutanix-hypervisor-alerts-list’
Base Command
nutanix-hypervisor-alert-resolve
Input
| Argument Name | Description | Required |
|---|---|---|
| alert_id | The ID of the alert to resolve. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| NutanixHypervisor.ResolvedAlerts.id | String | ID of the alert to be resolved. |
| NutanixHypervisor.ResolvedAlerts.successful | Boolean | Whether the alert was resolved successfully. |
| NutanixHypervisor.ResolvedAlerts.message | String | The message returned by the resolve task. |
Command Example
!nutanix-hypervisor-alert-resolve alert_id=da53aaa3-8c29-4b68-9f27-e0927ca694ce
Context Example
{
"NutanixHypervisor": {
"ResolvedAlerts": {
"id": "da53aaa3-8c29-4b68-9f27-e0927ca694ce",
"message": null,
"successful": true
}
}
}
Human Readable Output
Results
id message successful da53aaa3-8c29-4b68-9f27-e0927ca694ce true
nutanix-hypervisor-alerts-acknowledge-by-filter
Acknowledges alerts using a filter.
Base Command
nutanix-hypervisor-alerts-acknowledge-by-filter
Input
| Argument Name | Description | Required |
|---|---|---|
| start_time | The start date in ISO date format, epoch time or time range(<number>; <time unit>, e.g., 12 hours, 7 days). Only alerts that were created on or after the specified date/time will be acknowledged. If no time zone is specified, UTC time zone will be used. |
Optional |
| end_time | The end date in ISO date format, epoch time or time range(<number> <time unit>;’, e.g., 12 hours, 7 days). Only alerts that were created on or before the specified date/time will be acknowledged. If no time zone is specified, UTC time zone will be used. |
Optional |
| severity | Comma-separated list of the severity levels of the alerts to resolve. Possible values are: CRITICAL, WARNING, INFO, AUDIT. | Optional |
| impact_types | Comma-separated list of impact types. Will acknowledge alerts whose impact type matches an impact types in the impact_types list. For example, alert ‘Incorrect NTP Configuration’ has impact type ‘SystemIndicator’. Given impact_types =’SystemIndicator’, only alerts with impact type ‘SystemIndicator’, such as ‘Incorrect NTP Configuration’ will be acknowledged. | Optional |
| entity_types | Comma-separated list of entity types. Will retrieve alerts whose entity_type matches an entity_type in the entity_types list. For more details see Nutanix README. If Nutanix service cannot recognize the entity type, it returns a 404 error. | Optional |
| limit | Maximum number of alerts to acknowledge. Nutanix does not have a maximum for the limit, but a very high limit will cause a read timeout exception. Default is 50. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| NutanixHypervisor.AcknowledgedFilterAlerts.num_successful_updates | Number | The number of the successful alerts acknowledged. |
| NutanixHypervisor.AcknowledgedFilterAlerts.num_failed_updates | Number | The number of the failed alerts to acknowledge. |
| NutanixHypervisor.AcknowledgedFilterAlerts.alert_status_list.id | String | ID of the status of the alert. |
| NutanixHypervisor.AcknowledgedFilterAlerts.alert_status_list.successful | Boolean | Whether acknowledgement for this task was successful. |
| NutanixHypervisor.AcknowledgedFilterAlerts.alert_status_list.message | String | Message returned by the acknowledge operation. |
Command Example
!nutanix-hypervisor-alerts-acknowledge-by-filter end_time=2021-12-22T13:14:15 entity_types=Host severity=WARNING
Context Example
{
"NutanixHypervisor": {
"AcknowledgedFilterAlerts": {
"num_failed_updates": 0,
"num_successful_updates": 0
}
}
}
Human Readable Output
Results
num_failed_updates num_successful_updates 0 0
nutanix-hypervisor-alerts-resolve-by-filter
Resolves alerts using a filter.
Base Command
nutanix-hypervisor-alerts-resolve-by-filter
Input
| Argument Name | Description | Required |
|---|---|---|
| start_time | The start date in ISO date format, epoch time or time range(<number> <time unit>’, e.g., 12 hours, 7 days). Only alerts that were created on or after the specified date/time will be resolved. If no time zone is specified, UTC time zone will be used. | Optional |
| end_time | The end date in ISO date format, epoch time or time range(<number> <time unit>’, e.g., 12 hours, 7 days). Only alerts that were created on or before the specified date/time will be resolved. If no time zone is specified, UTC time zone will be used. | Optional |
| severity | Comma-separated list of the severity levels of the alerts to resolve. Possible values are: CRITICAL, WARNING, INFO, AUDIT. | Optional |
| impact_types | Comma-separated list of impact types. Will resolve alerts whose impact type matches an impact types in the impact_types list. For example, alert ‘Incorrect NTP Configuration’ has impact type ‘SystemIndicator’. Given impact_types = ‘SystemIndicator’, only alerts with impact type ‘SystemIndicator’, such as ‘Incorrect NTP Configuration’ will be resolved. | Optional |
| entity_types | Comma-separated list of entity types. Will resolve alerts whose entity_type matches an entity_type in the entity_types list. For more details see Nutanix README. If Nutanix service cannot recognize the entity type, it returns a 404 error. | Optional |
| limit | Maximum number of alerts to resolve. Nutanix does not have a maximum for the limit, but a very high limit value will cause a read timeout exception. Default is 50. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| NutanixHypervisor.ResolvedFilterAlerts.num_successful_updates | Number | The number of successful alerts resolved. |
| NutanixHypervisor.ResolvedFilterAlerts.num_failed_updates | Number | The number of failed alerts to resolve. |
| NutanixHypervisor.ResolvedFilterAlerts.alert_status_list.id | String | ID of the status of the alert. |
| NutanixHypervisor.ResolvedFilterAlerts.alert_status_list.successful | Boolean | Whether the resolution for this task was successful. |
| NutanixHypervisor.ResolvedFilterAlerts.alert_status_list.message | String | Message returned by the resolve operation. |
Command Example
!nutanix-hypervisor-alerts-resolve-by-filter limit=2 impact_types=SystemIndicator entity_types=VM
Context Example
{
"NutanixHypervisor": {
"ResolvedFilterAlerts": {
"num_failed_updates": 0,
"num_successful_updates": 0
}
}
}
Human Readable Output
Results
num_failed_updates num_successful_updates 0 0
Configuration parameters
base_url— Server URL (required)isFetch— Fetch incidentsincidentType— Incident typecredentials— Username (required)incidentFetchInterval— Incidents Fetch Intervalmax_fetch— Maximum number of incidents per fetchalert_status_filters— Alert Status Filtersalert_type_ids— Alert type IDsimpact_types— Impact Typesfirst_fetch— First fetch timestampinsecure— Trust any certificate (not secure)proxy— Use system proxy settings
Commands (9)
-
nutanix-hypervisor-alert-acknowledgeAcknowledges the alert with the specified alert_id.
-
nutanix-hypervisor-alert-resolveResolves the alert with the specified alert_id. Alert ID is the 'id' field returned for alerts by command 'nutanix-hypervisor-alerts-list'.
-
nutanix-hypervisor-alerts-acknowledge-by-filterAcknowledges alerts using a filter.
-
nutanix-hypervisor-alerts-listGets the list of alerts generated in the cluster that matches the filters. Nutanix fetches the latest alerts created if there are more than the defined maximum number of alerts.
-
nutanix-hypervisor-alerts-resolve-by-filterResolves alerts using a filter.
-
nutanix-hypervisor-hosts-listGets the list of physical hosts configured in the cluster.
-
nutanix-hypervisor-task-results-getReturns the results of given tasks. If a task is not ready, its status will be returned.
-
nutanix-hypervisor-vm-powerstatus-changeSet power state of a virtual machine. If the virtual machine is being powered on and no host is specified, the host with the most available CPU and memory will be chosen. Note that such a host may not be available. If the virtual machine is being power cycled, a different host can be specified to start it on. The command returns a task UUID that can be monitored by the nutanix-hypervisor-task-results-get command.
-
nutanix-hypervisor-vms-listGets a list of virtual machines.
import copy import pytz import urllib3 from CommonServerPython import * # Disable insecure warnings urllib3.disable_warnings() """ CONSTANTS """ USECS_ENTRIES_MAPPING = { "boot_time_in_usecs": "boot_time", "create_time_usecs": "create_time", "start_time_usecs": "start_time", "complete_time_usecs": "complete_time", "last_updated_time_usecs": "last_updated", "created_time_stamp_in_usecs": "created_time", "last_occurrence_time_stamp_in_usecs": "last_occurrence", "acknowledged_time_stamp_in_usecs": "acknowledged_time", "resolved_time_stamp_in_usecs": "resolved_time", } HOST_FIELDS_NOT_VERBOSE = { "service_vmid", "uuid", "name", "service_vmexternal_ip", "hypervisor_key", "hypervisor_address", "hypervisor_username", "controller_vm_backplane_ip", "management_server_name", "monitored", "serial", "state", "vzone_name", "cpu_model", "num_cpu_cores", "num_cpu_threads", "num_cpu_sockets", "hypervisor_full_name", "hypervisor_type", "num_vms", "boot_time_in_usecs", "is_degraded", "is_secure_booted", "is_hardware_virtualized", "reboot_pending", "cluster_uuid", "has_csr", "host_type", "boot_time", } ALERT_FIELDS_NOT_VERBOSE = { "id", "alert_type_uuid", "check_id", "resolved", "auto_resolved", "acknowledged", "service_vmid", "node_uuid", "created_time_stamp_in_usecs", "last_occurrence_time_stamp_in_usecs", "cluster_uuid", "originating_cluster_uuid", "severity", "impact_types", "classifications", "acknowledged_by_username", "message", "detailed_message", "alert_title", "operation_type", "acknowledged_time_stamp_in_usecs", "resolved_time_stamp_in_usecs", "resolved_by_username", "user_defined", "affected_entities", "created_time", "last_occurrence", } TIMEOUT_INTERVAL = 1 UTC_TIMEZONE = pytz.timezone("utc") NUTANIX_HOST_FIELDS_TO_REMOVE = { "disk_hardware_configs", "cpu_frequency_in_hz", "cpu_capacity_in_hz", "memory_capacity_in_bytes", "stats", "usage_stats", } BASE_URL_SUFFIX = "/PrismGateway/services/rest/v2.0" """ CLIENT CLASS """ class Client(BaseClient): CONTENT_JSON = {"content-type": "application/json"} def __init__(self, base_url, verify, proxy, auth): super().__init__(base_url=base_url, verify=verify, proxy=proxy, auth=auth, headers=self.CONTENT_JSON) def http_request(self, method: str, url_suffix: str, params: dict = None, json_data: dict = None): """ Wrapper function for BaseClient http request function to catch errors from http requests, and send a human readable exception. That is because those exceptions are not human readable and need better description of the exception to explain the customer why the http request failed on those requests. Args: method (str): The http method. url_suffix (str): The suffix to be added to base url. params (Dict): The params to be sent in the. json_data (Dict): The data to be sent Returns: """ try: return self._http_request(method=method, url_suffix=url_suffix, params=params, json_data=json_data) except DemistoException as e: if "Invalid filter criteria specified." in str(e): raise DemistoException("""Filter criteria given is invalid or is not written in the correct format. Use the 'filter' argument description 'to build your filter correctly.""") if "Unrecognized field" in str(e): raise DemistoException("Filter criteria given is invalid.") if "General error parsing FIQL expression" in str(e): raise DemistoException( "Filter criteria given is not written in a valid format. The correct format can be found in the " "argument description." ) raise e def fetch_incidents(self, params: dict, last_run: dict): alert_status_filters = params.get("alert_status_filters") auto_resolved = get_alert_status_filter("Auto Resolved", "Not Auto Resolved", alert_status_filters) resolved = get_alert_status_filter("Resolved", "Unresolved", alert_status_filters) acknowledged = get_alert_status_filter("Acknowledged", "Unacknowledged", alert_status_filters) if auto_resolved is not None and resolved is False: raise DemistoException(f"""The combination of 'resolved=false' and 'auto_resolved={auto_resolved}' is not allowed.""") resolved = True if auto_resolved else resolved severity = params.get("severity") alert_type_ids = params.get("alert_type_ids") impact_types = params.get("impact_types") fetch_time = params.get("first_fetch", "5 days").strip() # to match the shape of the time returned by Nutanix service. first_fetch_time = get_optional_time_parameter_as_epoch(fetch_time) last_fetch_epoch_time = last_run.get("last_fetch_epoch_time", first_fetch_time) response = self.get_nutanix_hypervisor_alerts_list( start_time=last_fetch_epoch_time, end_time=None, resolved=resolved, auto_resolved=auto_resolved, acknowledged=acknowledged, severity=severity, alert_type_ids=alert_type_ids, impact_types=impact_types, entity_types=None, page=None, limit=None, ) alerts = sanitize_outputs(response.get("entities")) incidents: List[dict[str, Any]] = [] for alert in alerts: alert_created_time = alert.get("created_time_stamp_in_usecs") try: occurred = convert_epoch_time_to_datetime(alert_created_time) except TypeError: demisto.debug(f"The following incident was found invalid and was skipped: {alert}") continue incident = { "name": alert.get("alert_title"), "type": "Nutanix Hypervisor Alert", "occurred": occurred, "rawJSON": json.dumps(remove_empty_elements(alert)), } incidents.append(incident) return incidents, {"last_fetch_epoch_time": int(datetime.utcnow().timestamp() * 1000000)} def get_nutanix_hypervisor_hosts_list(self, filter_: Optional[str], limit: Optional[int], page: Optional[int]): return self.http_request( method="GET", url_suffix="hosts", params=assign_params(filter_criteria=filter_, count=limit, page=page) ) def get_nutanix_hypervisor_vms_list(self, filter_: Optional[str], offset: Optional[int], limit: Optional[int]): return self.http_request( method="GET", url_suffix="vms", params=assign_params(filter=filter_, offset=offset, length=limit) ) def nutanix_hypervisor_vm_power_status_change(self, uuid: Optional[str], host_uuid: Optional[str], transition: Optional[str]): return self.http_request( method="POST", url_suffix=f"vms/{uuid}/set_power_state", json_data=assign_params(uuid=uuid, host_uuid=host_uuid, transition=transition), ) def nutanix_hypervisor_task_results(self, completed_tasks: List[str]): return self.http_request( method="POST", url_suffix="tasks/poll", json_data=assign_params(completed_tasks=completed_tasks, timeout_interval=TIMEOUT_INTERVAL), ) def nutanix_hypervisor_task_details(self, task_id: str): return self.http_request(method="GET", url_suffix=f"tasks/{task_id}") def get_nutanix_hypervisor_alerts_list( self, start_time: Optional[int], end_time: Optional[int], resolved: Optional[bool], auto_resolved: Optional[bool], acknowledged: Optional[bool], severity: Optional[str], alert_type_ids: Optional[str], impact_types: Optional[str], entity_types: Optional[str], page: Optional[int], limit: Optional[int], ): return self.http_request( method="GET", url_suffix="alerts", params=assign_params( start_time_in_usecs=start_time, end_time_in_usecs=end_time, resolved=resolved, auto_resolved=auto_resolved, acknowledged=acknowledged, severity=severity, alert_type_uuid=alert_type_ids, impact_types=impact_types, entity_type=entity_types, page=page, count=limit, ), ) def post_nutanix_hypervisor_alert_acknowledge(self, alert_id: Optional[str]): return self.http_request( method="POST", url_suffix=f"alerts/{alert_id}/acknowledge", ) def post_nutanix_hypervisor_alert_resolve(self, alert_id: Optional[str]): return self.http_request( method="POST", url_suffix=f"alerts/{alert_id}/resolve", ) def post_nutanix_hypervisor_alerts_acknowledge_by_filter( self, start_time: Optional[int], end_time: Optional[int], severity: Optional[str], impact_types: Optional[str], entity_types: Optional[str], limit: Optional[int], ): return self.http_request( method="POST", url_suffix="alerts/acknowledge", params=assign_params( start_time_in_usecs=start_time, end_time_in_usecs=end_time, severity=severity, impact_types=impact_types, entity_type=entity_types, count=limit, ), ) def post_nutanix_hypervisor_alerts_resolve_by_filter( self, start_time: Optional[int], end_time: Optional[int], severity: Optional[str], impact_types: Optional[str], entity_types: Optional[str], limit: Optional[int], ): return self.http_request( method="POST", url_suffix="alerts/resolve", params=assign_params( start_time_in_usecs=start_time, end_time_in_usecs=end_time, severity=severity, impact_types=impact_types, entity_type=entity_types, count=limit, ), ) """ HELPER FUNCTIONS """ def get_optional_time_parameter_as_epoch(arg: Optional[str]) -> Optional[int]: """ Receives arg, expects that the time argument will be either: - Epoch time. - Iso time. Args: arg (str): The argument to turn into epoch time. Returns: - If 'arg' is None, returns None. - If 'arg' is exists and is epoch time or iso time, returns the epoch time of the argument. - If 'arg' exists and is not epoch or iso, throws DemistoException exception. """ maybe_unaware_date = arg_to_datetime(arg, is_utc=True) if not maybe_unaware_date: return None aware_time_date = maybe_unaware_date if maybe_unaware_date.tzinfo else UTC_TIMEZONE.localize(maybe_unaware_date) return int(aware_time_date.timestamp() * 1000000) def get_optional_boolean_arg(args: dict, argument_name: str) -> Optional[bool]: """ Extracts the argument from Demisto arguments, and in case argument exists, returns the boolean value of the argument. Args: args (Dict): Demisto arguments. argument_name (str): Name of the argument. Returns: - If argument exists and is boolean, returns its boolean value. - If argument exists and is not boolean, raises DemistoException. - If argument does not exist, returns None. """ argument = args.get(argument_name) argument = argToBoolean(argument) if argument else None return argument def convert_epoch_time_to_datetime(epoch_time: Optional[int]) -> Optional[str]: """ Receives epoch time, and returns epoch_time representation as date with UTC timezone. If received epoch time is 0, or epoch_time does not exist, returns None. Args: epoch_time (int): The epoch_time to convert. Returns: - The date time with UTC timezone that matches the epoch time if 'epoch_time' is not 0. - None if 'epoch_time' is 0. - None if epoch_time is None. """ if not epoch_time or epoch_time == 0: return None maybe_date_time = arg_to_datetime(epoch_time / 1000.0) if not maybe_date_time: return None return maybe_date_time.isoformat() def get_alert_status_filter(true_value: str, false_value: str, alert_status_filters: Optional[List[str]]) -> Optional[bool]: """ Receives alert_status filters, which contains all the alert status filters chosen by the user. checks if the argument name which corresponds to true value ('true_value') is found, or if the argument name which corresponds to false value ('false_value') is found, and returns the corresponding value. In case user selected both 'true_value' and 'false_value', will raise a DemistoException to indicate the user such case is not possible. Args: true_value (str): The name of the argument that expresses true value. false_value (str): The name of the argument that expresses false value. alert_status_filters (List[str]): All the alert status filters chosen by the user. Returns: - Throws DemistoException if 'false_value' and 'true_value' are found in 'alert_status_filters' list. - False if 'false_value' was found in 'alert_status_filters' list. - True if 'true_value' was found in 'alert_status_filters' list. - None if both 'true_value' and 'false_value' were not found in 'alert_status_filters' list. - None if alert_status_filters is None. """ if not alert_status_filters: return None if true_value in alert_status_filters and false_value in alert_status_filters: raise DemistoException( f"Invalid alert status filters configurations, only one of {true_value},{false_value} can be chosen." ) result_value = None if true_value in alert_status_filters: result_value = True elif false_value in alert_status_filters: result_value = False return result_value def add_iso_entries_to_dict(outputs: List[dict]) -> None: """ Takes list of outputs, for each output: For each field in the output that is contained in 'USECS_ENTRIES_MAPPING' keys, adds a new entry of the corresponding value to the key in 'USECS_ENTRIES_MAPPING', Value of the new entry will be the iso format corresponding to the timestamp from the 'USECS_ENTRIES_MAPPING' key. Args: outputs (List[Dict]): List of the outputs to be transformed. Returns: Modifies the outputs. """ for output in outputs: for old_entry_name, new_entry_name in USECS_ENTRIES_MAPPING.items(): if old_entry_name in output: output[new_entry_name] = convert_epoch_time_to_datetime(output.get(old_entry_name)) def get_human_readable_headers(outputs: List[dict]) -> List[Any]: """ Retrieves all of the keys that their value is not dict recursively Args: outputs (List[Dict]): Input list of dictionaries. Returns: List with all of the keys that don't have inner dictionaries. """ def contains_dict(entry: Any) -> bool: if isinstance(entry, dict): return True elif isinstance(entry, list): return any(contains_dict(item) for item in entry) return False human_readable_keys: List[Set] = [{k for k, v in output.items() if not contains_dict(v)} for output in outputs] if not human_readable_keys: return [] return list(set.intersection(*human_readable_keys)) def task_exists(client: Client, task_id: str) -> bool: """ Receives task_id, and checks if task exists. Check is done by performing an API call to Nutanix service to receive task details. If the task is not found by Nutanix, it will return an error indicating the task with the ID of 'task_id' is not found. Args: client (Client): The client to perform the API request to Nutanix service. task_id (str): The ID of the task to check if exists. Returns: - True if task exists. - False if task does not exist. """ try: client.nutanix_hypervisor_task_details(task_id) return True except DemistoException as e: if e.message and f"{task_id} is not found" in e.message: return False raise e def sanitize_outputs(outputs: List[dict]) -> List[dict]: """ Sanitizes outputs, adds ISO entries to outputs if needed, and removes empty elements. Args: outputs (List[Dict]): The outputs to sanitize. Returns: Outputs with additional ISO entries if needed, and all empty elements removed. """ outputs_without_empty_elements = [remove_empty_elements(output) for output in outputs] add_iso_entries_to_dict(outputs_without_empty_elements) return outputs_without_empty_elements """ COMMAND FUNCTIONS """ def test_module_command(client: Client, params: dict) -> str: """ Tests API connectivity, authentication, and ability to fetch incidents. Returning 'ok' indicates that the integration works like it is supposed to. Connection to the service is successful. Raises exceptions if something goes wrong. Args: client (Client): Nutanix client to perform the API calls. params (Dict): Demisto params. Returns: 'ok' if test passed, anything else will fail the test. """ try: client.fetch_incidents(params, {}) return "ok" except DemistoException as e: if e.message and "Error in API call [401] - UNAUTHORIZED" in e.message: raise DemistoException("Unauthorized - make sure you have the right credentials") if e.message and "Error in API call [404] - NOT FOUND" in e.message: raise DemistoException("""Page not found - make sure 'Server URL' parameter is correct""") raise e def fetch_incidents_command(client: Client, params: dict): """ Wrapper function that calls client fetch_incidents function with last run and demisto params. Updates the new run, and uploads incidents to Demisto. Args: client (Client): The client to perform Nutanix API request and fetch incidents. params (Dict): Demisto params. Returns: Fetches incidents to Demisto. """ last_run = demisto.getLastRun() incidents, next_run = client.fetch_incidents(params, last_run) demisto.setLastRun(next_run) demisto.incidents(incidents) def nutanix_hypervisor_hosts_list_command(client: Client, args: dict): """ Gets a list all physical hosts configured in the cluster by Nutanix service. Possible filters: - page: The offset page to start retrieving hosts. When page is specified, limit argument is required, else Nutanix service returns an error "Page number cannot be specified without count". - limit: The number of hosts to retrieve, has to be positive. - filter: Retrieve hosts that matches the filters given. - Each filter is written in the following way: filter_name==filter_value or filter_name!=filter_value. - Possible combinations of OR (using comma ',') and AND (using semicolon ';'), for Example: storage.capacity_bytes==2;host_nic_ids!=35,host_gpus==x is parsed by Nutanix the following way: Return all hosts s.t (storage.capacity_bytes == 2 AND host_nic_ids != 35) OR host_gpus == x. In case response was successful, response will be a of list of hosts details. Args: client (Client): Client object to perform request. args (Dict): Demisto arguments. Returns: CommandResults. """ filter_ = args.get("filter") limit = arg_to_number(args.get("limit", 50)) page = arg_to_number(args.get("page")) verbose = get_optional_boolean_arg(args, "verbose") raw_response = client.get_nutanix_hypervisor_hosts_list(filter_, limit, page) raw_outputs = raw_response.get("entities") # if verbose - remove fields that should be removed always if verbose: outputs = [{k: v for k, v in raw_output.items() if k not in NUTANIX_HOST_FIELDS_TO_REMOVE} for raw_output in raw_outputs] # if not verbose - output only fields that should be outputted. else: outputs = [{k: v for k, v in raw_output.items() if k in HOST_FIELDS_NOT_VERBOSE} for raw_output in raw_outputs] final_outputs = sanitize_outputs(outputs) return CommandResults( outputs_prefix="NutanixHypervisor.Host", outputs_key_field="uuid", outputs=final_outputs, readable_output=tableToMarkdown("Nutanix Hosts List", final_outputs, get_human_readable_headers(final_outputs)), raw_response=raw_response, ) def nutanix_hypervisor_vms_list_command(client: Client, args: dict): """ Gets a list all virtual machines by Nutanix service. Possible filters: - offset: The offset to start retrieving virtual machines. - limit: Maximum number of virtual machines to retrieve. - filter: Retrieve virtual machines that matches the filters given. - Each filter is written in the following way: filter_name==filter_value or filter_name!=filter_value. - Possible combinations of OR (using comma ',') and AND (using semicolon ';'), for Example: machine_type==pc;power_state!=off,ha_priority==0 is parsed by Nutanix the following way: Return all virtual machines s.t (machine type == pc AND power_state != off) OR ha_priority == 0. In case response was successful, response will be a list of virtual machines details. Args: client (Client): Client object to perform request. args (Dict): Demisto arguments. Returns: CommandResults. """ filter_ = args.get("filter") offset = arg_to_number(args.get("offset")) limit = arg_to_number(args.get("limit", 50)) raw_response = client.get_nutanix_hypervisor_vms_list(filter_, offset, limit) outputs = sanitize_outputs(raw_response.get("entities")) return CommandResults( outputs_prefix="NutanixHypervisor.VM", outputs_key_field="uuid", outputs=outputs, readable_output=tableToMarkdown("Nutanix Virtual Machines List", outputs, get_human_readable_headers(outputs)), raw_response=raw_response, ) def nutanix_hypervisor_vm_power_status_change_command(client: Client, args: dict): """ Set power state of the virtual machine matching vm_uuid argument to power state given in transition argument. If the virtual machine is being powered on and no host is specified, the scheduler will pick the one with the most available CPU and memory that can support the Virtual Machine. If the virtual machine is being power cycled, a different host can be specified to start it on. This is also an asynchronous operation that results in the creation of a task object. The UUID of this task object is returned as the response of this operation. This task can be monitored by using the nutanix-hypervisor-task-results-get command In case response was successful, response will be a dict {'task_uuid': int}. Args: client (Client): Client object to perform request. args (Dict): Demisto arguments. Returns: CommandResults. """ vm_uuid = args.get("vm_uuid") host_uuid = args.get("host_uuid") transition = args.get("transition") raw_response = client.nutanix_hypervisor_vm_power_status_change(vm_uuid, host_uuid, transition) return CommandResults( outputs_prefix="NutanixHypervisor.VMPowerStatus", outputs_key_field="task_uuid", outputs=raw_response, raw_response=raw_response, ) def nutanix_hypervisor_task_results_get_command(client: Client, args: dict): """ Poll tasks given by task_ids to check if they are ready. Returns all the tasks from 'task_ids' list that are ready at the moment Nutanix service was polled. In case no task is ready, waits 'TIMEOUT_INTERVAL' (1 second) seconds and in case no task had finished, returns a time out response. In case response was successful, response will be a dict containing key 'completed_tasks_info' which holds details about every completed task returned by Nutanix service. In case response timed out, response will be a dict {'timed_out': True}. Args: client (Client): Client object to perform request. args (Dict): Demisto arguments. Returns: CommandResults. """ task_ids_list: List[str] = argToList(args.get("task_ids")) raw_response = client.nutanix_hypervisor_task_results(task_ids_list) outputs = copy.deepcopy(raw_response.get("completed_tasks_info", [])) for output in outputs: task_id = output.get("uuid") task_ids_list.remove(task_id) for uncompleted_task_id in task_ids_list: progress_status = "In Progress" if task_exists(client, uncompleted_task_id) else "Task Was Not Found" outputs.append({"uuid": uncompleted_task_id, "progress_status": progress_status}) final_outputs = sanitize_outputs(outputs) return CommandResults( outputs_prefix="NutanixHypervisor.Task", outputs_key_field="uuid", readable_output=tableToMarkdown("Nutanix Hypervisor Tasks Status", final_outputs), outputs=final_outputs, raw_response=raw_response, ) def nutanix_hpyervisor_alerts_list_command(client: Client, args: dict): """ Get the list of Alerts generated in the cluster which matches the filters if given. Possible filters: - start_time: Retrieve alerts that their creation time have been after 'start_time'. - end_time: Retrieve alerts that their creation time have been before 'end_time'. - auto_resolved: If auto_resolved is True, retrieves alerts that have been resolved, and were auto_resolved. If auto_resolved is False, retrieves alerts that have been resolved, and were not auto_resolved. - resolved: If resolved is True, retrieves alerts that have been resolved. If resolved is False, retrieves alerts that have not been resolved. - acknowledged: If acknowledged is True, retrieves alerts that have been acknowledged. If acknowledged is False, retrieves alerts that have been acknowledged. - severity: Retrieve any alerts that their severity level matches one of the severities in severity list. Possible severities: [CRITICAL, WARNING, INFO, AUDIT]. - alert_type_ids: Retrieve alerts that id of their type matches one alert_type_id in alert_type_id list. For example, alert 'Alert E-mail Failure' has type id of A111066. Given alert_type_ids = 'A111066', only alerts of 'Alert E-mail Failure' will be retrieved. - impact_types: Retrieve alerts that their impact type matches one of the impact_type in impact_types list. Possible impact types: [Availability, Capacity, Configuration, Performance, SystemIndicator] For example, alert 'Incorrect NTP Configuration' has impact type 'SystemIndicator'. Given Impact Types = 'SystemIndicator',only alerts with impact type 'SystemIndicator', such as 'Incorrect NTP Configuration' will be retrieved. - entity_types: Retrieve alerts that their entity_type matches one of the entity_type in entity_types list. Examples for entity types: [VM, Host, Disk, Storage Container, Cluster]. If Nutanix service can't recognize the entity type, it returns 404 response. - page: The offset of page number in the query response to start retrieving alerts. When page is specified, 'limit' argument is required, else Nutanix service returns an error "Page number cannot be specified without count". - limit: Maximum number of alerts to retrieve. Must be between 1-1000 else Nutanix service returns an error "Number of alerts/events to retrieve cannot be greater than 1,000". In case response was successful, response will be a dict containing key 'entities' with value of list of alerts. Each element in the list contains data about the alert. Args: client (Client): Client object to perform request. args (Dict): Demisto arguments. Returns: CommandResults. """ start_time = get_optional_time_parameter_as_epoch(args.get("start_time")) end_time = get_optional_time_parameter_as_epoch(args.get("end_time")) auto_resolved = get_optional_boolean_arg(args, "auto_resolved") resolved = get_optional_boolean_arg(args, "resolved") if auto_resolved is not None and resolved is False: raise DemistoException(f"""The combination of 'resolved=false' and 'auto_resolved={auto_resolved}' is not allowed.""") resolved = True if auto_resolved else resolved acknowledged = get_optional_boolean_arg(args, "acknowledged") severity = args.get("severity") alert_type_ids = args.get("alert_type_ids") impact_types = args.get("impact_types") entity_types = args.get("entity_types") page = arg_to_number(args.get("page")) limit = arg_to_number(args.get("limit", 50)) verbose = get_optional_boolean_arg(args, "verbose") raw_response = client.get_nutanix_hypervisor_alerts_list( start_time, end_time, resolved, auto_resolved, acknowledged, severity, alert_type_ids, impact_types, entity_types, page, limit, ) outputs = sanitize_outputs(raw_response.get("entities")) # if not verbose - output only fields that should be outputted. if not verbose: outputs = [{k: v for k, v in raw_output.items() if k in ALERT_FIELDS_NOT_VERBOSE} for raw_output in outputs] return CommandResults( outputs_prefix="NutanixHypervisor.Alerts", outputs_key_field="id", outputs=outputs, readable_output=tableToMarkdown("Nutanix Alert List", outputs, get_human_readable_headers(outputs)), raw_response=raw_response, ) def nutanix_hypervisor_alert_acknowledge_command(client: Client, args: dict): """ Acknowledge alert with the specified alert_id. In case response was successful, response will be a dict {'id': str, 'successful': bool, 'message': Optional[str]} In case of an invalid alert id, status code 422 - UNPROCESSED ENTITY will be returned by Nutanix service. Args: client (Client): Client object to perform request. args (Dict): Demisto arguments. Returns: CommandResults. """ alert_id = args.get("alert_id") raw_response = client.post_nutanix_hypervisor_alert_acknowledge(alert_id) return CommandResults( outputs_prefix="NutanixHypervisor.AcknowledgedAlerts", outputs_key_field="id", outputs=remove_empty_elements(raw_response), raw_response=raw_response, ) def nutanix_hypervisor_alert_resolve_command(client: Client, args: dict): """ Resolve alert with the specified alert_id. In case response was successful, response will be a dict {'id': str, 'successful': bool, 'message': Optional[str]}. In case of an invalid alert id, status code 422 - UNPROCESSED ENTITY will be returned by Nutanix service. Args: client (Client): Client object to perform request. args (Dict): Demisto arguments. Returns: CommandResults. """ alert_id = args.get("alert_id") raw_response = client.post_nutanix_hypervisor_alert_resolve(alert_id) return CommandResults( outputs_prefix="NutanixHypervisor.ResolvedAlerts", outputs_key_field="id", outputs=remove_empty_elements(raw_response), raw_response=raw_response, ) def nutanix_hypervisor_alerts_acknowledge_by_filter_command(client: Client, args: dict): """ Acknowledges all of the Alerts which matches the filters if given. - start_time: Acknowledge alerts that their creation time have been after 'start_time'. - end_time: Acknowledge alerts that their creation time have been before 'end_time'. - severity: Acknowledge any alerts that their severity level matches one of the severities in severity list. Possible severities: [CRITICAL, WARNING, INFO, AUDIT]. - impact_types: Acknowledge alerts that their impact type matches one of the impact_type in impact_types list. Possible impact types: [Availability, Capacity, Configuration, Performance, SystemIndicator] For example, alert 'Incorrect NTP Configuration' has impact type 'SystemIndicator'. Given Impact Types = 'SystemIndicator',only alerts with impact type 'SystemIndicator', such as 'Incorrect NTP Configuration' will be acknowledged. - entity_types: Acknowledge alerts that their entity_type matches one of the entity_type in entity_types list. Example for entity types: [VM, Host, Disk, Storage Container, Cluster]. If Nutanix service can't recognize the entity type, it returns 404 response. - limit: Maximum number of alerts to acknowledge. Nutanix does not have max for limit, but a very high limit value will cause read timeout exception. In case response was successful, outputs will be a dict of {'num_successful_updates': int, 'num_failed_updates': int, 'alert_status_list' : List[Dict]}. where every element in 'alert_status_list' is {id: str, message: str, successful: bool} Args: client (Client): Client object to perform request. args (Dict): Demisto arguments. Returns: CommandResults. """ start_time = get_optional_time_parameter_as_epoch(args.get("start_time")) end_time = get_optional_time_parameter_as_epoch(args.get("end_time")) severity = args.get("severity") impact_types = args.get("impact_types") entity_types = args.get("entity_types") limit = arg_to_number(args.get("limit", 50)) raw_response = client.post_nutanix_hypervisor_alerts_acknowledge_by_filter( start_time, end_time, severity, impact_types, entity_types, limit ) outputs = { "num_successful_updates": raw_response.get("num_successful_updates", 0), "num_failed_updates": raw_response.get("num_failed_updates", 0), } return CommandResults(outputs_prefix="NutanixHypervisor.AcknowledgedFilterAlerts", outputs=outputs, raw_response=raw_response) def nutanix_hypervisor_alerts_resolve_by_filter_command(client: Client, args: dict): """ Resolves all of the Alerts which matches the filters if given. Possible filters: - start_time: Resolve alerts that their creation time have been after 'start_time'. - end_time: Resolve alerts that their creation time have been before 'end_time'. - severity: Resolve any alerts that their severity level matches one of the severities in severity list. - impact_types: Resolve alerts that their impact type matches one of the impact_type in impact_types list. Possible impact types: [Availability, Capacity, Configuration, Performance, SystemIndicator] For example, alert 'Incorrect NTP Configuration' has impact type 'SystemIndicator'. Given Impact Types = 'SystemIndicator',only alerts with impact type 'SystemIndicator', such as 'Incorrect NTP Configuration' will be resolved. - entity_types: Resolve alerts that their entity_type matches one of the entity_type in entity_types list. Example for entity types: [VM, Host, Disk, Storage Container, Cluster]. If Nutanix service can't recognize the entity type, it returns 404 response. - page: The offset of page number in the query response to start resolving alerts. - limit: Maximum number of alerts to resolve. Nutanix does not have max for limit, but a very high limit value will cause read timeout exception. In case response was successful, outputs will be a dict of {'num_successful_updates': int, 'num_failed_updates': int, 'alert_status_list' : List[Dict]}. where every element in 'alert_status_list' is {id: str, message: str, successful: bool} Args: client (Client): Client object to perform request. args (Dict): Demisto arguments. Returns: CommandResults. """ start_time = get_optional_time_parameter_as_epoch(args.get("start_time")) end_time = get_optional_time_parameter_as_epoch(args.get("end_time")) severity = args.get("severity") impact_types = args.get("impact_types") entity_types = args.get("entity_types") limit = arg_to_number(args.get("limit", 50)) raw_response = client.post_nutanix_hypervisor_alerts_resolve_by_filter( start_time, end_time, severity, impact_types, entity_types, limit ) outputs = { "num_successful_updates": raw_response.get("num_successful_updates", 0), "num_failed_updates": raw_response.get("num_failed_updates", 0), } return CommandResults(outputs_prefix="NutanixHypervisor.ResolvedFilterAlerts", outputs=outputs, raw_response=raw_response) """ MAIN FUNCTION """ def main() -> None: command = demisto.command() params = demisto.params() args = demisto.args() credentials = params.get("credentials") username = credentials.get("identifier") password = credentials.get("password") base_url = params.get("base_url") + BASE_URL_SUFFIX verify_certificate = not params.get("insecure", False) proxy = params.get("proxy", False) demisto.debug(f"Command being called is {demisto.command()}") try: client = Client(base_url=base_url, verify=verify_certificate, proxy=proxy, auth=(username, password)) if command == "test-module": return_results(test_module_command(client, params)) elif command == "fetch-incidents": fetch_incidents_command(client, params) elif command == "nutanix-hypervisor-hosts-list": return_results(nutanix_hypervisor_hosts_list_command(client, args)) elif command == "nutanix-hypervisor-vms-list": return_results(nutanix_hypervisor_vms_list_command(client, args)) elif command == "nutanix-hypervisor-vm-powerstatus-change": return_results(nutanix_hypervisor_vm_power_status_change_command(client, args)) elif command == "nutanix-hypervisor-task-results-get": return_results(nutanix_hypervisor_task_results_get_command(client, args)) elif command == "nutanix-hypervisor-alerts-list": return_results(nutanix_hpyervisor_alerts_list_command(client, args)) elif command == "nutanix-hypervisor-alert-acknowledge": return_results(nutanix_hypervisor_alert_acknowledge_command(client, args)) elif command == "nutanix-hypervisor-alert-resolve": return_results(nutanix_hypervisor_alert_resolve_command(client, args)) elif command == "nutanix-hypervisor-alerts-acknowledge-by-filter": return_results(nutanix_hypervisor_alerts_acknowledge_by_filter_command(client, args)) elif command == "nutanix-hypervisor-alerts-resolve-by-filter": return_results(nutanix_hypervisor_alerts_resolve_by_filter_command(client, args)) else: raise NotImplementedError(f'Command "{command}" is not implemented.') # Log exceptions and return errors except Exception as e: return_error(f"Failed to execute {demisto.command()} command.\nError:\n{str(e)}") """ ENTRY POINT """ if __name__ in ("__main__", "__builtin__", "builtins"): main()