How to use the pyeapi.api.Entity function in pyeapi

To help you get started, we’ve selected a few pyeapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arista-eosplus / pyeapi / pyeapi / api / stp.py View on Github external
Interface Parameters:
    name (string): The name of the interface the STP configuration is in
        reference to.  The interface name is the full interface identifier

    portfast (string): The portfast configuration value for the interface.
        Accepted values are 'edge', 'network', or 'disabled'

    bpduguard (boolean): True if the BPDU Guard feature is enabled on the
        interface or False if it is disabled
"""

import re

from pyeapi.api import Entity, EntityCollection

class Stp(Entity):
    """The Stp class implements global configuration for spanning-tree

    The spanning-tree protocol provides both global and interface
    configuration options.  This class is the top-level class that provides
    access to all spanning-tree configuration options supported.

    Example:
        The below example demonstrates how to use the STP class to work
        with both global configuration and interface configuration.

        >>> import pyeapi.resources.stp
        >>> stp = pyeapi.resources.stp.instance(node)
        >>> stp.set_mode('mstp')
        True
        >>> stp.interfaces.set_bpduguard('Ethernet1', True)
        True
github arista-eosplus / pyeapi / pyeapi / api / ntp.py View on Github external
#
"""Module for managing the NTP configuration in EOS

This module provides an API for configuring NTP resources using
EOS and eAPI.

Arguments:
    name (string): The interface port that specifies the NTP source.
"""

import re

from pyeapi.api import Entity


class Ntp(Entity):
    """The Ntp class implements global NTP router configuration
    """

    def __init__(self, *args, **kwargs):
        super(Ntp, self).__init__(*args, **kwargs)

    def get(self):
        """Returns the current NTP configuration

        The Ntp resource returns the following:

            * source_interface (str): The interface port that specifies
                                      NTP server
            * servers (list): A list of the NTP servers that have been
                              assigned to the node. Each entry in the
                              list is a key/value pair of the name of
github arista-eosplus / pyeapi / pyeapi / api / ospf.py View on Github external
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
"""Module for working with OSPF configuration in EOS

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

"""

import re
from pyeapi.api import Entity
from pyeapi.utils import make_iterable

class Ospf(Entity):
    """ The Ospf class implements global Ospf router configuration
    """

    def __init__(self, *args, **kwargs):
        super(Ospf, self).__init__(*args, **kwargs)
        pass

    def get(self):
        """Returns the OSPF routing configuration

           Args:
                None
           Returns:
               dict:
                    keys: router_id (int): OSPF router-id
                          networks (dict): All networks that
github arista-eosplus / pyeapi / pyeapi / api / system.py View on Github external
in EOS.   It provides the following class implementations:

    * System -- Configures global system settings

System Attributes:
    hostname (string): The hostname of the node as configured in the
        running-configuration.

"""

import re

from pyeapi.api import Entity


class System(Entity):
    """The System class implements global config for the node

    Global configuration settings include those thaat identify the node
    and provide node level configuration such as hostname
    """

    def get(self):
        """Returns the system configuration abstraction

        The System resource returns the following:

            * hostname (str): The hostname value

        Returns:
            dict: Represents the node's system configuration
        """
github arista-eosplus / pyeapi / pyeapi / api / mlag.py View on Github external
shutdown (bool): The administrative state of the global MLAG process.

Interface Parameters:
    mlag_id (str): The interface mlag parameter parsed from the nodes
        interface configuration.  Valid values for the mlag id are in
        the range of 1 to 2000

"""

import re

from pyeapi.api import Entity


class Mlag(Entity):
    """The Mlag class provides management of the MLAG configuration

    The Mlag class is derived from Entity and provides an API for working
    with the nodes MLAG configuraiton.
    """

    def get(self):
        """Returns the Mlag configuration as a resource dict

        Returns:
            dict: A dict ojbect containing the Mlag resource attributes.
        """
        resource = dict()
        resource.update(self._parse_config())
        resource.update(self._parse_interfaces())
github arista-eosplus / pyeapi / pyeapi / api / bgp.py View on Github external
"""API module for Bgp
"""

import re

from collections import namedtuple

import netaddr

from pyeapi.api import Entity, EntityCollection
from pyeapi.utils import make_iterable

Network = namedtuple('Network', 'prefix length route_map')


class Bgp(Entity):
    """The Bgp class implements global BGP router configuration
    """

    def __init__(self, *args, **kwargs):
        super(Bgp, self).__init__(*args, **kwargs)
        self._neighbors = None

    @property
    def neighbors(self):
        if self._neighbors is not None:
            return self._neighbors
        self._neighbors = BgpNeighbors(self.node)
        return self._neighbors

    def get(self):
        """Returns the bgp routing configuration as a dict object