Allow a different host for readonly connections.

Signed-off-by: Jeremy Orlow <jorlow@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@2131 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/afe/readonly_connection.py b/frontend/afe/readonly_connection.py
index 19ac51e..81d468f 100644
--- a/frontend/afe/readonly_connection.py
+++ b/frontend/afe/readonly_connection.py
@@ -24,17 +24,20 @@
 
     def _save_django_state(self):
         self._old_connection = django_connection.connection
+        self._old_host = settings.DATABASE_HOST
         self._old_username = settings.DATABASE_USER
         self._old_password = settings.DATABASE_PASSWORD
 
 
     def _restore_django_state(self):
         django_connection.connection = self._old_connection
+        settings.DATABASE_HOST = self._old_host
         settings.DATABASE_USER = self._old_username
         settings.DATABASE_PASSWORD = self._old_password
 
 
     def _get_readonly_connection(self):
+        settings.DATABASE_HOST = settings.DATABASE_READONLY_HOST
         settings.DATABASE_USER = settings.DATABASE_READONLY_USER
         settings.DATABASE_PASSWORD = settings.DATABASE_READONLY_PASSWORD
         django_connection.connection = None
diff --git a/frontend/settings.py b/frontend/settings.py
index 98e34bd..07c4024 100644
--- a/frontend/settings.py
+++ b/frontend/settings.py
@@ -29,6 +29,8 @@
 DATABASE_USER = c.get_config_value(_section, "user")
 DATABASE_PASSWORD = c.get_config_value(_section, "password")
 
+DATABASE_READONLY_HOST = c.get_config_value(_section, "readonly_host",
+                                            default=DATABASE_HOST)
 DATABASE_READONLY_USER = c.get_config_value(_section, "readonly_user",
                                             default=DATABASE_USER)
 DATABASE_READONLY_PASSWORD = c.get_config_value(_section, "readonly_password",