def check_attach(self, context, volume, instance=None):
        if volume['status'] != 'available':
            msg = "Status of volume '%s' must be available" % volume
            raise exception.InvalidVolume(reason=msg)
        if volume['attach_status'] == 'attached':
            msg = "already attached"
            raise exception.InvalidVolume(reason=msg)
        if instance and not CONF.cinder.cross_az_attach:
            if instance['availability_zone'] != volume['availability_zone']:
                msg = "Instance and volume not in same availability_zone"
                raise exception.InvalidVolume(reason=msg)
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/tests/unit/fake_volume.py/API.check_attach/original