-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1316 from Emantor/topic/power-backend-poe-mib
labgrid/driver/power: add poe-mib backend
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" tested with Cisco CBS350, should be compatible with switches implementing the PoE administration MiB""" | ||
|
||
from ..exception import ExecutionError | ||
from ...util.snmp import SimpleSNMP | ||
|
||
OID = "1.3.6.1.2.1.105.1.1.1.3.1" | ||
|
||
def power_set(host, port, index, value): | ||
_snmp = SimpleSNMP(host, 'private', port=port) | ||
outlet_control_oid = "{}.{}".format(OID, index) | ||
|
||
oid_value = "1" if value else "2" | ||
|
||
_snmp.set(outlet_control_oid, oid_value) | ||
|
||
def power_get(host, port, index): | ||
_snmp = SimpleSNMP(host, 'private', port=port) | ||
output_status_oid = "{}.{}".format(OID, index) | ||
|
||
value = _snmp.get(output_status_oid) | ||
|
||
if value == 1: # On | ||
return True | ||
if value == 2: # Off | ||
return False | ||
|
||
raise ExecutionError("failed to get SNMP value") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters