prevent duplicate XML expansion of job templates

Whenever a project has different values for a project and that parameter
is not used in the template, we ended up regenerating the exact same
job.

This patch getXMLForTemplateJob() to make it remember whether an
expanded template has already had its XML generated.  I am using json
which let us serialize an arbitrary data structure and more specially
let us sort the dictionary keys to make sure we always end up with the
same serialization.

The `test` time for my setup went from 34 seconds down to 17 seconds.

Change-Id: I8f4ea2780025fefd3ba58e2ed32d4bd762093acf
Reviewed-on: https://review.openstack.org/24409
Reviewed-by: Arnaud Fabre <fabre.arnaud@gmail.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Khai Do <zaro0508@gmail.com>
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins