def __init__(self, sensorNode): """\brief Initializes the class \param serialNode (\c SensorNode) A SensorNode object containing information to instantiate the class with """ self.__sensorNode = sensorNode self.__ipAddress = sensorNode.getInterfaces("infrastructure")[0].getIP() self.snmp = SNMP("private",self.__ipAddress,SNMP.SNMPv1)
def setCommunity(self, c): """\brief Sets the community and updates the snmp commands accordingly \param c (\c string) The community """ self.__community = c del self.snmp self.snmp = SNMP(self.__community, self.__ipAddress, SNMP.SNMPv1)
def __init__(self, switchNode, minimumVLANInternalID, maximumVLANInternalID, minimumInterfaceInternalID, maximumInterfaceInternalID): """\brief Initializes the class \param switchNode (\c SwitchNode) The SwitchNode object to obtain information from to initialize the class with \param macIDLength (\c int) The length of the id of an snmp result coming from a mac address query. The id is anything to the left of the equal sign, and its length is the number of dot-separated terms. """ if (switchNode.getInfrastructure() == "yes"): self.__ipAddress = switchNode.getInterfaces("infrastructure")[0].getIP() else: self.__ipAddress = switchNode.getInterfaces("management")[0].getIP() self.__switchName = switchNode.getNodeID() self.snmp = SNMP(switchNode.getSNMPwriteCommunity(),self.__ipAddress) # cache of static tables self.__refresh = True # reload self.__dot1dBasePortIfIndex = None self.__ifDescr = None self.__ifName = None self.__dot1qVlanStaticUntaggedPorts = None self.__dot1qVlanStaticEgressPorts = None self.__dot1qPvid = None self.__dot1qTpFdbPort = None self.__dot1qTpFdbStatus = None self.__dot1qVlanFdbId = None self.__dot1qVlanStaticName = None # ports self.__ports = {} self.refreshPortInfo() # vlans self.__vlans = {}
def Test2(): print "Testing getting temperature reading" s = SNMP("private", "192.168.1.9") res = s.get(SNMP.extremeCurrentTemperature) del s del res dump_garbage()
def __init__(self, switchNode, minimumVLANInternalID, maximumVLANInternalID, minimumInterfaceInternalID, maximumInterfaceInternalID): """\brief Initializes the class \param switchNode (\c SwitchNode) The SwitchNode object to obtain information from to initialize the class with \param minimumVLANInternalID (\c int) The minimum number for a vlan's internal id \param maximumVLANInternalID (\c int) The maximum number for a vlan's internal id \param minimumInterfaceInternalID (\c int) The minimum number for an interface's internal id \param maximumInterfaceInternalID (\c int) The maximum number for an interface's internal id """ Switch.__init__(self, switchNode, minimumVLANInternalID, maximumVLANInternalID, minimumInterfaceInternalID, maximumInterfaceInternalID) self.snmp = SNMP(self.getCommunity(), self.getIPAddress(), SNMP.SNMPv1)
def __init__(self, powerswitchNode): """\brief Initializes the class \param powerswitchNode (\c PowerswitchNode) A PowerswitchNode object containing information to instantiate the class with """ self.__powerswitchNode = powerswitchNode self.__community = powerswitchNode.getSNMPwriteCommunity() self.__powerswitchNodeID = powerswitchNode.getNodeID() self.__ipAddress = powerswitchNode.getInterfaces( "infrastructure")[0].getIP() self.__username = None self.__password = None if (powerswitchNode.getUsers() != None): self.__username = powerswitchNode.getUsers()[0].getUsername() self.__password = powerswitchNode.getUsers()[0].getPassword() self.snmp = SNMP(self.__community, self.__ipAddress, SNMP.SNMPv1)
def Test1(): print "Testing creation and deletion of one snmp object" s = SNMP("public", "192.168.1.2") del s dump_garbage()