From 11ae4700b7b9bfbd0f86adc099bf8a8a10434620 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Tue, 11 Jun 2013 15:25:39 +0000
Subject: [PATCH] CR-1829 OPENDJ-982 Upgrade: SNMP Connection Handler does not start after the upgrade As suggested in CR, a new upgrade task has been created 'Rename SNMP security config file'. This task is launched if the old SNMP config file actually exists in the config/snmp/security. The task renames the file with the new opendj name.
---
opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java b/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
index 3728290..51b6701 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -422,6 +422,61 @@
};
}
+ /**
+ * Renames the SNMP security config file if it exists. Since 2.5.0.7466 this
+ * file has been renamed.
+ *
+ * @param summary
+ * The summary of this upgrade task.
+ * @return An upgrade task which renames the old SNMP security config file if
+ * it exists.
+ */
+ public static UpgradeTask renameSnmpSecurityConfig(final Message summary)
+ {
+ return new AbstractUpgradeTask()
+ {
+ @Override
+ public void perform(final UpgradeContext context) throws ClientException
+ {
+ /*
+ * Snmp config file contains old name in old version(like 2.4.5), in
+ * order to make sure the process will still work after upgrade, we need
+ * to rename it - only if it exists.
+ */
+ if (UpgradeUtils.configSnmpSecurityDirectory.exists())
+ {
+ ProgressNotificationCallback pnc =
+ new ProgressNotificationCallback(0, summary, 0);
+ try
+ {
+ final File oldSnmpConfig =
+ new File(UpgradeUtils.configSnmpSecurityDirectory
+ + File.separator + "opends-snmp.security");
+ if (oldSnmpConfig.exists())
+ {
+ context.notifyProgress(pnc.changeProgress(20));
+ LOG.log(Level.INFO, summary.toString());
+
+ final File snmpConfig =
+ new File(UpgradeUtils.configSnmpSecurityDirectory
+ + File.separator + "opendj-snmp.security");
+
+ FileManager.rename(oldSnmpConfig, snmpConfig);
+
+ context.notifyProgress(pnc.changeProgress(100));
+ }
+ }
+ catch (final Exception ex)
+ {
+ manageTaskException(context,
+ ERR_UPGRADE_RENAME_SNMP_SECURITY_CONFIG_FILE.get(ex
+ .getMessage()), pnc);
+ }
+ }
+ }
+ };
+ }
+
private static UpgradeTask addConfigEntry0(final Message summary,
final Message description, final boolean needsUserConfirmation,
final String... ldif)
--
Gitblit v1.10.0