Refactored the TH server from the db migration plugin, to make the puppet code more generic.

Change-Id: I14483c831e8af1c36a882355e52f3fd88d92f669