pyhpecw7.features.portchannel module¶
Manage portchannels on HPCOM7 devices.
-
class
pyhpecw7.features.portchannel.
Portchannel
(device, groupid, pc_type)[source]¶ Bases:
object
This class is used to collect data or configure a specific portchannel.
Parameters: - device (HPCOM7) – connected instance of a
pyhpecw7.comware.HPCOM7
object. - groupid (str) – group # of the RAGG/BAGG interface
- pc_type (str) – must be “bridged” or “routed”
-
groupid
¶ group # of the RAGG/BAGG interface
Type: str
-
pc_type
¶ must be “bridged” or “routed”
Type: str
-
members_to_remove
¶ interface names to remove from the portchannel
Type: list
-
desired_lacp_mode
¶ set to “active” or “passive”. Should be set when
mode
is set to the value oflacp
inbuild_config
.Type: str
-
build
(stage=False, **portchannel)[source]¶ Stage or execute a config object to add/update portchannel
Parameters: - state (str) – must be “present” or “absent”
- portchannel – see Keyword Args
- stage (bool) – whether to stage the commands or execute immediately
Keyword Arguments: - members (list) – OPTIONAL - list of members by interface name being configured
- min_ports (str) – OPTIONAL - number that represents selected-port minimum
- max_ports (str) – OPTIONAL - number that represents selected-port maximum
- lacp_to_change (list) – OPTIONAL - list of interfaces that need have their lacp mode changed
Note
desired_lacp_mode
needs to be set for the members inportchannel['lacp_to_change']
to take effect.members_to_remove
can be set to remove members during the build process. This should also be a list of interface names.Returns: True if stage=True and successfully staged List of etree.Element XML responses if immediate execution
-
get_all_members
(list_type='name', asdict=False)[source]¶ Gets ports that are a member to any port channel
Parameters: - list_type (str) – must be “name” or “ifindex”
- asdict (bool) – determines if a dict should be returned this overrides list_type (see Returns)
Returns: - if asdict=True regardless of other Args, a dict
is returned that has interface names as keys and the group of the port-channel that is config’d on that interface as the key
- if list_type is name (default), a list of interface
names is returned. The names of interfaces that have any portchannel config’d.
- if list_type is set to “ifindex”, the list has all
ifindexes instead of names of interfaces that have a portchannel config’d.
if list_type is misconfigured, an error string is returned.
Return type: 1 of 4 objects can be returned based on input args
-
get_config
()[source]¶ Get current configuration for a given portchannel
Returns: This returns a dictionary that has the following k/v pairs if the portchannel exists: groupid (str): group ID of the portchannel ncgroupid (str): INTERNAL group ID used by the switch to differentiate between bridged, routed, and other types of LAGGs. Kept to assist in troubleshooting. mode (str): will be “static” or “dynamic” members (list): list of current members by interface name min_ports (str): number that represents selected-port minimum max_ports (str): number that represents selected-port maximum lacp_modes_by_interface (dict): list of dicts that have two key/value pairs. sample_dict=(interface=’FortyGigE1/0/1’, lacp_mode=’passive’) It returns an empty dictionary if the portchannel group does not exist.
-
get_index_from_interface
(interface)[source]¶ Get IfIndex from interface name
Parameters: interface (str) – name of the interface Returns: This returns the IfIndex for an interface.
-
get_lacp_mode_by_name
(name)[source]¶ Get current LACP mode for a given interface
Parameters: name (str) – full name of the interface Returns: “active” or “passive” Return type: mode (str)
-
get_portchannels
()[source]¶ Get a list of portchannel groups that exist on the switch
Returns: This returns a list of numbers represented as strings that are the portchannel groups that exist on the switch.
-
get_selected_port_max
()[source]¶ Get selected port max configuration
Returns: This returns the selected-port maximum configured value on the switch, else it returns None
-
get_selected_port_min
()[source]¶ Get selected port min configuration
Returns: This returns the selected-port minimum configured value on the switch, else it returns None
-
param_check
(**portchannel)[source]¶ Param validation for portchannel
Parameters: - state (str) – present or absent
- portchannel – see Keyword Args
Keyword Arguments: members (list) – members by interface name being configured
Raises: - InvalidPortType – when existing port type does not match desired type of portchannel
- AggregationGroupError – when an interface is already a member of a different portchannel than the one being configured.
- device (HPCOM7) – connected instance of a