meridor / perspective-backend

Scalable multi-cloud management API and shell
Apache License 2.0
16 stars 6 forks source link

Instances are only matched with suffix #205

Closed vania-pooh closed 7 years ago

vania-pooh commented 7 years ago

Need to test the following:

perspective>reboot one,two
Nothing selected for this operation. Exiting.
perspective>reboot one.example.com,two.example.com
Going to reboot 2 instances.
vania-pooh commented 7 years ago

Difference between these cases:

# Without suffix we use REGEX
2016-12-29 19:38:17,327 [             XNIO-1 I/O-2] INFO  org.meridor.perspective.rest.resources.InstancesResource     - Processing query #708 with sql = "select instances.id, instances.real_id, instances.name, projects.id, projects.name, instances.cloud_id, instances.cloud_type, images.name, flavors.name, instances.addresses, instances.state, instances.last_updated from instances inner join projects on instances.project_id = projects.id left join flavors on instances.project_id = flavors.project_id and instances.flavor_id = flavors.id left join images on instances.image_id = images.id where instances.name regexp :instances.name: or instances.name regexp :instances.name1: order by instances.name asc" and parameters = [org.meridor.perspective.sql.Parameter@1d25a2e8[index=<null>, name=instances.name, value=one], org.meridor.perspective.sql.Parameter@34077ef2[index=<null>, name=instances.name1, value=two]]
2016-12-29 19:38:24,254 [             XNIO-1 I/O-2] DEBUG org.meridor.perspective.rest.resources.InstancesResource     - Query #708 results = [0 rows, status = success, message = <empty>]

# With suffix we use exact match
2016-12-29 19:39:47,237 [             XNIO-1 I/O-1] INFO  org.meridor.perspective.rest.resources.InstancesResource     - Processing query #709 with sql = "select instances.id, instances.real_id, instances.name, projects.id, projects.name, instances.cloud_id, instances.cloud_type, images.name, flavors.name, instances.addresses, instances.state, instances.last_updated from instances inner join projects on instances.project_id = projects.id left join flavors on instances.project_id = flavors.project_id and instances.flavor_id = flavors.id left join images on instances.image_id = images.id where instances.name = :instances.name: or instances.name = :instances.name1: order by instances.name asc" and parameters = [org.meridor.perspective.sql.Parameter@71ee79e4[index=<null>, name=instances.name, value=one], org.meridor.perspective.sql.Parameter@6963ed17[index=<null>, name=instances.name1, value=two]]
vania-pooh commented 7 years ago

This was fixed in #138.