def undo(self, workflow_dict): try: environment = workflow_dict['environment'] if 'volume' in workflow_dict: volume = workflow_dict['volume'] LOG.info("Destroying nfsaas volume...") provider = NfsaasProvider() provider.revoke_access(environment=environment, host=volume.host, export_id=volume.nfsaas_export_id) provider.drop_export(environment=environment, export_id=volume.nfsaas_export_id) volume.delete() return True except Exception: traceback = full_stack() workflow_dict['exceptions']['error_codes'].append(DBAAS_0022) workflow_dict['exceptions']['traceback'].append(traceback) return False
def purge_unused_exports(): from dbaas_nfsaas.models import HostAttr databaseinfras = DatabaseInfra.objects.filter(plan__provider=Plan.CLOUDSTACK).prefetch_related('instances') for databaseinfra in databaseinfras: instances = databaseinfra.instances.exclude(instance_type__in=[Instance.MONGODB_ARBITER, Instance.REDIS_SENTINEL]) environment = databaseinfra.environment plan = databaseinfra.plan for instance in instances: exports = HostAttr.objects.filter(host=instance.hostname, is_active=False) for export in exports: snapshots = Snapshot.objects.filter(export_path=export.nfsaas_path, purge_at=None) if snapshots: continue LOG.info('Export {} will be removed'.format(export.nfsaas_export_id)) host = export.host export_id = export.nfsaas_export_id nfsaas_client = NfsaasProvider() nfsaas_client.revoke_access(environment=environment, plan=plan, host=host, export_id=export_id) nfsaas_client.drop_export(environment=environment, plan=plan, export_id=export_id) export.delete()
def purge_unused_exports(): from dbaas_nfsaas.models import HostAttr databaseinfras = DatabaseInfra.objects.filter( plan__provider=Plan.CLOUDSTACK).prefetch_related('instances') for databaseinfra in databaseinfras: instances = databaseinfra.get_driver().get_database_instances() environment = databaseinfra.environment for instance in instances: exports = HostAttr.objects.filter(host=instance.hostname, is_active=False) for export in exports: snapshots = Snapshot.objects.filter(export_path=export.nfsaas_path, purge_at=None) if snapshots: continue LOG.info( 'Export {} will be removed'.format(export.nfsaas_export_id)) host = export.host export_id = export.nfsaas_export_id clean_unused_data(export_id=export_id, export_path=export.nfsaas_path, host=instance.hostname, databaseinfra=databaseinfra) nfsaas_client = NfsaasProvider() nfsaas_client.revoke_access(environment=environment, host=host, export_id=export_id) nfsaas_client.drop_export(environment=environment, export_id=export_id) export.delete()
def purge_unused_exports(): from dbaas_nfsaas.models import HostAttr databaseinfras = DatabaseInfra.objects.filter(plan__provider=Plan.CLOUDSTACK).prefetch_related('instances') for databaseinfra in databaseinfras: instances = databaseinfra.instances.exclude(instance_type__in=[Instance.MONGODB_ARBITER, Instance.REDIS_SENTINEL]) environment = databaseinfra.environment plan = databaseinfra.plan for instance in instances: exports = HostAttr.objects.filter(host=instance.hostname, is_active=False) for export in exports: snapshots = Snapshot.objects.filter(export_path=export.nfsaas_path, purge_at=None) if snapshots: continue LOG.info('Export {} will be removed'.format(export.nfsaas_export_id)) host = export.host export_id = export.nfsaas_export_id nfsaas_client = NfsaasProvider() nfsaas_client.revoke_access(environment=environment, host=host, export_id=export_id) nfsaas_client.drop_export(environment=environment, export_id=export_id) export.delete()
def purge_unused_exports(): from dbaas_nfsaas.models import HostAttr databaseinfras = DatabaseInfra.objects.filter( plan__provider=Plan.CLOUDSTACK).prefetch_related('instances') for databaseinfra in databaseinfras: instances = databaseinfra.get_driver().get_database_instances() environment = databaseinfra.environment for instance in instances: exports = HostAttr.objects.filter(host=instance.hostname, is_active=False) for export in exports: snapshots = Snapshot.objects.filter( export_path=export.nfsaas_path, purge_at=None) if snapshots: continue LOG.info('Export {} will be removed'.format( export.nfsaas_export_id)) host = export.host export_id = export.nfsaas_export_id clean_unused_data(export_id=export_id, export_path=export.nfsaas_path, host=instance.hostname, databaseinfra=databaseinfra) nfsaas_client = NfsaasProvider() nfsaas_client.revoke_access(environment=environment, host=host, export_id=export_id) nfsaas_client.drop_export(environment=environment, export_id=export_id) export.delete()
def destroy_unused_export(export_id, export_path, host, databaseinfra): clean_unused_data(export_id, export_path, host, databaseinfra) provider = NfsaasProvider() provider.drop_export(environment=databaseinfra.environment, export_id=export_id)