Giter VIP home page Giter VIP logo

openlmi-scripts's Introduction

openlmi-scripts

Client-side python libraries for system management through OpenLMI providers.

It comprises of small python eggs targeted on one or more OpenLMI providers. We call these eggs scripts. They are installed separately although they can depend on each other.

They contain python library itself as well as command line interface. This interface is registered with LMI Meta-command which is a part of OpenLMI Tools. LMI Meta-command loads it and offers to interface with broker through command line.

For more information please refer to online documentation on pythonhosted.

Structure

Each subdirectory of commands/ contains library for interfacing with particular set of OpenLMI providers. Each contains its own setup.py file, that handles its installation and registration of script. They have one common feature. Each such setup.py must pass entry_points dictionary to the setup() function, wich associates commands defined in script with its name with LMI Meta-command.

Dependencies

Code base is written for python 2.7. There are following python dependencies:

  • openlmi-tools >= 0.9.1 (tools-PyPI)
  • python-docopt
  • pandoc

Installation

Use standard setuptools script for installation:

$ cd openlmi-scripts/commands/$CMD
$ make setup
$ python setup.py install --user

This installs particular client library and command line interface for LMI Meta-command.

Script eggs are also available on PyPI, install them with:

$ # add any provider you want to interact with
$ pip install --user openlmi-scripts-service openlmi-scripts-software

Developing lmi scripts.

This documents how to quickly develop lmi scripts without the need to reinstall python eggs, when anything is changed. This presumes, that the development process takes place in a git repository checked out from git. It can be located anywhere on system.

Before we start with setting up an environment, please double check that you don't have installed anything from openlmi-scripts in system path (/usr/lib/python2.7/site-packages/lmi/scripts should not exist). And make sure, that user path is also cleared:

$ rm -rf $HOME/.local/lib/python2.7/site-packages/lmi*
$ rm -rf $HOME/.local/lib/python2.7/site-packages/openlmi*

Install all dependencies (named above).

Either via rpms (on Fedora or RHEL) or from respective git repositories or from PyPI.

Let's setup an environment:

  1. Create a workspace directory for current $USER (let's call it a WSP). This is a place, where our eggs and binaries will be "installed". It can be located anywhere, for example:

    $ WSP=~/.python_workspace $ mkdir $WSP

  2. Add workspace to your python path to make all modules installed there importable (you can add this to your ~/.bashrc):

    $ export PYTHONPATH="$WSP:$PYTHONPATH"

  3. Add workspace to your PATH, so the installed binaries can be run:

    $ export PATH="$WSP:$PATH"

  4. Now let's "install" to our workspace. First cd to checked out openlmi-scripts repository.

  5. Install them and any commands you want -- possibly your own

    $ DEVELOPDIR="$WSP" make develop-all

Now any change made to openlmi-scripts is immediately reflected in LMI Meta-command.

Uploading to PyPI

Since PyPI expects README file to be in a reStructuredText markup language and the one present is written in markdown, it needs to be converted to it. So please make sure you have pandoc installed before running:

$ make upload

Versioning

All the scripts share the same version. Version string resides in VERSION file in root directory. When changed, all setup.py scripts need to be regenerated. This is done with:

$ make setup-all

Makefile rules

There are various rules provided to ease the development. Most of them may be applied to all commands/libraries at once. They are:

  • clean - remove temporary and generated files
  • develop - install library in developing mode
  • doc - build html documentation
  • readme - create README.txt file out of README.md
  • sdist - creates source tarball in dist directory
  • setup - writes a setup.py and doc/conf.py files from their skeletons
  • upload - upload to PyPI
  • upload-docs - upload documentation to pythonhosted

Each script's Makefile has the same interface. The root Makefile is an exception. It takes care of command libraries. It defines all the rules above with -all suffix. They operate on all subcommands at once. Such rules are:

  • clean-all
  • doc-all
  • develop-all
  • setup-all
  • upload-all
  • upload-docs-all

To limit the set of commands that shall be processed, the COMMANDS environment variable may be used. For example following command:

$ COMMANDS='storage software networking' make clean-all

Will clean storage, software and networking directories.


openlmi-scripts's People

Contributors

jsafrane avatar pbrezina avatar rrakus avatar sgallagher avatar tbzatek avatar tsmetana avatar vcrhonek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openlmi-scripts's Issues

unicode failures

Scripts can not work with unicode arguments. I've tested only LogicalFile providers and scripts. Steps to reproduce:

  1. install openlmi-logicalfile and related scripts (openlmi-scripts-logicalfile)

  2. make some file or directory with non-ascii characters e.g.:

      /root/složka
    
  3. try to list /root:

      lmi --trace -h localhost lf list '/root'
    
  4. watch the output (below)

  5. try to show it:

      lmi --trace -h localhost lf show '/root/složka'
    
  6. watch the output (below)

Output of list looks like this:

lmi --hosts-file hosts-file lf list '/root'
ERROR: invocation failed for host "http://kvm-fedora20:5988"
Traceback (most recent call last):
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/session.py", line 105, in process_session
    self.process_host_result(connection.hostname, True, result)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/session.py", line 133, in process_host_result
    self.produce_output(result)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/endpoint.py", line 317, in produce_output
    self.formatter.produce_output(data)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/formatter/__init__.py", line 342, in produce_output
    super(TableFormatter, self).produce_output(rows)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/formatter/__init__.py", line 238, in produce_output
    for row in rows:
  File "/home/miminar/workspace/openlmi-scripts/commands/logicalfile/lmi/scripts/logicalfile/logicalfile.py", line 143, in lf_list
    ident = f.associators(AssocClass='LMI_FileIdentity')[0]
  File "/home/miminar/.local/lib/python2.7/site-packages/openlmi_tools-0.7-py2.7.egg/lmi/shell/LMIDecorators.py", line 210, in wrapper
    return fn(self_wr, *args, **kwargs)
  File "/home/miminar/.local/lib/python2.7/site-packages/openlmi_tools-0.7-py2.7.egg/lmi/shell/LMIDecorators.py", line 85, in wrapper
    return fn(self_wr, *args, **kwargs)
  File "/home/miminar/.local/lib/python2.7/site-packages/openlmi_tools-0.7-py2.7.egg/lmi/shell/LMIInstance.py", line 327, in associators
    associators_list = self._conn._client._get_associators(self._cim_instance, **kwargs)
  File "/home/miminar/.local/lib/python2.7/site-packages/openlmi_tools-0.7-py2.7.egg/lmi/shell/LMIBaseClient.py", line 538, in _get_associators
    return self._cliconn.Associators(instance.path, **params)
  File "/usr/lib/python2.7/site-packages/pywbem/cim_operations.py", line 695, in Associators
    **params)
  File "/usr/lib/python2.7/site-packages/pywbem/cim_operations.py", line 167, in imethodcall
    verify_callback = self.verify_callback)
  File "/usr/lib/python2.7/site-packages/pywbem/cim_http.py", line 212, in wbem_request
    h.send(data)
  File "/usr/lib/python2.7/site-packages/pywbem/cim_http.py", line 91, in send
    self.sock.sendall(str)
  File "/usr/lib64/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u017e' in position 582: ordinal not in range(128)
There was 1 error:
host http://kvm-fedora20:5988
    (UnicodeEncodeError) 'ascii' codec can't encode character u'\u017e' in position 582: ordinal not in range(128)

Output of show looks like this:

ERROR: invocation failed for host "http://kvm-fedora20:5988"
Traceback (most recent call last):
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/session.py", line 105, in process_session
    self.process_host_result(connection.hostname, True, result)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/session.py", line 133, in process_host_result
    self.produce_output(result)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/command/endpoint.py", line 317, in produce_output
    self.formatter.produce_output(data)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/formatter/__init__.py", line 342, in produce_output
    super(TableFormatter, self).produce_output(rows)
  File "/home/miminar/workspace/openlmi-scripts/lmi/scripts/common/formatter/__init__.py", line 238, in produce_output
    for row in rows:
  File "/home/miminar/workspace/openlmi-scripts/commands/logicalfile/lmi/scripts/logicalfile/logicalfile.py", line 192, in lf_show
    raise LmiFailed("Could not get target: %s" % target)
LmiFailed: Could not get target: /root/složka
There was 1 error:
host http://kvm-fedora20:5988
    Could not get target: /root/složka

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.