def modify_script(vsdParams, setup_result): print ( "These are the setup_result params for modify_script: " + str(setup_result)) print ("These are the VSD params for modify_script: " + str(vsdParams)) # remove trailing space at the end of the metadata metadata = vsdParams['metadata'].rstrip() print ("VSD metadata" + str(metadata)) metadata = dict(e.split('=') for e in metadata.split(',')) print ("Modified metadata" + str(metadata)) # updating the setup_result dict setup_result.update(metadata) params = setup_result print ( "The updated params from metadata and return from the setup result: " + str(params)) dyn.add_cli(""" configure service vpls %(vplsSvc_id)s service-mtu %(svc-mtu)s exit exit exit """ % params) # Result is passed to teardown_script return params
def teardown_script(setupParams): print ("These are the teardown_script setupParams: " + str(setupParams)) servicetype = setupParams['servicetype'] if servicetype == "L2DOMAIN": dyn.add_cli(""" configure service vpls %(vplsSvc_id)s no description proxy-arp shut no proxy-arp bgp-evpn vxlan shut exit no evi exit no vxlan vni %(vni)s bgp no route-distinguisher no route-target exit no bgp no bgp-evpn sap %(sap)s shutdown exit no sap %(sap)s shutdown exit no vpls %(vplsSvc_id)s exit exit """ % {'vplsSvc_id': setupParams['vplsSvc_id'], 'vni': setupParams['vni'], 'sap': setupParams['sap']}) return setupParams
def teardown_script(setupParams): print("These are the teardown_script setupParams: " + str(setupParams)) servicetype = setupParams.get('servicetype') if servicetype == "L2DOMAIN-IRB": dyn.add_cli( """ configure service vpls %(vplsSvc_id)s no description bgp-evpn vxlan shut exit no evi exit no vxlan vni %(vni)s bgp no route-distinguisher no route-target exit no bgp no bgp-evpn shutdown exit no vpls %(vplsSvc_id)s vprn %(vprnSvc_id)s interface "irbvpls-%(vplsSvc_id)s" no vpls vrrp %(vrrp_ID)s shut no vrrp %(vrrp_ID)s shutdown exit no interface "irbvpls-%(vplsSvc_id)s" shutdown exit no vprn %(vprnSvc_id)s exit """ % { 'vplsSvc_id': setupParams['vplsSvc_id'], 'vprnSvc_id': setupParams['vprnSvc_id'], 'vni': setupParams['vni'], 'vrrp_ID': setupParams['vrrp_ID'] }) return setupParams
def teardown_script(setupParams): print("These are the teardown_script setupParams: " + str(setupParams)) servicetype = setupParams['servicetype'] if servicetype == "VRF-VXLAN": print("Test1") print("These are the teardown_script setupParams: " + str(setupParams)) dyn.add_cli( """ configure service vpls %(vplsSvc_id)s bgp-evpn vxlan shut exit no evi exit no vxlan vni %(vni)s no bgp-evpn shutdown exit no vpls %(vplsSvc_id)s vprn %(vprnSvc_id)s interface lo1 shutdown no interface lo1 interface "vpls-%(vplsSvc_id)s" vpls "vpls%(vplsSvc_id)s" no evpn-tunnel exit no vpls shutdown exit no interface "vpls-%(vplsSvc_id)s" shutdown exit no vprn %(vprnSvc_id)s exit """ % { 'vplsSvc_id': setupParams['vplsSvc_id'], 'vprnSvc_id': setupParams['vprnSvc_id'], 'vni': setupParams['vni'] }) return setupParams
def revert_script(vsdParams, setup_result): print("These are the setup_result params for revert_script: " + str(setup_result)) print("These are the VSD params for revert_script: " + str(vsdParams)) # When modify fails, the revert is called and then the teardown is called. # It is recommended to revert to same value as used in setup for the # attributes modified in modify_script. params = setup_result dyn.add_cli(""" configure service vpls %(vplsSvc_id)s service-mtu 2000 exit exit exit """ % params) # Result is passed to teardown_script return params
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 }
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}
def teardown_script(setupParams): print("These are the teardown_script setupParams: " + str(setupParams)) servicetype = setupParams.get('servicetype') if servicetype == "VRF-VXLAN": dyn.add_cli( """ configure service vpls %(vplsSvc_id)s no description bgp-evpn vxlan shut exit no evi exit no vxlan vni %(vni)s bgp no route-distinguisher no route-target exit no bgp no bgp-evpn shutdown exit no vpls %(vplsSvc_id)s vprn %(vprnSvc_id)s interface lo1 shutdown no interface lo1 interface "vpls-%(vplsSvc_id)s" vpls "vpls%(vplsSvc_id)s" no evpn-tunnel exit no vpls shutdown exit no interface "vpls-%(vplsSvc_id)s" interface %(customer)s create sap %(customersap)s shutdown no sap %(customersap)s shutdown exit no interface %(customer)s bgp shutdown no bgp shutdown exit no vprn %(vprnSvc_id)s exit configure router policy-options begin no community _VSD_%(vplsSvc_id)s no policy-statement vsi_import_%(vplsSvc_id)s no policy-statement vsi_export_%(vplsSvc_id)s commit exit """ % { 'vplsSvc_id': setupParams['vplsSvc_id'], 'vprnSvc_id': setupParams['vprnSvc_id'], 'vni': setupParams['vni'], 'customer': setupParams['customer'], 'customersap': setupParams['customersap'] }) return setupParams
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 }
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 }