示例#1
0
def setup_script(vsdParams):

    print ("These are the VSD params: " + str(vsdParams))
    servicetype = vsdParams['servicetype']
    vni = vsdParams['vni']
    rtdc = vsdParams['rt']

# add "target:" if provisioned by VSD (VSD uses x:x format whereas tools
# command uses target:x:x format)
    if not rtdc.startswith('target'):
        rtdc = "target:" + rtdc

    metadata = vsdParams['metadata']

# remove trailing space at the end of the metadata
    metadata = metadata.rstrip()

    print ("VSD metadata" + str(metadata))

    metadata = dict(e.split('=') for e in metadata.split(','))
    print ("Modified metadata" + str(metadata))
    vplsSvc_id = str(int(dyn.select_free_id("service-id")) + 500)
    print ("this is the free svc id picked up by the system: " + vplsSvc_id)

    if servicetype == "L2DOMAIN":

        rddc = metadata['rddc']
        rdwan = metadata['rdwan']
        rtwan = metadata['rtwan']
        if not rtwan.startswith('target'):
            rtwan = "target:" + rtwan
        print ('servicetype, VPLS id, rtdc, vni, rddc, rdwan, rtwan:',
               servicetype, vplsSvc_id, rtdc, vni, rddc, rdwan, rtwan)
        dyn.add_cli("""
        configure service
           vpls %(vplsSvc_id)s customer 1 create
              description vpls%(vplsSvc_id)s
              bgp
                 route-distinguisher %(rddc)s
                 route-target %(rtdc)s
              exit
              bgp 2
                 route-distinguisher %(rdwan)s
                 route-target %(rtwan)s
              exit
              vxlan vni %(vni)s create
              exit
              bgp-evpn
                  evi %(vplsSvc_id)s
                  vxlan
                      no shut
                  exit
                  mpls
                      ingress-replication-bum-label
                      ecmp 2
                      bgp-instance 2
                      auto-bind-tunnel
                          resolution any
                      exit
                      no shutdown
                  exit
              exit
              no shutdown
              exit
            exit
        exit
      """ % {'vplsSvc_id': vplsSvc_id, 'vni': vsdParams['vni'], 'rtdc': rtdc, 'rddc': rddc, 'rdwan': rdwan, 'rtwan': rtwan})
        # L2DOMAIN returns setupParams: vplsSvc_id, servicetype, vni
        return {'vplsSvc_id': vplsSvc_id,
                'servicetype': servicetype, 'vni': vni}
def setup_script(vsdParams):

    print("These are the VSD params: " + str(vsdParams))
    servicetype = vsdParams.get('servicetype')
    vni = vsdParams.get('vni')
    rt = vsdParams.get('rt')

    # add "target:" if provisioned by VSD (VSD uses x:x format whereas tools
    # command uses target:x:x format)
    if not rt.startswith('target'):
        rt = "target:" + rt

    metadata = vsdParams['metadata']

    # remove trailing space at the end of the metadata
    metadata = metadata.rstrip()

    print("VSD metadata" + str(metadata))
    metadata = dict(e.split('=') for e in metadata.split(','))
    print("Modified metadata" + str(metadata))
    vplsSvc_id = dyn.select_free_id("service-id")
    vprnSvc_id = dyn.select_free_id("service-id")
    print("this are the free svc ids picked up by the system: VPLS:" +
          vplsSvc_id + " + VPRN:" + vprnSvc_id)

    if servicetype == "L2DOMAIN-IRB":
        vprn_RD = metadata['vprnRD']
        vprn_RT = metadata['vprnRT']
        irb_GW = metadata['irbGW']
        vrrp_ID = metadata['vrrpID']
        vrrp_IP = metadata['vrrpIP']
        vrrp_PRIO = metadata['vrrpPRIO']
        print(
            'servicetype, VPLS id, rt, vni, VPRN id, vprn_RD, vprn_RT, irb_GW, vrrp_ID, vrrp_IP, vrrp_PRIO:',
            servicetype, vplsSvc_id, rt, vni, vprnSvc_id, vprn_RD, vprn_RT,
            irb_GW, vrrp_ID, vrrp_IP, vrrp_PRIO)
        dyn.add_cli(
            """
        configure service
           vpls %(vplsSvc_id)s customer 1 name vpls%(vplsSvc_id)s create
              allow-ip-int-bind vxlan-ipv4-tep-ecmp
              exit
              description vpls%(vplsSvc_id)s
              bgp
                 route-target %(rt)s
              exit
              vxlan vni %(vni)s create
              exit
              bgp-evpn
                  evi %(vplsSvc_id)s
                  vxlan
                      no shut
                  exit
              exit
              no shutdown
              exit
            exit
        exit
        configure service
           vprn %(vprnSvc_id)s customer 1 create
              auto-bind-tunnel resolution any
              route-distinguisher %(vprn_RD)s
              vrf-target %(vprn_RT)s
              interface "irbvpls-%(vplsSvc_id)s" create
                 address %(irb_GW)s
                 vrrp %(vrrp_ID)s
                     priority %(vrrp_PRIO)s
                     backup %(vrrp_IP)s
                     ping-reply
                 exit
                 vpls "vpls%(vplsSvc_id)s"
                 exit
              exit
              no shutdown
           exit
        exit

      """ % {
                'vplsSvc_id': vplsSvc_id,
                'vprnSvc_id': vprnSvc_id,
                'vni': vsdParams['vni'],
                'rt': rt,
                'vprn_RD': vprn_RD,
                'vprn_RT': vprn_RT,
                'irb_GW': irb_GW,
                'vrrp_ID': vrrp_ID,
                'vrrp_IP': vrrp_IP,
                'vrrp_PRIO': vrrp_PRIO
            })
        # L2DOMAIN-IRB returns setupParams: vplsSvc_id, vprnSvc_id,
        # servicetype, vni, vprn_RD, vprn_RT, irb_GW, vrrp_ID, vrrp_IP,
        # vrrp_PRIO
        return {
            'vplsSvc_id': vplsSvc_id,
            'vprnSvc_id': vprnSvc_id,
            'servicetype': servicetype,
            'vni': vni,
            'vprn_RD': vprn_RD,
            'vprn_RT': vprn_RT,
            'irb_GW': irb_GW,
            'vrrp_ID': vrrp_ID,
            'vrrp_IP': vrrp_IP,
            'vrrp_PRIO': vrrp_PRIO
        }
示例#3
0
def setup_script(vsdParams):

    print ("These are the VSD params: " + str(vsdParams))
    servicetype = vsdParams['servicetype']
    vni = vsdParams['vni']
    rt = vsdParams['rt']

# add "target:" if provisioned by VSD (VSD uses x:x format whereas tools
# command uses target:x:x format)
    if not rt.startswith('target'):
        rt = "target:" + rt

    metadata = vsdParams['metadata']

# remove trailing space at the end of the metadata
    metadata = metadata.rstrip()

    print ("VSD metadata" + str(metadata))

    metadata = dict(e.split('=') for e in metadata.split(','))
    print ("Modified metadata" + str(metadata))
    vplsSvc_id = dyn.select_free_id("service-id")
    print ("this is the free svc id picked up by the system: " + vplsSvc_id)

    if servicetype == "L2DOMAIN":

        rd = metadata['rd']
        sap = metadata['sap']
        opergroup = metadata['opergroup']
        print ('servicetype, VPLS id, rt, vni, rd, sap, opergroup:',
               servicetype, vplsSvc_id, rt, vni, rd, sap, opergroup)
        dyn.add_cli("""
        configure service
           vpls %(vplsSvc_id)s customer 1 name  evi%(vplsSvc_id)s create
              description vpls%(vplsSvc_id)s
              proxy-arp
                 dynamic-arp-populate
                 no shut
                 exit
              bgp
                 route-distinguisher %(rd)s
                 route-target %(rt)s
              exit
              vxlan vni %(vni)s create
              exit
              bgp-evpn
                  evi %(vplsSvc_id)s
                  vxlan
                      no shut
                  exit
              exit
              sap %(sap)s create
                  monitor-oper-group %(opergroup)s
                  no shutdown
              exit
              no shutdown
              exit
            exit
        exit
      """ % {'vplsSvc_id': vplsSvc_id, 'vni': vsdParams['vni'], 'rt': rt, 'rd': metadata['rd'], 'sap': sap, 'opergroup': metadata['opergroup']})
        # L2DOMAIN returns setupParams: vplsSvc_id, servicetype, vni, sdp,
        # opergroup
        return {'vplsSvc_id': vplsSvc_id, 'servicetype': servicetype,
                'vni': vni, 'sap': sap, 'opergroup': opergroup}
示例#4
0
def setup_script(vsdParams):

    print("These are the VSD params: " + str(vsdParams))
    servicetype = vsdParams.get('servicetype')
    vni = vsdParams.get('vni')
    rt = vsdParams.get('rt')

    # add "target:" if provisioned by VSD (VSD uses x:x format whereas tools
    # command uses target:x:x format)
    if not rt.startswith('target'):
        rt = "target:" + rt

    metadata = vsdParams['metadata']

    # remove trailing space at the end of the metadata
    metadata = metadata.rstrip()

    print("VSD metadata" + str(metadata))
    metadata = dict(e.split('=') for e in metadata.split(','))
    print("Modified metadata" + str(metadata))
    vplsSvc_id = dyn.select_free_id("service-id")
    vprnSvc_id = dyn.select_free_id("service-id")
    print("this are the free svc ids picked up by the system: VPLS:" +
          vplsSvc_id + " + VPRN:" + vprnSvc_id)

    if servicetype == "VRF-VXLAN":

        rd = metadata['rd']
        vprn_AS = metadata['vprnAS']
        vprn_RD = metadata['vprnRD']
        vprn_RT = metadata['vprnRT']
        vprn_Lo = metadata['vprnLo']
        customer = metadata['customer']
        customeras = metadata['customeras']
        customerip = metadata['customerip']
        customerpass = metadata['customerpass']
        customersubnet = metadata['customersubnet']
        customersap = metadata['customersap']
        print(
            'servicetype, VPLS id, rt, vni, rd, VPRN id, vprn_AS, vprn_RD, vprn_RT, vprn_Lo, customer, customeras, customerip, customerpass, customersubnet, customersap:',
            servicetype, vplsSvc_id, rt, vni, rd, vprnSvc_id, vprn_AS, vprn_RD,
            vprn_RT, vprn_Lo, customer, customeras, customerip, customerpass,
            customersubnet, customersap)
        dyn.add_cli(
            """
        configure router policy-options
           begin
             community _VSD_%(vplsSvc_id)s members %(rt)s
             policy-statement vsi_import_%(vplsSvc_id)s
                entry 10
                   from
                      family evpn
                      community _VSD_%(vplsSvc_id)s
                      exit
                   action accept
                   exit
                exit
             exit
             policy-statement vsi_export_%(vplsSvc_id)s
                entry 10
                   from
                      family evpn
                      exit
                      action accept
                      community add _VSD_%(vplsSvc_id)s
                      exit
                   exit
              exit
           commit
        exit

        configure service
           vpls %(vplsSvc_id)s customer 1  name l3-backhaul-vpls%(vplsSvc_id)s create
              allow-ip-int-bind vxlan-ipv4-tep-ecmp
                 exit
              description vpls%(vplsSvc_id)s
              bgp
                 route-distinguisher %(rd)s
                 vsi-import vsi_import_%(vplsSvc_id)s
                 vsi-export vsi_export_%(vplsSvc_id)s
                 exit
              vxlan vni %(vni)s create
                 exit
              bgp-evpn
                 ip-route-advertisement
                 vxlan
                     no shut
                     exit
                 exit
              no shutdown
              exit
            exit
        exit


        configure service
           vprn %(vprnSvc_id)s customer 1 create
              auto-bind-tunnel resolution any
              router-id %(vprn_Lo)s
              autonomous-system %(vprn_AS)s
              route-distinguisher %(vprn_RD)s
              vrf-target %(vprn_RT)s
              interface "vpls-%(vplsSvc_id)s" create
                 vpls "vpls%(vplsSvc_id)s" evpn-tunnel
                 exit
              interface "lo1" create
                 address %(vprn_Lo)s/32
                 loopback
                 exit
              no shutdown
              interface %(customer)s create
                address %(customersubnet)s
                sap %(customersap)s create
                exit
             exit
              bgp group %(customer)s
                 peer-as %(customeras)s
                 neighbor %(customerip)s authentication-key %(customerpass)s
             exit
        exit

      """ % {
                'vplsSvc_id': vplsSvc_id,
                'vprnSvc_id': vprnSvc_id,
                'vni': vsdParams['vni'],
                'rt': rt,
                'rd': metadata['rd'],
                'vprn_AS': vprn_AS,
                'vprn_RD': vprn_RD,
                'vprn_RT': vprn_RT,
                'vprn_Lo': vprn_Lo,
                'customer': customer,
                'customeras': customeras,
                'customerip': customerip,
                'customerpass': customerpass,
                'customersubnet': customersubnet,
                'customersap': customersap
            })
        # VRF-VXLAN returns setupParams: vplsSvc_id, vprnSvc_id, servicetype,
        # vni, vprn_AS, vprn_RD, vprn_RT, vprn_Lo
        return {
            'vplsSvc_id': vplsSvc_id,
            'vprnSvc_id': vprnSvc_id,
            'servicetype': servicetype,
            'vni': vni,
            'vprn_AS': vprn_AS,
            'vprn_RD': vprn_RD,
            'vprn_RT': vprn_RT,
            'vprn_Lo': vprn_Lo,
            'customer': customer,
            'customeras': customeras,
            'customerip': customerip,
            'customerpass': customerpass,
            'customersubnet': customersubnet,
            'customersap': customersap
        }
def setup_script(vsdParams):
    print("These are the VSD params: " + str(vsdParams))
    servicetype = vsdParams['servicetype']
    vni = vsdParams['vni']
    rt = vsdParams['rt']
    # add "target:" if provisioned by VSD (VSD uses x:x format whereas tools
    # command uses target:x:x format)
    if not rt.startswith('target'):
        rt = "target:" + rt
    metadata = vsdParams['metadata']
    # remove trailing space at the end of the metadata
    metadata = metadata.rstrip()
    print("VSD metadata" + str(metadata))
    metadata = dict(e.split('=') for e in metadata.split(','))
    print("Modified metadata" + str(metadata))
    vplsSvc_id = dyn.select_free_id("service-id")
    # vprnSvc_id = dyn.select_free_id("service-id")
    print("this are the free svc ids picked up by the system: VPLS:" +
          vplsSvc_id)

    if servicetype == "L2DOMAIN":
        rd = metadata['rd']
        # vprn_AS = metadata ['vprnAS']
        # vprn_RD = metadata ['vprnRD']
        # vprn_RT = metadata ['vprnRT']
        # vprn_Lo = metadata ['vprnLo']
        # irb_GW = metadata ['irbGW']
        print('servicetype, VPLS id, rt, vni, rd', servicetype, vplsSvc_id, rt,
              vni, rd)
        dyn.add_cli(
            """
        configure service
          vpls %(vplsSvc_id)s customer 1 name vpls%(vplsSvc_id)s create
          description vpls%(vplsSvc_id)s
          proxy-arp
            dynamic-arp-populate
            no shutdown
          exit
          bgp
            route-distinguisher %(rd)s
            route-target %(rt)s
            pw-template-binding 1 import-rt %(rt)s
            exit
          exit
          vxlan vni %(vni)s create
          exit
          bgp-ad
            vpls-id %(rd)s
            no shut
          exit
          bgp-evpn
            evi %(vplsSvc_id)s
            vxlan
              no shut
            exit
          exit
          no shutdown
          exit
          exit
        exit
        """ % {
                'vplsSvc_id': vplsSvc_id,
                'vni': vsdParams['vni'],
                'rt': rt,
                'rd': metadata['rd'],
            })
        # L2DOMAIN returns setupParams: vplsSvc_id, vprnSvc_id, servicetype, vni
        return {
            'vplsSvc_id': vplsSvc_id,
            'servicetype': servicetype,
            'vni': vni
        }
示例#6
0
def setup_script(vsdParams):

    print("These are the VSD params: " + str(vsdParams))
    servicetype = vsdParams['servicetype']
    vni = vsdParams['vni']
    rt = vsdParams['rt']

    # add "target:" if provisioned by VSD (VSD uses x:x format whereas tools
    # command uses target:x:x format)
    if not rt.startswith('target'):
        rt = "target:" + rt

    metadata = vsdParams['metadata']

    # remove trailing space at the end of the metadata
    metadata = metadata.rstrip()

    print("VSD metadata" + str(metadata))
    metadata = dict(e.split('=') for e in metadata.split(','))
    print("Modified metadata" + str(metadata))
    vplsSvc_id = dyn.select_free_id("service-id")
    vprnSvc_id = dyn.select_free_id("service-id")
    print("this are the free svc ids picked up by the system: VPLS:" +
          vplsSvc_id + " + VPRN:" + vprnSvc_id)

    if servicetype == "VRF-VXLAN":

        rd = metadata['rd']
        vprn_AS = metadata['vprnAS']
        vprn_RD = metadata['vprnRD']
        vprn_RT = metadata['vprnRT']
        vprn_Lo = metadata['vprnLo']
        print(
            'servicetype, VPLS id, rt, vni, rd, VPRN id, vprn_AS, vprn_RD, vprn_RT, vprn_Lo:',
            servicetype, vplsSvc_id, rt, vni, rd, vprnSvc_id, vprn_AS, vprn_RD,
            vprn_RT, vprn_Lo)
        dyn.add_cli(
            """

        configure service
           vpls %(vplsSvc_id)s customer 1 name l3-backhaul-vpls%(vplsSvc_id)s create
              allow-ip-int-bind vxlan-ipv4-tep-ecmp
                 exit
              description vpls%(vplsSvc_id)s
              bgp
                 route-distinguisher %(rd)s
                 route-target %(rt)s
                 exit
              vxlan vni %(vni)s create
                 exit
              bgp-evpn
                 ip-route-advertisement
                 vxlan
                     no shut
                     exit
                 exit
              no shutdown
              exit
            exit
        exit


        configure service
           vprn %(vprnSvc_id)s customer 1 create
              autonomous-system %(vprn_AS)s
              route-distinguisher %(vprn_RD)s
              auto-bind-tunnel resolution any
              vrf-target %(vprn_RT)s
              interface "vpls-%(vplsSvc_id)s" create
                 vpls "vpls%(vplsSvc_id)s" evpn-tunnel
                 exit
              interface "lo1" create
                 address %(vprn_Lo)s/32
                 loopback
                 exit
              no shutdown
              exit
        exit

      """ % {
                'vplsSvc_id': vplsSvc_id,
                'vprnSvc_id': vprnSvc_id,
                'vni': vsdParams['vni'],
                'rt': rt,
                'rd': metadata['rd'],
                'vprn_AS': vprn_AS,
                'vprn_RD': vprn_RD,
                'vprn_RT': vprn_RT,
                'vprn_Lo': vprn_Lo
            })
        # VRF-VXLAN returns setupParams: vplsSvc_id, vprnSvc_id, servicetype,
        # vni, vprn_AS, vprn_RD, vprn_RT, vprn_Lo
        return {
            'vplsSvc_id': vplsSvc_id,
            'vprnSvc_id': vprnSvc_id,
            'servicetype': servicetype,
            'vni': vni,
            'vprn_AS': vprn_AS,
            'vprn_RD': vprn_RD,
            'vprn_RT': vprn_RT,
            'vprn_Lo': vprn_Lo
        }