How to use the genie.decorator.managedattribute function in genie

To help you get started, we’ve selected a few genie 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 CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / ospf / gracefulrestart.py View on Github external
# ==========================================================================
    #                           MANAGED ATTRIBUTES
    # ==========================================================================

    # +- DeviceAttributes
    #   +- VrfAttributes

    # gr_enable
    gr_enable = managedattribute(
        name='gr_enable',
        default=None,
        type=(None, managedattribute.test_istype(bool)))

    # gr_type
    gr_type = managedattribute(
        name='gr_type',
        default=GR_TYPE.ietf,
        type=(None, GR_TYPE))

    # gr_helper_enable
    gr_helper_enable = managedattribute(
        name='gr_helper_enable',
        default=None,
        type=(None, managedattribute.test_istype(bool)))

    # gr_restart_interval
    gr_restart_interval = managedattribute(
        name='gr_restart_interval',
        default=None,
        type=(None, managedattribute.test_istype(int)))
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / pim / pim.py View on Github external
from genie.abstract import Lookup

from genie.ops.base import Context
from genie.ops.base import Base as ops_Base

from genie.libs import parser


class Pim(Routing, DeviceFeature, InterfaceFeature):

    address_families = managedattribute(
        name='address_families',
        finit=typedset(AddressFamily, {AddressFamily.ipv4}).copy,
        type=typedset(AddressFamily)._from_iterable)

    sparse = managedattribute(
        name='sparse',
        default=None,
        type=(None, managedattribute.test_istype(bool)))

    rp_address = managedattribute(
        name='rp_address',
        default=None,
        type=(None, IPv4Address, IPv6Address))

    # ==================== NXOS specific ====================

    # feature pim
    # feature pim6
    enabled = managedattribute(
        name='enabled',
        default=False,
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / lisp / lisp.py View on Github external
# etr_dyn_eid_weight
    etr_dyn_eid_weight = managedattribute(
        name='etr_dyn_eid_weight',
        default=None,
        type=(None, managedattribute.test_istype(int)))

    # ==========================================================================
    # +- DeviceAttributes
    #   +- RouterInstanceAttributes
    #     +- InstanceAttributes
    #       +- ServiceAttributes
    # ==========================================================================

    # etr_eid_vrf
    etr_eid_vrf = managedattribute(
        name='etr_eid_vrf',
        default=None,
        type=(None, managedattribute.test_istype(str)))

    # ==========================================================================
    # +- DeviceAttributes
    #   +- RouterInstanceAttributes
    #     +- InstanceAttributes
    #       +- ServiceAttributes
    #         +- DbMappingAttributes
    # ==========================================================================

    # etr_eid_rlocs
    etr_eid_rlocs = managedattribute(
        name='etr_eid_rlocs',
        default=None,
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / rsvp / rsvp.py View on Github external
type=(None, managedattribute.test_istype(bool)))

    log_events_nsr = managedattribute(
        name='log_events_nsr',
        default=None,
        type=(None, managedattribute.test_istype(bool)))

    sig_checksum = managedattribute(
        name='sig_checksum',
        default=None,
        type=(None, managedattribute.test_istype(bool)))

    sig_event_per_pulse = managedattribute(
        name='sig_event_per_pulse',
        default=None,
        type=(None, managedattribute.test_istype(int)))

    sig_gr = managedattribute(
        name='sig_gr',
        default=None,
        type=(None, managedattribute.test_istype(bool)))

    sig_gr_mode = managedattribute(
        name='sig_gr_mode',
        default='full',
        type=(None, managedattribute.test_istype(str)))

    sig_gr_recov_time = managedattribute(
        name='sig_gr_recov_time',
        default=None,
        type=(None, managedattribute.test_istype(int)))
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / route_policy / route_policy.py View on Github external
sb = str(vb)
        return any(
            fnmatch.fnmatchcase(sb, a)
            if isinstance(a , str)
            else vb == a)

    op = managedattribute(
        name='op',
        type=managedattribute.test_in((
            op_contains,
            op_matches_any,
        )))

    operands = managedattribute(
        name='operands',
        type=managedattribute.test_tuple_of(_identity))

    if_attr = managedattribute(
        name='if_attr',
        finit=RoutePolicyAttributes,
        type=managedattribute.test_istype(RoutePolicyAttributes))

    else_attr = managedattribute(
        name='else_attr',
        finit=RoutePolicyAttributes,
        type=managedattribute.test_istype(RoutePolicyAttributes))

    def __init__(self, op, *operands):
        self.op = op
        self.operands = operands
        super().__init__()
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / bgp / bgp.py View on Github external
        @property
        def remove_neighbor(self):
            return self.vrf_attr[None].remove_neighbor

        @property
        def address_family_attr(self):
            return self.vrf_attr[None].address_family_attr

        @property
        def neighbor_attr(self):
            return self.vrf_attr[None].neighbor_attr

        def __init__(self, parent, key):
            super().__init__(parent, key)

    device_attr = managedattribute(
        name='device_attr',
        read_only=True,
        doc=DeviceAttributes.__doc__)

    @device_attr.initter
    def device_attr(self):
        return SubAttributesDict(self.DeviceAttributes, parent=self)

    def __init__(self, asn=None, bgp_id=None, instance_name=None, *args, **kwargs):
        if asn:
            self.asn = asn
        if bgp_id:
            self.bgp_id = int(bgp_id)
        if instance_name:
            self.instance_name = instance_name
        # Make sure at least one was populated:
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / rsvp / rsvp.py View on Github external
sig_hello_gr_refresh_misses = managedattribute(
        name='sig_hello_gr_refresh_misses',
        default=None,
        type=(None, managedattribute.test_istype(int)))

    sig_message_bundle = managedattribute(
        name='sig_message_bundle',
        default=None,
        type=(None, managedattribute.test_istype(bool)))

    sig_outofband_vrf = managedattribute(
        name='sig_outofband_vrf',
        default=None,
        type=(None, managedattribute.test_isinstance(Vrf)))

    sig_patherr_state_removal = managedattribute(
        name='sig_patherr_state_removal',
        default=None,
        type=(None, managedattribute.test_istype(bool)))

    sig_prefixfilt_acl = managedattribute(
        name='sig_prefixfilt_acl',
        default=None,
        type=(None, managedattribute.test_isinstance(AccessList)))

    class PrefixFilteringAction(Enum):
        drop = 'drop'

    sig_prefixfilt_defdenyaction = managedattribute(
        name='sig_prefixfilt_defdenyaction',
        default=None,
        type=(None, PrefixFilteringAction))
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / stream / stream.py View on Github external
    @eth_encap_range1.deleter
    def eth_encap_range1(self):
        try:
            del self.eth_encap_val1
        except AttributeError:
            pass
        try:
            del self.eth_encap_count1
        except AttributeError:
            pass
        try:
            del self.eth_encap_step1
        except AttributeError:
            pass

    eth_encap_val2 = managedattribute(
        name='eth_encap_val2',
        type=(None, managedattribute.test_istype(int)))

    @eth_encap_val2.defaulter
    def eth_encap_val2(self):
        source = self.source
        if isinstance(source, Interface):
            source_instance = self.source_instance
            # TODO source_instance
            return getattr(source, 'eth_encap_val2', None)
        else:
            return None

    eth_encap_count2 = managedattribute(
        name='eth_encap_count2',
        type=managedattribute.test_istype(int))
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / interface / iosxe / interface.py View on Github external
autoroute_announce = managedattribute(
        name='autoroute_announce',
        default=None,
        type=(None, bool))

    forwarding_adjacency = managedattribute(
        name='forwarding_adjacency',
        default=None,
        type=(None,bool))

    record_route = managedattribute(
        name='record_route',
        default=None,
        type=(None,bool))

    frr = managedattribute(
        name='frr',
        default=None,
        type=(None,bool))

    ipv4_unnumbered_interface = managedattribute(
        name='ipv4_unnumbered_interface',
        default=None,
        type=(None,
              managedattribute.test_isinstance(Interface)))

    priority_setup = managedattribute(
        name='priority_setup',
        default=None,
        type=(None,int))

    priority_hold = managedattribute(
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / device / hltapi / device.py View on Github external
import genie.libs.conf.device.tgen
from genie.libs.conf.stream.stream import Stream, StreamStats

logger = logging.getLogger(__name__)


class Device(genie.libs.conf.device.tgen.Device):
    '''Base Device class for HLTAPI-based TGEN devices'''

    class Hltapi(object):
        '''HLTAPI abstraction object.

        HLTAPI Device subclasses are encouraged to subclass Hltapi as well to customize HLTAPI calls to allow Vendor-specific requirements.
        '''

        device = managedattribute(
            name='device',
            type=managedattribute.auto_ref,  # TODO Device is not finished declaring yet
            gettype=managedattribute.auto_unref,
            doc='''The HLTAPI-based Genie Device object''')

        @property
        def pyats_connection(self):
            '''The pyATS connection used for HLTAPI access'''
            connectionmgr = self.device.connectionmgr
            try:
                return connectionmgr.connections['hltapi']
            except KeyError:
                # TODO This might not be a HltApiConnection!?
                return connectionmgr.connections[connectionmgr.default_alias]

        @property