summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--trove/guestagent/datastore/experimental/db2/manager.py1
-rw-r--r--trove/guestagent/datastore/experimental/db2/service.py13
-rw-r--r--trove/guestagent/datastore/experimental/db2/system.py3
-rw-r--r--trove/tests/unittests/guestagent/test_db2_manager.py2
4 files changed, 19 insertions, 0 deletions
diff --git a/trove/guestagent/datastore/experimental/db2/manager.py b/trove/guestagent/datastore/experimental/db2/manager.py
index 621845a3..02319653 100644
--- a/trove/guestagent/datastore/experimental/db2/manager.py
+++ b/trove/guestagent/datastore/experimental/db2/manager.py
@@ -50,6 +50,7 @@ class Manager(manager.Manager):
device.format()
device.mount(mount_point)
LOG.debug('Mounted the volume.')
+ self.app.update_hostname()
self.app.change_ownership(mount_point)
self.app.start_db()
diff --git a/trove/guestagent/datastore/experimental/db2/service.py b/trove/guestagent/datastore/experimental/db2/service.py
index 933f5fa6..e63c9d6f 100644
--- a/trove/guestagent/datastore/experimental/db2/service.py
+++ b/trove/guestagent/datastore/experimental/db2/service.py
@@ -43,6 +43,19 @@ class DB2App(object):
LOG.debug("state_change_wait_time = %s." % self.state_change_wait_time)
self.status = status
+ def update_hostname(self):
+ """
+ When DB2 server is installed, it uses the hostname of the
+ instance were the image was built. This needs to be updated
+ to reflect the guest instance.
+ """
+ LOG.debug("Update the hostname of the DB2 instance.")
+ try:
+ run_command(system.UPDATE_HOSTNAME,
+ superuser='root')
+ except exception.ProcessExecutionError:
+ raise RuntimeError(_("Command to update the hostname failed."))
+
def change_ownership(self, mount_point):
"""
When DB2 server instance is installed, it does not have the
diff --git a/trove/guestagent/datastore/experimental/db2/system.py b/trove/guestagent/datastore/experimental/db2/system.py
index 9aa7ac83..34fc2fe2 100644
--- a/trove/guestagent/datastore/experimental/db2/system.py
+++ b/trove/guestagent/datastore/experimental/db2/system.py
@@ -15,6 +15,9 @@
TIMEOUT = 1200
DB2_INSTANCE_OWNER = "db2inst1"
+UPDATE_HOSTNAME = (
+ 'source /home/db2inst1/sqllib/db2profile;'
+ 'db2set -g DB2SYSTEM="$(hostname)"')
ENABLE_AUTOSTART = (
"/opt/ibm/db2/V10.5/instance/db2iauto -on " + DB2_INSTANCE_OWNER)
DISABLE_AUTOSTART = (
diff --git a/trove/tests/unittests/guestagent/test_db2_manager.py b/trove/tests/unittests/guestagent/test_db2_manager.py
index cea03a69..3193507a 100644
--- a/trove/tests/unittests/guestagent/test_db2_manager.py
+++ b/trove/tests/unittests/guestagent/test_db2_manager.py
@@ -55,6 +55,7 @@ class GuestAgentDB2ManagerTest(trove_testtools.TestCase):
self.orig_create_users = db2_service.DB2Admin.create_user
self.orig_list_users = db2_service.DB2Admin.list_users
self.orig_delete_user = db2_service.DB2Admin.delete_user
+ self.orig_update_hostname = db2_service.DB2App.update_hostname
def tearDown(self):
super(GuestAgentDB2ManagerTest, self).tearDown()
@@ -73,6 +74,7 @@ class GuestAgentDB2ManagerTest(trove_testtools.TestCase):
db2_service.DB2Admin.create_user = self.orig_create_users
db2_service.DB2Admin.list_users = self.orig_list_users
db2_service.DB2Admin.delete_user = self.orig_delete_user
+ db2_service.DB2App.update_hostname = self.orig_update_hostname
def test_update_status(self):
mock_status = MagicMock()