#NEWLINE# def get_net_assoc( self , context , assoc_id , bgpvpn_id , fields = None ) : #NEWLINE# #INDENT# LOG . debug ( ( 'get_net_assoc called for %s for BGPVPN %s, with fields = %s' % ( assoc_id , bgpvpn_id , fields ) ) ) #NEWLINE# oc_client = self . _get_opencontrail_api_client ( context ) #NEWLINE# try : #NEWLINE# #INDENT# net_assoc = json . loads ( oc_client . kv_store ( 'RETRIEVE' , key = assoc_id ) ) #NEWLINE# #UNINDENT# except ( oc_exc . OpenContrailAPINotFound , ValueError ) : #NEWLINE# #INDENT# raise bgpvpn_ext . BGPVPNNetAssocNotFound ( id = assoc_id , bgpvpn_id = bgpvpn_id ) #NEWLINE# #UNINDENT# if ( ( not isinstance ( net_assoc , dict ) ) or ( 'bgpvpn_net_assoc' not in net_assoc ) ) : #NEWLINE# #INDENT# raise bgpvpn_ext . BGPVPNNetAssocNotFound ( id = assoc_id , bgpvpn_id = bgpvpn_id ) #NEWLINE# #UNINDENT# net_assoc = net_assoc [ 'bgpvpn_net_assoc' ] #NEWLINE# if ( net_assoc [ 'bgpvpn_id' ] != bgpvpn_id ) : #NEWLINE# #INDENT# raise bgpvpn_ext . BGPVPNNetAssocNotFound ( id = assoc_id , bgpvpn_id = bgpvpn_id ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# get_fields = [ 'tenant_id' , 'route_targets' , 'import_targets' , 'export_targets' ] #NEWLINE# bgpvpn = self . get_bgpvpn ( context , net_assoc [ 'bgpvpn_id' ] , fields = get_fields ) #NEWLINE# #UNINDENT# except bgpvpn . BGPVPNNotFound : #NEWLINE# #INDENT# raise bgpvpn_ext . BGPVPNNetAssocNotFound ( id = assoc_id , bgpvpn_id = bgpvpn_id ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# oc_client . id_to_fqname ( net_assoc [ 'network_id' ] ) #NEWLINE# #UNINDENT# except oc_exc . OpenContrailAPINotFound : #NEWLINE# #INDENT# self . _set_bgpvpn_association ( oc_client , 'DELETE' , bgpvpn , [ net_assoc [ 'network_id' ] ] ) #NEWLINE# oc_client . kv_store ( 'DELETE' , key = assoc_id ) #NEWLINE# raise bgpvpn_ext . BGPVPNNetAssocNotFound ( id = assoc_id , bgpvpn_id = bgpvpn_id ) #NEWLINE# #UNINDENT# net_assoc = utils . make_net_assoc_dict ( net_assoc [ 'id' ] , net_assoc [ 'tenant_id' ] , net_assoc [ 'bgpvpn_id' ] , net_assoc [ 'network_id' ] , fields ) #NEWLINE# return net_assoc