Пример #1
0
 def create_group(group_name):
     ent = model.AuthGroup(key=model.group_key(group_name),
                           members=imported_groups[group_name],
                           created_ts=timestamp,
                           created_by=auth.get_service_self_identity(),
                           modified_ts=timestamp,
                           modified_by=auth.get_service_self_identity())
     to_put.append(ent)
Пример #2
0
 def create_group(group_name):
   ent = model.AuthGroup(
       key=model.group_key(group_name),
       members=imported_groups[group_name],
       created_ts=timestamp,
       created_by=auth.get_service_self_identity(),
       modified_ts=timestamp,
       modified_by=auth.get_service_self_identity())
   to_put.append(ent)
Пример #3
0
 def config_fetcher():
   conf = cls.fetch()
   if not conf:
     conf = cls()
     conf.set_defaults()
     conf.store(updated_by=auth.get_service_self_identity())
   return conf
Пример #4
0
 def clear_group(group_name):
     ent = system_groups[group_name]
     if ent.members:
         ent.members = []
         ent.modified_ts = timestamp
         ent.modified_by = auth.get_service_self_identity()
         to_put.append(ent)
Пример #5
0
 def clear_group(group_name):
   ent = system_groups[group_name]
   if ent.members:
     ent.members = []
     ent.modified_ts = timestamp
     ent.modified_by = auth.get_service_self_identity()
     to_put.append(ent)
Пример #6
0
 def config_fetcher():
     conf = cls.fetch()
     if not conf:
         conf = cls()
         conf.set_defaults()
         conf.store(updated_by=auth.get_service_self_identity())
     return conf
Пример #7
0
 def update_group(group_name):
     existing = system_groups[group_name]
     imported = imported_groups[group_name]
     if existing.members != imported:
         existing.members = imported
         existing.modified_ts = timestamp
         existing.modified_by = auth.get_service_self_identity()
         to_put.append(existing)
Пример #8
0
 def update_group(group_name):
   existing = system_groups[group_name]
   imported = imported_groups[group_name]
   if existing.members != imported:
     existing.members = imported
     existing.modified_ts = timestamp
     existing.modified_by = auth.get_service_self_identity()
     to_put.append(existing)
Пример #9
0
def write_config(text, config_revision=None, modified_by=None):
    """Validates config text blobs and puts it into the datastore.

  Raises:
    ValueError on invalid format.
  """
    validate_config(text)
    e = GroupImporterConfig(key=config_key(),
                            config_proto=text,
                            config_revision=config_revision,
                            modified_by=modified_by
                            or auth.get_service_self_identity())
    e.put()
Пример #10
0
def write_config(text, config_revision=None, modified_by=None):
  """Validates config text blobs and puts it into the datastore.

  Raises:
    ValueError on invalid format.
  """
  validate_config(text)
  e = GroupImporterConfig(
      key=config_key(),
      config=read_legacy_config(),
      config_proto=text,
      config_revision=config_revision,
      modified_by=modified_by or auth.get_service_self_identity())
  e.put()
Пример #11
0
      def fetcher():
        with fetcher.cache_lock:
          expiry = fetcher.cache_expiry
          if expiry is not None and utils.utcnow() < expiry:
            raise ndb.Return(fetcher.cache_value)

        # Do not lock while yielding, it would cause deadlock.
        # Also do not cache a future, it might cross ndb context boundary.
        # If there is no cached value, multiple concurrent requests will make
        # multiple RPCs, but as soon as one of them updates cache, subsequent
        # requests will use the cached value, for a minute.
        conf = yield cls.fetch_async()
        if not conf:
          conf = cls()
          conf.set_defaults()
          yield conf.store_async(updated_by=auth.get_service_self_identity())

        with fetcher.cache_lock:
          fetcher.cache_expiry = utils.utcnow() + datetime.timedelta(minutes=1)
          fetcher.cache_value = conf
        raise ndb.Return(conf)