Source:
public void testHost ( ) { testValidSql ( "Host: sortby cpu_usage desc" , "SELECT * FROM ((SELECT distinct vds.* FROM vds ) ORDER BY usage_cpu_percent DESC NULLS LAST,vds_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Host: name =\"test1\" sortby cpu_usage desc" , "SELECT * FROM ((SELECT distinct vds.* FROM vds WHERE vds.vds_name LIKE test1 ) ORDER BY usage_cpu_percent DESC NULLS LAST,vds_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Host: CPU_USAGE > 80 sortby cpu_usage desc" , "SELECT * FROM ((SELECT distinct vds.* FROM vds WHERE vds.usage_cpu_percent > 80 ) ORDER BY usage_cpu_percent DESC NULLS LAST,vds_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Host: user.name = \"user1\" sortby cpu_usage desc" , "SELECT * FROM ((SELECT distinct vds.* FROM vds LEFT OUTER JOIN vdc_users_with_tags ON vds.vds_id=vdc_users_with_tags.vm_guid WHERE vdc_users_with_tags.name LIKE user1 ) ORDER BY usage_cpu_percent DESC NULLS LAST,vds_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Host: STORAGE.name = \"sd1\" sortby cpu_usage desc" , "SELECT * FROM (SELECT * FROM vds WHERE ( vds_id IN (SELECT distinct vds_with_tags.vds_id FROM vds_with_tags LEFT OUTER JOIN storage_domains_with_hosts_view ON vds_with_tags.storage_id=storage_domains_with_hosts_view.id WHERE storage_domains_with_hosts_view.storage_name LIKE sd1 )) ORDER BY usage_cpu_percent DESC NULLS LAST,vds_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Host: EVENT.severity=error and CPU_USAGE > 80 sortby cpu_usage desc" , "SELECT * FROM ((SELECT distinct vds.* FROM vds LEFT OUTER JOIN audit_log ON vds.vds_id=audit_log.vds_id WHERE ( audit_log.severity = '2' AND vds.usage_cpu_percent > 80 )) ORDER BY usage_cpu_percent DESC NULLS LAST,vds_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Host: EVENT.severity=error and tag=tag1 sortby cpu_usage desc" , "SELECT * FROM (SELECT * FROM vds WHERE ( vds_id IN (SELECT distinct vds_with_tags.vds_id FROM vds_with_tags LEFT OUTER JOIN audit_log ON vds_with_tags.vds_id=audit_log.vds_id WHERE ( audit_log.severity = '2' AND vds_with_tags.tag_name IN ('tag1','all') ))) ORDER BY usage_cpu_percent DESC NULLS LAST,vds_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Host: tag=\"tag1\"" , "SELECT * FROM (SELECT * FROM vds WHERE ( vds_id IN (SELECT distinct vds_with_tags.vds_id FROM vds_with_tags WHERE vds_with_tags.tag_name IN ('tag1','all') )) ORDER BY vds_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Host: vm.name=\"vm1\"" , "SELECT * FROM ((SELECT distinct vds.* FROM vds LEFT OUTER JOIN vms_with_tags ON vds.vds_id=vms_with_tags.run_on_vds WHERE vms_with_tags.vm_name LIKE vm1 ) ORDER BY vds_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Vms: cluster = default and Templates.name = template_1 and Storage.name = storage_1" , "SELECT * FROM (SELECT * FROM vms WHERE ( vm_guid IN (SELECT distinct vms_with_tags.vm_guid FROM vms_with_tags LEFT OUTER JOIN vm_templates_storage_domain ON vms_with_tags.vmt_guid=vm_templates_storage_domain.vmt_guid LEFT OUTER JOIN storage_domains_with_hosts_view ON vms_with_tags.storage_id=storage_domains_with_hosts_view.id WHERE ( ( vms.vds_group_name LIKE default AND vm_templates_storage_domain.name LIKE template\\_1 ) AND storage_domains_with_hosts_view.storage_name LIKE storage\\_1 ))) ORDER BY vm_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Vms: cluster = default and Templates.name = template_1 and Storage.name = storage_1 and Vnic.network_name = vnic_1" , "SELECT * FROM (SELECT * FROM vms WHERE ( vm_guid IN (SELECT distinct vms_with_tags.vm_guid FROM vms_with_tags LEFT OUTER JOIN vm_templates_storage_domain ON vms_with_tags.vmt_guid=vm_templates_storage_domain.vmt_guid LEFT OUTER JOIN storage_domains_with_hosts_view ON vms_with_tags.storage_id=storage_domains_with_hosts_view.id LEFT OUTER JOIN vm_interface_view ON vms_with_tags.vm_guid=vm_interface_view.vm_guid WHERE ( ( ( vms.vds_group_name LIKE default AND vm_templates_storage_domain.name LIKE template\\_1 ) AND storage_domains_with_hosts_view.storage_name LIKE storage\\_1 ) AND vm_interface_view.network_name LIKE vnic\\_1 ))) ORDER BY vm_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; }

Target:
public void testVm ( ) { testValidSql ( "Vm: status=Up or status=PoweringUp or status=MigratingTo or status=WaitForLaunch or status=RebootInProgress or status=PoweringDown or status=Paused or status=Unknown sortby cpu_usage desc" , "SELECT * FROM ((SELECT distinct vms.* FROM vms WHERE ( ( ( ( ( ( ( vms.status = '1' OR vms.status = '2' ) OR vms.status = '6' ) OR vms.status = '9' ) OR vms.status = '10' ) OR vms.status = '16' ) OR vms.status = '4' ) OR vms.status = '7' )) ORDER BY usage_cpu_percent DESC NULLS LAST,vm_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Vm:" , "SELECT * FROM ((SELECT distinct vms.* FROM vms ) ORDER BY vm_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Vm: user.name = user1" , "SELECT * FROM ((SELECT distinct vms.* FROM vms LEFT OUTER JOIN vdc_users_with_tags ON vms.vm_guid=vdc_users_with_tags.vm_guid WHERE vdc_users_with_tags.name LIKE user1 ) ORDER BY vm_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Vm: user.name = \"user1\" and user.tag=\"tag1\"" , "SELECT * FROM (SELECT * FROM vms WHERE ( vm_guid IN (SELECT distinct vms_with_tags.vm_guid FROM vms_with_tags LEFT OUTER JOIN vdc_users_with_tags ON vms_with_tags.vm_guid=vdc_users_with_tags.vm_guid WHERE ( vdc_users_with_tags.name LIKE user1 AND vdc_users_with_tags.tag_name IN ('tag1','all') ))) ORDER BY vm_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Vm: mac=00:1a:4a:d4:53:94" , "SELECT * FROM (SELECT * FROM vms WHERE ( vm_guid IN (SELECT distinct vms_with_tags.vm_guid FROM vms_with_tags WHERE ( vms_with_tags.cluster_compatibility_version LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.cluster_name LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.custom_cpu_name LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.custom_emulated_machine LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.description LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.free_text_comment LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.guest_cur_user_name LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.quota_name LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.run_on_vds_name LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.storage_pool_name LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.tag_name LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.vm_fqdn LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.vm_host LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.vm_ip LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.vm_name LIKE '%mac=00:1a:4a:d4:53:94%' OR vms_with_tags.vm_pool_name LIKE '%mac=00:1a:4a:d4:53:94%' ) )) ORDER BY vm_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; testValidSql ( "Vms: SORTBY IP DESC" , "SELECT * FROM ((SELECT distinct vms.* FROM vms ) ORDER BY vm_ip_inet_array DESC NULLS LAST,vm_name ASC ) as T1 OFFSET (1 -1) LIMIT 0" ) ; }