NAME
App::Netdisco::Util::Port
DESCRIPTION
A set of helper subroutines to support parts of the Netdisco application.
There are no default exports, however the :all tag will export all subroutines.
EXPORT_OK
port_acl_by_role_check( $port, $device?, $user? )
Permission check on
portctl_by_roleif the device and user are provided. A bare username will be promoted to a user instance.A user may hold several roles and is permitted what any one of them permits. A role which is not defined grants nothing, and a user whose roles are all undefined is refused.
Will return false if these checks fail, otherwise true.
port_acl_check( $port, $device?, $user? )
Permission check that
portctl_noandportctl_onlypass for the device.
Will return false if these checks fail, otherwise true.
port_acl_service( $port, $device?, $user? )
Checks if admin up/down or PoE status on a port can be changed.
Returns false if the request should be denied, true if OK to proceed.
First checks portctl_nameonly, portctl_uplinks, portctl_nowaps, and portctl_nophones.
Then checks according to port_acl_check and port_acl_by_role_check above.
port_acl_pvid( $port, $device?, $user? )
Checks if native vlan (pvid) on a port can be changed.
Returns false if the request should be denied, true if OK to proceed.
First checks portctl_native_vlan;
Then checks according to port_acl_service.
device_acl_by_role_check( $device, $user? )
Permission check on portctl_by_role for a change which belongs to the device rather than to one of its ports, such as its location or contact.
A role ACL naming devices and ports is matched on the device alone, because there is no port to match. This is the same decision the device details view makes when it chooses whether to render an editable cell.
As for ports, a user holding several roles is permitted what any one permits.
Returns false if the request should be denied, true if OK to proceed.
port_acl_name( $port, $device?, $user? )
Checks if name (description) on a port can be changed.
Returns false if the request should be denied, true if OK to proceed.
Only setting portctl_by_role is checked.
get_port( $device, $portname )
Given a device IP address and a port name, returns a DBIx::Class::Row object for the Port on the Device in the Netdisco database.
The device IP can also be passed as a Device DBIx::Class object.
Returns undef if the device or port are not known to Netdisco.
Returns ($device_instance, $port_instance) in list context, otherwise just $port_instance.
get_iid( $info, $port )
Given an SNMP::Info instance for a device, and the name of a port, returns the current interface table index for that port. This can be used in further SNMP requests on attributes of the port.
Returns undef if there is no such port name on the device.
get_powerid( $info, $port )
Given an SNMP::Info instance for a device, and the name of a port, returns the current PoE table index for the port. This can be used in further SNMP requests on PoE attributes of the port.
Returns undef if there is no such port name on the device.
is_vlan_subinterface( $port )
Returns true if the $port DBIx::Class object represents a vlan subinterface or is the logical parent of such a port.
This uses simple checks on the port type and descr, and therefore might sometimes returns a false-negative result.
port_has_phone( $port )
Returns true if the $port DBIx::Class object has a phone connected.
port_has_wap( $port )
Returns true if the $port DBIx::Class object has a wireless AP connected.
to_speed( $speed )
Incorporate SNMP::Info munge_highspeed to avoid extra dependency on web frontend.