core: Nullity check in GetVmTemplateQuery

Nullity check added to VM template- the query tries to get a template
from the DB and didn't check if the returned value is null which will
result in NullPointerException thrown from the query.

Change-Id: I994083a491db2b78f3ce24783fb0afa3348030d3
Bug-Url: https://bugzilla.redhat.com/1162078
Signed-off-by: Amit Aviram <aaviram@redhat.com>