[Pacemaker] how to determin crm version / features from within a RA

Andrew Beekhof andrew at beekhof.net
Thu Jun 25 14:47:55 UTC 2009


On Thu, Jun 11, 2009 at 3:16 PM, Lars
Ellenberg<lars.ellenberg at linbit.com> wrote:
> On Thu, Jun 11, 2009 at 01:59:56PM +0200, Dejan Muhamedagic wrote:
>> > so, to summarize, I hacked up a compare_version.
>> > and I think I even avoided bashisms! that is once in a life time :)
>>
>> Exemplary ;-)
>
> It may depend on some GNU stuff in sed and sort, though.
>
>> > comments?
>> > overkill?
>> > useful?
>>
>> Yes. Unfortunately, the thing got quite complicated. Some
>> comments:
>>
>>       sort_keys=$(seq $l | sed -e 's/.*/ -k&,&/;2~2 s/$/n/')
>>
>> Won't even try to unravel this magic.
>
> l was set to the number or version parts (non-numeric, numeric).
> so I get $l "columns", need that many sort keys.
> and they need to do "ascii" and "numeric" sort.
>
> seq 3
> 1
> 2
> 3
> seq 3 | sed -e 's/.*/ -k&,&/'
>  -k1,1
>  -k2,2
>  -k3,3
> ... | -e '2~2 s/$/n/'
> "every second of two lines, append an n" (for numeric sort).
>  -k1,1
>  -k2,2n
>  -k3,3
>
>> eval $(cibadmin -Ql |
>>     sed -n -e '1 s/^<cib validate-with=\("[^"]*"\).*$/_CIB_VALIDATE_WITH=\1/p' \
>>
>> Beware: Attributes may come in any order. AFAIK, no guarantee at
>> all about it.
>>
>>            -e 's/^[[:space:]]*<nvpair id="cib.bootstrap.options.dc.version".*
>>
>> Also, the id may be just about anything, can't rely on that,
>> better use the name attribute.
>
> is it, really arbitrary for the cib bootstrap things?
>>                  value="\([0-9.:]*\).*$/_DC_VERSION=\1/p')
>>
>> Hmm, don't really like eval here. If you really can't do without
>> it, at least protect the value with quotes. The same above with
>> _CIB_VALIDATE_WITH.
>
> of course I can do without it.
> I want to avoid to have to do it in two passes.
> but no need.  the _DC_VERSION value only contains [0-9.:],
> which does not need to be quoted.
> for the _CIB_VALIDATE_WITH, the \("[^"]*"\) intentionally
> captures the enclosing quotes. ok, it could theoretically
> at one point in the future contain a backslash.
> but would
> <cib validate-with="something\" ...> be valid xml?

I'd guess not.
But the schema is strict on what values validate-with can hold and
that wont be one of them.

Can we back up a moment though and restate the problem?
Is there a specific version barrier you're looking for?




More information about the Pacemaker mailing list