original_docstring: Associate the floating ip address and update state.
docstring: Associate the floating ip address and update state.
docstring_tokens: Associate the floating ip address and update state .
code: def _associate_floatingip(self, floatingip, fixedip_addr,
                                floatingip_addr, loopback_idx, external_idx):
          """Associate the floating ip address and update state."""
  
          # It is possible that during a VPP+agent restart scenario, the tenant's
          # VRF has not been set on the loopback
          tenant_vrf = self.vpp.get_interface_vrf(loopback_idx)
          if not tenant_vrf:
              LOG.debug("Router: Tenant VRF:%s not been set yet", tenant_vrf)
              return
          else:
              LOG.debug('Router: Tenant VRF:%s, floating IP:%s and bvi_idx:%s',
                        tenant_vrf, floatingip_addr, loopback_idx)
  
          LOG.debug("Router: associating floatingip:%s with fixedip: %s "
                    "loopback_idx:%s, external_idx:%s", floatingip_addr,
                    fixedip_addr, loopback_idx, external_idx)
          snat_interfaces = self.vpp.get_snat_interfaces()
          if loopback_idx and loopback_idx not in snat_interfaces:
              self.vpp.set_snat_on_interface(loopback_idx)
          if external_idx and external_idx not in snat_interfaces:
              self.vpp.set_snat_on_interface(external_idx, is_inside=False)
          #
          # For different tenants mapped to different VRFs, it is quite possible
          # that the same fixed IP addr is mapped to different floating IP addrs,
          # for example:
          #
          # (192.168.10.5, FIP1, VRF1)
          # (192.168.10.5, FIP2, VRF2)
          #
          # So, we check for (localip, extip, tenenat_vrf) in VPP before creating
          # the mapping.
          (localip, extip) = (ip_address(fixedip_addr),
                              ip_address(floatingip_addr))
          add_nat_mapping = True
          for m in self.vpp.get_snat_static_mappings():
              if (localip == m.local_ip_address and
                      extip == m.external_ip_address and tenant_vrf == m.vrf_id):
                  add_nat_mapping = False
          if add_nat_mapping:
              LOG.debug("Router: setting 1:1 SNAT %s:%s in tenant_vrf:%s",
                        fixedip_addr, floatingip_addr, tenant_vrf)
              self.vpp.set_snat_static_mapping(localip, extip,
                                               tenant_vrf)
              # Clear any dynamic NAT sessions for the 1:1 NAT to take effect
              self.vpp.clear_snat_sessions(localip)
              self.floating_ips[floatingip]['tenant_vrf'] = tenant_vrf
              self.floating_ips[floatingip]['state'] = True
              LOG.debug('Router: Associated floating IP: %s',
                        self.floating_ips[floatingip])
          else:
              LOG.debug('Router: SNAT 1:1 mapping already exists for floating'
                        'IP: %s', self.floating_ips[floatingip])
code_tokens: def _associate_floatingip ( self , floatingip , fixedip_addr , floatingip_addr , loopback_idx , external_idx ) : tenant_vrf = self . vpp . get_interface_vrf ( loopback_idx ) if not tenant_vrf : LOG . debug ( "Router: Tenant VRF:%s not been set yet" , tenant_vrf ) return else : LOG . debug ( 'Router: Tenant VRF:%s, floating IP:%s and bvi_idx:%s' , tenant_vrf , floatingip_addr , loopback_idx ) LOG . debug ( "Router: associating floatingip:%s with fixedip: %s " "loopback_idx:%s, external_idx:%s" , floatingip_addr , fixedip_addr , loopback_idx , external_idx ) snat_interfaces = self . vpp . get_snat_interfaces ( ) if loopback_idx and loopback_idx not in snat_interfaces : self . vpp . set_snat_on_interface ( loopback_idx ) if external_idx and external_idx not in snat_interfaces : self . vpp . set_snat_on_interface ( external_idx , is_inside = False ) ( localip , extip ) = ( ip_address ( fixedip_addr ) , ip_address ( floatingip_addr ) ) add_nat_mapping = True for m in self . vpp . get_snat_static_mappings ( ) : if ( localip == m . local_ip_address and extip == m . external_ip_address and tenant_vrf == m . vrf_id ) : add_nat_mapping = False if add_nat_mapping : LOG . debug ( "Router: setting 1:1 SNAT %s:%s in tenant_vrf:%s" , fixedip_addr , floatingip_addr , tenant_vrf ) self . vpp . set_snat_static_mapping ( localip , extip , tenant_vrf ) self . vpp . clear_snat_sessions ( localip ) self . floating_ips [ floatingip ] [ 'tenant_vrf' ] = tenant_vrf self . floating_ips [ floatingip ] [ 'state' ] = True LOG . debug ( 'Router: Associated floating IP: %s' , self . floating_ips [ floatingip ] ) else : LOG . debug ( 'Router: SNAT 1:1 mapping already exists for floating' 'IP: %s' , self . floating_ips [ floatingip ] )
short_docstring: Associate the floating ip address and update state.
short_docstring_tokens: Associate the floating ip address and update state .
comment: """Associate the floating ip address and update state."""$SEP$# It is possible that during a VPP+agent restart scenario, the tenant's$SEP$# VRF has not been set on the loopback$SEP$#$SEP$# For different tenants mapped to different VRFs, it is quite possible$SEP$# that the same fixed IP addr is mapped to different floating IP addrs,$SEP$# for example:$SEP$#$SEP$# (192.168.10.5, FIP1, VRF1)$SEP$# (192.168.10.5, FIP2, VRF2)$SEP$#$SEP$# So, we check for (localip, extip, tenenat_vrf) in VPP before creating$SEP$# the mapping.$SEP$# Clear any dynamic NAT sessions for the 1:1 NAT to take effect