def __get__(self, model_instance, model_class): """Fetches collection of model instances of this collection property.""" if model_instance is not None: query = Query(self.__model) return query.filter(self.__property + ' =', model_instance) else: return self
def __get__(self, model_instance, model_class): """Fetches collection of model instances of this collection property.""" if model_instance is not None: query = Query(self.__model) if isinstance(self.__property, list): props = [] for prop in self.__property: props.append("%s =" % prop) return query.filter(props, model_instance) else: return query.filter(self.__property + ' =', model_instance) else: return self
def purge_all_snapshots(instance_volumes): """Remove all EBS snapshots and SDB metadata.""" for vol in instance_volumes: logger.info("Querying for all snapshots for volume: %s" % vol.id) # only delete snapshots for the volumes that we were working on query = Query(Backup) query.filter("volumeid =", vol.id) for backup in query: logger.info("Removing EBS snapshot %s" % backup.snapshotid) try: vol.connection.delete_snapshot(backup.snapshotid) backup.delete() except: logger.error( "Unable to delete snapshot %s, please delete manually." % ( backup.snapshotid))
def find(cls, **params): q = Query(cls) for key, value in params.items(): q.filter('%s =' % key, value) return q
def find(cls, limit=None, next_token=None, **params): q = Query(cls, limit=limit, next_token=next_token) for key, value in params.items(): q.filter('%s =' % key, value) return q