'Creates a snapshot.'

def create_snapshot(self, snapshot):

    (ret, output) = self.dpl.create_vdev_snapshot(self._conver_uuid2hex(snapshot['volume_id']), self._conver_uuid2hex(snapshot['id']), snapshot.get('display_name', ''), snapshot.get('display_description', ''))
    if (ret == errno.EAGAIN):
        (ret, event_uuid) = self._get_event_uuid(output)
        if (ret == 0):
            status = self._wait_event(self.dpl.get_vdev_status, snapshot['volume_id'], event_uuid)
            if (status['state'] != 'available'):
                msg = (_('Flexvisor    failed    to    create    snapshot    for    volume    %(id)s:    %(status)s.') % {'id': snapshot['volume_id'], 'status': ret})
                raise exception.VolumeBackendAPIException(data=msg)
        else:
            msg = (_('Flexvisor    failed    to    create    snapshot    for    volume    (failed    to    get    event)    %(id)s.') % {'id': snapshot['volume_id']})
            raise exception.VolumeBackendAPIException(data=msg)
    elif (ret != 0):
        msg = (_('Flexvisor    failed    to    create    snapshot    for    volume    %(id)s:    %(status)s.') % {'id': snapshot['volume_id'], 'status': ret})
        raise exception.VolumeBackendAPIException(data=msg)
