openstack using name instead of id

Can I use name instead of id for openstack api such as show instance? When I send server name in the url, I got 404. Is there any way to get the id of the instance by means of its name?


Solution 1:

Short answer: It needs to be the ID.

According to the API reference, to get server details you GET /servers/{server_id}. And server_id is the ID, not the name.

The command openstack server show can be used with a UUID or the server's name. In the latter case, the command probably performs a GET /servers/ reference) to convert the name to an ID, then the above GET /servers/{server_id}.

One way of learning about rules and best practices of OpenStack APIs is to run CLI commands with the openstack --debug option. This will show you details of the APIs that the command issues.