# Ospf

Module for working with OSPF configuration in EOS

This module provides an API for creating/modifying/deleting OSPF configurations

class pyeapi.api.ospf.Ospf(*args, **kwargs)

  Bases: `Entity`

  The Ospf class implements global Ospf router configuration

  add_network(network, netmask, area=0)

    Adds a network to be advertised by OSPF

    Parameters:

      - network (str) – The network to be advertised in dotted decimal notation

      - netmask (str) – The netmask to configure

      - area (str) – The area the network belongs to. By default this value is 0

    Returns:

      True if the command completes successfully

    Return type:

      bool

    Exception:
      ValueError: This will get raised if network or netmask

        are not passed to the method

  add_redistribution(protocol, route_map_name=None)

    Adds a protocol redistribution to OSPF

    Parameters:

      - protocol (str) – protocol to redistribute

      - route_map_name (str) – route-map to be used to filter the protocols

    Returns:

      True if the command completes successfully

    Return type:

      bool

    Exception:
      ValueError: This will be raised if the protocol pass is not one

        of the following: [rip, bgp, static, connected]

  configure_ospf(cmd)

    Allows for a list of OSPF subcommands to be configured”

    Parameters:

      cmd – (list or str): Subcommand to be entered

    Returns:

      True if all the commands completed successfully

    Return type:

      bool

  create(ospf_process_id, vrf=None)

    Creates a OSPF process in the specified VRF or the default VRF.

    Parameters:

      - ospf_process_id (str) – The OSPF process Id value

      - vrf (str) – The VRF to apply this OSPF process to

    Returns:

      True if the command completed successfully

    Return type:

      bool

    Exception:
      ValueError: If the ospf_process_id passed in less

        than 0 or greater than 65536

  delete()

    Removes the entire ospf process from the running configuration

    Parameters:

      None –

    Returns:

      True if the command completed succssfully

    Return type:

      bool

  get(vrf=None)

    Returns the OSPF routing configuration

    Parameters:

      vrf (str) – VRF name to return OSPF routing config for

    Returns:

      keys:

        router_id (int): OSPF router-id

        vrf (str): VRF of the OSPF process networks (dict): All networks that are advertised in OSPF

        ospf_process_id (int): OSPF proc id

        redistribution (dict): All protocols that are configured to be redistributed in OSPF

        shutdown (bool): Gives the current shutdown off the process

    Return type:

      dict

  remove_network(network, netmask, area=0)

    Removes a network advertisment by OSPF

    Parameters:

      - network (str) – The network to be removed in dotted decimal notation

      - netmask (str) – The netmask to configure

      - area (str) – The area the network belongs to. By default this value is 0

    Returns:

      True if the command completes successfully

    Return type:

      bool

    Exception:
      ValueError: This will get raised if network or netmask

        are not passed to the method

  remove_redistribution(protocol)

    Removes a protocol redistribution to OSPF

    Parameters:

      - protocol (str) – protocol to redistribute

      - route_map_name (str) – route-map to be used to filter the protocols

    Returns:

      True if the command completes successfully

    Return type:

      bool

    Exception:
      ValueError: This will be raised if the protocol pass is not one

        of the following: [rip, bgp, static, connected]

  set_no_shutdown()

    Removes the shutdown property from the OSPF process

    Parameters:

      None –

    Returns:

      True if the commands are completed successfully

    Return type:

      bool

  set_router_id(value=None, default=False, disable=False)

    Controls the router id property for the OSPF Proccess

    Parameters:

      - value (str) – The router-id value

      - default (bool) – Controls the use of the default keyword

      - disable (bool) – Controls the use of the no keyword

    Returns:

      True if the commands are completed successfully

    Return type:

      bool

  set_shutdown()

    Shutdowns the OSPF process

    Parameters:

      None –

    Returns:

      True if the commands are completed successfully

    Return type:

      bool

pyeapi.api.ospf.instance(api)

  Returns an instance of Ospf