Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exclude =
socs/mibs/MBG-SNMP-LTNG-MIB.py,
socs/mibs/SNMPv2-MIB.py,
socs/mibs/MBG-SNMP-ROOT-MIB.py,
socs/mibs/IBOOTBAR-MIB.py,
socs/mibs/IBOOTPDU-MIB.py,
socs/mibs/UPS-MIB.py,
socs/mibs/MBG-SYNCBOX-N2X-MIB.py,
Expand Down
25 changes: 19 additions & 6 deletions docs/agents/ibootbar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
iBootbar Agent
====================

The iBootbar Agent is an OCS Agent which monitors and sends commands to the iBoot PDU.
Monitoring and commanding is performed via SNMP.
The iBootbar Agent is an OCS Agent which monitors and sends commands to the dataprobe
iBoot PDU or iBoot Bar. iBoot Bar is an older device. Monitoring and commanding is
performed via SNMP.

.. argparse::
:filename: ../socs/agents/ibootbar/agent.py
Expand All @@ -25,17 +26,29 @@ OCS Site Config

To configure the iBootbar Agent we need to add a ibootbarAgent
block to our ocs configuration file. Here is an example configuration block
using all of the available arguments::
for IBoot PDU using all of the available arguments::

{'agent-class': 'ibootbarAgent',
'instance-id': 'ibootbar',
'arguments': [['--address', '10.10.10.50'],
['--port', 161],
['--mode', 'acq'],
['--ibootbar-type', 'IBOOTPDU'],
['--snmp-version', 2]]},

Here is an example configuration block for IBoot Bar using all of the available
arguments::

{'agent-class': 'ibootbarAgent',
'instance-id': 'ibootbar',
'arguments': [['--address', '10.10.10.50'],
['--port', 161],
['--mode', 'acq'],
['--ibootbar-type', 'IBOOTBAR'],
['--snmp-version', 1]]},

.. note::
The ``--address`` argument should be the address of the iBoot PDU on the network.
The ``--address`` argument should be the address of the iBootbar on the network.

Docker Compose
``````````````
Expand All @@ -61,8 +74,8 @@ debugging. The default level is "info".
Description
-----------

The iBootbar, or iBoot PDU, will be used to power various components on the SO
site. The iBootbar Agent allows the monitoring and commanding of the iBoot PDU.
The iBootbar will be used to power various components on the SO site.
The iBootbar Agent allows the monitoring and commanding of the iBoot PDU.
It monitors the state of each outlet, can set the state of each outlet, can
cycle each outlet, and reboot the system. The iBootbar has an Simple Network
Management Protocol (SNMP) interface.
Expand Down
33 changes: 27 additions & 6 deletions socs/agents/ibootbar/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ class ibootbarAgent:
Address of the ibootbar.
port : int
SNMP port to issue GETs to, default to 161.
ibootbar_type : str
Type of dataprobe ibootbar (IBOOTPDU or IBOOTBAR), defaults to
IBOOTPDU.
version : int
SNMP version for communication (1, 2, or 3), defaults to 2.
lock_outlet : list of ints
Expand All @@ -180,7 +183,8 @@ class ibootbarAgent:
txaio logger object, created by the OCSAgent
"""

def __init__(self, agent, address, port=161, version=2, lock_outlet=None):
def __init__(self, agent, address, port=161, ibootbar_type='IBOOTPDU',
version=2, lock_outlet=None):
self.agent = agent
self.is_streaming = False
self.log = self.agent.log
Expand All @@ -196,6 +200,7 @@ def __init__(self, agent, address, port=161, version=2, lock_outlet=None):
self.outlet_locked[i] = False

self.log.info(f'Using SNMP version {version}.')
self.ibootbar_type = ibootbar_type
self.version = version
self.address = address
self.snmp = SNMPTwister(address, port)
Expand Down Expand Up @@ -264,8 +269,8 @@ def acq(self, session, params=None):

# Create the lists of OIDs to send get commands
for i in range(8):
get_list.append(('IBOOTPDU-MIB', 'outletStatus', i))
name_list.append(('IBOOTPDU-MIB', 'outletName', i))
get_list.append((self.ibootbar_type + '-MIB', 'outletStatus', i))
name_list.append((self.ibootbar_type + '-MIB', 'outletName', i))

# Issue SNMP GET commands
get_result = yield self.snmp.get(get_list, self.version)
Expand Down Expand Up @@ -350,7 +355,10 @@ def set_outlet(self, session, params=None):
state = 0

# Issue SNMP SET command to given outlet
outlet = [('IBOOTPDU-MIB', 'outletControl', outlet_id)]
if self.ibootbar_type == 'IBOOTPDU':
outlet = [('IBOOTPDU-MIB', 'outletControl', outlet_id)]
elif self.ibootbar_type == 'IBOOTBAR':
outlet = [('IBOOTBAR-MIB', 'outletCommand', outlet_id)]
setcmd = yield self.snmp.set(outlet, self.version, state)
self.log.info('{}'.format(setcmd))

Expand Down Expand Up @@ -385,12 +393,18 @@ def cycle_outlet(self, session, params=None):
return False, 'Outlet {} is locked. Cannot cycle outlet.'.format(params['outlet'])

# Issue SNMP SET command for cycle time
set_cycle = [('IBOOTPDU-MIB', 'outletCycleTime', outlet_id)]
if self.ibootbar_type == 'IBOOTPDU':
set_cycle = [('IBOOTPDU-MIB', 'outletCycleTime', outlet_id)]
elif self.ibootbar_type == 'IBOOTBAR':
set_cycle = [('IBOOTBAR-MIB', 'cycleTime', outlet_id)]
setcmd1 = yield self.snmp.set(set_cycle, self.version, params['cycle_time'])
self.log.info('{}'.format(setcmd1))

# Issue SNMP SET command to given outlet
outlet = [('IBOOTPDU-MIB', 'outletControl', outlet_id)]
if self.ibootbar_type == 'IBOOTPDU':
outlet = [('IBOOTPDU-MIB', 'outletControl', outlet_id)]
elif self.ibootbar_type == 'IBOOTBAR':
outlet = [('IBOOTBAR-MIB', 'outletCommand', outlet_id)]
setcmd2 = yield self.snmp.set(outlet, self.version, 2)
self.log.info('{}'.format(setcmd2))
self.log.info('Cycling outlet {} for {} seconds'.
Expand All @@ -414,6 +428,9 @@ def set_initial_state(self, session, params=None):
Performs a software reboot. The outlets are then set to their
respective initial states. This takes about 30 seconds.
"""
if self.ibootbar_type == 'IBOOTBAR':
return False, 'Software reboot is not supported for IBOOTBAR type devices.'

with self.lock.acquire_timeout(3, job='reboot') as acquired:
if not acquired:
return False, "Could not acquire lock"
Expand Down Expand Up @@ -468,6 +485,9 @@ def add_agent_args(parser=None):
pgroup.add_argument("--address", help="Address to listen to.")
pgroup.add_argument("--port", default=161,
help="Port to listen on.")
pgroup.add_argument("--ibootbar-type", default='IBOOTPDU',
choices=['IBOOTPDU', 'IBOOTBAR'],
help='Type of dataprobe ibootbar')
pgroup.add_argument("--snmp-version", default='2', choices=['1', '2', '3'],
help="SNMP version for communication. Must match "
+ "configuration on the ibootbar.")
Expand Down Expand Up @@ -496,6 +516,7 @@ def main(args=None):
p = ibootbarAgent(agent,
address=args.address,
port=int(args.port),
ibootbar_type=args.ibootbar_type,
version=int(args.snmp_version),
lock_outlet=args.lock_outlet)

Expand Down
Loading