def _check_volume_availability(self, context, volume, force):
    'Check if the volume can be used.'
    if (volume['status'] not in ['available', 'in-use']):
        msg = _('Volume status must be available/in-use.')
        raise exception.InvalidVolume(reason=msg)
    if ((not force) and ('in-use' == volume['status'])):
        msg = _('Volume status is in-use.')
        raise exception.InvalidVolume(reason=msg)
Check if the volume can be used.
def _check_volume_availability(self, context, volume, force):
    
    if (volume['status'] not in ['available', 'in-use']):
        msg = _('Volume status must be available/in-use.')
        raise exception.InvalidVolume(reason=msg)
    if ((not force) and ('in-use' == volume['status'])):
        msg = _('Volume status is in-use.')
        raise exception.InvalidVolume(reason=msg)