def do(self):
        from backup.tasks import make_instance_snapshot_backup
        from backup.models import BackupGroup
        if (self.database_migrate
                and self.database_migrate.host_migrate_snapshot):
            snapshot = self.database_migrate.host_migrate_snapshot
        else:
            group = BackupGroup()
            group.save()
            snapshot = make_instance_snapshot_backup(
                self.instance, {}, group, provider_class=self.provider_class)

            if not snapshot:
                raise Exception('Backup was unsuccessful in {}'.format(
                    self.instance))

            snapshot.is_automatic = False
            snapshot.save()
        if self.database_migrate:
            host_migrate = self.host_migrate
            host_migrate.snapshot = snapshot
            host_migrate.save()
        else:
            self.step_manager.snapshot = snapshot
            self.step_manager.save()

        if snapshot.has_warning:
            raise Exception('Backup was warning')
    def do(self, workflow_dict):
        try:
            group = BackupGroup()
            group.save()

            for host_and_export in workflow_dict['hosts_and_exports']:
                host = host_and_export['host']
                export_id = host_and_export['old_export_id']

                ret = make_host_backup(database=workflow_dict['database'],
                                       instance=host.instances.all()[0],
                                       export_id=export_id,
                                       group=group)
                if not ret:
                    msg = 'Could not make snapshot for export_id: {} on host {}'.format(
                        export_id, host)
                    LOG.error(msg)
                    raise Exception(msg)

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0021)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
    def do(self):
        from backup.tasks import make_instance_snapshot_backup
        from backup.models import BackupGroup
        if self.database_migrate and self.database_migrate.host_migrate_snapshot:
            snapshot = self.database_migrate.host_migrate_snapshot
        else:
            group = BackupGroup()
            group.save()
            snapshot = make_instance_snapshot_backup(
                self.instance,
                {},
                group,
                provider_class=VolumeProviderBaseMigrate
            )

            if not snapshot:
                raise Exception('Backup was unsuccessful in {}'.format(self.instance))

            snapshot.is_automatic = False
            snapshot.save()
        if self.database_migrate:
            host_migrate = self.host_migrate
            host_migrate.snapshot = snapshot
            host_migrate.save()
        else:
            self.step_manager.snapshot = snapshot
            self.step_manager.save()

        if snapshot.has_warning:
            raise Exception('Backup was warning')
Пример #4
0
    def do(self, workflow_dict):
        try:
            group = BackupGroup()
            group.save()

            for instance in workflow_dict['instances']:
                error = {}
                snapshot = make_instance_snapshot_backup(instance=instance,
                                                         error=error,
                                                         group=group)

                if snapshot and snapshot.was_successful:
                    msg = "Backup for %s was successful" % (str(instance))
                    LOG.info(msg)
                elif snapshot and snapshot.has_warning:
                    msg = "Backup for %s has warning" % (str(instance))
                    LOG.info(msg)
                else:
                    msg = "Backup for %s was unsuccessful. Error: %s" % (
                        str(instance), error['errormsg'])
                    LOG.error(msg)
                    raise Exception(msg)

            return True

        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0023)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
 def group(self):
     from backup.models import BackupGroup
     group = BackupGroup()
     group.save()
     return group
 def group(self):
     from backup.models import BackupGroup
     group = BackupGroup()
     group.save()
     return group