manageiq-api
manageiq-api copied to clipboard
Include condition expression with compliance details response
A request that includes the compliance_details
of a VM returns the description of the condition contained within the compliance policy but does not include the expression, itself.
It would be good if the expression contents could also be included in the response to avoid additional API requests to get it.
api/vms/60?attributes=id,last_compliance,last_compliance.compliance_details
{
"href": "http://localhost:3000/api/vms/10000000000775",
"id": "10000000000775",
"vendor": "openstack",
"format": null,
"version": null,
"name": "te-2wqc-tnefkpuld6b5-o7cx47e2jeuo-server-qpad26atkfb4",
"description": null,
"location": "unknown",
"config_xml": null,
"autostart": null,
"host_id": null,
"last_sync_on": "2019-06-13T12:27:32Z",
"created_on": "2019-06-13T12:25:52Z",
"updated_on": "2019-11-13T09:38:43Z",
"storage_id": null,
"guid": "6ac2b8fa-3d98-46c6-ad5a-ddafbf4323ae",
"ems_id": "10000000000012",
"last_scan_on": "2019-06-13T12:27:32Z",
"last_scan_attempt_on": "2019-06-13T12:26:06Z",
"uid_ems": "ae9e8160-7cad-4908-884d-314ea53689db",
"retires_on": null,
"retired": null,
"boot_time": null,
"tools_status": null,
"standby_action": null,
"power_state": "off",
"state_changed_on": "2019-11-13T09:38:43Z",
"previous_state": "ACTIVE",
"connection_state": "connected",
"last_perf_capture_on": null,
"registered": null,
"busy": null,
"smart": null,
"memory_reserve": null,
"memory_reserve_expand": null,
"memory_limit": null,
"memory_shares": null,
"memory_shares_level": null,
"cpu_reserve": null,
"cpu_reserve_expand": null,
"cpu_limit": null,
"cpu_shares": null,
"cpu_shares_level": null,
"cpu_affinity": null,
"ems_created_on": null,
"template": false,
"evm_owner_id": null,
"miq_group_id": "10000000000034",
"linked_clone": null,
"fault_tolerance": null,
"type": "ManageIQ::Providers::Openstack::CloudManager::Vm",
"ems_ref": "ae9e8160-7cad-4908-884d-314ea53689db",
"ems_cluster_id": null,
"retirement_warn": null,
"retirement_last_warn": null,
"vnc_port": null,
"flavor_id": "10000000000651",
"availability_zone_id": "10000000000007",
"cloud": true,
"retirement_state": null,
"cloud_network_id": null,
"cloud_subnet_id": null,
"cloud_tenant_id": "10000000000004",
"raw_power_state": "SHUTOFF",
"publicly_available": null,
"orchestration_stack_id": "10000000000052",
"retirement_requester": null,
"tenant_id": "10000000000009",
"resource_group_id": null,
"deprecated": null,
"storage_profile_id": null,
"cpu_hot_add_enabled": null,
"cpu_hot_remove_enabled": null,
"memory_hot_add_enabled": null,
"memory_hot_add_limit": null,
"memory_hot_add_increment": null,
"hostname": null,
"ems_ref_type": null,
"restart_needed": null,
"last_compliance": {
"id": "10000000042212",
"resource_id": "10000000000775",
"resource_type": "VmOrTemplate",
"compliant": true,
"timestamp": "2020-03-25T20:28:00Z",
"updated_on": "2020-03-25T20:28:00Z",
"event_type": "vm_compliance_check",
"compliance_details": [
{
"id": "10000000042212",
"compliance_id": "10000000042212",
"created_on": "2020-03-25T20:28:00Z",
"updated_on": "2020-03-25T20:28:00Z",
"miq_policy_id": "10000000000017",
"miq_policy_desc": "GT's Compliance policy",
"miq_policy_result": true,
"condition_id": "10000000000006",
"condition_desc": "Memory over 4GB",
"condition_result": true
}
]
},...
A second request is necessary to get the expression included on condition 10000000000006
http://localhost:3000//api/conditions/10000000000006
{
"href": "http://localhost:3000/api/conditions/10000000000006",
"id": "10000000000006",
"name": "d5407028-7ffe-44ef-9edc-20fe675e24a9",
"description": "Memory over 4GB",
"expression": {
"exp": {
"<=": {
"field": "Vm-mem_cpu",
"value": "4096"
}
},
"context_type": null
},
"towhat": "Vm",
"file_mtime": null,
"created_on": "2020-03-24T14:41:35Z",
"updated_on": "2020-03-24T14:43:46Z",
"guid": "d5407028-7ffe-44ef-9edc-20fe675e24a9",
"filename": null,
"applies_to_exp": null,
"miq_policy_id": null,
"notes": null,
"read_only": null,...
API usage:
http://localhost:3000/api/vms/10000000000775?attributes=last_compliance_conditions,last_compliance_condition_expressions
Response:
{
"href": "http://localhost:3000/api/vms/10000000000775",
"id": "10000000000775",
"vendor": "openstack",
"format": null,
"version": null,
"name": "te-2wqc-tnefkpuld6b5-o7cx47e2jeuo-server-qpad26atkfb4",
"description": null,
"location": "unknown",
"config_xml": null,
"autostart": null,
"host_id": null,
"last_sync_on": "2019-06-13T12:27:32Z",
"created_on": "2019-06-13T12:25:52Z",
"updated_on": "2019-11-13T09:38:43Z",
"storage_id": null,
"guid": "6ac2b8fa-3d98-46c6-ad5a-ddafbf4323ae",
"ems_id": "10000000000012",
"last_scan_on": "2019-06-13T12:27:32Z",
"last_scan_attempt_on": "2019-06-13T12:26:06Z",
"uid_ems": "ae9e8160-7cad-4908-884d-314ea53689db",
"retires_on": null,
"retired": null,
"boot_time": null,
"tools_status": null,
"standby_action": null,
"power_state": "off",
"state_changed_on": "2019-11-13T09:38:43Z",
"previous_state": "ACTIVE",
"connection_state": "connected",
"last_perf_capture_on": null,
"registered": null,
"busy": null,
"smart": null,
"memory_reserve": null,
"memory_reserve_expand": null,
"memory_limit": null,
"memory_shares": null,
"memory_shares_level": null,
"cpu_reserve": null,
"cpu_reserve_expand": null,
"cpu_limit": null,
"cpu_shares": null,
"cpu_shares_level": null,
"cpu_affinity": null,
"ems_created_on": null,
"template": false,
"evm_owner_id": null,
"miq_group_id": "10000000000034",
"linked_clone": null,
"fault_tolerance": null,
"type": "ManageIQ::Providers::Openstack::CloudManager::Vm",
"ems_ref": "ae9e8160-7cad-4908-884d-314ea53689db",
"ems_cluster_id": null,
"retirement_warn": null,
"retirement_last_warn": null,
"vnc_port": null,
"flavor_id": "10000000000651",
"availability_zone_id": "10000000000007",
"cloud": true,
"retirement_state": null,
"cloud_network_id": null,
"cloud_subnet_id": null,
"cloud_tenant_id": "10000000000004",
"raw_power_state": "SHUTOFF",
"publicly_available": null,
"orchestration_stack_id": "10000000000052",
"retirement_requester": null,
"tenant_id": "10000000000009",
"resource_group_id": null,
"deprecated": null,
"storage_profile_id": null,
"cpu_hot_add_enabled": null,
"cpu_hot_remove_enabled": null,
"memory_hot_add_enabled": null,
"memory_hot_add_limit": null,
"memory_hot_add_increment": null,
"hostname": null,
"ems_ref_type": null,
"restart_needed": null,
"last_compliance_conditions": [
{
"href": "http://localhost:3000/api/conditions/10000000000006",
"id": "10000000000006",
"name": "d5407028-7ffe-44ef-9edc-20fe675e24a9",
"description": "Memory over 4GB",
"expression": {
"exp": {
"<=": {
"field": "Vm-mem_cpu",
"value": "4096"
}
},
"context_type": null
},
"towhat": "Vm",
"file_mtime": null,
"created_on": "2020-03-24T14:41:35Z",
"updated_on": "2020-03-24T14:43:46Z",
"guid": "d5407028-7ffe-44ef-9edc-20fe675e24a9",
"filename": null,
"applies_to_exp": null,
"miq_policy_id": null,
"notes": null,
"read_only": null
}
],
"last_compliance_condition_expressions": [
"VM and Instance : Memory <= 4096"
],
@gtanzillo can this be linked to an Epic that we can track on the Roadmap, instead of having this issue on the Roadmap?
@chessbyte I guess it belongs with https://github.com/ManageIQ/manageiq-api/issues/782, which was completed. Should I create a new epic or add it to that one and open it up again? Also, this is a lower priority now because Omar is preloading the conditions with a separate request and that satisfies his requirement.
@gtanzillo I think it is ok to reopen Epics if some work was overlooked. As for lower priority, we have similar on OUDC epic
Removed this from the Jansa milestone... @gtanzillo please link to an existing roadmap item or add it directly to the roadmap.
This issue has been automatically marked as stale because it has not been updated for at least 3 months.
If you can still reproduce this issue on the current release or on master
, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.