NAME

cdb - the cplant db swiss-army-knife (get/set tool)


MODULE

base


SYNOPSIS

cdb [--help] [--db dbname] [-r] KEY|:KEYn[:KEYn...][=VALUE]

QUERY-FOR-VALUE

    cdb [-r] KEY[:KEYn...]          
    returns VALUE of KEY[:KEYn...]
    if -r is given, KEY is treated as a perl regular expression
    (it is internally tightly anchored so it must match entire actual
    key).

QUERY-FOR-KEY

    cdb [-r] :KEYn[:KEYn...]=VALUE       
    returns (top-level) KEY(s) for which :KEYn[:KEY]=VALUE
    if -r is given, VALUE is treated as a perl regular expression (it
    is internally tightly anchored so it must match entire actual
    value).

SET

    NOT IMPLEMENTED YET, but intended use is as follows...
    cdb [-r] -s KEY[:ATTR...]=VALUE    
    sets KEY[:ATTR]=VALUE, iff it already exists.
    cdb [-r] -S KEY[:ATTR...]=VALUE    
    sets KEY[:ATTR]=VALUE, creating it if necessary.
    cdb [-r] [-s|-S] is a very sharp knife, use with *extreme* caution.


EXAMPLES

QUERY-FOR-KEY

If you'd like to know who the monitor node is, `cdb :role=monitor` will tell you (if there is one).

If you'd like to know who has admin-0 as their leader, `cdb :leader=admin-0` will tell you.

If you'd like to know how many compute nodes are defined in the db, `cdb :role=compute | wc -l` will tell you.

QUERY-FOR-VALUE

If you'd like to see what admin-0 looks like in the db, `cdb admin-0` will show you (ie `lookup admin-0`).

If you'd like to know what node.n-4.b-1's role, `cdb node.n-4.b-1:role` will tell you (ie- akin to `get_role node.n-4.b-1`).

If you'd like to see where the power connectors for all n-5's go to, `cdb -r .+n-5.+:power` will show you.

If you'd like to see all the console connections in t-40, `cdb -r .+t-40:console` will show you.


CAVEATS

You might like to know what devices have power-1.b-0 as their power controller and execute `cdb :power=power-0.b-0`, but cdb will not return an answer. The reason is that cdb uses KEYn's as keys to hashes inside db objects, and not all db structures are HASHes (ie: power and interfaces are ARRAYs). To resolve this, cdb could make some assumptions about ARRAYs or contain some hardcoded notions about the db object substructure, or the db design could be changed to use only HASHes. The latter option poses the greatest effort, and possibly the greatest rewards as well.