class AddressFamilyAttributes(AddressFamilySubAttributes): rp_addresses = managedattribute( name='rp_addresses', finit=typedset( managedattribute.test_isinstance(RPAddressGroup)).copy, type=typedset( managedattribute.test_isinstance( RPAddressGroup))._from_iterable, doc='A `set` of RPAddressGroup associated objects') def add_static_rp(self, rp_addresses): self.rp_addresses.add(rp_addresses) def remove_static_rp(self, rp_addresses): rp_addresses._device = None try: self.rp_addresses.remove(rp_addresses) except: pass class InterfaceAttributes(InterfaceSubAttributes): pass interface_attr = managedattribute( name='interface_attr', read_only=True, doc=InterfaceAttributes.__doc__) @interface_attr.initter def interface_attr(self): return SubAttributesDict(self.InterfaceAttributes, parent=self)
class AddressFamilyAttributes(AddressFamilySubAttributes): mroutes = managedattribute( name='mroutes', finit=typedset( managedattribute.test_isinstance(Mroute)).copy, type=typedset(managedattribute.test_isinstance( Mroute))._from_iterable, doc='A `set` of Mroute associated objects') def add_mroute(self, mroute): self.mroutes.add(mroute) def remove_mroute(self, mroute): mroute._device = None try: self.mroutes.remove(mroute) except: pass # Compatibility class InterfaceAttributes(InterfaceSubAttributes): pass interface_attr = managedattribute( name='interface_attr', read_only=True, doc=InterfaceAttributes.__doc__) @interface_attr.initter def interface_attr(self): return SubAttributesDict(self.InterfaceAttributes, parent=self)
class PseudowireInterface(VirtualInterface): _interface_name_types = ( 'pseudowire', 'Pseudowire', ) pseudowire_neighbor = managedattribute( name='pseudowire_neighbor', type=(None, managedattribute.test_isinstance(PseudowireNeighbor))) encapsulation = managedattribute( name='encapsulation', default=EncapsulationType.mpls, type=(None, EncapsulationType)) preferred_path = managedattribute( name='preferred_path', default=None, type=(None, managedattribute.test_isinstance(Interface), IPv4Address)) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.pseudowire_neighbor.pseudowire_interface = self def _build_config_interface_submode(self, configurations, attributes, unconfig): #super()._build_config_interface_submode(configurations=configurations, # attributes=attributes, # unconfig=unconfig) # Virtual interfaces can be fully unconfigured if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxe: interface {name} / shutdown shutdown = attributes.value('shutdown') if shutdown is not None: if shutdown: configurations.append_line('shutdown', raw=True) else: configurations.append_line('no shutdown', raw=True) configurations.append_line(attributes.format('encapsulation {encapsulation}', transform={ EncapsulationType.mpls: 'mpls', EncapsulationType.l2tpv3: 'l2tpv3', })) if attributes.value('pseudowire_neighbor') is not None: configurations.append_line(attributes.format('neighbor {pseudowire_neighbor.ip} {pseudowire_neighbor.pw_id}')) v = attributes.value('preferred_path') if v is not None: if isinstance(v,Interface): configurations.append_line(attributes.format('preferred-path interface {preferred_path.name}')) elif isinstance(v,IPv4Address): configurations.append_line(attributes.format('preferred-path peer {preferred_path}'))
class VrfAttributes(VrfSubAttributes): def __init__(self, parent, key): self.vrf_id = key super().__init__(parent, key) ssm = managedattribute( name='ssm', finit=typedset(managedattribute.test_isinstance(Ssm)).copy, type=typedset( managedattribute.test_isinstance(Ssm))._from_iterable, doc='A `set` of ssm associated objects') def add_ssm(self, ssm): self.ssm.add(ssm) def remove_ssm(self, ssm): ssm._device = None try: self.ssm.remove(ssm) except: pass class InterfaceAttributes(InterfaceSubAttributes): def __init__(self, parent, key): self.intf = key super().__init__(parent, key) groups = managedattribute( name='groups', finit=typedset( managedattribute.test_isinstance(IgmpGroup)).copy, type=typedset(managedattribute.test_isinstance( IgmpGroup))._from_iterable, doc='A `set` of IgmpGroup associated objects') def add_groups(self, groups): self.groups.add(groups) def remove_groups(self, groups): groups._device = None try: self.groups.remove(groups) except: pass interface_attr = managedattribute(name='interface_attr', read_only=True, doc=InterfaceAttributes.__doc__) @interface_attr.initter def interface_attr(self): return SubAttributesDict(self.InterfaceAttributes, parent=self)
class NeighborAttributes(PseudowireNeighborSubAttributes): # ip -> self.neighbor.ip # pw_id -> self.neighbor.pw_id ipv6_source = managedattribute(name='ipv6_source', default=None, type=(None, IPv6Address)) mpls_static_label = managedattribute( name='mpls_static_label', default=None, type=(None, managedattribute.test_istype(int))) pw_class = managedattribute( name='pw_class', default=None, type=(None, managedattribute.test_isinstance(PseudowireClass))) redundancy_group = managedattribute(name='redundancy_group', type=(None, str)) redundancy_priority = managedattribute(name='redundancy_priority', type=(None, int)) encapsulation = managedattribute(name='encapsulation', default=EncapsulationType.mpls, type=(None, EncapsulationType))
class AddressFamilyAttributes(AddressFamilySubAttributes): allowed_keys = (AddressFamily.ipv4, AddressFamily.ipv6) advertise_interfaces = managedattribute( name='advertise_interfaces', type=typedset(managedattribute.test_isinstance( Interface))._from_iterable) @advertise_interfaces.defaulter def advertise_interfaces(self): return frozenset(self.parent.advertise_interfaces) class NeighborAttributes(IPLsrNeighborSubAttributes): def __init__(self, **kwargs): super().__init__(**kwargs) neighbor_attr = managedattribute( name='neighbor_attr', read_only=True, doc=NeighborAttributes.__doc__) @neighbor_attr.initter def neighbor_attr(self): return SubAttributesDict(self.NeighborAttributes, parent=self) def __init__(self, **kwargs): super().__init__(**kwargs)
class DeviceAttributes(genie.conf.base.attributes.DeviceSubAttributes): backbone_interfaces = managedattribute( name='backbone_interfaces', type=typedset( managedattribute.test_isinstance(Interface))._from_iterable) @backbone_interfaces.defaulter def backbone_interfaces(self): device = self.device return frozenset(interface for interface in self.parent.backbone_interfaces if interface.device is device) class InterfaceAttributes( genie.conf.base.attributes.InterfaceSubAttributes): def __init__(self, parent, key): super().__init__(parent, key) interface_attr = managedattribute(name='interface_attr', read_only=True, doc=InterfaceAttributes.__doc__) @interface_attr.initter def interface_attr(self): return SubAttributesDict(self.InterfaceAttributes, parent=self) # interfaces -- See DeviceSubAttributes def __init__(self, parent, key): super().__init__(parent, key)
class Redistribution(object): protocol = managedattribute(name='protocol', type=(managedattribute.test_in(( 'connected', 'subscriber', )), managedattribute.test_isinstance(Routing))) metric = managedattribute(name='metric', default=None, type=(None, managedattribute.test_istype(int))) route_policy = managedattribute(name='route_policy', default=None, type=_defer_route_policy_type) def __init__(self, protocol, **kwargs): if not kwargs and isinstance(protocol, Redistribution): # copy constructor kwargs = vars(protocol) else: self.protocol = protocol for k, v in kwargs.items(): setattr(self, k, v)
class InterfaceAttributes(InterfaceSubAttributes): # Interface Static Neighbor multi-line configs intf_staticnbr_keys = managedattribute( name='intf_staticnbr_keys', finit=typedset(managedattribute.test_isinstance(InterfaceStaticNeighbor)).copy, type=typedset(managedattribute.test_isinstance(InterfaceStaticNeighbor))._from_iterable, doc='A `set` of InterfaceStaticNeighbor keys objects') def add_staticnbr_key(self, intf_staticnbr_key): self.intf_staticnbr_keys.add(intf_staticnbr_key) def remove_staticnbr_key(self, intf_staticnbr_key): intf_staticnbr_key._device = None try: self.intf_staticnbr_keys.remove(intf_staticnbr_key) except: pass
def _defer_route_policy_type(value): # Avoid the cyclic dependency by deferring the route_policy type # transformations from genie.libs.conf.route_policy import RoutePolicy transforms = (None, managedattribute.test_isinstance(RoutePolicy)) # Cache for speed Redistribution.route_policy = Redistribution.route_policy.copy( type=transforms) return managedattribute._transform(value, transforms)
class InterfaceAttributes(InterfaceSubAttributes): groups = managedattribute( name='groups', finit=typedset( managedattribute.test_isinstance(MldGroup)).copy, type=typedset(managedattribute.test_isinstance( MldGroup))._from_iterable, doc='A `set` of MldGroup associated objects') def add_groups(self, groups): self.groups.add(groups) def remove_groups(self, groups): groups._device = None try: self.groups.remove(groups) except: pass
class NeighborAttributes(PseudowireNeighborSubAttributes): # ip -> self.neighbor.ip # pw_id -> self.neighbor.pw_id # evi -> self.neighbor.evi # ac_id -> self.neighbor.ac_id # source_ac_id -> self.neighbor.source_ac_id dhcp_ipv4_snooping_profile = managedattribute( name='dhcp_ipv4_snooping_profile', default=None, type=( None, managedattribute.test_is(False), # False managedattribute.test_istype(str), # <profile> )) igmp_snooping_profile = managedattribute( name='igmp_snooping_profile', default=None, type=( None, managedattribute.test_is(False), # False managedattribute.test_istype(str), # <profile> )) mld_snooping_profile = managedattribute( name='mld_snooping_profile', default=None, type=( None, managedattribute.test_is(False), # False managedattribute.test_istype(str), # <profile> )) mpls_static_label = managedattribute( name='mpls_static_label', default=None, type=(None, managedattribute.test_istype(int))) pw_class = managedattribute( name='pw_class', default=None, type=(None, managedattribute.test_isinstance(PseudowireClass))) split_horizon = managedattribute( name='split_horizon', default=None, type=(None, managedattribute.test_istype(bool))) static_mac_address = managedattribute(name='static_mac_address', default=None, type=(None, MAC))
class InterfaceAttributes(InterfaceSubAttributes): def __init__(self, parent, key): self.intf = key super().__init__(parent, key) groups = managedattribute( name='groups', finit=typedset( managedattribute.test_isinstance(IgmpGroup)).copy, type=typedset(managedattribute.test_isinstance( IgmpGroup))._from_iterable, doc='A `set` of IgmpGroup associated objects') def add_groups(self, groups): self.groups.add(groups) def remove_groups(self, groups): groups._device = None try: self.groups.remove(groups) except: pass
class CeAttributes(KeyedSubAttributes): @classmethod def _sanitize_key(cls, key): return int(key) ce_id = managedattribute(name='ce_id', read_only=True) # read-only key interfaces = managedattribute( name='interfaces', finit=typedset( managedattribute.test_isinstance(Interface)).copy, type=typedset( managedattribute.test_isinstance( Interface))._from_iterable) def add_interface(self, intf): # TODO DEPRECATE self.interfaces.add(intf) def remove_interface(self, intf): # TODO DEPRECATE self.interfaces.remove(intf) class InterfaceAttributes(InterfaceSubAttributes): remote_ce_id = None #Always only one per interface # interface GigabitEthernet0/0/1/0 remote-ce-id 2000 # !!% Invalid argument: AC already used by existing xconnect interface_attr = None # InterfaceAttributes def __init__(self, parent, key): self._ce_id = key super().__init__(parent=parent) self.interface_attr = SubAttributesDict( self.InterfaceAttributes, parent=self)
class TunnelTeInterface(TunnelInterface, genie.libs.conf.interface.TunnelTeInterface): tunnel_mode = managedattribute(name='tunnel_mode', default='mpls traffic-eng', type=managedattribute.test_in( ('mpls traffic-eng', ))) destination = managedattribute(name='destination', default=None, type=(None, IPv4Address)) 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(name='priority_hold', default=None, type=(None, int)) affinity = managedattribute(name='affinity', default=None, type=(None, str)) te_bw = managedattribute(name='te_bw', default=None, type=(None, int, str)) te_backup_bw = managedattribute(name='te_backup_bw', default=None, type=(None, int, str)) path_options = managedattribute( name='path_options', finit=set, type=managedattribute.test_set_of( # TODO managedattribute.test_isinstance(PathOption)), managedattribute.test_istype(str)), gettype=frozenset, doc='A `set` of PathOption associated objects') def add_path_option(self, path_option): self._path_options.add(path_option) def remove_path_option(self, path_option): self._path_options.remove(path_option) class PathOptionAttributes(KeyedSubAttributes): @classmethod def _sanitize_key(cls, key): return str(key) path_option = managedattribute( name='path_option', read_only=True, # key doc='The path-option name (read-only key)') dynamic = managedattribute(name='dynamic', default=None, type=managedattribute.test_istype(bool)) explicit_name = managedattribute( name='explicit_name', default=None, type=managedattribute.test_istype(str)) def __init__(self, parent, key, **kwargs): self._path_option = key super().__init__(parent=parent, **kwargs) def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not apply assert not kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxe: interface tunnel1 / tunnel mpls traffic-eng path-option 1 dynamic if attributes.value('dynamic'): configurations.append_line( attributes.format( 'tunnel mpls traffic-eng path-option {path_option} dynamic' )) # iosxe: interface tunnel1 / tunnel mpls traffic-eng path-option 1 explicit name someword configurations.append_line(attributes.format\ ('tunnel mpls traffic-eng path-option {path_option} explicit name {explicit_name}')) return str(configurations) def build_unconfig(self, apply=True, attributes=None, **kwargs): return self.build_config(apply=apply, attributes=attributes, unconfig=True, **kwargs) path_option_attr = managedattribute(name='path_option_attr', read_only=True, doc=PathOptionAttributes.__doc__) @path_option_attr.initter def path_option_attr(self): return SubAttributesDict(self.PathOptionAttributes, parent=self) def __init__(self, *args, **kwargs): self.path_options # init! super().__init__(*args, **kwargs) def _build_config_interface_submode(self, configurations, attributes, unconfig): #super()._build_config_interface_submode(configurations=configurations, # attributes=attributes, # unconfig=unconfig) # Virtual interfaces can be fully unconfigured if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxe: interface {name} / shutdown shutdown = attributes.value('shutdown') if shutdown is not None: if shutdown: configurations.append_line('shutdown', raw=True) else: configurations.append_line('no shutdown', raw=True) # iosxe: interface tunnel1 / tunnel mode mpls traffic-eng configurations.append_line( attributes.format('tunnel mode {tunnel_mode}')) # iosxe: interface tunnel1 / ip unnumbered Loopback0 configurations.append_line( attributes.format( 'ip unnumbered {ipv4_unnumbered_interface.name}')) # iosxe: interface tunnel1 / tunnel destination 1.2.3.4 configurations.append_line( attributes.format('tunnel destination {destination}')) # iosxe: interface tunnel1 / tunnel mpls traffic-eng autoroute announce if attributes.value('autoroute_announce'): configurations.append_line( 'tunnel mpls traffic-eng autoroute announce') # iosxe: interface tunnel1 / tunnel mpls traffic-eng forwarding adjacency if attributes.value('forwarding_adjacency'): configurations.append_line( 'tunnel mpls traffic-eng forwarding-adjacency') # iosxe: interface tunnel1 / tunnel mpls traffic-eng record-route if attributes.value('record_route'): configurations.append_line('tunnel mpls traffic-eng record_route') # iosxe: interface tunnel1 / tunnel mpls traffic-eng priority <0-7> <0-7> configurations.append_line( attributes.format( 'tunnel mpls traffic-eng priority {priority_setup} {priority_hold}' )) # iosxe: interface tunnel1 / tunnel mpls traffic-eng affinity 0xFFFF configurations.append_line( attributes.format('tunnel mpls traffic-eng affinity {affinity}')) # iosxe: interface tunnel1 / tunnel mpls traffic-eng bandwidth 1000 configurations.append_line( attributes.format('tunnel mpls traffic-eng affinity {te_bw}')) # iosxe: interface tunnel1 / tunnel mpls traffic-eng backup-bw 1000 configurations.append_line( attributes.format( 'tunnel mpls traffic-eng affinity {te_backup_bw}')) # iosxe: interface tunnel1 / tunnel mpls trafic-eng fast-reroute if attributes.value('frr'): configurations.append_line('tunnel mpls traffic-eng fast-reroute') # iosxe: interface tunnel-te1 / description some line data v = attributes.value('description') if v: if v is True: pass # TODO Create a usefull default description else: configurations.append_line('description {}'.format(v)) # iosxe: interface tunnel-te1 / ipv4 address 1.2.3.0/24 # ADD PATH OPTIONS for ns, attributes2 in attributes.mapping_values( 'path_option_attr', keys=self.path_options, sort=True): configurations.append_block( ns.build_config(apply=False, unconfig=unconfig, attributes=attributes2))
class VrfAttributes(VrfSubAttributes): address_families = managedattribute( name='address_families', type=typedset(AddressFamily)._from_iterable) @address_families.defaulter def address_families(self): return frozenset(self.parent.address_families) advertise_interfaces = managedattribute( name='advertise_interfaces', type=typedset(managedattribute.test_isinstance( Interface))._from_iterable) @advertise_interfaces.defaulter def advertise_interfaces(self): return frozenset(self.parent.advertise_interfaces) # implicit: interface_attr = parent.interface_attr # implicit: interfaces = parent.interfaces router_id = managedattribute( name='router_id', default=None, type=(None, IPv4Address,\ managedattribute.test_isinstance(Interface))) class NeighborAttributes(IPLsrNeighborSubAttributes): def __init__(self, **kwargs): super().__init__(**kwargs) neighbor_attr = managedattribute(name='neighbor_attr', read_only=True, doc=NeighborAttributes.__doc__) @neighbor_attr.initter def neighbor_attr(self): return SubAttributesDict(self.NeighborAttributes, parent=self) neighbors = managedattribute( name='neighbors', finit=typedset(_ldp_neighbor).copy, type=typedset(_ldp_neighbor)._from_iterable) class AddressFamilyAttributes(AddressFamilySubAttributes): allowed_keys = (AddressFamily.ipv4, AddressFamily.ipv6) advertise_interfaces = managedattribute( name='advertise_interfaces', type=typedset(managedattribute.test_isinstance( Interface))._from_iterable) @advertise_interfaces.defaulter def advertise_interfaces(self): return frozenset(self.parent.advertise_interfaces) class NeighborAttributes(IPLsrNeighborSubAttributes): def __init__(self, **kwargs): super().__init__(**kwargs) neighbor_attr = managedattribute( name='neighbor_attr', read_only=True, doc=NeighborAttributes.__doc__) @neighbor_attr.initter def neighbor_attr(self): return SubAttributesDict(self.NeighborAttributes, parent=self) def __init__(self, **kwargs): super().__init__(**kwargs) address_family_attr = managedattribute( name='address_family_attr', read_only=True, doc=AddressFamilyAttributes.__doc__) @address_family_attr.initter def address_family_attr(self): return SubAttributesDict(self.AddressFamilyAttributes, parent=self) def __init__(self, **kwargs): super().__init__(**kwargs)
class DeviceAttributes(genie.conf.base.attributes.DeviceSubAttributes): enabled_feature = managedattribute( name='enabled_feature', default=False, type=managedattribute.test_istype(bool), doc='''Argument to control 'feature ldp' CLI''') address_families = managedattribute( name='address_families', type=typedset(AddressFamily)._from_iterable) @address_families.defaulter def address_families(self): return frozenset(self.parent.address_families) advertise_interfaces = managedattribute( name='advertise_interfaces', type=typedset( managedattribute.test_isinstance(Interface))._from_iterable) @advertise_interfaces.defaulter def advertise_interfaces(self): device = self.device return frozenset(interface for interface in self.parent.advertise_interfaces if interface.device is device) @property def vrfs(self): return \ self.force_vrfs | \ {intf.vrf for intf in self.interfaces} @property def interfaces(self): device = self.device interfaces = set(self.parent.interfaces) #interfaces.update(*[link.interfaces for link in self.parent.links]) interfaces = {intf for intf in interfaces if intf.device is device} return frozenset(interfaces) class MldpAttributes(SubAttributes): def __init__(self, _device_attr): self._device_attr = _device_attr super().__init__( # Ldp.mldp parent=_device_attr.parent.mldp) @property def testbed(self): return self._device_attr.testbed @property def device_name(self): return self._device_attr.device_name @property def device(self): return self._device_attr.device mldp = managedattribute(name='mldp', read_only=True, doc=MldpAttributes.__doc__) @mldp.initter def mldp(self): return self.MldpAttributes(_device_attr=self) class VrfAttributes(VrfSubAttributes): address_families = managedattribute( name='address_families', type=typedset(AddressFamily)._from_iterable) @address_families.defaulter def address_families(self): return frozenset(self.parent.address_families) advertise_interfaces = managedattribute( name='advertise_interfaces', type=typedset(managedattribute.test_isinstance( Interface))._from_iterable) @advertise_interfaces.defaulter def advertise_interfaces(self): return frozenset(self.parent.advertise_interfaces) # implicit: interface_attr = parent.interface_attr # implicit: interfaces = parent.interfaces router_id = managedattribute( name='router_id', default=None, type=(None, IPv4Address,\ managedattribute.test_isinstance(Interface))) class NeighborAttributes(IPLsrNeighborSubAttributes): def __init__(self, **kwargs): super().__init__(**kwargs) neighbor_attr = managedattribute(name='neighbor_attr', read_only=True, doc=NeighborAttributes.__doc__) @neighbor_attr.initter def neighbor_attr(self): return SubAttributesDict(self.NeighborAttributes, parent=self) neighbors = managedattribute( name='neighbors', finit=typedset(_ldp_neighbor).copy, type=typedset(_ldp_neighbor)._from_iterable) class AddressFamilyAttributes(AddressFamilySubAttributes): allowed_keys = (AddressFamily.ipv4, AddressFamily.ipv6) advertise_interfaces = managedattribute( name='advertise_interfaces', type=typedset(managedattribute.test_isinstance( Interface))._from_iterable) @advertise_interfaces.defaulter def advertise_interfaces(self): return frozenset(self.parent.advertise_interfaces) class NeighborAttributes(IPLsrNeighborSubAttributes): def __init__(self, **kwargs): super().__init__(**kwargs) neighbor_attr = managedattribute( name='neighbor_attr', read_only=True, doc=NeighborAttributes.__doc__) @neighbor_attr.initter def neighbor_attr(self): return SubAttributesDict(self.NeighborAttributes, parent=self) def __init__(self, **kwargs): super().__init__(**kwargs) address_family_attr = managedattribute( name='address_family_attr', read_only=True, doc=AddressFamilyAttributes.__doc__) @address_family_attr.initter def address_family_attr(self): return SubAttributesDict(self.AddressFamilyAttributes, parent=self) def __init__(self, **kwargs): super().__init__(**kwargs) vrf_attr = managedattribute(name='vrf_attr', read_only=True, doc=VrfAttributes.__doc__) @vrf_attr.initter def vrf_attr(self): return SubAttributesDict(self.VrfAttributes, parent=self) @property def router_id(self): return self.vrf_attr[None].router_id @router_id.setter def router_id(self, value): self.vrf_attr[None].router_id = value @property def neighbor_attr(self): return self.vrf_attr[None].neighbor_attr @property def address_family_attr(self): return self.vrf_attr[None].address_family_attr class InterfaceAttributes( genie.conf.base.attributes.InterfaceSubAttributes): address_families = managedattribute( name='address_families', type=typedset(AddressFamily)._from_iterable) @address_families.defaulter def address_families(self): return frozenset(self.parent.address_families) class AddressFamilyAttributes(AddressFamilySubAttributes): allowed_keys = (AddressFamily.ipv4, AddressFamily.ipv6) def __init__(self, **kwargs): super().__init__(**kwargs) address_family_attr = managedattribute( name='address_family_attr', read_only=True, doc=AddressFamilyAttributes.__doc__) @address_family_attr.initter def address_family_attr(self): return SubAttributesDict(self.AddressFamilyAttributes, parent=self) def __init__(self, **kwargs): super().__init__(**kwargs) interface_attr = managedattribute(name='interface_attr', read_only=True, doc=InterfaceAttributes.__doc__) @interface_attr.initter def interface_attr(self): return SubAttributesDict(self.InterfaceAttributes, parent=self) def __init__(self, **kwargs): super().__init__(**kwargs)
class MldpAttributes(object): enabled = managedattribute(name='enabled', default=False, type=managedattribute.test_istype(bool)) csc = managedattribute(name='csc', default=None, type=(None, managedattribute.test_istype(bool))) forwarding_recursive = managedattribute( name='forwarding_recursive', default=None, type=(None, managedattribute.test_istype(bool))) forwarding_recursive_route_policy = managedattribute( name='forwarding_recursive_route_policy', default=None, type=(None, managedattribute.test_isinstance(RoutePolicy))) make_before_break = managedattribute( name='make_before_break', default=None, type=(None, managedattribute.test_istype(bool))) make_before_break_delay = managedattribute( name='make_before_break_delay', default=None, type=(None, managedattribute.test_istype(int))) make_before_break_delete_delay = managedattribute( name='make_before_break_delete_delay', default=None, type=(None, managedattribute.test_istype(int))) make_before_break_route_policy = managedattribute( name='make_before_break_route_policy', default=None, type=(None, managedattribute.test_istype(int))) mofrr = managedattribute(name='mofrr', default=None, type=(None, managedattribute.test_istype(bool))) mofrr_route_policy = managedattribute( name='mofrr_route_policy', default=None, type=(None, managedattribute.test_isinstance(RoutePolicy))) route_policy_in = managedattribute( name='route_policy_in', default=None, type=(None, managedattribute.test_isinstance(RoutePolicy))) recursive_fec = managedattribute( name='recursive_fec', default=None, type=(None, managedattribute.test_istype(bool))) recorsive_fec_route_policy = managedattribute( name='recorsive_fec_route_policy', default=None, type=(None, managedattribute.test_isinstance(RoutePolicy))) rib_unicast_always = managedattribute( name='rib_unicast_always', default=None, type=(None, managedattribute.test_istype(int))) # TODO need support for multiple root_ip/num_lsps mp2mp_static_root_ip = managedattribute(name='mp2mp_static_root_ip', default=None, type=(None, IPv4Address)) mp2mp_static_num_lsps = managedattribute( name='mp2mp_static_num_lsps', default=None, type=(None, managedattribute.test_istype(int))) p2mp_static_root_ip = managedattribute(name='p2mp_static_root_ip', default=None, type=(None, IPv4Address)) p2mp_static_num_lsps = managedattribute( name='p2mp_static_num_lsps', default=None, type=(None, managedattribute.test_istype(int))) log_internal = managedattribute( name='log_internal', default=None, type=(None, managedattribute.test_istype(bool))) log_notifications = managedattribute( name='log_notifications', default=None, type=(None, managedattribute.test_istype(bool)))
class Ldp(DeviceFeature, LinkFeature): @property def interfaces(self): interfaces = set() interfaces.update(*[link.interfaces for link in self.links]) return frozenset(interfaces) @property def vrfs(self): return \ self.force_vrfs | \ {intf.vrf for intf in self.interfaces} force_vrfs = managedattribute(name='force_vrfs', read_only=True, finit=set, gettype=frozenset) # XXXJST TODO force_vrfs needs to also be accessible per-device. Being read_only, that can't happen def add_force_vrf(self, vrf): assert vrf is None or isinstance(vrf, Vrf) self.force_vrfs # init! self._force_vrfs.add(vrf) def remove_force_vrf(self, vrf): assert vrf is None or isinstance(vrf, Vrf) self.force_vrfs # init! self._force_vrfs.remove(vrf) address_families = managedattribute( name='address_families', finit=typedset(AddressFamily, {AddressFamily.ipv4}).copy, type=typedset(AddressFamily)._from_iterable) # Top level configs shutdown = managedattribute(name='shutdown', default=None, type=(None, managedattribute.test_istype(bool))) default_route = managedattribute(name='default_route', default=None, type=(None, managedattribute.test_istype(bool))) capabilities_cisco_iosxr = managedattribute( name='capabilities_cisco_iosxr', default=None, type=(None, managedattribute.test_istype(bool))) default_vrf_impl_ipv4 = managedattribute( name='default_vrf_impl_ipv4', default=None, type=(None, managedattribute.test_istype(bool))) ds_tlv = managedattribute(name='ds_tlv', default=None, type=(None, managedattribute.test_istype(bool))) hello_holdtime = managedattribute(name='hello_holdtime', default=None, type=(None, managedattribute.test_istype(int))) targetted_hello_holdtime = managedattribute( name='targetted_hello_holdtime', default=None, type=(None, managedattribute.test_istype(int))) hello_interval = managedattribute(name='hello_interval', default=None, type=(None, managedattribute.test_istype(int))) targetted_hello_interval = managedattribute( name='targetted_hello_interval', default=None, type=(None, managedattribute.test_istype(int))) instance_tlv = managedattribute(name='instance_tlv', default=None, type=(None, managedattribute.test_istype(bool))) quickstart = managedattribute(name='quickstart', default=None, type=(None, managedattribute.test_istype(bool))) targeted_hello_holdtime = managedattribute( name='targeted_hello_holdtime', default=None, type=(None, managedattribute.test_istype(int))) targeted_hello_interval = managedattribute( name='targeted_hello_interval', default=None, type=(None, managedattribute.test_istype(int))) entropy_label = managedattribute(name='entropy_label', default=None, type=(None, managedattribute.test_istype(bool))) gr = managedattribute(name='gr', default=None, type=(None, managedattribute.test_istype(bool))) gr_fwdstate_holdtime = managedattribute( name='gr_fwdstate_holdtime', default=None, type=(None, managedattribute.test_istype(int))) gr_max_recovery = managedattribute( name='gr_max_recovery', default=None, type=(None, managedattribute.test_istype(int))) gr_neighbor_liveness = managedattribute( name='gr_neighbor_liveness', default=None, type=(None, managedattribute.test_istype(int))) gr_reconnect_timeout = managedattribute( name='gr_reconnect_timeout', default=None, type=(None, managedattribute.test_istype(int))) igp_sync = managedattribute(name='igp_sync', default=None, type=(None, managedattribute.test_istype(bool))) igp_sync_delay_time = managedattribute( name='igp_sync_delay_time', default=None, type=(None, managedattribute.test_istype(int))) igp_sync_delay_on_proc_restart = managedattribute( name='igp_sync_delay_on_proc_restart', default=None, type=(None, managedattribute.test_istype(int))) igp_sync_delay_on_session_up = managedattribute( name='igp_sync_delay_on_session_up', default=None, type=(None, managedattribute.test_istype(int), managedattribute.test_in((False, )))) log_gr = managedattribute(name='log_gr', default=None, type=(None, managedattribute.test_istype(bool))) log_hello_adj = managedattribute(name='log_hello_adj', default=None, type=(None, managedattribute.test_istype(bool))) log_neighbor = managedattribute(name='log_neighbor', default=None, type=(None, managedattribute.test_istype(bool))) log_nsr = managedattribute(name='log_nsr', default=None, type=(None, managedattribute.test_istype(bool))) log_sess_prot = managedattribute(name='log_sess_prot', default=None, type=(None, managedattribute.test_istype(bool))) ltrace_buffer_multiplier = managedattribute( name='ltrace_buffer_multiplier', default=None, type=(None, managedattribute.test_istype(int))) dualstack_tlv_compliance = managedattribute( name='dualstack_tlv_compliance', default=None, type=(None, managedattribute.test_istype(bool))) dualstack_transport_max_wait = managedattribute( name='dualstack_transport_max_wait', default=None, type=(None, managedattribute.test_istype(int))) dualstack_transport_prefer_ipv4 = managedattribute( name='dualstack_transport_prefer_ipv4', default=None, type=(None, managedattribute.test_istype(bool))) password_type = managedattribute(name='password_type', default=None, type=(None, PasswordType)) password = managedattribute(name='password', default=None, type=(None, managedattribute.test_istype(str))) password_for_acl = managedattribute( name='password_for_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) disable_password = managedattribute( name='disable_password', default=None, type=(None, managedattribute.test_istype(bool))) nsr = managedattribute(name='nsr', default=None, type=(None, managedattribute.test_istype(bool))) session_backoff_init = managedattribute( name='session_backoff_init', default=None, type=(None, managedattribute.test_istype(int))) session_backoff_max = managedattribute( name='session_backoff_max', default=None, type=(None, managedattribute.test_istype(int))) session_holdtime = managedattribute( name='session_holdtime', default=None, type=(None, managedattribute.test_istype(int))) session_protection = managedattribute( name='session_protection', default=None, type=(None, managedattribute.test_istype(bool))) session_protection_for_acl = managedattribute( name='session_protection_for_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) session_protection_dur = managedattribute( name='session_protection_dur', default=None, type=(None, managedattribute.test_istype(int), managedattribute.test_in((float('inf'), )))) signalling_dscp = managedattribute( name='signalling_dscp', default=None, type=(None, managedattribute.test_istype(int))) session_dod_with_acl = managedattribute( name='session_dod_with_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) gr_maintain_acl = managedattribute( name='gr_maintain_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) disc_hello_dualstack_tlv = managedattribute( name='disc_hello_dualstack_tlv', default=None, type=(None, managedattribute.test_in(( AddressFamily.ipv4, AddressFamily.ipv6, )))) igp_autoconfig = managedattribute( name='igp_autoconfig', default=None, type=(None, managedattribute.test_istype(bool))) transport_address = managedattribute(name='transport_address', default=None, type=(None, managedattribute.test_in( ('interface', )), IPv4Address, IPv6Address)) targeted = managedattribute(name='targeted', default=None, type=(None, managedattribute.test_istype(bool))) advertise = managedattribute(name='advertise', default=None, type=(None, managedattribute.test_istype(bool))) advertise_expnull = managedattribute( name='advertise_expnull', default=None, type=(None, managedattribute.test_istype(bool))) advertise_expnull_for_acl = managedattribute( name='advertise_expnull_for_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) advertise_expnull_to_acl = managedattribute( name='advertise_expnull_to_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) advertise_interfaces = managedattribute( name='advertise_interfaces', finit=typedset(managedattribute.test_isinstance(Interface)).copy, type=typedset( managedattribute.test_isinstance(Interface))._from_iterable) allocate_for_acl = managedattribute( name='allocate_for_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) allocate_for_host_routes = managedattribute( name='allocate_for_host_routes', default=None, type=(None, managedattribute.test_istype(bool))) default_route = managedattribute(name='default_route', default=None, type=(None, managedattribute.test_istype(bool))) impnull_override_for_acl = managedattribute( name='impnull_override_for_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) targeted_hello_accept = managedattribute( name='targeted_hello_accept', default=None, type=(None, managedattribute.test_istype(bool))) targeted_hello_accept_from_acl = managedattribute( name='targeted_hello_accept_from_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) redist_bgp = managedattribute(name='redist_bgp', default=None, type=(None, managedattribute.test_istype(bool))) redist_bgp_advto_acl = managedattribute( name='redist_bgp_advto_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) redist_bgp_as = managedattribute(name='redist_bgp_as', default=None, type=(None, managedattribute.test_istype(int))) te_autotunnel_mesh_group_id = managedattribute( name='te_autotunnel_mesh_group_id', default=None, type=(None, managedattribute.test_in( ('all', )), managedattribute.test_istype(int))) advertise_for_acl = managedattribute( name='advertise_for_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) advertise_to_acl = managedattribute( name='advertise_to_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) accept_for_acl = managedattribute( name='accept_for_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) session_dod_acl = managedattribute( name='session_dod_acl', default=None, type=(None, managedattribute.test_isinstance(AccessList))) class MldpAttributes(object): enabled = managedattribute(name='enabled', default=False, type=managedattribute.test_istype(bool)) csc = managedattribute(name='csc', default=None, type=(None, managedattribute.test_istype(bool))) forwarding_recursive = managedattribute( name='forwarding_recursive', default=None, type=(None, managedattribute.test_istype(bool))) forwarding_recursive_route_policy = managedattribute( name='forwarding_recursive_route_policy', default=None, type=(None, managedattribute.test_isinstance(RoutePolicy))) make_before_break = managedattribute( name='make_before_break', default=None, type=(None, managedattribute.test_istype(bool))) make_before_break_delay = managedattribute( name='make_before_break_delay', default=None, type=(None, managedattribute.test_istype(int))) make_before_break_delete_delay = managedattribute( name='make_before_break_delete_delay', default=None, type=(None, managedattribute.test_istype(int))) make_before_break_route_policy = managedattribute( name='make_before_break_route_policy', default=None, type=(None, managedattribute.test_istype(int))) mofrr = managedattribute(name='mofrr', default=None, type=(None, managedattribute.test_istype(bool))) mofrr_route_policy = managedattribute( name='mofrr_route_policy', default=None, type=(None, managedattribute.test_isinstance(RoutePolicy))) route_policy_in = managedattribute( name='route_policy_in', default=None, type=(None, managedattribute.test_isinstance(RoutePolicy))) recursive_fec = managedattribute( name='recursive_fec', default=None, type=(None, managedattribute.test_istype(bool))) recorsive_fec_route_policy = managedattribute( name='recorsive_fec_route_policy', default=None, type=(None, managedattribute.test_isinstance(RoutePolicy))) rib_unicast_always = managedattribute( name='rib_unicast_always', default=None, type=(None, managedattribute.test_istype(int))) # TODO need support for multiple root_ip/num_lsps mp2mp_static_root_ip = managedattribute(name='mp2mp_static_root_ip', default=None, type=(None, IPv4Address)) mp2mp_static_num_lsps = managedattribute( name='mp2mp_static_num_lsps', default=None, type=(None, managedattribute.test_istype(int))) p2mp_static_root_ip = managedattribute(name='p2mp_static_root_ip', default=None, type=(None, IPv4Address)) p2mp_static_num_lsps = managedattribute( name='p2mp_static_num_lsps', default=None, type=(None, managedattribute.test_istype(int))) log_internal = managedattribute( name='log_internal', default=None, type=(None, managedattribute.test_istype(bool))) log_notifications = managedattribute( name='log_notifications', default=None, type=(None, managedattribute.test_istype(bool))) mldp = managedattribute(name='mldp', read_only=True, finit=MldpAttributes, doc=MldpAttributes.__doc__) class DeviceAttributes(genie.conf.base.attributes.DeviceSubAttributes): enabled_feature = managedattribute( name='enabled_feature', default=False, type=managedattribute.test_istype(bool), doc='''Argument to control 'feature ldp' CLI''') address_families = managedattribute( name='address_families', type=typedset(AddressFamily)._from_iterable) @address_families.defaulter def address_families(self): return frozenset(self.parent.address_families) advertise_interfaces = managedattribute( name='advertise_interfaces', type=typedset( managedattribute.test_isinstance(Interface))._from_iterable) @advertise_interfaces.defaulter def advertise_interfaces(self): device = self.device return frozenset(interface for interface in self.parent.advertise_interfaces if interface.device is device) @property def vrfs(self): return \ self.force_vrfs | \ {intf.vrf for intf in self.interfaces} @property def interfaces(self): device = self.device interfaces = set(self.parent.interfaces) #interfaces.update(*[link.interfaces for link in self.parent.links]) interfaces = {intf for intf in interfaces if intf.device is device} return frozenset(interfaces) class MldpAttributes(SubAttributes): def __init__(self, _device_attr): self._device_attr = _device_attr super().__init__( # Ldp.mldp parent=_device_attr.parent.mldp) @property def testbed(self): return self._device_attr.testbed @property def device_name(self): return self._device_attr.device_name @property def device(self): return self._device_attr.device mldp = managedattribute(name='mldp', read_only=True, doc=MldpAttributes.__doc__) @mldp.initter def mldp(self): return self.MldpAttributes(_device_attr=self) class VrfAttributes(VrfSubAttributes): address_families = managedattribute( name='address_families', type=typedset(AddressFamily)._from_iterable) @address_families.defaulter def address_families(self): return frozenset(self.parent.address_families) advertise_interfaces = managedattribute( name='advertise_interfaces', type=typedset(managedattribute.test_isinstance( Interface))._from_iterable) @advertise_interfaces.defaulter def advertise_interfaces(self): return frozenset(self.parent.advertise_interfaces) # implicit: interface_attr = parent.interface_attr # implicit: interfaces = parent.interfaces router_id = managedattribute( name='router_id', default=None, type=(None, IPv4Address,\ managedattribute.test_isinstance(Interface))) class NeighborAttributes(IPLsrNeighborSubAttributes): def __init__(self, **kwargs): super().__init__(**kwargs) neighbor_attr = managedattribute(name='neighbor_attr', read_only=True, doc=NeighborAttributes.__doc__) @neighbor_attr.initter def neighbor_attr(self): return SubAttributesDict(self.NeighborAttributes, parent=self) neighbors = managedattribute( name='neighbors', finit=typedset(_ldp_neighbor).copy, type=typedset(_ldp_neighbor)._from_iterable) class AddressFamilyAttributes(AddressFamilySubAttributes): allowed_keys = (AddressFamily.ipv4, AddressFamily.ipv6) advertise_interfaces = managedattribute( name='advertise_interfaces', type=typedset(managedattribute.test_isinstance( Interface))._from_iterable) @advertise_interfaces.defaulter def advertise_interfaces(self): return frozenset(self.parent.advertise_interfaces) class NeighborAttributes(IPLsrNeighborSubAttributes): def __init__(self, **kwargs): super().__init__(**kwargs) neighbor_attr = managedattribute( name='neighbor_attr', read_only=True, doc=NeighborAttributes.__doc__) @neighbor_attr.initter def neighbor_attr(self): return SubAttributesDict(self.NeighborAttributes, parent=self) def __init__(self, **kwargs): super().__init__(**kwargs) address_family_attr = managedattribute( name='address_family_attr', read_only=True, doc=AddressFamilyAttributes.__doc__) @address_family_attr.initter def address_family_attr(self): return SubAttributesDict(self.AddressFamilyAttributes, parent=self) def __init__(self, **kwargs): super().__init__(**kwargs) vrf_attr = managedattribute(name='vrf_attr', read_only=True, doc=VrfAttributes.__doc__) @vrf_attr.initter def vrf_attr(self): return SubAttributesDict(self.VrfAttributes, parent=self) @property def router_id(self): return self.vrf_attr[None].router_id @router_id.setter def router_id(self, value): self.vrf_attr[None].router_id = value @property def neighbor_attr(self): return self.vrf_attr[None].neighbor_attr @property def address_family_attr(self): return self.vrf_attr[None].address_family_attr class InterfaceAttributes( genie.conf.base.attributes.InterfaceSubAttributes): address_families = managedattribute( name='address_families', type=typedset(AddressFamily)._from_iterable) @address_families.defaulter def address_families(self): return frozenset(self.parent.address_families) class AddressFamilyAttributes(AddressFamilySubAttributes): allowed_keys = (AddressFamily.ipv4, AddressFamily.ipv6) def __init__(self, **kwargs): super().__init__(**kwargs) address_family_attr = managedattribute( name='address_family_attr', read_only=True, doc=AddressFamilyAttributes.__doc__) @address_family_attr.initter def address_family_attr(self): return SubAttributesDict(self.AddressFamilyAttributes, parent=self) def __init__(self, **kwargs): super().__init__(**kwargs) interface_attr = managedattribute(name='interface_attr', read_only=True, doc=InterfaceAttributes.__doc__) @interface_attr.initter def interface_attr(self): return SubAttributesDict(self.InterfaceAttributes, parent=self) def __init__(self, **kwargs): super().__init__(**kwargs) 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, **kwargs): super().__init__(**kwargs) def build_config(self, links=None, apply=True, attributes=None, **kwargs): attributes = AttributesHelper(self, attributes) cfgs = {} if links is None: devices = self.devices else: devices = set().union(*[link.devices for link in links]) for key, sub, attributes2 in attributes.mapping_items('device_attr', keys=devices, sort=True): cfgs[key] = sub.build_config(apply=False, attributes=attributes2) if apply: self.testbed.config_on_devices(cfgs, fail_invalid=True) else: return cfgs def build_unconfig(self, links=None, apply=True, attributes=None, **kwargs): attributes = AttributesHelper(self, attributes) cfgs = {} if links is None: devices = self.devices else: devices = set().union(*[link.devices for link in links]) for key, sub, attributes2 in attributes.mapping_items('device_attr', keys=devices, sort=True): cfgs[key] = sub.build_unconfig(apply=False, attributes=attributes2) if apply: self.testbed.config_on_devices(cfgs, fail_invalid=True) else: return cfgs
def vnis(self): from genie.libs.conf.evpn import Vni return typedset(managedattribute.test_isinstance(Vni))
class Vrf(DeviceFeature): vnis = managedattribute( name='vnis', #finit=typedset(managedattribute.test_isinstance(Evi)).copy, # circular dependency! #type=typedset(managedattribute.test_isinstance(Evi))._from_iterable) # circular dependency! doc='A `set` of Evi associated objects') @vnis.initter def vnis(self): from genie.libs.conf.evpn import Vni return typedset(managedattribute.test_isinstance(Vni)) @vnis.setter def vnis(self, value): from genie.libs.conf.evpn import Vni self._vnis = typedset(managedattribute.test_isinstance(Vni), value) @property def interfaces(self): return frozenset([ interface for interface in self.testbed.interfaces if interface.vrf is self ]) name = managedattribute(name='name', read_only=True) # read-only hash key description = managedattribute(name='description', default=None, type=(None, managedattribute.test_istype(str))) amt_flush_routes = managedattribute( name='amt_flush_routes', default=None, type=(None, managedattribute.test_istype(bool))) amt_pseudo_interface = managedattribute( name='amt_pseudo_interface', default=None, type=(None, managedattribute.test_isinstance(Interface))) fallback_vrf = managedattribute( name='fallback_vrf', default=None, # Self-reference; Done after: type=(None, managedattribute.test_isinstance(Vrf)) ) mhost_ipv4_default_interface = managedattribute( name='mhost_ipv4_default_interface', default=None, type=(None, managedattribute.test_isinstance(Interface))) mhost_ipv6_default_interface = managedattribute( name='mhost_ipv6_default_interface', default=None, type=(None, managedattribute.test_isinstance(Interface))) scale_mode = managedattribute(name='scale_mode', default=None, type=(None, managedattribute.test_in(('big', )))) remote_route_filtering = managedattribute( name='remote_route_filtering', default=None, type=(None, managedattribute.test_istype(bool))) vpn_id = managedattribute(name='vpn_id', default=None, type=(None, managedattribute.test_isinstance(VpnId))) rd = managedattribute(name='rd', default=None, type=(None, RouteDistinguisher, managedattribute.test_in(('auto', )))) address_families = managedattribute( name='address_families', finit=typedset(AddressFamily, {AddressFamily.ipv4_unicast}).copy, type=typedset(AddressFamily)._from_iterable) export_route_policy = managedattribute( name='export_route_policy', default=None, type=(None, managedattribute.test_istype(RoutePolicy))) export_route_targets = managedattribute( name='export_route_targets', finit=typedset(RouteTarget.ImportExport).copy, type=typedset(RouteTarget.ImportExport)._from_iterable) export_to_default_vrf_route_policy = managedattribute( name='export_to_default_vrf_route_policy', default=None, type=(None, managedattribute.test_istype(RoutePolicy))) export_to_vrf_allow_imported_vpn = managedattribute( name='export_to_vrf_allow_imported_vpn', default=None, type=(None, managedattribute.test_istype(bool))) export_to_vrf_import_stitching_rt = managedattribute( name='export_to_vrf_import_stitching_rt', default=None, type=(None, managedattribute.test_istype(bool))) import_from_default_vrf_route_policy = managedattribute( name='import_from_default_vrf_route_policy', default=None, type=(None, managedattribute.test_istype(RoutePolicy))) import_from_default_vrf_route_policy_maximum_prefixes = managedattribute( name='import_from_default_vrf_route_policy_maximum_prefixes', default=None, type=(None, managedattribute.test_istype(int))) import_from_default_vrf_advertise_as_vpn = managedattribute( name='import_from_default_vrf_advertise_as_vpn', default=None, type=(None, managedattribute.test_istype(bool))) import_route_policy = managedattribute( name='import_route_policy', default=None, type=(None, managedattribute.test_istype(RoutePolicy))) import_route_targets = managedattribute( name='import_route_targets', finit=typedset(RouteTarget.ImportExport).copy, type=typedset(RouteTarget.ImportExport)._from_iterable) maximum_prefix = managedattribute(name='maximum_prefix', default=None, type=(None, managedattribute.test_istype(int))) maximum_prefix_threshold = managedattribute( name='maximum_prefix_threshold', default=None, type=(None, managedattribute.test_istype(int))) maximum_prefix_reinstall_threshold = managedattribute( name='maximum_prefix_reinstall_threshold', default=None, type=(None, managedattribute.test_istype(int))) maximum_prefix_warning_only = managedattribute( name='maximum_prefix_warning_only', default=None, type=(None, managedattribute.test_istype(bool))) shutdown = managedattribute(name='shutdown', default=None, type=(None, managedattribute.test_istype(bool))) import_from_global_map = managedattribute( name='import_from_global_map', default=None, type=(None, managedattribute.test_istype(str))) export_to_global_map = managedattribute( name='export_to_global_map', default=None, type=(None, managedattribute.test_istype(str))) routing_table_limit_number = managedattribute( name='routing_table_limit_number', default=None, type=(None, managedattribute.test_istype(int))) alert_percent_value = managedattribute( name='alert_percent_value', default=None, type=(None, managedattribute.test_istype(int))) simple_alert = managedattribute(name='simple_alert ', default=None, type=(None, managedattribute.test_istype(bool))) class RTTYPE(Enum): type1 = 'import' type2 = 'export' type3 = 'both' rt_type = managedattribute(name='rt_type', default=None, type=(None, RTTYPE), doc='import export or both') vni = managedattribute(name='vni', default=None, type=(None, managedattribute.test_istype(int))) class DeviceAttributes(DeviceSubAttributes): @property def vnis(self): device = self.device return frozenset( [vni for vni in self.parent.vnis if vni.device is device]) @property def interfaces(self): device = self.device return frozenset([ interface for interface in self.parent.interfaces if interface.device is device ]) export_route_targets = managedattribute( name='export_route_targets', type=typedset(RouteTarget.ImportExport)._from_iterable) @export_route_targets.defaulter def export_route_targets(self): return frozenset(self.parent.export_route_targets) import_route_targets = managedattribute( name='import_route_targets', type=typedset(RouteTarget.ImportExport)._from_iterable) @import_route_targets.defaulter def import_route_targets(self): return frozenset(self.parent.import_route_targets) address_families = managedattribute( name='address_families', type=typedset(AddressFamily)._from_iterable) @address_families.defaulter def address_families(self): return frozenset(self.parent.address_families) class AddressFamilyAttributes(AddressFamilySubAttributes): class RouteTargetAttributes(KeyedSubAttributes): def __init__(self, parent, key): self.rt = key super().__init__(parent) route_target_attr = managedattribute( name='route_target_attr', read_only=True, doc=RouteTargetAttributes.__doc__) @route_target_attr.initter def route_target_attr(self): return SubAttributesDict(self.RouteTargetAttributes, parent=self) def __init__(self, *args, **kwargs): self.address_family_attr = SubAttributesDict( self.AddressFamilyAttributes, parent=self) super().__init__(*args, **kwargs) 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, name, *args, **kwargs): assert isinstance(name, str) self._name = name super().__init__(*args, **kwargs) def __eq__(self, other): if not isinstance(other, Vrf): return NotImplemented return (self.name, self.testbed) \ == (other.name, other.testbed) def __lt__(self, other): if not isinstance(other, Vrf): return NotImplemented return (self.name, self.testbed) \ < (other.name, other.testbed) def __hash__(self): return hash(self.name) def build_config(self, devices=None, apply=True, attributes=None, **kwargs): cfgs = {} assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) if devices is None: devices = self.devices devices = set(devices) for key, sub, attributes2 in attributes.mapping_items('device_attr', keys=devices, sort=True): cfgs[key] = sub.build_config(apply=False, attributes=attributes2) cfgs = {key: value for key, value in cfgs.items() if value} if apply: self.testbed.config_on_devices(cfgs, fail_invalid=True) else: return cfgs def build_unconfig(self, devices=None, apply=True, attributes=None, **kwargs): cfgs = {} assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) if devices is None: devices = self.devices devices = set(devices) for key, sub, attributes2 in attributes.mapping_items('device_attr', keys=devices, sort=True): cfgs[key] = sub.build_unconfig(apply=False, attributes=attributes2) cfgs = {key: value for key, value in cfgs.items() if value} if apply: self.testbed.config_on_devices(cfgs, fail_invalid=True) else: return cfgs
def vnis(self, value): from genie.libs.conf.evpn import Vni self._vnis = typedset(managedattribute.test_isinstance(Vni), value)
else: return cfgs def build_unconfig(self, devices=None, apply=True, attributes=None, **kwargs): cfgs = {} assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) if devices is None: devices = self.devices devices = set(devices) for key, sub, attributes2 in attributes.mapping_items('device_attr', keys=devices, sort=True): cfgs[key] = sub.build_unconfig(apply=False, attributes=attributes2) cfgs = {key: value for key, value in cfgs.items() if value} if apply: self.testbed.config_on_devices(cfgs, fail_invalid=True) else: return cfgs Vrf.fallback_vrf = Vrf.fallback_vrf.copy( type=(None, managedattribute.test_isinstance(Vrf)))
class Pseudowire(Base): '''A Pseudowire. Example: # Containers (either Xconnect and/or BridgeDomain) xc = Xconnect(...) bd = BridgeDomain(...) # Create a PseudowireIPv4Neighbor: pwnbr1 = xc.create_pseudowire_neighbor(device=dev1, ip=lo2.ipv4.ip, pw_id=123) # Create a PseudowireIPv6Neighbor: pwnbr1 = xc.create_pseudowire_neighbor(device=dev1, ip=lo2.ipv6.ip, pw_id=123) # Create a PseudowireEviNeighbor pwnbr1 = xc.create_pseudowire_neighbor(device=dev1, evi=evi2, ac_id=123) # pwnbr1.container --> xc # pwnbr1.device --> dev1 # Create a PseudowireIPv4Neighbor: pwnbr2 = bd.create_pseudowire_neighbor(device=dev2, ip=lo1.ipv4.ip, pw_id=123) # Create a PseudowireEviNeighbor pwnbr2 = bd.create_pseudowire_neighbor(device=dev2, evi=evi1, ac_id=123) # pwnbr2.container --> bd # pwnbr2.device --> dev2 pw = Pseudowire(neighbors=[pwnbr1, pwnbr2]) # Implicit: # xc.add_segment(pw) # bd.add_segment(pw) ''' EncapsulationType = EncapsulationType EncapsulationProtocol = EncapsulationProtocol TransportMode = TransportMode neighbors = managedattribute(name='neighbors', read_only=True, gettype=frozenset) @property def neighbor_devices(self): return frozenset(neighbor.device for neighbor in self.neighbors) @property def testbed(self): for nbr in self.neighbors: return nbr.testbed pw_class = managedattribute( name='pw_class', default=None, type=(None, managedattribute.test_isinstance(PseudowireClass))) split_horizon = managedattribute(name='split_horizon', default=None, type=(None, managedattribute.test_istype(bool))) static_mac_address = managedattribute(name='static_mac_address', default=None, type=(None, MAC)) ipv6_source = managedattribute(name='ipv6_source', default=None, type=(None, IPv6Address)) dhcp_ipv4_snooping_profile = managedattribute( name='dhcp_ipv4_snooping_profile', default=None, type=( None, managedattribute.test_is(False), # False managedattribute.test_istype(str), # <profile> )) igmp_snooping_profile = managedattribute( name='igmp_snooping_profile', default=None, type=( None, managedattribute.test_is(False), # False managedattribute.test_istype(str), # <profile> )) mld_snooping_profile = managedattribute( name='mld_snooping_profile', default=None, type=( None, managedattribute.test_is(False), # False managedattribute.test_istype(str), # <profile> )) mpls_static_label = managedattribute(name='mpls_static_label', default=None, type=(None, managedattribute.test_is(int))) def __init__(self, neighbors, **kwargs): neighbors = set(neighbors) if len(neighbors) != 2: raise ValueError('Exactly 2 neighbors are expected: %r' % (neighbors, )) # XXXJST TODO for nbr in neighbors: if not isinstance(nbr, PseudowireNeighbor): raise ValueError('%r is not a PseudowireNeighbor' % (nbr, )) self._neighbors = set(neighbors) super().__init__() for nbr in self.neighbors: nbr.container.add_pseudowire(self) for k, v in kwargs.items(): for nbr in self.neighbors: setattr(nbr, k, v) def __hash__(self): return hash(id(self)) # TODO Always unique
class Vlan(DeviceFeature, LinkFeature): @property def interfaces(self): interfaces = set() interfaces.update(*[link.interfaces for link in self.links]) return frozenset(interfaces) def __init__(self, vlan_id=None, vlan=None, *args, **kwargs): if vlan_id: # old structure self.vlan_id = int(vlan_id) if vlan: # new structure self.vlan = vlan super().__init__(*args, **kwargs) vlan_id = managedattribute(name='vlan_id', default=None, type=managedattribute.test_istype(int), doc='A single-tagged VLAN') shutdown = managedattribute(name='shutdown', default=None, type=(None, managedattribute.test_istype(bool)), doc='Shutdown VLAN switching') class Media(Enum): enet = 'enet' fddi = 'fddi' media = managedattribute(name='media', default=None, type=(None, Media), doc='Vlan media type') name = managedattribute(name='name', default=None, type=(None, managedattribute.test_istype(str)), doc='Vlan name') are = managedattribute( name='are', default=None, type=(None, managedattribute.test_istype(int)), doc='Maximum number of All Route Explorer hops for this VLAN') bridge = managedattribute(name='bridge', default=None, type=(None, managedattribute.test_istype(int)), doc='''Value of the bridge number for FDDI Net or Token Ring Net type VLANs''') bridge_type = managedattribute(name='bridge_type', default=None, type=(None, managedattribute.test_istype(str)), doc='Vlan bridge type') stp_type = managedattribute(name='stp_type', default=None, type=(None, managedattribute.test_istype(str)), doc='Spanning tree type of the VLAN') ste = managedattribute( name='ste', default=None, type=(None, managedattribute.test_istype(int)), doc='Maximum number of Spanning Tree Explorer hops for this VLAN') class Status(Enum): ACTIVE = 'active' SUSPENDED = 'suspend' status = managedattribute(name='Status', default=None, type=(None, Status), doc='Vlan state') class Tpid(Enum): DEFAULT = 'TPID_0x8100' QNQ = 'TPID_0x8A88' ALTERANTE = 'TPID_0x9100' ALTERANTE2 = 'TPID_0X9200' tpid = managedattribute(name='tpid', default=None, type=(None, Tpid), doc='''Tag protocol identifier field (TPID) that is accepted on the VLAN''') class Backupcrf(Enum): enable = 'enable' disable = 'disable' backupcrf = managedattribute(name='backupcrf', default=None, type=(None, Backupcrf), doc='Backup CRF mode of the VLAN') parent_id = managedattribute( name='parent_id', default=None, type=(None, managedattribute.test_isinstance(int)), doc='ID number of the Parent VLAN of FDDI or Token Ring type VLANs') tb_vlan1 = managedattribute( name='tb_vlan1', default=None, type=(None, managedattribute.test_isinstance(int)), doc='ID number of the first translational VLAN for this VLAN') tb_vlan2 = managedattribute( name='tb_vlan2', default=None, type=(None, managedattribute.test_isinstance(int)), doc='ID number of the second translational VLAN for this VLAN') said = managedattribute(name='said', default=None, type=(None, managedattribute.test_isinstance(int)), doc='IEEE 802.10 SAID') ring = managedattribute(name='ring', default=None, type=(None, managedattribute.test_isinstance(int)), doc='Ring number of FDDI or Token Ring type VLANs') dot1q_tag_native = managedattribute( name='dot1q_tag_native', default=None, type=(None, managedattribute.test_istype(bool)), doc='Tag native vlan') accounting_type = managedattribute( name='accounting_type', default=None, type=(None, managedattribute.test_istype(str)), doc='Input/Output accounting packets') group_name = managedattribute(name='group_name', default=None, type=(None, managedattribute.test_istype(str)), doc='Vlan group name') configuration_id_list = managedattribute( name='configuration_id_list', default=None, type=(None, managedattribute.test_istype(str)), doc='Vlan id list') group_id_list = managedattribute(name='group_id_list', default=None, type=(None, managedattribute.test_istype(str)), doc='List of vlans in this group') private_vlan_type = managedattribute( name='private_vlan_type', default=None, type=(None, managedattribute.test_istype(str)), doc='Configure a private VLAN') private_vlan_association_action = managedattribute( name='private_vlan_association_action', default=None, type=(None, managedattribute.test_istype(str)), doc='Vlan private association action, add/remove') private_vlan_association_ids = managedattribute( name='private_vlan_association_ids', default=None, type=(None, managedattribute.test_istype(str)), doc='VLAN IDs of the private VLANs to be configured') remote_span = managedattribute(name='remote_span', default=None, type=(None, managedattribute.test_istype(bool)), doc='Configure as Remote SPAN VLAN') access_map_action = managedattribute( name='access_map_action', default=None, type=(None, managedattribute.test_istype(str)), doc='Vlan access-map action value, Drop packets/Forward packets') access_map_sequence = managedattribute( name='access_map_sequence', default=None, type=(None, managedattribute.test_istype(int)), doc='Sequence to insert to/delete from existing vlan access-map entry') datalink_flow_monitor = managedattribute( name='datalink_flow_monitor', default=None, type=(None, managedattribute.test_istype(bool)), doc='Apply a Flow Monitor for vlan NetFlow configuration commands') redirect_interface = managedattribute( name='redirect_interface', default=None, type=(None, managedattribute.test_istype(str)), doc='Redirect matched packets to the specified interface(s)') access_map_match = managedattribute( name='access_map_match', default=None, type=(None, managedattribute.test_istype(str)), doc='Access-list match type, IP/IPV6/Mac') access_list = managedattribute(name='access_list', default=None, type=(None, managedattribute.test_istype(str)), doc='Access-list name') # ============NXOS specific=========================== egress_load_balance = managedattribute( name='egress_load_balance', default=None, type=(None, managedattribute.test_istype(bool)), doc='Load balancing on the egress interface') # ========================XE and NX new Structure================= vlan = managedattribute(name='vlan', default=None, type=managedattribute.test_istype(str), doc='A VLAN id') class State(Enum): ACTIVE = 'active' SUSPEND = 'suspended' UNSUPPORT = 'unsupport' SHUTDOWN = 'shutdown' state = managedattribute(name='state', default=None, type=(None, State), doc='Obtain vlan state') # ==================================================== # NXOS specific managed attributes for new structure # ==================================================== # enabled enabled = managedattribute( name='enabled', default=None, type=(None, managedattribute.test_istype(bool)), doc='Enable feature interface-vlan and feature vn-segment-vlan-based') # enabled_interface_vlan enabled_interface_vlan = managedattribute( name='enabled_interface_vlan', default=None, type=(None, managedattribute.test_istype(bool)), doc='Enable feature interface-vlan') # enabled_vn_segment_vlan_based enabled_vn_segment_vlan_based = managedattribute( name='enabled_vn_segment_vlan_based', default=None, type=(None, managedattribute.test_istype(bool)), doc='Enable feature vn-segment-vlan-based') vn_segment_id = managedattribute(name='vn_segment_id', default=None, type=(None, managedattribute.test_istype(int)), doc='Segment id') class Mode(Enum): CE = 'ce' FABRICPATH = 'fabricpath' mode = managedattribute(name='mode', default=None, type=(None, Mode), doc='Vlan mode') config_vlan_id = managedattribute(name='config_vlan_id', default=None, type=(None, managedattribute.test_istype(str)), doc='Configuration vlan id') ip_igmp_snooping = managedattribute( name='ip_igmp_snooping', default=None, type=(None, managedattribute.test_istype(bool)), doc='IGMP Snooping information for the vlan') # ============================================= # Device attributes # ============================================= class DeviceAttributes(genie.conf.base.attributes.DeviceSubAttributes): @property def interfaces(self): device = self.device interfaces = set(self.parent.interfaces) interfaces = {intf for intf in interfaces if intf.device is device} return frozenset(interfaces) class AccessMapAttributes(KeyedSubAttributes): def __init__(self, parent, key): self.access_map_id = key super().__init__(parent=parent) access_map_attr = managedattribute(name='access_map_attr', read_only=True, doc=AccessMapAttributes.__doc__) @access_map_attr.initter def access_map_attr(self): return SubAttributesDict(self.AccessMapAttributes, parent=self) # added for new vlan structure class VlanAttributes(KeyedSubAttributes): def __init__(self, parent, key): self.vlan = key super().__init__(parent) vlan_attr = managedattribute(name='vlan_attr', read_only=True, doc=VlanAttributes.__doc__) @vlan_attr.initter def vlan_attr(self): return SubAttributesDict(self.VlanAttributes, parent=self) class VlanConfigAttributes(KeyedSubAttributes): def __init__(self, parent, key): self.vlan = key super().__init__(parent) config_vlan_attr = managedattribute(name='config_vlan_attr', read_only=True, doc=VlanConfigAttributes.__doc__) @config_vlan_attr.initter def config_vlan_attr(self): return SubAttributesDict(self.VlanConfigAttributes, parent=self) # added for old vlan structure class VlanConfigurationAttributes(KeyedSubAttributes): def __init__(self, parent, key): self.vlan_configuration_id = key super().__init__(parent=parent) vlan_configuration_attr = managedattribute( name='vlan_configuration_attr', read_only=True, doc=VlanConfigurationAttributes.__doc__) @vlan_configuration_attr.initter def vlan_configuration_attr(self): return SubAttributesDict(self.VlanConfigurationAttributes, parent=self) class InterfaceAttributes( genie.conf.base.attributes.InterfaceSubAttributes): # Fix parent recursion @property def parent(self): return self._device_attr @property def device_name(self): return self._device_attr.device_name # Fix parent recursion @property def device(self): return self._device_attr.device def __init__(self, parent, key, **kwargs): self._device_attr = parent super().__init__(parent=None, key=key, **kwargs) interface_attr = managedattribute(name='interface_attr', read_only=True, doc=InterfaceAttributes.__doc__) @interface_attr.initter def interface_attr(self): return SubAttributesDict(self.InterfaceAttributes, parent=self) 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) # ========================================================= # build_config # ========================================================= def build_config(self, devices=None, interfaces=None, links=None, apply=True, attributes=None, **kwargs): attributes = AttributesHelper(self, attributes) cfgs = {} devices, interfaces, links = \ consolidate_feature_args(self, devices, interfaces, links) for key, sub, attributes2 in attributes.mapping_items('device_attr', keys=devices, sort=True): cfgs[key] = sub.build_config(apply=False, attributes=attributes2) if apply: for device_name, cfg in sorted(cfgs.items()): self.testbed.config_on_devices(cfg, fail_invalid=True) else: return cfgs def build_unconfig(self, devices=None, interfaces=None, links=None, apply=True, attributes=None, **kwargs): attributes = AttributesHelper(self, attributes) cfgs = {} devices, interfaces, links = \ consolidate_feature_args(self, devices, interfaces, links) for key, sub, attributes2 in attributes.mapping_items('device_attr', keys=devices, sort=True): cfgs[key] = sub.build_unconfig(apply=False, attributes=attributes2) if apply: for device_name, cfg in sorted(cfgs.items()): self.testbed.config_on_devices(cfg, fail_invalid=True) else: return cfgs
class Vni(ConfigurableBase): vni_id = managedattribute( name='vni_id', read_only=True, # read-only hash key doc='VNI ID (mandatory)') device = managedattribute(name='device', read_only=True, gettype=managedattribute.auto_unref) @property def testbed(self): return self.device.testbed nve = managedattribute(name='nve', default=None, gettype=managedattribute.auto_unref) @nve.deleter def nve(self): old_nve = self.nve del self._nve # may raise AttributeError if old_nve is not None: if self in old_nve.vnis: old_nve.remove_vni(self) @nve.setter def nve(self, nve): if nve is not None and not isinstance(nve, NveInterface): raise ValueError(nve) old_nve = self.nve if old_nve is not None: if self in old_nve.vnis: old_nve.remove_vni(self) self._nve = None if nve is not None: if nve.vnis_map.get(self.vni_id, None) is not self: assert nve.device is self.device nve.add_vni(self) self._nve = weakref.ref(nve) host_reachability_protocol = managedattribute( name='host_reachability_protocol', default=None, type=(None, managedattribute.test_istype(str))) load_balance = managedattribute(name='load_balance', default=None, type=(None, managedattribute.test_istype(str))) mcast_group = managedattribute(name='mcast_group', default=None, type=(None, managedattribute.test_istype(str))) vrf = managedattribute(name='vrf', default=None, type=(None, managedattribute.test_isinstance(Vrf))) def __init__(self, vni_id, device=None, nve=None, *args, **kwargs): if not device: if not nve: raise TypeError('provide either device or nve arguments') device = nve.device self._vni_id = int(vni_id) self._device = weakref.ref(device) super().__init__(*args, nve=nve, **kwargs) def _on_added_from_nve_interface(self, nve): self.nve = nve def _on_removed_from_nve_interface(self, nve): self.nve = None def __eq__(self, other): if not isinstance(other, Vni): return NotImplemented # return (self.device, self.vni_id) == (other.device, other.vni_id) return (self.vni_id, self.device) == (other.vni_id, other.device) def __lt__(self, other): if not isinstance(other, Vni): return NotImplemented return (self.device, self.vni_id) < (other.device, other.vni_id) def __hash__(self): return hash(self.vni_id)
class PseudowireNeighbor(Neighbor): container = managedattribute( name='container', read_only=True, gettype=managedattribute.auto_unref, doc= 'The container (BridgeDomain, Xconnect, Vfi, Pseudowire, Evpn) (mandatory)' ) device = managedattribute(name='device', read_only=True, gettype=managedattribute.auto_unref, doc='The device (mandatory)') pseudowire_interface = managedattribute( name='pseudowire_interface', default=None, type=( None, managedattribute.test_isinstance(( Interface, # e.g.: iosxe PseudowireInterface )))) @property def testbed(self): device = self.device return device and device.testbed def __new__(cls, *args, **kwargs): factory_cls = cls if cls is PseudowireNeighbor: if 'ip' in kwargs: factory_cls = PseudowireIPNeighbor elif 'evi' in kwargs: factory_cls = PseudowireEviNeighbor else: raise TypeError('\'ip\' or \'evi\' arguments missing') if factory_cls is not cls: self = factory_cls.__new__(factory_cls, *args, **kwargs) elif super().__new__ is object.__new__: self = super().__new__(factory_cls) else: self = super().__new__(factory_cls, *args, **kwargs) return self def __init__(self, container, device=None, **kwargs): assert container if device is None: device = container.device assert isinstance(device, Device) self._container = weakref.ref(container) self._device = weakref.ref(device) super().__init__(**kwargs) def _neighbor_comparison_tokens(self): container = self.container return super()._neighbor_comparison_tokens() + ( 'device', self.device, 'container', container and __class__.__name__, container, ) def __hash__(self): return hash((self.device, self.container))
class DeviceAttributes(genie.conf.base.attributes.DeviceSubAttributes): update_source = managedattribute( name='update_source', default=None, type=(None, managedattribute.test_isinstance(Interface))) vrfs = managedattribute( name='vrfs', finit=typedset(managedattribute.test_isinstance(( type(None), Vrf)), {None}).copy, type=typedset(managedattribute.test_isinstance(( type(None), Vrf)))._from_iterable) def add_vrf(self, vrf): # TODO DEPRECATE self.vrfs.add(vrf) def remove_vrf(self, vrf): # TODO DEPRECATE self.vrfs.remove(vrf) @property def router_id(self): return self.vrf_attr[None].router_id @router_id.setter def router_id(self, value): self.vrf_attr[None].router_id = value class PeerSessionAttributes(KeyedSubAttributes): def __init__(self, parent, key): self.ps_name = key super().__init__(parent) peer_session_attr = managedattribute( name='peer_session_attr', read_only=True, doc=PeerSessionAttributes.__doc__) @peer_session_attr.initter def peer_session_attr(self): return SubAttributesDict(self.PeerSessionAttributes, parent=self) class PeerPolicyAttributes(KeyedSubAttributes): def __init__(self, parent, key): self.pp_name = key super().__init__(parent) peer_policy_attr = managedattribute( name='peer_policy_attr', read_only=True, doc=PeerPolicyAttributes.__doc__) @peer_policy_attr.initter def peer_policy_attr(self): return SubAttributesDict(self.PeerPolicyAttributes, parent=self) class VrfAttributes(VrfSubAttributes): rd = Vrf.rd.copy() @rd.defaulter def rd(self): vrf = self.vrf return vrf and vrf.rd address_families = managedattribute( name='address_families', finit=typedset(AddressFamily).copy, type=typedset(AddressFamily)._from_iterable) @address_families.defaulter def address_families(self): return self.parent.address_families.copy() class AddressFamilyAttributes(AddressFamilySubAttributes): pass address_family_attr = managedattribute( name='address_family_attr', read_only=True, doc=AddressFamilySubAttributes.__doc__) @address_family_attr.initter def address_family_attr(self): return SubAttributesDict(self.AddressFamilyAttributes, parent=self) class NeighborAttributes(IPNeighborSubAttributes): address_families = managedattribute( name='address_families', finit=typedset(AddressFamily).copy, type=typedset(AddressFamily)._from_iterable) @address_families.defaulter def address_families(self): return self.parent.address_families.copy() class AddressFamilyAttributes(AddressFamilySubAttributes): pass address_family_attr = managedattribute( name='address_family_attr', read_only=True, doc=AddressFamilySubAttributes.__doc__) @address_family_attr.initter def address_family_attr(self): return SubAttributesDict(self.AddressFamilyAttributes, parent=self) neighbor_attr = managedattribute( name='neighbor_attr', read_only=True, doc=NeighborAttributes.__doc__) @neighbor_attr.initter def neighbor_attr(self): return SubAttributesDict(self.NeighborAttributes, parent=self) router_id = managedattribute( name='router_id', default=None, type=(None, IPv4Address)) neighbors = managedattribute( name='neighbors', finit=set, type=managedattribute.test_set_of(IPNeighbor), gettype=frozenset) neighbors = managedattribute( name='neighbors', finit=typedset(IPNeighbor).copy, type=typedset(IPNeighbor)._from_iterable) def add_neighbor(self, neighbor): # TODO DEPRECATE self.neighbors.add(neighbor) def remove_neighbor(self, neighbor): # TODO DEPRECATE self.neighbors.remove(neighbor) vrf_attr = managedattribute( name='vrf_attr', read_only=True, doc=VrfAttributes.__doc__) @vrf_attr.initter def vrf_attr(self): return SubAttributesDict(self.VrfAttributes, parent=self) @property def neighbors(self): return self.vrf_attr[None].neighbors @property def add_neighbor(self): return self.vrf_attr[None].add_neighbor @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)
class EmulatedDevice(Device): role = Device.role.copy( default=Device.Role.emulated) tgen_interface = managedattribute( name='tgen_interface', type=managedattribute.test_auto_ref( managedattribute.test_isinstance(Interface)), gettype=managedattribute.auto_unref) @property def tgen_device(self): return self.tgen_interface.device tgen_handle = managedattribute( name='tgen_handle', default=None, type=(None, managedattribute.test_istype(str)), doc='''The emulated device handle, as understood by HLTAPI/low-level vendor APIs.''') emulated_loopback = managedattribute( name='emulated_loopback', default=None, #type=(None, managedattribute.test_isinstance(EmulatedLoopbackInterface)), ) emulated_interface = managedattribute( name='emulated_interface', default=None, #type=(None, managedattribute.test_isinstance(EmulatedInterface)), ) emulated_link = managedattribute( name='emulated_link', default=None, type=(None, managedattribute.test_isinstance(EmulatedLink)), ) @property def tgen_port_handle(self): return self.tgen_interface.tgen_port_handle @property def os(self): return self.tgen_device.os @property def context(self): return self.tgen_device.context @property def type(self): return self.tgen_device.type gateway_interface = managedattribute( name='gateway_interface', type=(None, managedattribute.test_isinstance(Interface))) @gateway_interface.defaulter def gateway_interface(self): return self.tgen_interface.gateway_interface @property def gateway_ipv4(self): gateway_interface = self.gateway_interface ipv4 = gateway_interface and gateway_interface.ipv4 return ipv4 and ipv4.ip @property def gateway_ipv6(self): gateway_interface = self.gateway_interface ipv6 = gateway_interface and gateway_interface.ipv6 return ipv6 and ipv6.ip def __new__(cls, name, *args, **kwargs): kwargs['name'] = name factory_cls = cls if factory_cls is EmulatedDevice: try: tgen_interface = kwargs['tgen_interface'] except KeyError: raise TypeError('Missing tgen_interface keyword argument') # need to load the correct Device for the right os. os = tgen_interface.device.os # Get the location where it will be loaded to mod = 'genie.libs.conf.device.{os}'.\ format(os=os) # import it OsDeviceModule = importlib.import_module(mod) factory_cls = OsDeviceModule.EmulatedDevice if factory_cls is not cls: self = factory_cls.__new__(factory_cls, *args, **kwargs) elif super().__new__ is object.__new__: self = super().__new__(factory_cls) else: self = super().__new__(factory_cls, *args, **kwargs) return self @abc.abstractmethod def __init__(self, name, *args, tgen_interface, create_loopback=True, create_interface=True, create_link=True, address_families={AddressFamily.ipv4}, lo_ipv4=None, lo_ipv6=None, ipv4=None, ipv6=None, mac_address=None, **kwargs): self.tgen_interface = tgen_interface # A lot may depend on this super().__init__(*args, name=name, **kwargs) tgen_device = self.tgen_device if create_loopback or create_interface: from genie.libs.conf.interface import EmulatedInterface from genie.libs.conf.interface import _get_descendent_subclass emul_os_interface_class = EmulatedInterface._get_os_specific_EmulatedInterface_class(self.os) if create_loopback: if self.os == 'pagent': # Pagent requires router IDs to have lower values than interfaces; # Promise an address in a class A network. # Always need IPv4 loopback if lo_ipv4 is None and AddressFamily.ipv4 in address_families: lo_ipv4 = self.testbed.ipv4_cache.reserve(type='A', prefixlen=32)[0] if lo_ipv6 is None and AddressFamily.ipv6 in address_families: pass # lo_ipv6 = self.testbed.ipv6_cache.reserve(TODO)[0] else: # Always need IPv4 loopback if lo_ipv4 is None and AddressFamily.ipv4 in address_families: lo_ipv4 = self.testbed.ipv4_cache.reserve(prefixlen=32)[0] if lo_ipv6 is None and AddressFamily.ipv6 in address_families: lo_ipv6 = self.testbed.ipv6_cache.reserve(prefixlen=128)[0] from genie.libs.conf.interface import LoopbackInterface emul_lo_interface_class = _get_descendent_subclass(emul_os_interface_class, LoopbackInterface) self.emulated_loopback = emul_lo_interface_class( device=self, name='Loopback0', ipv4=lo_ipv4, lo_ipv6=lo_ipv6, ) if create_interface: router_interface = self.gateway_interface from genie.libs.conf.interface import EthernetInterface emul_phy_interface_class = _get_descendent_subclass(emul_os_interface_class, EthernetInterface) # TODO support other interface base classes #### set vRtrIntf [lindex [enaTbGetInterfacePeer $vTgenIntf -linktype {iflink ifmesh}] 0] if self.os == 'pagent': # XXXJST TODO -- Pagent can use multiple emulations (OSPF) but they overwrite the main port's IP if ipv4 is None and AddressFamily.ipv4 in address_families: ipv4 = self.tgen_interface.ipv4 if ipv6 is None and AddressFamily.ipv6 in address_families: ipv6 = self.tgen_interface.ipv6 if mac_address is None: mac_address = self.tgen_interface.mac_address self.emulated_interface = emul_phy_interface_class( device=self, name=self.tgen_interface.name, mac_address=mac_address, ipv4=ipv4, ipv6=ipv6, ) else: if ipv4 is None and AddressFamily.ipv4 in address_families: base_ipv4 = self.tgen_interface.ipv4 assert base_ipv4 broadcast_address = base_ipv4.network.broadcast_address for n in itertools.count(1): ipv4_ip = base_ipv4.ip + n if ipv4_ip == broadcast_address: raise RuntimeError('No ipv4 addresses left in %r\'s network' % (base_ipv4,)) ipv4 = IPv4Interface((ipv4_ip, base_ipv4.network.prefixlen)) if not self.testbed.find_interfaces(ipv4=ipv4): break if ipv6 is None and AddressFamily.ipv6 in address_families: base_ipv6 = self.tgen_interface.ipv6 assert base_ipv6 broadcast_address = base_ipv6.network.broadcast_address for n in itertools.count(1): ipv6_ip = base_ipv6.ip + n if ipv6_ip == broadcast_address: raise RuntimeError('No ipv6 addresses left in %r\'s network' % (base_ipv6,)) ipv6 = IPv6Interface((ipv6_ip, base_ipv6.network.prefixlen)) if not self.testbed.find_interfaces(ipv6=ipv6): break if mac_address is None: mac_address = self.testbed.mac_cache.reserve(count=1)[0] self.emulated_interface = emul_phy_interface_class( device=self, name='Ethernet0', ipv4=ipv4, ipv6=ipv6, mac_address=mac_address, ) if create_link: self.emulated_link = EmulatedLink( name='{}-emulated_link'.format(name), interfaces=[self.emulated_interface, router_interface]) def __repr__(self): try: name = self.name tgen_interface = self.tgen_interface assert tgen_interface tgen_device = tgen_interface.device assert tgen_device except: return super().__repr__() else: return '<%s object %r on %s %s at 0x%x>' % ( self.__class__.__name__, name, tgen_device.name, tgen_interface.name, id(self)) @abc.abstractmethod def build_config(self, *args, **kwargs): return '' @abc.abstractmethod def build_unconfig(self, *args, **kwargs): return ''
class PhysicalInterface(Interface, genie.libs.conf.interface.tgen.PhysicalInterface): '''Class for physical HLTAPI-based TGEN interfaces/ports''' class InterfaceMode(Enum): ethernet = 'ethernet' atm = 'atm' pos_hdlc = 'pos_hdlc' fr = 'fr' pos_ppp = 'pos_ppp' intf_mode = managedattribute(name='intf_mode', default=InterfaceMode.ethernet, type=InterfaceMode) tgen_port_handle = managedattribute( name='tgen_port_handle', doc='''The port handle, as understood by HLTAPI/low-level vendor APIs. If the HLTAPI connection sets this value on the interface object, this value will be returned. Otherwise, the Interface's name is used. ''') tgen_handle = managedattribute( name='tgen_handle', default=None, doc='''The logical interface configuration handle, as understood by HLTAPI/low-level vendor APIs.''') @tgen_port_handle.defaulter def tgen_port_handle(self): try: return self.tgen_port_handle except AttributeError: pass return self.name class PhysicalMode(Enum): fiber = gbic = 'fiber' copper = rj45 = 'copper' sfp = 'sfp' phy_mode = managedattribute(name='phy_mode', default=None, type=(None, PhysicalMode)) class OperationalMode(Enum): normal = 'normal' loopback = 'loopback' op_mode = managedattribute(name='op_mode', default=OperationalMode.normal, type=OperationalMode) @property def layer2_peer_interfaces(self): '''Get the list of layer2 peer interfaces, the one(s) physically connected and from which layer2 protocol is chosen.''' # TODO find appropriate peer... # - from link of type [iflink ifmesh ctrlink] # - if multiple peers (broadcast), return all # **NOTE** # Links under Genie Interface object is deprecated # Placed the below workaround to bypass the Unittest (commented out) # for link in self.links: # if self.link.obj_state != 'active': # continue for interface in self.link.interfaces: if interface.obj_state != 'active': continue if interface.device is not self.device: yield interface gateway_interface = managedattribute( name='gateway_interface', type=(None, managedattribute.test_isinstance( genie.libs.conf.interface.Interface))) @gateway_interface.defaulter def gateway_interface(self): # TODO find appropriate peer... # - in priority from link of type [xc bd otnxc], # then [iflink ifmesh ctrlink], then other types. # - if multiple peers (broadcast), take the first. # **NOTE** # Links under Genie Interface object is deprecated # Placed the below workaround to bypass the Unittest (commented out) # for link in self.links: # if self.link.obj_state != 'active': # continue for interface in self.link.interfaces: if interface.obj_state != 'active': continue if interface.device is not self.device: return interface @property def gateway_ipv4(self): gw_ip = None gw_intf = self.gateway_interface if gw_intf is not None and gw_intf.ipv4: return gw_intf.ipv4.ip if self.ipv4: # Find a linked interface on the same IP network for gw_intf in (intf for intf in self.link.interfaces): if gw_intf is not self \ and gw_intf.ipv4 \ and gw_intf.ipv4.network == self.ipv4.network: return gw_intf.ipv4 # Pick a dummy IP on the same network for gw_ip in self.ipv4.network: if gw_ip != self.ipv4.ip: return gw_ip return None @property def gateway_ipv6(self): gw_ip = None gw_intf = self.gateway_interface if gw_intf is not None and gw_intf.ipv6: return gw_intf.ipv6.ip if self.ipv6: # Find a linked interface on the same IP network for gw_intf in (intf for intf in self.link.interfaces): if gw_intf is not self \ and gw_intf.ipv6 \ and gw_intf.ipv6.network == self.ipv6.network: return gw_intf.ipv6 # Pick a dummy IP on the same network for gw_ip in self.ipv6.network: if gw_ip != self.ipv6.ip: return gw_ip return None def _build_interface_config_hltkwargs(self, attributes=None, unconfig=False): attributes = AttributesHelper(self, attributes) hltkwargs = None if unconfig: if self.tgen_port_configured: hltkwargs = {} hltkwargs['port_handle'] = self.tgen_port_handle hltkwargs['mode'] = 'destroy' else: hltkwargs = {} hltkwargs['mode'] = mode = 'modify' \ if self.tgen_port_configured else 'config' hltkwargs['port_handle'] = self.tgen_port_handle # hltkwargs['aps'] = TODO # hltkwargs['aps_arch'] = TODO # hltkwargs['aps_channel'] = TODO # hltkwargs['aps_request_1_1'] = TODO # hltkwargs['aps_request_1_n'] = TODO # hltkwargs['aps_switch_mode'] = TODO hltkwargs.update( attributes.format_dict({'phy_mode': '{phy_mode.value}'})) hltkwargs.update( attributes.format_dict({'intf_mode': '{intf_mode.value}'})) if self.intf_mode is self.InterfaceMode.ethernet: hltkwargs.update( attributes.format_dict( {'autonegotiation': '{auto_negotiation:d}'})) # speed and duplex may also be used with auto_negotiation to # limit possibilities. hltkwargs.update(attributes.format_dict({'speed': '{speed}'})) hltkwargs.update(attributes.format_dict({'duplex': '{duplex}'})) elif self.intf_mode is self.InterfaceMode.atm: # hltkwargs['speed'] = TODO # hltkwargs['atm_enable_coset'] = TODO # hltkwargs['atm_enable_pattern_matching'] = TODO # hltkwargs['atm_encapsulation'] = TODO # hltkwargs['atm_filler_cell'] = TODO # hltkwargs['atm_interface_type'] = TODO # hltkwargs['atm_packet_decode_mode'] = TODO # hltkwargs['atm_reassembly_timeout'] = TODO pass elif self.intf_mode in ( self.InterfaceMode.pos_hdlc, self.InterfaceMode.fr, self.InterfaceMode.pos_ppp, ): # hltkwargs['speed'] = TODO hltkwargs.update( attributes.format_dict( {'tx_scrambling': '{tx_scrambling:d}'})) hltkwargs.update( attributes.format_dict( {'rx_scrambling': '{rx_scrambling:d}'})) else: raise ValueError('Unsupported intf_mode %r' % (self.intf_mode, )) hltkwargs.update( attributes.format_dict({'op_mode': '{op_mode.value}'})) if self.op_mode is self.OperationalMode.loopback: pass elif self.op_mode is self.OperationalMode.normal: if self.intf_mode is self.InterfaceMode.ethernet: hltkwargs.update( attributes.format_dict( {'src_mac_addr': '{mac_address}'})) if self.mac_address is not None: pass # hltkwargs['src_mac_addr_step'] = TODO if self.ipv4 is not None: # hltkwargs['arp_cache_retrieve'] = TODO # hltkwargs['arp_req_retries'] = TODO # hltkwargs['arp_req_timer'] = TODO hltkwargs.update( attributes.format_dict({'arp_send_req': '1'})) if self.eth_encap_val1 is not None: hltkwargs['vlan'] = 1 hltkwargs['vlan_id'] = self.eth_encap_val1 # TODO # if { [set count [enaTbGetInterfaceParam $vIntf -count]] > 1 } { # hltkwargs['vlan_id_mode'] = "increment" # hltkwargs['vlan_id_step'] = [expr { # [enaTbGetInterfaceParam $vIntf -instance 1 -eth-encap-val1] - # $vlan # }] # hltkwargs['vlan_id_count'] = $count # } else { hltkwargs['vlan_id_mode'] = "fixed" # } # hltkwargs['vlan_user_priority'] = TODO if self.eth_encap_val2 is not None: hltkwargs['vlan_id_inner'] = self.eth_encap_val2 # if { [set count [enaTbGetInterfaceParam $vIntf -count]] > 1 } { # hltkwargs['vlan_id_inner_mode'] = "increment" # hltkwargs['vlan_id_inner_step'] = [expr { # [enaTbGetInterfaceParam $vIntf -instance 1 -eth-encap-val2] - # $vlan # }] # hltkwargs['vlan_id_inner_count'] = $count # } else { hltkwargs['vlan_id_inner_mode'] = "fixed" # } else: hltkwargs['vlan'] = 0 elif self.intf_mode is self.InterfaceMode.atm: pass elif self.intf_mode in ( self.InterfaceMode.pos_hdlc, self.InterfaceMode.fr, self.InterfaceMode.pos_ppp, ): pass else: raise ValueError('Unsupported intf_mode %r' % (self.intf_mode, )) if self.ipv4: hltkwargs['intf_ip_addr'] = self.ipv4.ip hltkwargs['netmask'] = self.ipv4.netmask gw_ip = self.gateway_ipv4 if gw_ip: hltkwargs['gateway'] = gw_ip else: hltkwargs['intf_ip_addr'] = '0.0.0.0' hltkwargs['netmask'] = '255.255.255.0' hltkwargs['gateway'] = '0.0.0.0' if self.ipv6: hltkwargs['ipv6_intf_addr'] = self.ipv6.ip hltkwargs['ipv6_prefix_length'] = \ self.ipv6.network.prefixlen gw_ip = self.gateway_ipv6 if gw_ip: hltkwargs['ipv6_gateway'] = gw_ip else: # hltkwargs['ipv6_intf_addr'] = '::' # hltkwargs['ipv6_prefix_length'] = 112 # hltkwargs['ipv6_gateway'] = '::' pass # hltkwargs['auto_line_rdi'] = TODO # hltkwargs['auto_line_rei'] = TODO # hltkwargs['auto_path_rdi'] = TODO # hltkwargs['auto_path_rei'] = TODO # hltkwargs['clocksource'] = TODO # hltkwargs['collision_exponent'] = TODO # hltkwargs['control_plane_mtu'] = TODO # hltkwargs['crlf_path_trace'] = TODO # hltkwargs['data_integrity'] = TODO # hltkwargs['dst_mac_addr'] = TODO # hltkwargs['enforce_mtu_on_rx'] = TODO # hltkwargs['ether_pause_mode'] = TODO # hltkwargs['framing'] = TODO # hltkwargs['gre_checksum_enable'] = TODO # hltkwargs['gre_dst_ip_addr'] = TODO # hltkwargs['gre_ip_addr'] = TODO # hltkwargs['gre_ip_prefix_length'] = TODO # hltkwargs['gre_ipv6_addr'] = TODO # hltkwargs['gre_ipv6_prefix_length'] = TODO # hltkwargs['gre_key_enable'] = TODO # hltkwargs['gre_key_in'] = TODO # hltkwargs['gre_key_out'] = TODO # hltkwargs['gre_seq_enable'] = TODO # hltkwargs['ignore_pause_frames'] = TODO # hltkwargs['internal_ppm_adjust'] = TODO # hltkwargs['interpacket_gap'] = TODO # hltkwargs['lais_lrdi_threshold'] = TODO # hltkwargs['line_ais'] = TODO # hltkwargs['line_bip24'] = TODO # hltkwargs['line_bip384'] = TODO # hltkwargs['line_bip96'] = TODO # hltkwargs['line_rdi'] = TODO # hltkwargs['line_rei'] = TODO # hltkwargs['line_type'] = TODO # hltkwargs['long_lof_wait'] = TODO # hltkwargs['output_enable'] = TODO # hltkwargs['path_ais'] = TODO # hltkwargs['path_bip8'] = TODO # hltkwargs['path_rdi'] = TODO # hltkwargs['path_rei'] = TODO # hltkwargs['path_type'] = TODO # hltkwargs['pause_length'] = TODO # hltkwargs['port_setup_mode'] = TODO # hltkwargs['prdi_threshold'] = TODO # hltkwargs['rpr_hec_seed'] = TODO # hltkwargs['rx_c2'] = TODO # hltkwargs['rx_enhanced_prdi'] = TODO # hltkwargs['rx_equalization'] = TODO # hltkwargs['rx_fcs'] = TODO # hltkwargs['rx_hec'] = TODO # hltkwargs['section_bip8'] = TODO # hltkwargs['section_unequip'] = TODO # hltkwargs['signal_fail_ber'] = TODO # hltkwargs['src_mac_addr'] = TODO # hltkwargs['ss_bits_pointer_interp'] = TODO # hltkwargs['static_atm_header_encapsulation'] = TODO # hltkwargs['static_atm_range_count'] = TODO # hltkwargs['static_dlci_count_mode'] = TODO # hltkwargs['static_dlci_repeat_count'] = TODO # hltkwargs['static_dlci_repeat_count_step'] = TODO # hltkwargs['static_dlci_value'] = TODO # hltkwargs['static_dlci_value_step'] = TODO # hltkwargs['static_enable'] = TODO # hltkwargs['static_fr_range_count'] = TODO # hltkwargs['static_indirect'] = TODO # hltkwargs['static_intf_handle'] = TODO # hltkwargs['static_ip_dst_addr'] = TODO # hltkwargs['static_ip_dst_count'] = TODO # hltkwargs['static_ip_dst_count_step'] = TODO # hltkwargs['static_ip_dst_increment'] = TODO # hltkwargs['static_ip_dst_increment_step'] = TODO # hltkwargs['static_ip_dst_prefix_len'] = TODO # hltkwargs['static_ip_dst_prefix_len_step'] = TODO # hltkwargs['static_ip_dst_range_step'] = TODO # hltkwargs['static_ip_range_count'] = TODO # hltkwargs['static_l3_protocol'] = TODO # hltkwargs['static_lan_range_count'] = TODO # hltkwargs['static_mac_dst'] = TODO # hltkwargs['static_mac_dst_count'] = TODO # hltkwargs['static_mac_dst_count_step'] = TODO # hltkwargs['static_mac_dst_mode'] = TODO # hltkwargs['static_mac_dst_step'] = TODO # hltkwargs['static_pvc_count'] = TODO # hltkwargs['static_pvc_count_step'] = TODO # hltkwargs['static_range_per_spoke'] = TODO # hltkwargs['static_site_id'] = TODO # hltkwargs['static_site_id_enable'] = TODO # hltkwargs['static_site_id_step'] = TODO # hltkwargs['static_vci'] = TODO # hltkwargs['static_vci_increment'] = TODO # hltkwargs['static_vci_increment_step'] = TODO # hltkwargs['static_vci_step'] = TODO # hltkwargs['static_vlan_enable'] = TODO # hltkwargs['static_vlan_id'] = TODO # hltkwargs['static_vlan_id_mode'] = TODO # hltkwargs['static_vlan_id_step'] = TODO # hltkwargs['static_vpi'] = TODO # hltkwargs['static_vpi_increment'] = TODO # hltkwargs['static_vpi_increment_step'] = TODO # hltkwargs['static_vpi_step'] = TODO # hltkwargs['transmit_clock_source'] = TODO # hltkwargs['transmit_mode'] = TODO # hltkwargs['tx_c2'] = TODO # hltkwargs['tx_enhanced_prdi'] = TODO # hltkwargs['tx_fcs'] = TODO # hltkwargs['tx_k2'] = TODO # hltkwargs['tx_preemphasis_main_tap'] = TODO # hltkwargs['tx_preemphasis_post_tap'] = TODO # hltkwargs['tx_s1'] = TODO return hltkwargs @abc.abstractmethod def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs)