예제 #1
0
        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)
예제 #2
0
            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)
예제 #3
0
            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 / signaling-protocol ldp (config-l2vpn-bg-bd-vfi-ad-sig)
                with configurations.submode_context('signaling-protocol ldp'):
                    if not attributes.value('enabled', force=True):
                        configurations.submode_cancel()

                    # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / signaling-protocol ldp / load-balancing flow-label both
                    # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / signaling-protocol ldp / load-balancing flow-label both static
                    # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / signaling-protocol ldp / load-balancing flow-label receive
                    # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / signaling-protocol ldp / load-balancing flow-label receive static
                    # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / signaling-protocol ldp / load-balancing flow-label transmit
                    # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / signaling-protocol ldp / load-balancing flow-label transmit static

                    # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / signaling-protocol ldp / vpls-id 1.2.3.4:1
                    # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / autodiscovery bgp / signaling-protocol ldp / vpls-id 100:200000
                    configurations.append_line(
                        attributes.format('vpls-id {vpls_id}'))

                return str(configurations)
예제 #4
0
파일: vfi.py 프로젝트: pythonxian/genielibs
            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 / signaling-protocol bgp (config-l2vpn-bg-bd-vfi-ad-sig)
                with configurations.submode_context('signaling-protocol bgp'):
                    if not attributes.value('enabled', force=True):
                        configurations.submode_cancel()

                return str(configurations)
예제 #5
0
            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)
예제 #6
0
            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)

                with configurations.submode_context(
                        'autodiscovery bgp signaling bgp'):
                    if not attributes.value('enabled', force=True):
                        configurations.submode_cancel()

                return str(configurations)
예제 #7
0
파일: vfi.py 프로젝트: pythonxian/genielibs
            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 / transport rsvp-te (config-l2vpn-bg-bd-vfi-p2mp-te)
                with configurations.submode_context('transport rsvp-te'):
                    if not attributes.value('enabled', force=True):
                        configurations.submode_cancel()

                    # iosxr: l2vpn / bridge group someword / bridge-domain someword2 / vfi someword3 / multicast p2mp / transport rsvp-te / attribute-set p2mp-te someword4
                    configurations.append_line(attributes.format('attribute-set p2mp-te {attribute_set_p2mp_te}'))

                return str(configurations)
예제 #8
0
                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 / signaling-protocol bgp (config-l2vpn)
                    with configurations.submode_context(
                            'signaling-protocol bgp'):
                        if not attributes.value('enabled', force=True):
                            configurations.submode_cancel()

                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / ce-range 11
                        configurations.append_line(
                            attributes.format('ce-range {ce_range}'))

                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / ce-id 1 (config-l2vpn)
                        for ns, attributes2 in attributes.mapping_values(
                                'ce_attr', keys=self.ce_ids, sort=True):
                            configurations.append_block(
                                ns.build_config(apply=False,
                                                unconfig=unconfig,
                                                attributes=attributes2))

                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label both
                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label both static
                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label receive
                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label receive static
                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label transmit
                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label transmit static

                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label both
                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label both static
                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label receive
                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label receive static
                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label transmit
                        # iosxr: l2vpn / xconnect group someword / mp2mp someword2 / autodiscovery bgp / signaling-protocol bgp / load-balancing flow-label transmit static

                    return str(configurations)
예제 #9
0
            def build_config(self,
                             apply=True,
                             attributes=None,
                             unconfig=False,
                             **kwargs):
                assert not apply
                attributes = AttributesHelper(self, attributes)
                configurations = CliConfigBuilder(unconfig=unconfig)

                # iosxr: evpn / load-balancing (config-evpn-lb)
                with configurations.submode_context('load-balancing'):
                    if not attributes.value('enabled', force=True):
                        configurations.submode_cancel()
                    if unconfig and attributes.iswildcard:
                        configurations.submode_unconfig()

                    # iosxr: evpn / load-balancing / flow-label static
                    if attributes.value('flow_label_static'):
                        configurations.append_line('flow-label static')

                return str(configurations)
예제 #10
0
            def build_config(self,
                             apply=True,
                             attributes=None,
                             unconfig=False,
                             **kwargs):
                assert not apply
                attributes = AttributesHelper(self, attributes)
                configurations = CliConfigBuilder(unconfig=unconfig)

                # iosxr: evpn / bgp (config-evpn-bgp)
                with configurations.submode_context('bgp'):
                    if not attributes.value('enabled', force=True):
                        configurations.submode_cancel()
                    if unconfig and attributes.iswildcard:
                        configurations.submode_unconfig()

                    # iosxr: evpn / bgp / rd 100:200000
                    # iosxr: evpn / bgp / rd 65536:200
                    # iosxr: evpn / bgp / rd 1.2.3.4:1
                    configurations.append_line(attributes.format('rd {rd}'))

                return str(configurations)
예제 #11
0
        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)
예제 #12
0
            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)