Pycopia SMI package

Parse and scan MIB files. Provides iterators for sequences, etc. to enable Pythonic access to SMI/MIB definitions.

It also provides a MIB to Python code compiler for use by the SNMP modules.

class pycopia.SMI.SMI.Element(this)[source]
get_node()[source]
get_parent()
class pycopia.SMI.SMI.Flags[source]
static clear(flag)[source]
static get_flags()[source]
classmethod no_descriptions(onoff=1)[source]

If SMI_FLAG_NODESCR is set, no description and references strings are stored in memory. This may save a huge amount of memory in case of applications that do not need this information.

classmethod recursive(onoff=1)[source]

If SMI_FLAG_RECURSIVE is set, the library also complains about errors in modules that are read due to import statements.

static set(flag)[source]
static set_flags(*flags)[source]
classmethod show_errors(onoff=1)[source]

If SMI_FLAG_ERRORS is not set, no error messages are printed at all to keep the SMI library totally quiet, which might be mandatory for some applications.

classmethod statistics(onoff=1)[source]

If SMI_FLAG_STATS is set, the library prints some module statistics.

stringmap = {Enum(8192, 'SMI_FLAG_ERRORS'): u'SMI_FLAG_ERRORS', Enum(2048, 'SMI_FLAG_NODESCR'): u'SMI_FLAG_NODESCR', Enum(4096, 'SMI_FLAG_VIEWALL'): u'SMI_FLAG_VIEWALL', Enum(16384, 'SMI_FLAG_RECURSIVE'): u'SMI_FLAG_RECURSIVE', Enum(32768, 'SMI_FLAG_STATS'): u'SMI_FLAG_STATS'}
static test(flag)[source]
classmethod toString()[source]
classmethod view_all(onoff=1)[source]

If SMI_FLAG_VIEWALL is set, ...

class pycopia.SMI.SMI.Import(this)[source]
module
name
class pycopia.SMI.SMI.IndexObjects(init=None, implied=False)[source]
class pycopia.SMI.SMI.Macro(this)[source]
decl
description
get_module()[source]
name
reference
status
class pycopia.SMI.SMI.Module(this)[source]
conformance
contactinfo
description
get_capabilities(statusfilt=None)[source]
get_columns(statusfilt=None)[source]
get_compliances(statusfilt=None)[source]
get_groups(statusfilt=None)[source]
get_identityNode()[source]
get_imports(statusfilt=None)[source]
get_macro(name)[source]
get_macros(statusfilt=None)[source]
get_node(name)[source]
get_nodes(kind=Enum(65535, 'SMI_NODEKIND_ANY'), statusfilt=None)[source]
get_notifications(statusfilt=None)[source]
get_revisions(statusfilt=None)[source]
get_rows(statusfilt=None)[source]
get_scalars(statusfilt=None)[source]
get_tables(statusfilt=None)[source]
get_type(name)[source]
get_types(statusfilt=None)[source]
identityNode
is_imported(module, name)[source]
language
name
organization
path
reference
class pycopia.SMI.SMI.NamedNumber(this)[source]
name
value
class pycopia.SMI.SMI.Node(this)[source]
OID
access
create
decl
description
format
get_OID()[source]
get_children(statusfilt=None)[source]
get_elements(statusfilt=None)[source]
get_index()[source]
get_line()[source]
get_module()[source]
get_options(statusfilt=None)[source]
get_parent()[source]
get_refinements(statusfilt=None)[source]
get_rowstatus()[source]
get_type()[source]
get_uniqueness_elements(statusfilt=None)[source]
implied
index
indexkind
name
nodekind
oid
oidlen
reference
render(flag=Enum(255, 'SMI_RENDER_ALL'))[source]
rowstatus
status
syntax
units
value
class pycopia.SMI.SMI.OID[source]
class pycopia.SMI.SMI.Option(this)[source]
description
get_node()[source]
get_parent()
class pycopia.SMI.SMI.Range(this)[source]
maxValue
minValue
class pycopia.SMI.SMI.Ranges(*args)[source]
class pycopia.SMI.SMI.Refinement(this)[source]
access
description
get_node()[source]
get_parent()
get_type()[source]
get_write_type()[source]
syntax
write_type
class pycopia.SMI.SMI.Revision(this)[source]
date
description
class pycopia.SMI.SMI.SMIobject(this)[source]
get_attributes()[source]
class pycopia.SMI.SMI.Type(this)[source]
BASETYPELIST = [u'Counter', u'Counter32', u'TimeTicks', u'Opaque', u'Unsigned32', u'Gauge32', u'Gauge', u'Counter64', u'IpAddress']
BASETYPEMAP = {Enum(1, 'SMI_BASETYPE_INTEGER32'): u'Integer32', Enum(2, 'SMI_BASETYPE_OCTETSTRING'): u'OctetString', Enum(3, 'SMI_BASETYPE_OBJECTIDENTIFIER'): u'ObjectIdentifier', Enum(4, 'SMI_BASETYPE_UNSIGNED32'): u'Unsigned32', Enum(6, 'SMI_BASETYPE_UNSIGNED64'): u'Counter64', Enum(10, 'SMI_BASETYPE_ENUM'): u'Enumeration', Enum(11, 'SMI_BASETYPE_BITS'): u'Bits'}
basetype
decl
description
enumerations
format
get_NamedNumbers(statusfilt=None)[source]
get_enumerations(statusfilt=None)[source]
get_line()[source]
get_module()[source]
get_named_numbers(statusfilt=None)
get_parent()[source]
get_ranges(statusfilt=None)[source]
get_snmptype()[source]
name
range_list(statusfilt=None)[source]
ranges
reference
render(flag=Enum(255, 'SMI_RENDER_ALL'))[source]
render_value(flag=Enum(255, 'SMI_RENDER_ALL'))[source]
snmptype
status
units
value
class pycopia.SMI.SMI.Value(this)[source]
basetype
get_value()[source]
len
render(typeobj, flag=Enum(255, 'SMI_RENDER_ALL'))[source]
value
class pycopia.SMI.SMI.Value_value(this)[source]
float32
float64
integer32
integer64
oid
ptr
unsigned32
unsigned64
pycopia.SMI.SMI.clear()[source]
pycopia.SMI.SMI.default_error_handler(path, line, severity, msg, tag)[source]
pycopia.SMI.SMI.get_module(modulename)[source]
pycopia.SMI.SMI.get_modules(statusfilt=None)[source]

returns an iterator that iterates over all loaded modules.

pycopia.SMI.SMI.get_node(nodespec)[source]

The get_node() function retrieves a Node that represents a node of any kind. Nodespec may be either a fully qualified descriptor, a simple node name, or a numerical OID. Nodes are also found, if node contains an instance identifier suffix.

pycopia.SMI.SMI.get_node_by_OID(oid)[source]

Retrieves a Node that matches the longest prefix of the node that is specified. If no such node is not found, return None.

pycopia.SMI.SMI.init(key='python', error_handler=<function default_error_handler at 0x65380c8>)[source]
pycopia.SMI.SMI.load_module(modulename)[source]
pycopia.SMI.SMI.load_modules(modname|modnamelist, ...)[source]

Takes multiple string arguments, or lists of strings, which should be module names, and loads them.

pycopia.SMI.SMI.set_error_level(level=0)[source]

Sets the pedantic level (0-9) of the SMI parsers of the SMI library,

pycopia.SMI.SMI.set_severity(pattern, severity)[source]

The set_severity() function allows you to set the severity of all error that have name prefixed by pattern to the value severity.

class pycopia.SMI.Objects.Capability(*args, **kwargs)[source]
class pycopia.SMI.Objects.ColumnObject(value=None, indexoid=None)[source]
OID = None
access = None
enumerations = None
get(session=None, indexoid=None)[source]
get_ratecounter(N=5)[source]
set(value, session=None, indexoid=None)[source]
set_index(indexoid)[source]
set_session(snmp_session=None)[source]
set_value(value)[source]
status = None
syntaxobject = None
varbind[source]
class pycopia.SMI.Objects.Compliance(*args, **kwargs)[source]
class pycopia.SMI.Objects.GroupObject[source]
OID = None
group = None
name = None
status = None
class pycopia.SMI.Objects.Index(init=None, implied=False)[source]
class pycopia.SMI.Objects.IndexObjects(init=None, implied=False)[source]
class pycopia.SMI.Objects.MacroObject[source]
class pycopia.SMI.Objects.ModuleObject(*args, **kwargs)[source]
conformance = None
description = None
language = None
name = None
path = None
class pycopia.SMI.Objects.NodeObject(*args, **kwargs)[source]
OID = None
access = None
enumerations = None
name = None
status = None
syntaxobject = None
class pycopia.SMI.Objects.NotificationObject[source]
class pycopia.SMI.Objects.ObjectTable(rowclass)[source]
fetch(session)[source]
class pycopia.SMI.Objects.PlainTable(rowobj, tabletitle='')[source]
class pycopia.SMI.Objects.RateCounter(obj, N=5)[source]

Wrapper for a MIB object that has a Counter syntax. Used to update a rate.

EWRA
RA
rate
update(time)[source]
class pycopia.SMI.Objects.RawTable(rowobj, tabletitle='')[source]

The SNMPTable class is a convenience class to make it easier to use MIB tables.

fetch(session)[source]
class pycopia.SMI.Objects.RowIterator(session, rowclass, startindex=None, count=0)[source]
class pycopia.SMI.Objects.RowObject(indexoid=None)[source]
activate(session=None)[source]
add_column(colobj)[source]
create = 0
createAndGo(session, *indexargs, **attribs)[source]
createAndWait(session, *indexargs, **attribs)[source]
deactivate(session=None)
destroy(session=None)[source]
get(session, indexoid=None)[source]
get_attributes()[source]
get_cache_value(name)[source]
get_indexvalue()[source]
get_indexvalues()[source]
get_status(session)[source]
get_values(*args)[source]
index = None
notInService(session=None)[source]
refresh(session=None)[source]
rowstatus = None
set(session=None, **attribs)[source]
set_indexoid(oid)[source]
set_session(snmp_session)[source]
class pycopia.SMI.Objects.RunningRate(type=<class 'pycopia.aid.unsigned'>, N=5)[source]

Computes rates based on counter input. Also maintains exponentially weighted running average. Update the object by calling the update() method with a Counter object and a time interval. Extract the instantaneous rate with the ‘rate’ attribute, a running average with the RA attribute, and an exponentially weighted running average with the EWRA attribute.

EWRA
ExponentialWeightedRunningAverage
RA
RunningAverage
append(counter, timestamp)
rate
update(counter, timestamp)[source]
class pycopia.SMI.Objects.ScalarObject(value=None)[source]
OID = None
access = None
enumerations = None
get(session=None, indexoid=None)[source]
get_ratecounter(N=5)[source]
set(val, session=None)[source]
set_session(snmp_session=None)[source]
status = None
syntaxobject = None
varbind[source]
pycopia.SMI.Objects.create(session, rowobj, *indexargs, **kwargs)[source]
pycopia.SMI.Objects.create_wait(session, rowobj, *indexargs, **kwargs)[source]
pycopia.SMI.Objects.get_object(session, rowclass, *indexargs)[source]
pycopia.SMI.Objects.get_plaintable(session, rowclass)[source]
pycopia.SMI.Objects.get_scalar(session, scalarclass)[source]
pycopia.SMI.Objects.get_table(session, rowclass)[source]
class pycopia.SMI.Compile.IndexGenerator(init=None, implied=False)[source]
class pycopia.SMI.Compile.ListGenerator(init=None)[source]
class pycopia.SMI.Compile.ObjectSourceGenerator(fo, oidfo, smimodule)[source]

Usage: ObjectSourceGenerator(fileobject, modulename)

Parameters:
fileobject = A file-type object. modulename = An SMI module name.
add_comment(text)[source]
finalize()[source]
genAll()[source]
genCapabilities()[source]
genColumns()[source]
genCompliances()[source]
genGroups()[source]
genImports()[source]
genMacros()[source]
genModule()[source]
genNodes()[source]
genNotifications()[source]
genRows()[source]
genScalars()[source]
genTypes()[source]
pycopia.SMI.Compile.compile_everything(all=False)[source]
pycopia.SMI.Compile.compile_module(modname, preload=None, all=False)[source]
pycopia.SMI.Compile.convert_name(name)[source]
pycopia.SMI.Compile.genClass(sminode, baseclass, attrdict=None, doc=None)[source]
pycopia.SMI.Compile.handle_specials(fo, smimodule)[source]
class pycopia.SMI.Basetypes.ApplicationSyntax[source]
class pycopia.SMI.Basetypes.AutonomousType(init=[], implied=False)[source]

The identity of an item

class pycopia.SMI.Basetypes.BITS(v=u'', implied=False)[source]

A collection of named bits.

clear(bit)[source]
enumerations = []
set(bit)[source]
test(bit)[source]
pycopia.SMI.Basetypes.Bits

alias of BITS

class pycopia.SMI.Basetypes.Boolean[source]

BOOLEAN

pycopia.SMI.Basetypes.Counter

alias of Counter32

class pycopia.SMI.Basetypes.Counter32(val)[source]

IMPLICIT INTEGER (0..4294967295)

class pycopia.SMI.Basetypes.Counter64(val)[source]

IMPLICIT INTEGER (0..18446744073709551615)

ranges = pycopia.SMI.Basetypes.Ranges(Range(0, 18446744073709551615))
class pycopia.SMI.Basetypes.DateAndTime(v=u'', implied=False)[source]
format = u'2d-1d-1d,1d:1d:1d.1d,1a1d:1d'
ranges = pycopia.SMI.Basetypes.Ranges(Range(8, 8), Range(11, 11))
class pycopia.SMI.Basetypes.DisplayString(v=u'', implied=False)[source]
format = u'255a'
ranges = pycopia.SMI.Basetypes.Ranges(Range(0, 255))
class pycopia.SMI.Basetypes.Enumeration[source]
enumerations = []
verify()[source]
verify_ex()[source]
pycopia.SMI.Basetypes.Gauge

alias of Gauge32

class pycopia.SMI.Basetypes.Gauge32(val)[source]

IMPLICIT INTEGER (0..4294967295)

class pycopia.SMI.Basetypes.GetBulkRequestPDU(request_id=0, non_repeaters=0, max_repetitions=10, varbinds=None)[source]
class pycopia.SMI.Basetypes.GetNextRequestPDU(request_id=0, error_status=0, error_index=0, varbinds=None)[source]
class pycopia.SMI.Basetypes.GetRequestPDU(request_id=0, error_status=0, error_index=0, varbinds=None)[source]
pycopia.SMI.Basetypes.INTEGER

alias of Integer32

class pycopia.SMI.Basetypes.InformRequestPDU(request_id=0, error_status=0, error_index=0, varbinds=None)[source]
class pycopia.SMI.Basetypes.InstancePointer(init=[], implied=False)[source]
class pycopia.SMI.Basetypes.Integer32[source]

INTEGER (-2147483648..2147483647)

oid_decode(oid)[source]
ranges = pycopia.SMI.Basetypes.Ranges(Range(-2147483648, 2147483647))
verify()[source]
verify_ex()[source]
class pycopia.SMI.Basetypes.IpAddress(address, mask=None)[source]

IMPLICIT OCTET STRING (SIZE (4))

oid_decode(oid)[source]
ranges = pycopia.SMI.Basetypes.Ranges(Range(4, 4))
class pycopia.SMI.Basetypes.MacAddress(v=u'', implied=False)[source]
format = u'1x:'
ranges = pycopia.SMI.Basetypes.Ranges(Range(6, 6))
pycopia.SMI.Basetypes.OBJECT_IDENTIFIER

alias of ObjectIdentifier

pycopia.SMI.Basetypes.OCTET_STRING

alias of OctetString

class pycopia.SMI.Basetypes.OID(oid)[source]
class pycopia.SMI.Basetypes.ObjectIdentifier(init=[], implied=False)[source]

OBJECT IDENTIFIER

get_object()[source]

Returns the object class this OID refers to, or None if it is not imported.

oid_decode(oid)[source]
class pycopia.SMI.Basetypes.ObjectSyntax[source]
class pycopia.SMI.Basetypes.OctetString(v=u'', implied=False)[source]

OCTET STRING (SIZE (0..65535))

oid_decode(oid)[source]
ranges = pycopia.SMI.Basetypes.Ranges(Range(0, 65535))
verify()[source]
verify_ex()[source]
class pycopia.SMI.Basetypes.Opaque(v=u'', implied=False)[source]

IMPLICIT OCTET STRING

decode()[source]
class pycopia.SMI.Basetypes.PhysAddress(v=u'', implied=False)[source]
format = u'1x:'
class pycopia.SMI.Basetypes.Range(minValue=-2147483647, maxValue=2147483647)[source]
verify(value)[source]
class pycopia.SMI.Basetypes.Ranges(*args)[source]
get_max()[source]
get_min()[source]
max

maximum value in ranges

min

minimum value in ranges

verify(value)[source]
class pycopia.SMI.Basetypes.ReportPDU(request_id=0, error_status=0, error_index=0, varbinds=None)[source]
class pycopia.SMI.Basetypes.ResponsePDU(request_id, error_status, error_index, varbinds)[source]
class pycopia.SMI.Basetypes.RowPointer(init=[], implied=False)[source]
class pycopia.SMI.Basetypes.RowStatus[source]
enumerations = [Enum(2, 'notInService'), Enum(5, 'createAndWait'), Enum(1, 'active'), Enum(4, 'createAndGo'), Enum(6, 'destroy'), Enum(3, 'notReady')]
isActive()[source]
isNotInService()[source]
isNotReady()[source]
class pycopia.SMI.Basetypes.SNMPv1TrapPDU(enterprise=None, agent=None, generic=None, specific=None, time_stamp=None, varbinds=None)[source]
class pycopia.SMI.Basetypes.SNMPv2TrapPDU(request_id=0, error_status=0, error_index=0, varbinds=None)[source]
class pycopia.SMI.Basetypes.SequenceOf[source]
class pycopia.SMI.Basetypes.SetRequestPDU(request_id=0, error_status=0, error_index=0, varbinds=None)[source]
class pycopia.SMI.Basetypes.SimpleSyntax[source]
class pycopia.SMI.Basetypes.StorageType[source]
enumerations = [Enum(1, 'other'), Enum(2, 'volatile'), Enum(3, 'nonVolatile'), Enum(4, 'permanent'), Enum(5, 'readOnly')]
pycopia.SMI.Basetypes.TAGGED_SEQUENCE

alias of SequenceOf

class pycopia.SMI.Basetypes.TAddress(v=u'', implied=False)[source]
ranges = pycopia.SMI.Basetypes.Ranges(Range(1, 255))
class pycopia.SMI.Basetypes.TDomain(init=[], implied=False)[source]
class pycopia.SMI.Basetypes.TestAndIncr[source]
ranges = pycopia.SMI.Basetypes.Ranges(Range(0, 2147483647))
class pycopia.SMI.Basetypes.TimeInterval[source]
ranges = pycopia.SMI.Basetypes.Ranges(Range(0, 2147483647))
class pycopia.SMI.Basetypes.TimeStamp(val)[source]
class pycopia.SMI.Basetypes.TimeTicks(val)[source]

IMPLICIT INTEGER (0..4294967295)

class pycopia.SMI.Basetypes.TruthValue[source]
enumerations = [Enum(1, 'true'), Enum(2, 'false')]
class pycopia.SMI.Basetypes.Unsigned32(val)[source]

IMPLICIT INTEGER (0..4294967295)

class pycopia.SMI.Basetypes.VarBind(oid, value=None, Object=None)[source]
clear()[source]
get_oid()[source]
get_value()[source]
name
oid
set_value(value)[source]
value
class pycopia.SMI.Basetypes.VarBindList[source]
class pycopia.SMI.Basetypes.VariablePointer(init=[], implied=False)[source]
pycopia.SMI.Basetypes.ber(obj)[source]
pycopia.SMI.Basetypes.bits_factory(basename, enums)[source]
pycopia.SMI.Basetypes.check_encoding(obj)[source]
pycopia.SMI.Basetypes.combine_ipaddress(addr_part, mask_part)[source]

combine_ipaddress(addr_part, mask_part) Helper function that takes two SNMP IpAddress objects, the first containing the address, and the second that contains a mask value in the “address” attribute (as returned by an SNMP get in some tables).

pycopia.SMI.Basetypes.encode_length(l)[source]
pycopia.SMI.Basetypes.encode_length_long(l)[source]
class pycopia.SMI.Basetypes.endOfMibView[source]
pycopia.SMI.Basetypes.get_RequestId()[source]
pycopia.SMI.Basetypes.get_gauge(val)[source]

Return a Gauge32 constrained to the defined range.

class pycopia.SMI.Basetypes.noSuchInstance[source]
class pycopia.SMI.Basetypes.noSuchObject[source]
pycopia.SMI.Basetypes.oid(obj)[source]

Previous topic

Pycopia Process package

Next topic

Pycopia mibs package