cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
1441
Views
0
Helpful
2
Replies
yitung
Cisco Employee

BGP VRF configuration

Hi ,

I want to do the following config but failed... anyone can help me to understand how to code it?? Many Thanks!!

I also have another question about how to add "redistribute connected". I can see "connected_routes" under Bgp.Instance.InstanceAs.FourByteAs.Vrfs.Vrf.VrfGlobal.VrfGlobalAfs.VrfGlobalAf but don't know how to construct "_is_presence"

=============================

router bgp 65001

vrf CCTV

  rd 65001:211

  address-family ipv4 unicast

   redistribute connected

=============================

I add the following to the sample config - nc-create-xr-ipv4-bgp-cfg-40-ydk.py:

# add VRF RD
bgp_vrf = four_byte_as.vrfs.Vrf()
bgp_vrf.vrf_name = "CCTV"
bgp_vrf.vrf_global.route_distinguisher.as_ = 65001
bgp_vrf.vrf_global.route_distinguisher.as_index = 211
bgp_vrf.exists = Empty()

# add VRF address_family name
vrf_af_ipv4_unicast = bgp_vrf.vrf_global.vrf_global_afs.VrfGlobalAf()
vrf_af_ipv4_unicast.af_name=xr_ipv4_bgp_datatypes.BgpAddressFamilyEnum.IPV4_UNICAST
vrf_af_ipv4_unicast.enable = Empty()
bgp_vrf.vrf_global.vrf_global_afs.vrf_global_af.append(vrf_af_ipv4_unicast)

four_byte_as.vrfs.vrf.append(bgp_vrf)
instance_as.four_byte_as.append(four_byte_as)
instance.instance_as.append(instance_as)
bgp.instance.append(instance)

Error display:

================

raise YPYServiceProviderError(error_code=YPYErrorCode.SERVER_COMMIT_ERR, error_msg=rep)

ydk.errors.YPYServiceProviderError: Server reported an error while committing change.

    error-type: application
    error-tag: operation-failed
    error-severity: error
    error-path: ns1:bgp/ns1:instance[instance-name = 'default']/ns1:instance-as[as = '0']/ns1:four-byte-as[as = '65001']/ns1:vrfs/ns1:vrf[vrf-name = 'CCTV']/ns1:vrf-global/ns1:route-distinguisher/ns1:as
    error-message: 'BGP' detected the 'warning' condition 'Invalid configuration item.'
1 ACCEPTED SOLUTION

Accepted Solutions
saalvare
Cisco Employee

You had a few mistakes. Lines 1-5, lines 11-12, line 15.  See:

    # global address family

    global_af = four_byte_as.default_vrf.global_.global_afs.GlobalAf()

    global_af.af_name = xr_ipv4_bgp_datatypes.BgpAddressFamilyEnum.vp_nv4_unicast

    global_af.enable = Empty()

    four_byte_as.default_vrf.global_.global_afs.global_af.append(global_af)

    # add VRF RD

    bgp_vrf = four_byte_as.vrfs.Vrf()

    bgp_vrf.vrf_name = "CCTV"

    bgp_vrf.vrf_global.route_distinguisher.type = xr_ipv4_bgp_cfg.BgpRouteDistinguisherEnum.as_

    bgp_vrf.vrf_global.route_distinguisher.as_xx = 0

    bgp_vrf.vrf_global.route_distinguisher.as_ = 65001

    bgp_vrf.vrf_global.route_distinguisher.as_index = 211

    bgp_vrf.vrf_global.exists = Empty()

    # add VRF address_family name

    vrf_af_ipv4_unicast = bgp_vrf.vrf_global.vrf_global_afs.VrfGlobalAf()

    vrf_af_ipv4_unicast.af_name=xr_ipv4_bgp_datatypes.BgpAddressFamilyEnum.ipv4_unicast

    vrf_af_ipv4_unicast.enable = Empty()

    bgp_vrf.vrf_global.vrf_global_afs.vrf_global_af.append(vrf_af_ipv4_unicast)

    four_byte_as.vrfs.vrf.append(bgp_vrf)

Note that I'm running YDK 0.5.2, so the Enum capitalization is slightly different.

Here's app the log:

2017-01-18 13:37:54,945 - ydk.providers.netconf_provider - INFO - NetconfServiceProvider connected to carreras:None using ssh

2017-01-18 13:37:54,979 - ydk.services.crud_service - INFO - CREATE operation initiated

2017-01-18 13:37:54,983 - ydk.providers._provider_plugin - DEBUG -

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:76421c22-4345-447d-ad76-360d7e3ce3d9">

  <edit-config>

    <target>

      <candidate/>

    </target>

    <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">

      <bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-cfg">

        <instance>

          <instance-name>default</instance-name>

          <instance-as>

            <as>0</as>

            <four-byte-as>

              <as>65001</as>

              <bgp-running></bgp-running>

              <default-vrf>

                <bgp-entity>

                  <neighbor-groups>

                    <neighbor-group>

                      <neighbor-group-name>IBGP</neighbor-group-name>

                      <create></create>

                      <neighbor-group-afs>

                        <neighbor-group-af>

                          <af-name>ipv4-unicast</af-name>

                          <activate></activate>

                        </neighbor-group-af>

                      </neighbor-group-afs>

                      <remote-as>

                        <as-xx>0</as-xx>

                        <as-yy>65001</as-yy>

                      </remote-as>

                      <update-source-interface>Loopback0</update-source-interface>

                    </neighbor-group>

                  </neighbor-groups>

                  <neighbors>

                    <neighbor>

                      <neighbor-address>172.16.255.2</neighbor-address>

                      <neighbor-group-add-member>IBGP</neighbor-group-add-member>

                    </neighbor>

                  </neighbors>

                </bgp-entity>

                <global>

                  <global-afs>

                    <global-af>

                      <af-name>ipv4-unicast</af-name>

                      <enable></enable>

                    </global-af>

                    <global-af>

                      <af-name>vp-nv4-unicast</af-name>

                      <enable></enable>

                    </global-af>

                  </global-afs>

                </global>

              </default-vrf>

              <vrfs>

                <vrf>

                  <vrf-name>CCTV</vrf-name>

                  <vrf-global>

                    <exists></exists>

                    <route-distinguisher>

                      <as>65001</as>

                      <as-index>211</as-index>

                      <as-xx>0</as-xx>

                      <type>as</type>

                    </route-distinguisher>

                    <vrf-global-afs>

                      <vrf-global-af>

                        <af-name>ipv4-unicast</af-name>

                        <enable></enable>

                      </vrf-global-af>

                    </vrf-global-afs>

                  </vrf-global>

                </vrf>

              </vrfs>

            </four-byte-as>

          </instance-as>

        </instance>

      </bgp>

    </config>

  </edit-config>

</rpc>

2017-01-18 13:37:55,099 - ydk.providers._provider_plugin - DEBUG -

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:76421c22-4345-447d-ad76-360d7e3ce3d9">

  <ok/>

</rpc-reply>

2017-01-18 13:37:55,100 - ydk.providers._provider_plugin - DEBUG -

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

  <commit/>

</rpc>

2017-01-18 13:37:55,466 - ydk.providers._provider_plugin - DEBUG -

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:76421c22-4345-447d-ad76-360d7e3ce3d9">

  <ok/>

</rpc-reply>

2017-01-18 13:37:55,466 - ydk.services.crud_service - INFO - CREATE operation completed

2017-01-18 13:37:55,663 - ydk.providers.netconf_provider - INFO - NetconfServiceProvider disconnected from carreras using ssh

View solution in original post

2 REPLIES 2
saalvare
Cisco Employee

You had a few mistakes. Lines 1-5, lines 11-12, line 15.  See:

    # global address family

    global_af = four_byte_as.default_vrf.global_.global_afs.GlobalAf()

    global_af.af_name = xr_ipv4_bgp_datatypes.BgpAddressFamilyEnum.vp_nv4_unicast

    global_af.enable = Empty()

    four_byte_as.default_vrf.global_.global_afs.global_af.append(global_af)

    # add VRF RD

    bgp_vrf = four_byte_as.vrfs.Vrf()

    bgp_vrf.vrf_name = "CCTV"

    bgp_vrf.vrf_global.route_distinguisher.type = xr_ipv4_bgp_cfg.BgpRouteDistinguisherEnum.as_

    bgp_vrf.vrf_global.route_distinguisher.as_xx = 0

    bgp_vrf.vrf_global.route_distinguisher.as_ = 65001

    bgp_vrf.vrf_global.route_distinguisher.as_index = 211

    bgp_vrf.vrf_global.exists = Empty()

    # add VRF address_family name

    vrf_af_ipv4_unicast = bgp_vrf.vrf_global.vrf_global_afs.VrfGlobalAf()

    vrf_af_ipv4_unicast.af_name=xr_ipv4_bgp_datatypes.BgpAddressFamilyEnum.ipv4_unicast

    vrf_af_ipv4_unicast.enable = Empty()

    bgp_vrf.vrf_global.vrf_global_afs.vrf_global_af.append(vrf_af_ipv4_unicast)

    four_byte_as.vrfs.vrf.append(bgp_vrf)

Note that I'm running YDK 0.5.2, so the Enum capitalization is slightly different.

Here's app the log:

2017-01-18 13:37:54,945 - ydk.providers.netconf_provider - INFO - NetconfServiceProvider connected to carreras:None using ssh

2017-01-18 13:37:54,979 - ydk.services.crud_service - INFO - CREATE operation initiated

2017-01-18 13:37:54,983 - ydk.providers._provider_plugin - DEBUG -

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:76421c22-4345-447d-ad76-360d7e3ce3d9">

  <edit-config>

    <target>

      <candidate/>

    </target>

    <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">

      <bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-cfg">

        <instance>

          <instance-name>default</instance-name>

          <instance-as>

            <as>0</as>

            <four-byte-as>

              <as>65001</as>

              <bgp-running></bgp-running>

              <default-vrf>

                <bgp-entity>

                  <neighbor-groups>

                    <neighbor-group>

                      <neighbor-group-name>IBGP</neighbor-group-name>

                      <create></create>

                      <neighbor-group-afs>

                        <neighbor-group-af>

                          <af-name>ipv4-unicast</af-name>

                          <activate></activate>

                        </neighbor-group-af>

                      </neighbor-group-afs>

                      <remote-as>

                        <as-xx>0</as-xx>

                        <as-yy>65001</as-yy>

                      </remote-as>

                      <update-source-interface>Loopback0</update-source-interface>

                    </neighbor-group>

                  </neighbor-groups>

                  <neighbors>

                    <neighbor>

                      <neighbor-address>172.16.255.2</neighbor-address>

                      <neighbor-group-add-member>IBGP</neighbor-group-add-member>

                    </neighbor>

                  </neighbors>

                </bgp-entity>

                <global>

                  <global-afs>

                    <global-af>

                      <af-name>ipv4-unicast</af-name>

                      <enable></enable>

                    </global-af>

                    <global-af>

                      <af-name>vp-nv4-unicast</af-name>

                      <enable></enable>

                    </global-af>

                  </global-afs>

                </global>

              </default-vrf>

              <vrfs>

                <vrf>

                  <vrf-name>CCTV</vrf-name>

                  <vrf-global>

                    <exists></exists>

                    <route-distinguisher>

                      <as>65001</as>

                      <as-index>211</as-index>

                      <as-xx>0</as-xx>

                      <type>as</type>

                    </route-distinguisher>

                    <vrf-global-afs>

                      <vrf-global-af>

                        <af-name>ipv4-unicast</af-name>

                        <enable></enable>

                      </vrf-global-af>

                    </vrf-global-afs>

                  </vrf-global>

                </vrf>

              </vrfs>

            </four-byte-as>

          </instance-as>

        </instance>

      </bgp>

    </config>

  </edit-config>

</rpc>

2017-01-18 13:37:55,099 - ydk.providers._provider_plugin - DEBUG -

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:76421c22-4345-447d-ad76-360d7e3ce3d9">

  <ok/>

</rpc-reply>

2017-01-18 13:37:55,100 - ydk.providers._provider_plugin - DEBUG -

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

  <commit/>

</rpc>

2017-01-18 13:37:55,466 - ydk.providers._provider_plugin - DEBUG -

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:76421c22-4345-447d-ad76-360d7e3ce3d9">

  <ok/>

</rpc-reply>

2017-01-18 13:37:55,466 - ydk.services.crud_service - INFO - CREATE operation completed

2017-01-18 13:37:55,663 - ydk.providers.netconf_provider - INFO - NetconfServiceProvider disconnected from carreras using ssh

View solution in original post

Overlooked your redistribution statement.  You  need to instantiate the presence class described in the documentation. See https://goo.gl/2mmaiT

This line creates the right config object:

    vrf_af_ipv4_unicast.connected_routes = vrf_af_ipv4_unicast.ConnectedRoutes()

Your IPv4 unicast config for the VRF would look:

    # add VRF RD

    bgp_vrf = four_byte_as.vrfs.Vrf()

    bgp_vrf.vrf_name = "CCTV"

    bgp_vrf.vrf_global.route_distinguisher.type = xr_ipv4_bgp_cfg.BgpRouteDistinguisherEnum.as_

    bgp_vrf.vrf_global.route_distinguisher.as_xx = 0

    bgp_vrf.vrf_global.route_distinguisher.as_ = 65001

    bgp_vrf.vrf_global.route_distinguisher.as_index = 211

    bgp_vrf.vrf_global.exists = Empty()

    # add VRF address_family name

    vrf_af_ipv4_unicast = bgp_vrf.vrf_global.vrf_global_afs.VrfGlobalAf()

    vrf_af_ipv4_unicast.af_name=xr_ipv4_bgp_datatypes.BgpAddressFamilyEnum.ipv4_unicast

    vrf_af_ipv4_unicast.enable = Empty()

    vrf_af_ipv4_unicast.connected_routes = vrf_af_ipv4_unicast.ConnectedRoutes()

Hope that clarifies.

Create
Recognize Your Peers
Content for Community-Ad