code: def _check_security_groups(self, names):
          
          self._init_os_api()
          log.debug("Checking existence of security group(s) %s ...", names)
          try:
              # python-novaclient < 8.0.0
              security_groups = self.nova_client.security_groups.list()
              existing = set(sg.name for sg in security_groups)
          except AttributeError:
              security_groups = self.neutron_client.list_security_groups()['security_groups']
              existing = set(sg[u'name'] for sg in security_groups)
  
          # TODO: We should be able to create the security group if it
          # doesn't exist and at least add a rule to accept ssh access.
          # Also, we should be able to add new rules to a security group
          # if needed.
          nonexisting = set(names) - existing
          if nonexisting:
              raise SecurityGroupError(
                  "Security group(s) `{0}` do not exist"
                  .format(', '.join(nonexisting)))
  
          # if we get to this point, all sec groups exist
          return True
docs: Raise an exception if any of the named security groups does not exist.
  
          :param List[str] groups: List of security group names
          :raises: `SecurityGroupError` if group does not exist