I've had this problem a few times and found two solutions to fix it.
It could be a software problem. In that case you can try to reboot your computer.
Another solution to get the CD/DVD drive back open is the paperclip trick. This is a mechanical emergency eject solution that also works when the drive doesn't have power. I've used this once on my laptop. It's very simple, on the front of your CD or DVD drive is a small hole. Gently push an unbend paperclip (or a similar thin object) into this hole until your drive opens.