Skip to content

Commit

Permalink
doc: RA dev guide: describe ocf_cmp_versions
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuhamedagic committed Sep 15, 2012
1 parent 19fac98 commit 6528f45
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions doc/dev-guides/ra-dev-guide.txt
Expand Up @@ -1286,6 +1286,36 @@ NOTE: If +ocf_is_true+ is used against an empty or non-existant
variable, it always returns an exit code of +1+, which is equivalent
to +false+.

=== Version comparison: +ocf_version_cmp+

A resource agent may want to check the version of software
installed. +ocf_version_cmp+ takes care of all the necessary
details.

The return codes are

* +0+ -- the first version is smaller (earlier) than the second
* +1+ -- the two versions are equal
* +2+ -- the first version is greater (later) than the second
* +3+ -- one of arguments is not recognized as a version string

The versions are allowed to contain digits, dots, and dashes.

[source,bash]
--------------------------------------------------------------------------
local v=`gooey --version`
ocf_version_cmp "$v" 12.0.8-1
case $? in
0) ocf_log err "we do not support version $v, it is too old"
exit $OCF_ERR_INSTALLED
;;
[12]) ;; # we can work with versions >= 12.0.8-1
3) ocf_log err "gooey produced version <$v>, too funky for me"
exit $OCF_ERR_INSTALLED
;;
esac
--------------------------------------------------------------------------

=== Pseudo resources: +ha_pseudo_resource+

"Pseudo resources" are those where the resource agent in fact does not
Expand Down

0 comments on commit 6528f45

Please sign in to comment.