Skip to content
Open
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
20 changes: 20 additions & 0 deletions lib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def showPortStatus(self):
first_row = ['Interface', 'Admin Mode', 'Physical Type', 'Port Status', 'Physical Mode', 'Link Speed', 'MTU']
showStatus(self._httpGet('port_status'), first_row)

def showPoeStatus(self):
first_row = ['Interface', 'Admin Mode', 'Priority', 'Schedule', 'High Power Mode', 'Power Detect Type', 'Power Limit Type', 'Status', 'Fault Status']
showStatus(self._httpGet('poe_status'), first_row)

def showPortChannel(self):
first_row = ['Interface', 'Name', 'Type', 'Admin Mode', 'Link Status', 'Members', 'Active Ports']
showStatus(self._httpGet('port_channel'), first_row)
Expand Down Expand Up @@ -347,6 +351,20 @@ def setPortStatus(self, interface, status):
}
self._httpPost('set_port_status', post_data)

def setPoeStatus(self, interface, status):
post_data = {
'admin_mode_sel[]': status, # enabled, disabled
'schedule_sel[]': 'none', # none, 1, 2
'priority_sel[]': 'low', # critical, high, low
'high_power_mode_sel[]': 'disable', # dot3at, disable
'power_detect_type_sel[]': '4pt_dot3af', # 4pt_dot3af, 4pt_dot3af_leg
'power_limit_type_sel[]': 'dot3af', # dot3af, user
'power_limit': '', # 3-15.4
'intfStr': interface,
'b_modal1_clicked': 'b_modal1_submit'
}
self._httpPost('set_port_status', post_data)

def setPortChannel(self, channel_id, interface_id_str, admin_mode, stp_mode, static_mode, clear = False):
interface_ids = parseIds(interface_id_str)
not_interface_ids = [i for i in range(1, 8 + 1) if i not in interface_ids]
Expand Down Expand Up @@ -481,12 +499,14 @@ def _ping_ajax(self, handle_val, host_name_ipaddr):
'port_channel': '/htdocs/pages/switching/port_channel_summary.lsp',
'all_config': '/htdocs/pages/base/support.lsp',
'port_status': '/htdocs/pages/base/port_summary.lsp?tg=switch_port_config&showtab=1',
'poe_status': '/htdocs/pages/base/poe_port_cfg.lsp',
'vlan_status': '/htdocs/pages/switching/vlan_status.lsp',
'port_statistic': '/htdocs/pages/base/port_summary_stats.lsp',
'add_vlan': '/htdocs/pages/switching/vlan_status_modal.lsp',
'del_vlan': '/htdocs/pages/switching/vlan_status.lsp',
'access_vlan': '/htdocs/pages/switching/vlan_per_port_modal.lsp',
'set_port_status': '/htdocs/pages/base/port_summary_modal.lsp',
'set_poe_status': '/htdocs/pages/base/poe_port_cfg_modal.lsp',
'set_sysinfo': '/htdocs/pages/base/dashboard.lsp',
'set_port_channel': '/htdocs/pages/switching/port_channel_modal.lsp',
'set_network': '/htdocs/pages/base/network_ipv4_cfg.lsp',
Expand Down
12 changes: 12 additions & 0 deletions lib/hpshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def do_showint(self, args):
"""Show interfaces status."""
cli.showPortStatus()

def do_showpoe(self, args):
"""Show POE status."""
cli.showPoeStatus()

def do_showportchannel(self, args):
"""Show port channel information."""
cli.showPortChannel()
Expand Down Expand Up @@ -157,6 +161,14 @@ def do_setportstatus(self, args):
mode = input("enable or disable a port(e/d)?")
cli.setPortStatus(input("Interfaces(1-8), TRK1-4 (54-57)?"), available_mode[mode])

def do_setpoestatus(self, args):
"""Enable or disable POE."""
available_mode = {'e':'enabled', 'd':'disabled'}
mode = input("enable or disable POE on a port (e/d)?")
while mode not in available_mode:
mode = input("enable or disable POE on a port (e/d)?")
cli.setPoeStatus(input("Interfaces(1-12)?"), available_mode[mode])

def do_ping(self, args):
"""Ping an IP through the switch"""
ipAddr, count, interval, size = input("IP address: "), input("Count (1-15): "), input("Interval (1-60 Seconds): "), input("Size (0-13000Bytes): ")
Expand Down