Package onep :: Package vty :: Module util :: Class DoHost
[frames] | no frames]

Class DoHost


This is a helper class that accepts input from shell scripts or shell commands and pipes them to the onep Python SDK. See __main__ below.

Environment variables with defaults:

ONEP_CERTIFICATE=~/ca.pem ONEP_PWD='' ONEP_USER='' ONEP_TRANSPORT=SessionConfig.SessionTransportMode.TIPC ONEP_UT_ADDR=127.0.0.1

------------------------------------------------------------------ Example bash shell script "dohost":

#!/bin/bash exec python /usr/lib/python2.7/site-packages/onep/vty/util.py "$@"

Example bash shell script usage:

~/> dohost 'show hostname' 'sho hostna' hostname N3k-2

hostname N3k-2

------------------------------------------------------------------

The class can also be included in other Python scripts. If an instantiated and connected NetworkElement class is not passed in, the class will look for environment variables and if not found, default to a TIPC connection.

---------------------------------------------------------------------- Example usage for Python script:

~/> python Python 2.7.1 (r271:86832, Mar 14 2011, 14:03:08) [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from onep.vty.util import DoHost >>> with DoHost() as console: ... output = console.dohost('show hostname', 'sho hostnam') ... for text in output: ... print text ... hostname N3k-2

hostname N3k-2

>>> -----------------------------------------------------------------------

Instance Methods
 
__init__(self, element=None)
x.__init__(...) initializes x; see help(type(x)) for signature
 
dohost(self, *commands)
 
__enter__(self)
 
__exit__(self, type, value, tb)

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, element=None)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)