def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not apply assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) if attributes.value('enabled'): sub, attributes2 = attributes.namespace( 'signaling_protocol_ldp') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) sub, attributes2 = attributes.namespace( 'signaling_protocol_bgp') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) return str(configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not apply assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 (config-l2vpn-bg-bd-vfi) if attributes.value('virtual', force=True): title = attributes.format('access-vfi {name}', force=True) else: title = attributes.format('vfi {name}', force=True) with configurations.submode_context(title): if unconfig and attributes.iswildcard: configurations.submode_unconfig() sub, attributes2 = attributes.namespace('autodiscovery_bgp') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) sub, attributes2 = attributes.namespace('multicast_p2mp') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / neighbor 1.2.3.4 pw-id 1 (config-l2vpn-bg-bd-vfi-pw) for sub, attributes2 in attributes.mapping_values( 'neighbor_attr', keys=self.pseudowire_neighbors, sort=True): configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / shutdown if attributes.value('shutdown'): configurations.append_line('shutdown') # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / vpn-id 1 configurations.append_line(attributes.format('vpn-id {vpn_id}')) return CliConfig(device=self.device, unconfig=unconfig, cli_config=configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not apply assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / multicast p2mp (config-l2vpn-bg-bd-vfi-p2mp) with configurations.submode_context('multicast p2mp'): if not attributes.value('enabled', force=True): configurations.submode_cancel() # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / multicast p2mp / signaling-protocol bgp (config-l2vpn-bg-bd-vfi-p2mp-bgp) #sub, attributes2 = attributes.namespace('signaling_protocol_bgp') #if sub is not None: # configurations.append_block( # sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / multicast p2mp / transport rsvp-te (config-l2vpn-bg-bd-vfi-p2mp-te) sub, attributes2 = attributes.namespace('transport_rsvp_te') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) return str(configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, contained=False, **kwargs): assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: l2vpn / pw-class someword (config-l2vpn) with configurations.submode_context( attributes.format('pw-class {name}', force=True)): if unconfig and attributes.iswildcard: configurations.submode_unconfig() ns, attributes2 = attributes.namespace('encapsulation') if ns is not None: configurations.append_block( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) if apply: if configurations: self.device.configure(configurations, fail_invalid=True) else: return CliConfig(device=self.device, unconfig=unconfig, cli_config=configurations, fail_invalid=True)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # virtual neighbor 70.70.70.70 pw-id 17300005 with configurations.submode_context( attributes.format('virtual neighbor {ip} pw-id {pw_id}', force=True)): if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxr: evpn / virtual neighbor 70.70.70.70 pw-id 17300005 / ethernet-segment (config-evpn-ac-es) ns, attributes2 = attributes.namespace('ethernet_segment') if ns is not None: configurations.append_block( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig, **kwargs)) return str(configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not apply attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: evpn / virtual vfi ac-vfi-5 / ethernet-segment (config-evpn-ac-es) with configurations.submode_context('ethernet-segment'): if not attributes.value('enabled', force=True): configurations.submode_cancel() if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxr: evpn / virtual vfi ac-vfi-5 / ethernet-segment / bgp route-target aaaa.bbbb.cccc ns, attributes2 = attributes.namespace('bgp') if ns is not None: configurations.append_block( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig, **kwargs)) # iosxr: evpn / virtual vfi ac-vfi-5 / ethernet-segment / identifier type 0 00.11.22.33.44.55.66.77.88 configurations.append_line( attributes.format( 'identifier type {esi.type} {esi.dotted}')) return str(configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # lldp run if attributes.value('enabled'): configurations.append_line(attributes.format('lldp run')) # lldp timer <hello_timer> if attributes.value('hello_timer'): configurations.append_line( attributes.format('lldp timer {hello_timer}')) # lldp holdtime <hold_timer> if attributes.value('hold_timer'): configurations.append_line( attributes.format('lldp holdtime {hold_timer}')) # lldp reinit <reinit_timer> if attributes.value('reinit_timer'): configurations.append_line( attributes.format('lldp reinit {reinit_timer}')) # tlv select attributes sub, attributes2 = attributes.namespace('tlv_select_attr') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # interface attributes for sub, attributes2 in attributes.mapping_values( 'interface_attr', sort=True, keys=self.interface_attr): configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) if apply: if configurations: self.device.configure(configurations) else: return CliConfig(device=self.device, unconfig=unconfig, cli_config=configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not kwargs, kwargs assert not apply attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) with configurations.submode_context( attributes.format('evi {evi_id}', force=True)): # iosxr: evpn / evi 1 / advertise-mac if attributes.value('advertise_mac'): configurations.append_line('advertise-mac') # iosxr: evpn / evi 1 / control-word-disable if attributes.value('control_word_disable'): configurations.append_line('control-word-disable') sub, attributes2 = attributes.namespace('bgp') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) sub, attributes2 = attributes.namespace('load_balancing') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) return CliConfig(device=self.device, unconfig=unconfig, cli_config=configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not apply attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: evpn / interface Bundle-Ether1 / ethernet-segment (config-evpn-ac-es) with configurations.submode_context('ethernet-segment'): if not attributes.value('enabled', force=True): configurations.submode_cancel() if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxr: evpn / interface Bundle-Ether1 / ethernet-segment / backbone-source-mac aaaa.bbbb.cccc configurations.append_line( attributes.format( 'backbone-source-mac {backbone_source_mac}')) # iosxr: evpn / interface Bundle-Ether1 / ethernet-segment / bgp route-target aaaa.bbbb.cccc ns, attributes2 = attributes.namespace('bgp') if ns is not None: configurations.append_block( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig, **kwargs)) # iosxr: evpn / interface Bundle-Ether1 / ethernet-segment / force single-homed if attributes.value('force_single_homed'): configurations.append_line('force single-homed') # iosxr: evpn / interface Bundle-Ether1 / ethernet-segment / identifier type 0 00.11.22.33.44.55.66.77.88 configurations.append_line( attributes.format( 'identifier type {esi.type} {esi.dotted}')) # iosxr: evpn / interface Bundle-Ether1 / ethernet-segment / load-balancing-mode single-active configurations.append_line( attributes.format( 'load-balancing-mode {load_balancing_mode}')) # iosxr: evpn / interface Bundle-Ether1 / ethernet-segment / service-carving manual (config-evpn-ac-es-vlan-man) # iosxr: evpn / interface Bundle-Ether1 / ethernet-segment / service-carving manual / primary someword secondary someword2 return str(configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, contained=False, **kwargs): assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: l2vpn (config-l2vpn) submode_stack = contextlib.ExitStack() if not contained: submode_stack.enter_context( configurations.submode_context('l2vpn')) # iosxr: l2vpn / pw-class someword (config-l2vpn) with configurations.submode_context( attributes.format('pw-class {name}', force=True)): if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxr: l2vpn / pw-class someword / backup disable delay <0-180> # iosxr: l2vpn / pw-class someword / backup disable never # iosxr: l2vpn / pw-class someword / encapsulation l2tpv3 (config-l2vpn) # iosxr: l2vpn / pw-class someword / encapsulation mpls (config-l2vpn) ns, attributes2 = attributes.namespace('encapsulation') if ns is not None: configurations.append_block( str( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig))) # iosxr: l2vpn / pw-class someword / mac-withdraw if attributes.value('mac_withdraw'): configurations.append_line('mac-withdraw') submode_stack.close() if apply: if configurations: self.device.configure(configurations, fail_invalid=True) else: return CliConfig(device=self.device, unconfig=unconfig, cli_config=configurations, fail_invalid=True)
def build_config(self, apply=True, attributes=None, unconfig=False): assert not apply attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) ns, attributes2 = attributes.namespace('bgp') if ns is not None: configurations.append_block( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) return str(configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not kwargs, kwargs assert not apply attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) with configurations.submode_context( attributes.format('l2vpn evpn instance {evi_id} {evi_mode}', force=True)): sub, attributes2 = attributes.namespace('bgp') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) return str(configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: evpn / interface Bundle-Ether1 (config-evpn-ac) with configurations.submode_context( attributes.format('interface {interface_name}', force=True)): if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxr: evpn / interface Bundle-Ether1 / ethernet-segment (config-evpn-ac-es) ns, attributes2 = attributes.namespace('ethernet_segment') if ns is not None: configurations.append_block( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig, **kwargs)) # iosxr: evpn / interface Bundle-Ether1 / mac-flush mvrp configurations.append_line( attributes.format('mac-flush {mac_flush}')) # iosxr: evpn / interface Bundle-Ether1 / timers (config-evpn-ac-timers) with configurations.submode_context('timers', cancel_empty=True): # iosxr: evpn / interface Bundle-Ether1 / timers / recovery 20 configurations.append_line( attributes.format('recovery {recovery_timer}', inherited=False)) if attributes.value('peering_timer', inherited=False) is not None: warnings.warn('evpn interface peering_timer', UnsupportedAttributeWarning) return str(configurations)
def build_config(self, apply=True, attributes=None, unconfig=False): assert not apply attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # nxos: evpn / vni 4096 l2 (config-evpn-evi) with configurations.submode_context( attributes.format('vni {vni.vni_id} l2', force=True)): if unconfig and attributes.iswildcard: configurations.submode_unconfig() ns, attributes2 = attributes.namespace('ethernet_segment') if ns is not None: configurations.append_block( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) return str(configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not apply assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxe: l2vpn vfi context {name} with configurations.submode_context( attributes.format('l2vpn vfi context {name}', force=True)): if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxr: l2vpn vfi context {name} / vpn id {vpn_id} assert self.vpn_id is not None configurations.append_line(attributes.format('vpn id {vpn_id}')) sub, attributes2 = attributes.namespace('autodiscovery_bgp') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) for sub, attributes2 in attributes.mapping_values( 'neighbor_attr', keys=self.pseudowire_neighbors, sort=True): configurations.append_block( str( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig))) return CliConfig(device=self.device, unconfig=unconfig, cli_config=configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, contained=False, **kwargs): assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: l2vpn (config-l2vpn) submode_stack = contextlib.ExitStack() if not contained: submode_stack.enter_context( configurations.submode_context('l2vpn')) # iosxr: l2vpn / bridge group someword (config-l2vpn-bg) with configurations.submode_context( attributes.format('bridge group {group_name}', force=True, cancel_empty=True)): # iosxr: l2vpn / bridge group someword / bridge-domain someword2 (config-l2vpn-bg-bd) with configurations.submode_context( attributes.format('bridge-domain {name}', force=True)): if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / coupled-mode # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / dhcp ipv4 snoop profile someword3 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / dynamic-arp-inspection (config-l2vpn-bg-bd-dai) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / dynamic-arp-inspection / address-validation (config-l2vpn-bg-bd-dai-av) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / dynamic-arp-inspection / address-validation / dst-mac # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / dynamic-arp-inspection / address-validation / ipv4 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / dynamic-arp-inspection / address-validation / src-mac # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / dynamic-arp-inspection / logging # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / evi 1 (config-l2vpn-bg-bd-evi) for sub, attributes2 in attributes.mapping_values( 'evi_attr', keys=self.evis, sort=True): configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / flooding disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / flooding unknown-unicast disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / igmp snooping disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / igmp snooping profile someword3 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / routed interface BVI1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 (config-l2vpn-bg-bd-ac) for sub, attributes2 in attributes.mapping_values( 'interface_attr', keys=self.interfaces, sort=True): configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / ip-source-guard (config-l2vpn-bg-bd-ipsg) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / ip-source-guard / logging # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / mac (config-l2vpn-bg-bd-mac) ns, attributes2 = attributes.namespace('mac') if ns is not None: configurations.append_block( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / member vni 1 (config-l2vpn-bg-bd-vni) for sub, attributes2 in attributes.mapping_values( 'vni_attr', keys=self.vnis, sort=True): configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / mld snooping profile someword3 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / mtu 100 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / neighbor 1.2.3.4 pw-id 1 (config-l2vpn-bg-bd-pw) for sub, attributes2 in attributes.mapping_values( 'neighbor_attr', keys=self.pseudowire_neighbors, sort=True): configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / neighbor evpn evi 1 target 1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / neighbor evpn evi 1 target 1 source 1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / nv satellite (config-l2vpn-bg-bd-nv) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / nv satellite / offload ipv4 multicast enable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb core (config-l2vpn-bg-bd-pbb-core) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb core / evi 1 (config-l2vpn-bg-bd-pbb-core-evi) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb core / mac (config-l2vpn-bg-bd-pbb-core-mac) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb core / mac / aging (config-l2vpn-bg-bd-pbb-core-mac-aging) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb core / mac / aging / time 300 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb core / mac / aging / type absolute # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb core / mac / aging / type inactivity # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb core / mac / learning # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb core / mac / learning disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb core / mmrp-flood-optimization # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb core / rewrite ingress tag push dot1ad 1 symmetric # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 (config-l2vpn-bg-bd-pbb-edge) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / dhcp ipv4 none # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / dhcp ipv4 snoop profile someword4 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / igmp snooping profile someword4 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac (config-l2vpn-bg-bd-pbb-edge-mac) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / aging (config-l2vpn-bg-bd-pbb-edge-mac-aging) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / aging / time 300 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / aging / type absolute # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / aging / type inactivity # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / learning # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / learning disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / limit (config-l2vpn-bg-bd-pbb-edge-mac-limit) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / limit / action flood # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / limit / action no-flood # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / limit / action none # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / limit / action shutdown # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / limit / maximum 1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / limit / notification both # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / limit / notification none # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / limit / notification syslog # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / limit / notification trap # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / secure (config-l2vpn-bg-bd-pbb-edge-mac-sec) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / secure / accept-shutdown # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / secure / action none # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / secure / action restrict # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / secure / action shutdown # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / secure / disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / secure / logging # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / mac / secure / logging disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / split-horizon group vfi disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / static-mac-address aaaa.bbbb.cccc bmac aaaa.bbbb.cccc # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / pbb edge i-sid 256 core-bridge someword3 / unknown-unicast-bmac aaaa.bbbb.cccc # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / shutdown if attributes.value('shutdown'): configurations.append_line('shutdown') # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / storm-control broadcast kbps 64 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / storm-control broadcast pps 1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / storm-control multicast kbps 64 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / storm-control multicast pps 1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / storm-control unknown-unicast kbps 64 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / storm-control unknown-unicast pps 1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / transport-mode vlan passthrough # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 (config-l2vpn-bg-bd-vfi) for vfi, attributes2 in attributes.sequence_values('vfis'): configurations.append_block( str( vfi.build_config(apply=False, attributes=attributes2, unconfig=unconfig))) submode_stack.close() if apply: if configurations: self.device.configure(str(configurations), fail_invalid=True) else: return CliConfig(device=self.device, unconfig=unconfig, cli_config=configurations, fail_invalid=True)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not apply assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: l2vpn / bridge group someword (config-l2vpn-bg) # iosxr: l2vpn / bridge group someword (config-l2vpn-bg) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 (config-l2vpn-bg-bd) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / routed interface BVI1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 (config-l2vpn-bg-bd-ac) with configurations.submode_context( attributes.format( 'routed interface {interface_name}' if isinstance( self.interface, BviInterface) else 'interface {interface_name}', force=True), exit_cmd='' if isinstance(self.interface, BviInterface) else 'exit', # routed interface may not be an actual submode ): if unconfig and attributes.iswildcard: configurations.submode_unconfig() if isinstance(self.interface, BviInterface): # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / routed interface BVI1 / split-horizon group core v = attributes.value('split_horizon_group_core') if v is True: configurations.append_line( 'split-horizon group core') if configurations: # There are configurations... It must be a submode; exit. configurations.append_line('exit', raw=True) else: # There are no configurations... May not be be a submode; Don't exit. pass else: # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dhcp ipv4 none # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dhcp ipv4 snoop profile someword3 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dynamic-arp-inspection (config-l2vpn-bg-bd-ac-dai) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dynamic-arp-inspection / address-validation (config-l2vpn-bg-bd-ac-dai-av) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dynamic-arp-inspection / address-validation / dst-mac # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dynamic-arp-inspection / address-validation / dst-mac disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dynamic-arp-inspection / address-validation / ipv4 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dynamic-arp-inspection / address-validation / ipv4 disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dynamic-arp-inspection / address-validation / src-mac # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dynamic-arp-inspection / address-validation / src-mac disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dynamic-arp-inspection / disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dynamic-arp-inspection / logging # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / dynamic-arp-inspection / logging disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / flooding # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / flooding disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / flooding unknown-unicast # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / flooding unknown-unicast disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / igmp snooping profile someword3 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / ip-source-guard (config-l2vpn-bg-bd-ac-ipsg) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / ip-source-guard / disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / ip-source-guard / logging # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / ip-source-guard / logging disable # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / mac (config-l2vpn-bg-bd-ac-mac) sub, attributes2 = attributes.namespace('mac') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / mac (config-l2vpn-bg-bd-ac-mac) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / mld snooping profile someword3 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / split-horizon group v = attributes.value('split_horizon_group') if v is True: configurations.append_line('split-horizon group') # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / static-mac-address aaaa.bbbb.cccc configurations.append_line( attributes.format( 'static-mac-address {static_mac_address}')) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / storm-control broadcast kbps 64 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / storm-control broadcast pps 1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / storm-control multicast kbps 64 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / storm-control multicast pps 1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / storm-control unknown-unicast kbps 64 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / interface Bundle-Ether1 / storm-control unknown-unicast pps 1 return str(configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not apply assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp (config-l2vpn-bg-bd-vfi-ad) with configurations.submode_context('autodiscovery bgp'): if not attributes.value('enabled', force=True): configurations.submode_cancel() # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / control-word if attributes.value('control_word'): configurations.append_line('control-word') # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / rd 1.2.3.4:1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / rd 100000:200 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / rd 100:200000 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / rd auto configurations.append_line(attributes.format('rd {rd}')) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-policy export <rtepol> configurations.append_line( attributes.format('route-policy {export_route_policy}')) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target 1.2.3.4:1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target 100000:200 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target 100:200000 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target export 1.2.3.4:1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target export 100000:200 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target export 100:200000 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target export import 1.2.3.4:1 (bug) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target export import 100000:200 (bug) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target export import 100:200000 (bug) both_route_targets = set(self.export_route_targets) & set( self.import_route_targets) for v, attributes2 in attributes.sequence_values( 'export_route_targets', sort=True): if v in both_route_targets: cfg = 'route-target {}'.format(v.route_target) else: cfg = 'route-target export {}'.format(v.route_target) if v.stitching: warnings.warn(UnsupportedAttributeWarning, 'route-target export/import stitching') configurations.append_line(cfg) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target import 1.2.3.4:1 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target import 100000:200 # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / route-target import 100:200000 for v, attributes2 in attributes.sequence_values( 'import_route_targets', sort=True): if v not in both_route_targets: cfg = 'route-target import {}'.format(v.route_target) if v.stitching: warnings.warn( UnsupportedAttributeWarning, 'route-target export/import stitching') configurations.append_line(cfg) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / signaling-protocol bgp (config-l2vpn-bg-bd-vfi-ad-sig) sub, attributes2 = attributes.namespace( 'signaling_protocol_bgp') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / signaling-protocol ldp (config-l2vpn-bg-bd-vfi-ad-sig) sub, attributes2 = attributes.namespace( 'signaling_protocol_ldp') if sub is not None: configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / table-policy <rtepol> configurations.append_line( attributes.format('table-policy {table_policy}')) return str(configurations)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: l2vpn (config-l2vpn) with configurations.submode_context('l2vpn'): if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxr: l2vpn / autodiscovery bgp (config-l2vpn-ad) # iosxr: l2vpn / autodiscovery bgp / signaling-protocol bgp (config-l2vpn-ad-sig) # iosxr: l2vpn / autodiscovery bgp / signaling-protocol bgp / mtu mismatch ignore # iosxr: l2vpn / bridge group someword (config-l2vpn-bg) # iosxr: l2vpn / bridge group someword / bridge-domain someword2 (config-l2vpn-bg-bd) for bd, attributes2 in attributes.sequence_values( 'bridge_domains'): configurations.append_block( str( bd.build_config(apply=False, attributes=attributes2, unconfig=unconfig, contained=True))) # iosxr: l2vpn / capability high-mode # iosxr: l2vpn / capability single-mode # iosxr: l2vpn / description someword # iosxr: l2vpn / ethernet ring g8032 someword (config-l2vpn) for ring, attributes2 in attributes.sequence_values( 'g8032_rings'): configurations.append_block( str( ring.build_config(apply=False, attributes=attributes2, unconfig=unconfig))) # iosxr: l2vpn / flexible-xconnect-service vlan-unaware someword (config-l2vpn) # iosxr: l2vpn / flexible-xconnect-service vlan-unaware someword / interface Bundle-Ether1 # iosxr: l2vpn / flexible-xconnect-service vlan-unaware someword / neighbor evpn evi 1 target 1 # iosxr: l2vpn / flexible-xconnect-service vlan-unaware someword / neighbor evpn evi 1 target 1 source 1 # iosxr: l2vpn / ignore-mtu-mismatch # iosxr: l2vpn / load-balancing flow src-dst-ip # iosxr: l2vpn / load-balancing flow src-dst-mac # iosxr: l2vpn / logging (config-l2vpn) # iosxr: l2vpn / logging / bridge-domain # iosxr: l2vpn / logging / nsr # iosxr: l2vpn / logging / pseudowire # iosxr: l2vpn / logging / pwhe-replication disable # iosxr: l2vpn / logging / vfi # iosxr: l2vpn / neighbor all ldp flap # iosxr: l2vpn / pbb (config-l2vpn) ns, attributes2 = attributes.namespace('pbb') if ns is not None: configurations.append_block( str( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig))) # iosxr: l2vpn / pw-class someword (config-l2vpn) for pwc, attributes2 in attributes.sequence_values( 'pseudowire_classes'): configurations.append_block( str( pwc.build_config(apply=False, attributes=attributes2, unconfig=unconfig, contained=True))) # iosxr: l2vpn / pw-grouping # iosxr: l2vpn / pw-oam refresh transmit 1 # iosxr: l2vpn / pw-routing (config-l2vpn) # iosxr: l2vpn / pw-routing / bgp (config-l2vpn) # iosxr: l2vpn / pw-routing / bgp / rd 100:200000 # iosxr: l2vpn / pw-routing / bgp / rd 65536:200 # iosxr: l2vpn / pw-routing / bgp / rd 1.2.3.4:1 # iosxr: l2vpn / pw-routing / global-id 1 # iosxr: l2vpn / pw-status disable # iosxr: l2vpn / redundancy (config-l2vpn) # iosxr: l2vpn / redundancy / iccp group 1 (config-l2vpn) # See IccpGroup objects # iosxr: l2vpn / router-id 1.2.3.4 configurations.append_line( attributes.format('router-id {router_id}')) # iosxr: l2vpn / snmp mib interface format external # iosxr: l2vpn / snmp mib pseudowire statistics # iosxr: l2vpn / tcn-propagation # iosxr: l2vpn / xconnect group someword (config-l2vpn) # iosxr: l2vpn / xconnect group someword / mp2mp someword2 (config-l2vpn) # iosxr: l2vpn / xconnect group someword / p2p someword2 (config-l2vpn) for xc, attributes2 in attributes.sequence_values('xconnects'): configurations.append_block( str( xc.build_config(apply=False, attributes=attributes2, unconfig=unconfig, contained=True))) if apply: if configurations: self.device.configure(configurations, fail_invalid=True) else: return CliConfig(device=self.device, unconfig=unconfig, cli_config=configurations, fail_invalid=True)
def build_config(self, interfaces=None, apply=True, attributes=None, unconfig=False, **kwargs): # assert not apply attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) if interfaces is None: interfaces = set(self.interfaces) else: interfaces = set(self.interfaces).intersection(interfaces) # iosxr: evpn (config-evpn) with configurations.submode_context('evpn'): if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxr: evpn / bgp (config-evpn-bgp) ns, attributes2 = attributes.namespace('bgp') if ns is not None: configurations.append_block( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig, **kwargs)) # iosxr: evpn / evi 1 (config-evpn-evi) for evi, attributes2 in attributes.sequence_values('evis', sort=True): if unconfig: configurations.append_block( evi.build_unconfig(apply=False, attributes=attributes2)) else: configurations.append_block( evi.build_config(apply=False, attributes=attributes2)) # iosxr: evpn / interface Bundle-Ether1 (config-evpn-ac) for sub, attributes2 in attributes.mapping_values( 'interface_attr', keys=interfaces, sort=True): configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig, **kwargs)) # iosxr: evpn / virtual neighbor 70.70.70.70 pw-id 17300005 for sub, attributes2 in attributes.mapping_values( 'pw_neighbor_attr', sort=True): configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig, **kwargs)) # iosxr: evpn / virtual vfi ac-vfi-5 for sub, attributes2 in attributes.mapping_values('vfi_attr', sort=True): configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig, **kwargs)) # iosxr: evpn / timers (config-evpn-timers) with configurations.submode_context('timers', cancel_empty=True): # iosxr: evpn / timers / recovery 20 configurations.append_line( attributes.format('recovery {recovery_timer}')) # iosxr: evpn / timers / peering <0-300> configurations.append_line( attributes.format('peering {peering_timer}')) # iosxr: evpn / source interface Loopback0 configurations.append_line( attributes.format( 'source interface {source_interface.name}')) # iosxr: evpn / load-balancing (config-evpn-lb) ns, attributes2 = attributes.namespace('load_balancing') if ns is not None: configurations.append_block( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig, **kwargs)) # iosxr: evpn / bgp (config-evpn-bgp) ns, attributes2 = attributes.namespace('bgp') if ns is not None: configurations.append_block( ns.build_config(apply=False, attributes=attributes2, unconfig=unconfig, **kwargs)) if apply: if configurations: self.device.configure(configurations, fail_invalid=True) else: return CliConfig(device=self.device, unconfig=unconfig, cli_config=configurations, fail_invalid=True)
def build_config(self, apply=True, attributes=None, unconfig=False, contained=False, **kwargs): assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: l2vpn (config-l2vpn) submode_stack = contextlib.ExitStack() if not contained: submode_stack.enter_context( configurations.submode_context('l2vpn')) # iosxr: l2vpn / xconnect group someword (config-l2vpn) with configurations.submode_context( attributes.format('xconnect group {group_name}', force=True, cancel_empty=True)): if self.xconnect_type is _Xconnect.Type.mp2mp: # iosxr: l2vpn / xconnect group someword / mp2mp someword2 (config-l2vpn) with configurations.submode_context( attributes.format('mp2mp {name}', force=True)): if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / control-word disable # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / interworking ethernet # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / l2-encapsulation ethernet # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / l2-encapsulation vlan # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / mtu 64 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / shutdown # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / vpn-id 1 configurations.append_line( attributes.format('vpn-id {vpn_id}')) # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp (config-l2vpn) ns, attributes2 = attributes.namespace( 'autodiscovery_bgp') if ns: configurations.append_block( ns.build_config(apply=False, unconfig=unconfig, attributes=attributes2)) elif self.xconnect_type is _Xconnect.Type.p2p: # iosxr: l2vpn / xconnect group someword / p2p someword2 (config-l2vpn) with configurations.submode_context( attributes.format('p2p {name}', force=True)): if unconfig and attributes.iswildcard: configurations.submode_unconfig() # iosxr: l2vpn / xconnect group someword / p2p someword2 / backup interface Bundle-Ether1 # iosxr: l2vpn / xconnect group someword / p2p someword2 / description someword3 configurations.append_line( attributes.format('description {description}')) # iosxr: l2vpn / xconnect group someword / p2p someword2 / interface Bundle-Ether1 for interface, attributes2 in attributes.sequence_values( 'interfaces', sort=True): configurations.append_line('interface {}'.\ format(interface.name)) # iosxr: l2vpn / xconnect group someword / p2p someword2 / interworking ethernet # iosxr: l2vpn / xconnect group someword / p2p someword2 / interworking ipv4 configurations.append_line( attributes.format('interworking {interworking}')) # iosxr: l2vpn / xconnect group someword / p2p someword2 / monitor-session someword3 # iosxr: l2vpn / xconnect group someword / p2p someword2 / neighbor 1.2.3.4 pw-id 1 (config-l2vpn) # iosxr: l2vpn / xconnect group someword / p2p someword2 / neighbor ipv4 1.2.3.4 pw-id 1 (config-l2vpn) # iosxr: l2vpn / xconnect group someword / p2p someword2 / neighbor ipv6 1:2::3 pw-id 1 (config-l2vpn) for sub, attributes2 in attributes.mapping_values( 'neighbor_attr', keys=self.pseudowire_neighbors, sort=True): configurations.append_block( sub.build_config(apply=False, attributes=attributes2, unconfig=unconfig)) # iosxr: l2vpn / xconnect group someword / p2p someword2 / neighbor evpn evi 1 target 1 source 1 else: warnings.warn( 'xconnect type mode {}'.format(self.xconnect_type), UnsupportedAttributeWarning) submode_stack.close() if apply: if configurations: self.device.configure(str(configurations), fail_invalid=True) else: return CliConfig(device=self.device, unconfig=unconfig, cli_config=configurations, fail_invalid=True)
def build_config(self, apply=True, attributes=None, unconfig=False, **kwargs): assert not apply assert not kwargs, kwargs attributes = AttributesHelper(self, attributes) configurations = CliConfigBuilder(unconfig=unconfig) # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp (config-l2vpn) with configurations.submode_context('autodiscovery bgp'): if not attributes.value('enabled', force=True): configurations.submode_cancel() # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / rd 100000:200 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / rd 100:200000 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / rd 1.2.3.4:1 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / rd auto configurations.append_line(attributes.format('rd {rd}')) # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-policy export <rtepol> # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target 100000:200 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target 100:200000 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target 1.2.3.4:1 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target export 100000:200 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target export 100:200000 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target export 1.2.3.4:1 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target export import 100000:200 (bug) # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target export import 100:200000 (bug) # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target export import 1.2.3.4:1 (bug) both_route_targets = set(self.export_route_targets) & set( self.import_route_targets) for v, attributes2 in attributes.sequence_values( 'export_route_targets', sort=True): if v in both_route_targets: cfg = 'route-target {}'.format(v.route_target) else: cfg = 'route-target export {}'.format( v.route_target) if v.stitching: warnings.warn( UnsupportedAttributeWarning, 'route-target export/import stitching') configurations.append_line(cfg) # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target import 100000:200 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target import 100:200000 # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / route-target import 1.2.3.4:1 for v, attributes2 in attributes.sequence_values( 'import_route_targets', sort=True): if v not in both_route_targets: cfg = 'route-target import {}'.format( v.route_target) if v.stitching: warnings.warn( UnsupportedAttributeWarning, 'route-target export/import stitching') configurations.append_line(cfg) # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp (config-l2vpn) ns, attributes2 = attributes.namespace( 'signaling_protocol_bgp') if ns: configurations.append_block( ns.build_config(apply=False, unconfig=unconfig, attributes=attributes2)) return str(configurations)