def _sync_provider_info(self, ctxt, volumes, snapshots):
    (updates, snapshot_updates) = self.driver.update_provider_info(volumes, snapshots)
    if updates:
        for volume in volumes:
            update = [updt for updt in updates if (updt['id'] == volume['id'])][0]
            if update:
                self.db.volume_update(ctxt, update['id'], {'provider_id': update['provider_id']})
    if snapshot_updates:
        cinder_snaps = self.db.snapshot_get_all(ctxt)
        for snap in cinder_snaps:
            if (not snap.get('provider_id', None)):
                update = [updt for updt in snapshot_updates if (updt['id'] == snap['id'])][0]
                if update:
                    self.db.snapshot_update(ctxt, update['id'], {'provider_id': update['provider_id']})
def _sync_provider_info(self, ctxt, volumes, snapshots):
    (updates, snapshot_updates) = self.driver.update_provider_info(volumes, snapshots)
    if updates:
        for volume in volumes:
            update = [updt for updt in updates if (updt['id'] == volume['id'])][0]
            if update:
                self.db.volume_update(ctxt, update['id'], {'provider_id': update['provider_id']})
    if snapshot_updates:
        cinder_snaps = self.db.snapshot_get_all(ctxt)
        for snap in cinder_snaps:
            if (not snap.get('provider_id', None)):
                update = [updt for updt in snapshot_updates if (updt['id'] == snap['id'])][0]
                if update:
                    self.db.snapshot_update(ctxt, update['id'], {'provider_id': update['provider_id']})