pyhpecw7.features.interface module

Manage interfaces on HPCOM7 devices.

class pyhpecw7.features.interface.Interface(device, interface_name)[source]

Bases: object

This class is used to get and build interface configurations on HPCOM7 devices.

Parameters:
  • device (HPCOM7) – connected instance of a phyp.comware.HPCOM7 object.
  • interface_name (str) – The name of the interface.
device

connected instance of a phyp.comware.HPCOM7 object.

Type:HPCOM7
interface_name

The name of the interface.

Type:str
iface_index

The device’s internal number representation of an interface.

Type:str
iface_type

The type of interface, for example: ‘LoopBack’, ‘FortyGigE’.

Type:str
is_ethernet

Whether the interface is ethernet.

Type:bool
is_routed

Whether the interface is in layer 3 mode. If this is False, the interface is either in bridged mode or does not exist.

Type:bool
iface_exists

Whether the interface exists. Physical interfaces should always exist. Logical interfaces may or may not exist.

Type:bool
build(stage=False, **params)[source]

Stage or execute the configuration to modify an interface.

Parameters:
  • stage (bool) – whether to stage the commands or execute immediately
  • **params – see Keyword Args.
Keyword Arguments:
 
  • admin (str) – The up/down state of the interface. ‘up’ or ‘down’.
  • speed (str) – The speed of the interface, in Mbps.
  • duplex (str) – The duplex of the interface. ‘full’, ‘half’, or ‘auto’.
  • description (str) – The textual description of the interface.
  • type (str) – Whether the interface is in layer 2 or layer 3 mode. ‘bridged’ or ‘routed’.
Raises:

InterfaceCreateError – if a logical interface cannot be created.

Returns:

True if stage=True and staging is successful etree.Element XML response if immediate execution

create_logical(stage=False)[source]

Stage or execute the configuration to create a logical interface.

Supported types include ‘LoopBack’, ‘Vlan-interface’, ‘Bridge-Aggregation’, and ‘Route-Aggregation’

Note

When stage=True, it’s the caller’s responsibility to call execute() on this class’s device object after this method is called.

Note

After execution, the caller must call update() on this class.

Returns:True if successful.
Raises:InterfaceCreateError – if the logical interface cannot be created.
default(stage=False)[source]

Stage or execute the configuration to default an interface.

stage (bool): whether to stage the commands or execute
immediately
Returns:True if stage=True and staging is successful etree.Element XML response if immediate execution
get_config()[source]

Return the currently configured parameters for the interface.

Returns:A dictionary of currently configured parameters for the interface, including:
admin (str):The up/down state of the interface. ‘up’ or ‘down’.
speed (str):The speed of the interface, in Mbps.
duplex (str):The duplex of the interface. ‘full’, ‘half’, or ‘auto’.
description (str):
 The textual description of the interface.
type (str):Whether the interface is in layer 2 or layer 3 mode. ‘bridged’ or ‘routed’.
get_default_config()[source]

Return the default configuration of an interface.

Returns:A dictionary of default interface configuration parameters, depending on the type of interface.

For example, for ethernet interfaces:

{
    'description': 'FortyGigE1/0/1 Interface',
    'admin': 'up',
    'speed': 'auto',
    'duplex': 'auto',
    'type': 'bridged'
}
param_check(**params)[source]

Checks given parameters against the interface for various errors.

Parameters:

**params – see Keyword Args

Keyword Arguments:
 
  • admin (str) – The up/down state of the interface. ‘up’ or ‘down’.
  • speed (str) – The speed of the interface, in Mbps.
  • duplex (str) – The duplex of the interface. ‘full’, ‘half’, or ‘auto’.
  • description (str) – The textual description of the interface.
  • type (str) – Whether the interface is in layer 2 or layer 3 mode. ‘bridged’ or ‘routed’.
Raises:
remove_logical(stage=False)[source]

Stage or execute the configuration to remove a logical interface.

Supported types include ‘LoopBack’, ‘Vlan-interface’, ‘Bridge-Aggregation’, and ‘Route-Aggregation’

Parameters:stage (bool) – whether to stage the commands or execute immediately

Note

It’s the caller’s responsibility to call execute() on this class’s device object after this method is called.

Returns:True if stage=True and staging is successful etree.Element XML response if immediate execution
Raises:InterfaceCreateError – if the logical interface cannot be removed.
update()[source]

Update self.iface_index and self.iface_exists.

Usually called after a logical interface is created.

Raises:InterfaceCreateError – if the interface hasn’t yet been successfully created.

Note

It is the responsibility of the caller to call update()` after staging (``create_logical()) and executing (execute() on this class’s device object) of commands to create an interface.