Pycopia SNMP package

Provices SNMP protocol modules and manager objects.

SNMP package

Basic Pythonic SNMP code. There is a low-level interface that allows you to use raw OIDs in requests, and a high-level that uses object names defined in the MIB.

class pycopia.SNMP.SNMP.CommunityBasedMessage(community='public', pdu=None, version=1)[source]
add_oid(oid, value=None)[source]
add_varbind(varbind)[source]
get_VarBindList()
get_varbinds()[source]
set_community(community_string)[source]
set_pdu(pdu)[source]
class pycopia.SNMP.SNMP.CommunityBasedSession(sessiondata=None)[source]
get(*oids)[source]
get_varbindlist(vbl)[source]
getbulk(bulkpdu)[source]
getnext(*oids)[source]
inform(varbindlist)[source]
set(varbindlist)[source]

Where varbindlist is a VarBindList containing VarBind objects.

set_varbind(varbind)[source]
class pycopia.SNMP.SNMP.CommunityName(name, access=Enum(0, 'RO'))[source]
class pycopia.SNMP.SNMP.CommunitySet[source]
add_RO(community)[source]
add_RW(community)[source]
add_community(community, access=Enum(0, 'RO'))[source]
get_RO()[source]
get_RW()[source]
get_by_access(access_enum)[source]
class pycopia.SNMP.SNMP.Message[source]
class pycopia.SNMP.SNMP.Session(sessiondata=None)[source]
close()[source]

close UDP socket to SNMP agent

get(*args)[source]
get_table(rowobj, insert_cb)[source]
get_table_row(index, col_oids)[source]
get_table_with_bulk(rowobj, insert_cb)[source]
get_table_with_getnext(rowoid, insert_cb)[source]
getbulk(*args)[source]
getnext(*args)[source]
inform(*args)[source]
open(sessiondata=None)[source]

create a UDP socket to SNMP agent

set(*args)[source]
class pycopia.SNMP.SNMP.UserBasedMessage[source]
class pycopia.SNMP.SNMP.UserBasedSession(sessiondata)[source]
class pycopia.SNMP.SNMP.ViewBasedSession(sessiondata)[source]
pycopia.SNMP.SNMP.get_session(host, readcommunity, writecommunity=None, version=1)[source]
pycopia.SNMP.SNMP.new_session(sessiondata)[source]
class pycopia.SNMP.SNMP.sessionData(agent=None, communities=None, retries=3, timeout=10, polltime=20, port=161, version=1, user=None, context=None)[source]
add_community(cname, access=Enum(0, 'RO'))[source]
add_community_RW(cname)[source]
del_community(cname)[source]
get_community(access)[source]
get_community_RO()[source]
get_community_RW()[source]
get_default_community()[source]
new_communities(cset)[source]
set_default_community(access)[source]
class pycopia.SNMP.traps.TrapRecord(timestamp, ip, community, pdu)[source]

Holder for SNMP Traps.

pycopia.SNMP.traps.get_dispatcher(*handlers)[source]

Return a TrapDispatcher instance ready to respond to traps.

class pycopia.SNMP.Manager.InterfaceEntry(name, ifindex, adminstatus, mtu, address, speed, iftype)[source]
class pycopia.SNMP.Manager.InterfaceTable(hostname)[source]
add_entry(If)[source]
class pycopia.SNMP.Manager.Manager(sess)[source]

An instance of this object represents an SNMP management session, with this instance acting as a manager role. This Manager object has a one-to-one relation to a device agent.

This object maps MIB scalar objects to object attributes. You can get or set these in the normal Python syntax.

Usage: device = Manager( snmp_session )

add_mib(mibmodule, mangler=<function default_name_mangler at 0x5483668>, subclassmodule=None)[source]
add_mibs(miblist, mangler=<function default_name_mangler at 0x5483668>)[source]
close()[source]
create(rowname, *indexargs, **kwargs)[source]
create_wait(rowname, *indexargs, **kwargs)[source]
destroy(rowname, *indexargs)[source]
get(rowname, *indexargs)[source]
get_attributes()

get_scalar_names() returns a list of scalar attributes for the managed device.

get_interface(index)[source]
get_interface_table()[source]
get_iterator(name, indexoid=None, count=0)[source]
get_notification_names()[source]
get_row_names()[source]
get_scalar_names()[source]

returns a list of scalar attributes for the managed device.

get_scalars(*args)[source]
get_table(mangledname)[source]
get_table_names()
get_tables()
getall(tablename[, indexoid=False])[source]

Gets all of the rows of a table (given by name). If an (optional) oid fragment is given as a second argument, this is used to restrict the objects retrieved to that index value. If the row has multiple indexes, you must supply a value in the order that the index is listed in the MIB.

pycopia.SNMP.Manager.default_name_mangler(name)[source]
pycopia.SNMP.Manager.get_manager(device, community, manager_class=<class 'pycopia.SNMP.Manager.Manager'>, mibs=None)[source]

Devices

The Devices package contains pre-written device manager objects that encapsulate device specific functionality. This may include special methods unique to a device.

For example, the EtherSwitch module allows you to get a table of VLAN entries easily.

manager = EtherSwitch.get_manager(agent, community)
print manager.get_vlan_table()

There is also support for controlling power switches. New modules can be added as needed.

Modules

Generic ethernet bridge or switch.

class pycopia.Devices.EtherSwitch.BridgeManager(sess)[source]
get_vlan_table()[source]
class pycopia.Devices.EtherSwitch.VlanTable(manager=None)[source]
clear()[source]
update(manager)[source]
class pycopia.Devices.EtherSwitch.VlanTableEntry(vlan, maxif)[source]
pycopia.Devices.EtherSwitch.get_manager(device, community)[source]
pycopia.Devices.EtherSwitch.get_vlan_ports(vlan, maxif)[source]

Table Of Contents

Previous topic

Pycopia mibs package

Next topic

Pycopia storage package