dealing with the scenario for hypervisor that hostname may or may not co...

...ntain domain name
The goal here is to figure out what host we're supposed to link to.  If you're looking at self.host() (the host we're already linked to), you're doing it wrong.  Re-think this and the last search..  I would recommend adding a hostname column to host, indexed like hostfqdn is.  You can then search both at once  (using the advancedquery syntax for searching:  Something like  Or(Eq('hostname', name), Eq('hostfqdn', name))

Then if neither of those match, try stripping everything after the . out of "name" and try again.  If still no luck, then report an error and we're done.