"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "barbican/model/clean.py" between
barbican-11.0.0.tar.gz and barbican-12.0.0.tar.gz

About: OpenStack Barbican is the OpenStack Key Manager service. It provides secure storage, provisioning and management of secret data.
The "Wallaby" series (latest release).

clean.py  (barbican-11.0.0):clean.py  (barbican-12.0.0)
skipping to change at line 56 skipping to change at line 56
models.CertificateAuthority, models.CertificateAuthority,
models.ProjectCertificateAuthority, models.ProjectCertificateAuthority,
models.ProjectQuotas] models.ProjectQuotas]
children_names = map(lambda child: child.__name__, project_children_tables) children_names = map(lambda child: child.__name__, project_children_tables)
LOG.debug("Children tables for Project table being checked: %s", LOG.debug("Children tables for Project table being checked: %s",
str(children_names)) str(children_names))
sub_query = session.query(models.Project.id) sub_query = session.query(models.Project.id)
for model in project_children_tables: for model in project_children_tables:
sub_query = sub_query.outerjoin(model, sub_query = sub_query.outerjoin(model,
models.Project.id == model.project_id) models.Project.id == model.project_id)
sub_query = sub_query.filter(model.id == None) # nopep8 sub_query = sub_query.filter(model.id == None) # noqa
sub_query = sub_query.subquery() sub_query = sub_query.subquery()
sub_query = sa_sql.select([sub_query]) sub_query = sa_sql.select([sub_query])
query = session.query(models.Project) query = session.query(models.Project)
query = query.filter(models.Project.id.in_(sub_query)) query = query.filter(models.Project.id.in_(sub_query))
delete_count = query.delete(synchronize_session='fetch') delete_count = query.delete(synchronize_session='fetch')
LOG.info("Cleaned up %(delete_count)s entries for " LOG.info("Cleaned up %(delete_count)s entries for "
"%(project_name)s", "%(project_name)s",
{'delete_count': str(delete_count), {'delete_count': str(delete_count),
'project_name': models.Project.__name__}) 'project_name': models.Project.__name__})
return delete_count return delete_count
skipping to change at line 90 skipping to change at line 90
:param threshold_date: soft deletions older than this date will be removed :param threshold_date: soft deletions older than this date will be removed
:returns: total number of entries removed from database :returns: total number of entries removed from database
""" """
LOG.debug("Cleaning soft deletes for %(parent_name)s without " LOG.debug("Cleaning soft deletes for %(parent_name)s without "
"a child in %(child_name)s" % "a child in %(child_name)s" %
{'parent_name': parent_model.__name__, {'parent_name': parent_model.__name__,
'child_name': child_model.__name__}) 'child_name': child_model.__name__})
session = repo.get_session() session = repo.get_session()
sub_query = session.query(parent_model.id) sub_query = session.query(parent_model.id)
sub_query = sub_query.outerjoin(child_model) sub_query = sub_query.outerjoin(child_model)
sub_query = sub_query.filter(child_model.id == None) # nopep8 sub_query = sub_query.filter(child_model.id == None) # noqa
sub_query = sub_query.subquery() sub_query = sub_query.subquery()
sub_query = sa_sql.select([sub_query]) sub_query = sa_sql.select([sub_query])
query = session.query(parent_model) query = session.query(parent_model)
query = query.filter(parent_model.id.in_(sub_query)) query = query.filter(parent_model.id.in_(sub_query))
query = query.filter(parent_model.deleted) query = query.filter(parent_model.deleted)
if threshold_date: if threshold_date:
query = query.filter(parent_model.deleted_at <= threshold_date) query = query.filter(parent_model.deleted_at <= threshold_date)
delete_count = query.delete(synchronize_session='fetch') delete_count = query.delete(synchronize_session='fetch')
LOG.info("Cleaned up %(delete_count)s entries for %(parent_name)s " LOG.info("Cleaned up %(delete_count)s entries for %(parent_name)s "
"with no children in %(child_name)s", "with no children in %(child_name)s",
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)