tdviet / fedcloudclient

EGI FedCloud Client
https://fedcloudclient.fedcloud.eu
MIT License
8 stars 9 forks source link

Return values from openstack and other 3rd party commands #175

Open EGI-ILM opened 1 year ago

EGI-ILM commented 1 year ago

Initial checklist

Problem

It will be useful to pass the return value of the openstack command into the shell, not only on text but as a value that can be directly queried by other scripts.

$ fedcloud openstack volume show test-volume2 --site ... --vo ...
Site: ..., command: volume show test-volume2
Error code:  1
Error message:  No volume with a name or ID of 'test-volume2' exists.

$ echo $?
0

This can apply to any other command that is called by fedcloudclient

Solution

Return the value / error code obtained from the openstack operation. In the example: 1.

Alternatives

Return an error code specific for fedcloud if the executed command fails. For example, a code error of 100 + the error code returned by the command. In the example: 101. This way it can be distinguished between specific fedcloudclient errors and 3rd party errors.

Note: 100 is just an example used for clarity, it could be 20 instead. Consider that there is a limited number of return codes that can be used (so the sum could be longer than this limit) and there are some reserved codes.