original_docstring: From vpp acl dump, populate the secgroups to VppACL mapping.
  
          Get a dump of existing vpp ACLs that are tagged, by tag
          Decode tag info
          populate secgroups data structure relating UUID of secgroup to ACL
          self.secgroups = {secgroup_id : VppAcl(in_idx, out_idx)}
          
docstring: From vpp acl dump, populate the secgroups to VppACL mapping.
  Get a dump of existing vpp ACLs that are tagged, by tag
  Decode tag info
  populate secgroups data structure relating UUID of secgroup to ACL
  self.secgroups = {secgroup_id : VppAcl(in_idx, out_idx)}
docstring_tokens: From vpp acl dump populate the secgroups to VppACL mapping . Get a dump of existing vpp ACLs that are tagged by tag Decode tag info populate secgroups data structure relating UUID of secgroup to ACL self . secgroups = { secgroup_id : VppAcl ( in_idx out_idx ) }
code: def populate_secgroup_acl_mappings(self):
          """From vpp acl dump, populate the secgroups to VppACL mapping.
  
          Get a dump of existing vpp ACLs that are tagged, by tag
          Decode tag info
          populate secgroups data structure relating UUID of secgroup to ACL
          self.secgroups = {secgroup_id : VppAcl(in_idx, out_idx)}
          """
          LOG.debug("Populating secgroup to VPP ACL map..")
  
          # Clear existing secgroups to ACL map for sanity
          self.secgroups = {}
          # Example of the acl_map data
          # acl_map: {'net-vpp.secgroup:<uuid>.from-vpp' : acl_idx
          #           'net-vpp.secgroup:<uuid>.to-vpp' : acl_idx,
          #           'net-vpp.common_spoof.from-vpp': acl_idx }
          acl_map = self.get_secgroup_acl_map()
          for item, acl_idx in acl_map.items():
              # Tags can be one of ours, or one something else set
              # decode_* functions attempt to match the tags to one of our
              # formats, and returns None if that's not a format it matches.
  
              secgroup_id, direction = decode_secgroup_tag(item)
              if secgroup_id is None:
                  # Check if this is one of our common spoof ACL tag
                  # If so, get the tag direction and set the secgroup_id to
                  # COMMON_SPOOF_TAG so the correct spoof ACL can be read
                  direction = decode_common_spoof_tag(item)
                  if direction is not None:
                      # But it is a valid spoof tag
                      secgroup_id = COMMON_SPOOF_TAG
                      ingress = direction == VPP_TO_VM
              else:  # one of our valid secgroup ACL tag
                  ingress = direction == VPP_TO_VM
  
              if secgroup_id is None:
                  # This is neither a security group or a spoof
                  # - so it's not installed by the mechdriver at all
                  continue
  
              vpp_acl = self.secgroups.get(secgroup_id,
                                           VppAcl(0xffffffff, 0xffffffff))
              # secgroup_id will be missing first pass, and should be
              # completed on the second round through.
              if ingress:
                  self.secgroups[secgroup_id] = vpp_acl._replace(
                      in_idx=acl_idx)
              else:
                  self.secgroups[secgroup_id] = vpp_acl._replace(
                      out_idx=acl_idx)
  
          if self.secgroups == {}:
              LOG.debug("We recovered an empty secgroups "
                        "to acl mapping. Possible reason: vpp "
                        "may have been restarted on host.")
  
          # py3 note: in py3 keys() does not return a list but the following
          # seems to work fine. Enclose in list() is problems arise.
          return self.secgroups.keys()
code_tokens: def populate_secgroup_acl_mappings ( self ) : LOG . debug ( "Populating secgroup to VPP ACL map.." ) self . secgroups = { } acl_map = self . get_secgroup_acl_map ( ) for item , acl_idx in acl_map . items ( ) : secgroup_id , direction = decode_secgroup_tag ( item ) if secgroup_id is None : direction = decode_common_spoof_tag ( item ) if direction is not None : secgroup_id = COMMON_SPOOF_TAG ingress = direction == VPP_TO_VM else : ingress = direction == VPP_TO_VM if secgroup_id is None : continue vpp_acl = self . secgroups . get ( secgroup_id , VppAcl ( 0xffffffff , 0xffffffff ) ) if ingress : self . secgroups [ secgroup_id ] = vpp_acl . _replace ( in_idx = acl_idx ) else : self . secgroups [ secgroup_id ] = vpp_acl . _replace ( out_idx = acl_idx ) if self . secgroups == { } : LOG . debug ( "We recovered an empty secgroups " "to acl mapping. Possible reason: vpp " "may have been restarted on host." ) return self . secgroups . keys ( )
short_docstring: From vpp acl dump, populate the secgroups to VppACL mapping.
short_docstring_tokens: From vpp acl dump populate the secgroups to VppACL mapping .
comment: """From vpp acl dump, populate the secgroups to VppACL mapping.
  
          Get a dump of existing vpp ACLs that are tagged, by tag
          Decode tag info
          populate secgroups data structure relating UUID of secgroup to ACL
          self.secgroups = {secgroup_id : VppAcl(in_idx, out_idx)}
          """$SEP$# Clear existing secgroups to ACL map for sanity$SEP$# Example of the acl_map data$SEP$# acl_map: {'net-vpp.secgroup:<uuid>.from-vpp' : acl_idx$SEP$#           'net-vpp.secgroup:<uuid>.to-vpp' : acl_idx,$SEP$#           'net-vpp.common_spoof.from-vpp': acl_idx }$SEP$# Tags can be one of ours, or one something else set$SEP$# decode_* functions attempt to match the tags to one of our$SEP$# formats, and returns None if that's not a format it matches.$SEP$# Check if this is one of our common spoof ACL tag$SEP$# If so, get the tag direction and set the secgroup_id to$SEP$# COMMON_SPOOF_TAG so the correct spoof ACL can be read$SEP$# But it is a valid spoof tag$SEP$# one of our valid secgroup ACL tag$SEP$# This is neither a security group or a spoof$SEP$# - so it's not installed by the mechdriver at all$SEP$# secgroup_id will be missing first pass, and should be$SEP$# completed on the second round through.$SEP$# py3 note: in py3 keys() does not return a list but the following$SEP$# seems to work fine. Enclose in list() is problems arise.