Use the OSPFSession module to configure the OSPF feature.

The OSPFSession Module contains two classes:

  • OSPFSession Class
  • OSPFInterface Class

Note: The OSPFInterface class is an attribute of the OSPFSession class. To use the OSPFInterface class, you must have an instance of the OSPFSession class.

OSPFSession Class

class OSPFSession(cisco.feature.Feature)

Example:
>>> from cisco.ospf import *
>>> ospf_session = OSPFSession('39')

cfg_distance

Configures an administrative distance for the OSPFv2 instance.

cfg_distance(self, dist, **kwargs)

Example:
>>> ospf_session.cfg_distance(100)
True

Arguments:

  • dist: Distance for OSPF routes, an integer ranging from 1 to 255.

Optional Arguments:

  • no: Set to True to set distances back to the default values.

Returns: True on success

cfg_maximum_paths

Configures the maximum number of parallel routes the OSPF can support.

cfg_maximum_paths(self, max, **kwargs)

Example:
>>> ospf_session.cfg_maximum_paths(64)
True

Arguments:

  • max: Maximum number of parallel routes that an IP routing protocol installs in a routing table. The range is from 1 to 64.

Optional Arguments:

  • no: Set to True to restore the default number of parallel routes.

Returns: True on success

cfg_router_id

Specifies the IP address to use as the router ID.

cfg_router_id(self, router_id, **kwargs)

Example:
>>> ospf_session.cfg_router_id("1.1.1.1")
True

Arguments:

  • router_id: A string in dotted quad format ('A.B.C.D') representing the IP Address of the router.

Optional Arguments:

  • no: A boolean, set to True to remove the router-id.

Returns: True on success

enable

Starts OSPF. Inherited from cisco.feature.Feature

enable(self, **kwargs)

Example:
>>> ospf_session.enable()
True

Arguments:

  • no: if True, stops the tacacs

Returns: True on success

disable

Disables OSPF. Inherited from cisco.feature.Feature

disable(self)

Example:
>>> ospf_session.disable()
True

Arguments: none

Returns: True on success

is_enabled

Reports whether OSPF is enabled. Inherited from cisco.feature.Feature

is_enabled(self)

Example:
>>> ospf_session.is_enabled()
False

Arguments: none

Returns: True if the feature is enabled.

is_shutdown

Checks if the OSPF routing process is shut down.

is_shutdown(self)

Example:
>>> ospf_session.is_shutdown()        
False

Arguments: None

Returns:

  • True if the OSPF process is enabled and shutdown.
  • False if the OSPF process is running or if OSPF is not enabled.

log_adjacency_changes

Logs a message for an up or down event on a neighbor.

log_adjacency_changes(self, **kwargs)

Example:
>>> ospf_session.log_adjacency_changes()
True

Optional Arguments:

  • no: A boolean, set to True to disable this feature.

Returns: True on success

name

Reports feature name, as used in "config terminal". Inherited from cisco.feature.Feature

name(self)

Example:
>>> ospf_session.name()
'ospf'

Arguments: none

Returns: Feature name, as used in "config terminal".

set_vrf

Sets the VRF context for subsequent API calls on a specified VRF object. Any configuration done on this OSPFSession object will be applied to this VRF.

set_vrf(self, vrf)

Example:
>>> ospf_session.set_vrf(12)
True

Arguments:

  • vrf: VRF name (string) or the VRF ID (int).

Returns: True on success

show_name

Reports feature name, as seen in "show feature". Inherited from cisco.feature.Feature

show_name(self)

Example:
>>> ospf_session.show_name()
'ospf'

Arguments: none

Returns: Feature name, as seen in "show feature".

shutdown

Shuts down the OSPF routing process. All existing OSPF configurations will be preserved.

shutdown(self)

Example:
>>> ospf_session.shutdown()
True

Arguments: None

Returns: True on success

start

start(self)

Example:
>>> ospf_session.start()
True

Arguments: None

Returns: True on success

state

Reports the state of one or all OSPF instances. Inherited from cisco.feature.Feature

state(self, instance=0)

Example:
>>> ospf_session.state(11)
'disabled'
>>> ospf_session.state()
{'11': 'disabled', '10': 'disabled', '13': 'disabled', '12': 'disabled', '15': 'disabled', '14': 'disabled', '16': 'disabled', '1': 'disabled', '3': 'disabled', '2': 'disabled', '5': 'disabled', '4': 'disabled', '7': 'disabled', '6': 'disabled', '9': 'disabled', '8': 'disabled'}

Optional Arguments:

  • instance: The instance of OSPF

Returns: state (or states if multiple instances) of feature

OSPFInterface Class

class OSPFInterface(object)

Example:
>>> import cisco
>>> from cisco.ospf import *
>>> ospf_session = OSPFSession('39')
>>> ospf_interface = ospf_session.OSPFInterface('Ethernet1/12', '20')   

Note: The OSPFInterface class is an attribute of the OSPFSession class. To use the OSPFInterface class, you must have an instance of the OSPFSession class.

add

Adds this interface to OSPFv2 instance and area.

add(self)

Example:
>>> ospf_interface.add()
True

Arguments: None.

Returns: True on success

cfg_dead_interval

Configures OSPFv2 dead interval for this interface.

cfg_dead_interval(self, dead_interval=60, **kwargs)

Example:
>>> ospf_interface.cfg_dead_interval(100)
True

Arguments:

  • dead_interval: The interval in seconds during which at least one hello packet must be received from a neighbor before the router declares that neighbor as down. Acceptable Range 1 to 65535.

Optional Arguments:

  • no: A boolean, set to True to remove the OSPF dead interval configuration.

Returns: True on success

cfg_hello_interval

Configures OSPFv2 hello interval for this interface.

cfg_hello_interval(self, hello_interval=60, **kwargs)

Example:
>>> ospf_interface.cfg_hello_interval(100)
True

Arguments:

  • hello_interval: The interval in seconds for sending hello packets to neighbors. The range is 1 to 65535 seconds.

Optional Arguments:

  • no: A boolean, set to True to remove the OSPF hello interval configuration.

Returns: True on success

cfg_mtu_ignore

Configures OSPFv2 to ignore any IP MTU mismatch with a neighbor.

cfg_mtu_ignore(self, **kwargs)

Example:
>>> ospf_interface.cfg_mtu_ignore()
True

Arguments: None

Optional Arguments:

  • no: A boolean, set to True to remove the OSPF mtu-ignore configuration.

Returns: True on success

cfg_ospf_cost

Configures OSPFv2 cost for this interface.

cfg_ospf_cost(self, ospf_cost=60, **kwargs)

Example:
>>> ospf_interface.cfg_ospf_cost(100)
True

Arguments:

  • cost: The link-state metric. The range 1 to 65535.

Optional Arguments:

  • no: A boolean, set to True to remove the OSPF cost configuration.

Returns: True on success

cfg_ospf_priority

Configures OSPFv2 priority for this interface. Priority is used to determine DR election in area.

cfg_ospf_priority(self, ospf_priority=60, **kwargs)

Example:
>>> ospf_interface.cfg_ospf_priority(100)
True

Arguments:

  • ospf_priority: The priority of the router. The range is from 0 to 255.

Optional Arguments:

  • no: A boolean, set to True to remove the OSPF priority configuration.

Returns: True on success

cfg_passive_interface

Suppresses OSPF routing updates on this interface.

cfg_passive_interface(self, **kwargs)

Example:
>>> ospf_interface.cfg_passive_interface()
True

Arguments: None

Optional Arguments:

  • no: A boolean, set to True to remove the OSPF passive-interface configuration.

Returns: True on success

shutdown

Shuts down the OSPF on this interface. All existing OSPF configurations will be preserved.

shutdown(self, **kwargs)

Example:
>>> ospf_interface.shutdown()
True

Arguments: None

Optional Arguments:

  • no: A boolean, set to True to remove the OSPF shutdown configuration.

Returns: True on success