I created git repository on https://github.com/openlmi/openlmi-scripts for our scripts. We don't use fedorahosted to allow super-easy contribution from community via github pull requests.
I also marked all other openlmi repositories on github as deprecated, these are just leftovers from our github evaluation.
Jan
On 07/03/2013 09:38 AM, Jan Safranek wrote:
Summarizing email replies and discussion around - in addition to the initial email, following also applies to scripts:
scripts reside in python standard directory, i.e. /usr/lib/python2.7/site-packages/lmi/scripts/storage/vg.py o there must be description (on wiki) how to copy, modify and use a modified script easily (e.g by setting PYTHONPATH or ~/.lmirc?).
scripts use standard python logging, lmishell provides formatter and writes them to appropriate place (stderr, file, ...)
lmishell also formats exceptions appropriately - as errors to stderr
scripts raise LmiError as exception, the top-level script (e.g. lmi metacommand, see below) catches it and either sends it to stderr or throws complete traceback (in verbose mode)
each script must check for remote API version and refuse to operate if it is incompatible o with optional override o -> our API must report its version in a profile registration o -> we need to do the profile registration in our providers!
the scripts reside on github, which allows for easy management of community contributions o again, this needs to be documented
there must be some 'common' library which defines support functions for logging, cmdline parsing and LmiError
Sample script usage (in lmishell):
from lmi.scripts import logicalfile files = logicalfile.list('/mnt') # 'files' is now array of LmiInstances of LMI_LogicalFile for file in files: print file.Name logicalfile.mkdir('/mnt/mydisk')
we create new 'metacommand' /usr/bin/lmi
o it scans common area (e.g. /usr/libexec/lmi/cmd) for sub-commands o it has uniform usage for various management areas: $ lmi directory list /mnt $ lmi directory create /mnt/payroll $ lmi storage list $ lmi service list $ lmi service restart httpd o it has interactive mode: $ lmi -c remote.host.openlmi.com -U root password: ****** > directory list /mnt > directory create /mnt/payroll > service list > service restart httpd o it can run command (or set of commands) on multiple remote hosts, consistently reporting errors + e.g. list of machines stored in a file + maybe SLP later + _we really need kerberos, passwords do not scale well here_ o we need documentation (on wiki), how to create new subcommands + the part in /usr/libexec/lmi/cmd just registers new subcommands and parses command line, calling functions imported from /usr/lib/python2.7/site-packages/lmi/scripts/ o we should *not* mimic existing cmdline tools (mdadm, vgcreate, ip, ...). Our goal should be to reduce the number of things new users need to learn. The variances in these classic tools is one of the primary issues with manageability on Linux.
openlmi-devel mailing list openlmi-devel@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/openlmi-devel