mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Violette Roche-Montane
11.25.2013 1e1c39644fa2efe85b0042a83269f13debdbad6d
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.

NOTA : The config/snmp/security/opends-snmp.security has been changed in 2.5.0.7466 and the community name as well. ( Cf. Matt's comment in CR).
5 files modified
84 ■■■■■ changed files
opends/src/messages/messages/tools.properties 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/Installation.java 10 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/Upgrade.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java 55 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java 10 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/tools.properties
@@ -2688,6 +2688,8 @@
configuration file '%s': %s
INFO_OPTION_ACCEPT_LICENSE_1836=Automatically accepts the product license \
(if present)
SEVERE_ERR_UPGRADE_RENAME_SNMP_SECURITY_CONFIG_FILE_1838=An error occurred when \
trying to rename the SNMP security config file: %s
# Upgrade tasks
INFO_UPGRADE_TASK_6869_SUMMARY_10000=Fixing de-DE collation matching rule OID
@@ -2708,3 +2710,5 @@
INFO_UPGRADE_TASK_8487_SUMMARY_10013=Adding PBKDF2 password storage scheme configuration
INFO_UPGRADE_TASK_8613_SUMMARY_10014=Adding HTTP connection handler configuration
INFO_UPGRADE_TASK_8832_SUMMARY_10015=Adding file-based HTTP access logger
INFO_UPGRADE_TASK_7466_SUMMARY_10016=Rename SNMP security config file
opends/src/server/org/opends/server/tools/upgrade/Installation.java
@@ -90,6 +90,16 @@
  public static final String TMP_PATH_RELATIVE = "tmp";
  /**
   * Relative path to the snmp directory.
   */
  public static final String SNMP_PATH_RELATIVE = "snmp";
  /**
   * Relative path to the security directory.
   */
  public static final String SECURITY_PATH_RELATIVE = "security";
  /**
   * The relative path to the current Configuration LDIF file.
   */
  public static final String CURRENT_CONFIG_FILE_NAME = "config.ldif";
opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
@@ -128,6 +128,9 @@
        "delete: objectClass",
        "objectClass: ds-cfg-file-based-access-log-publisher"));
    register ("2.5.0.7466",
        renameSnmpSecurityConfig(INFO_UPGRADE_TASK_7466_SUMMARY.get()));
    register("2.5.0.7748",
        newAttributeTypes(INFO_UPGRADE_TASK_7748_1_SUMMARY.get(),
        "00-core.ldif", "etag"),
@@ -272,6 +275,8 @@
          "cn=File Count Retention Policy,cn=Log Retention Policies,cn=config",
        "ds-cfg-log-file-permissions: 640",
        "ds-cfg-enabled: false"));
    /*
     * All upgrades will refresh the server configuration schema and generate
     * a new upgrade folder.
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)
opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
@@ -97,14 +97,20 @@
  /** The template/config/schema folder of the current installation. */
  static final File templateConfigSchemaDirectory = new File(
      getInstallationPath(), Installation.TEMPLATE_RELATIVE_PATH
          + File.separator + Installation.CONFIG_PATH_RELATIVE + File.separator
          + Installation.SCHEMA_PATH_RELATIVE);
          + File.separator + Installation.CONFIG_PATH_RELATIVE
          + File.separator + Installation.SCHEMA_PATH_RELATIVE);
  /** The template/config folder of the current installation. */
  static final File templateConfigDirectory = new File(
      getInstallationPath(), Installation.TEMPLATE_RELATIVE_PATH
          + File.separator + Installation.CONFIG_PATH_RELATIVE);
  /** The config snmp security folder of the current installation. */
  static final File configSnmpSecurityDirectory = new File(
      getInstallationPath(), Installation.CONFIG_PATH_RELATIVE
      + File.separator + Installation.SNMP_PATH_RELATIVE + File.separator
      + Installation.SECURITY_PATH_RELATIVE);
  /**
   * Returns the path of the installation of the directory server. Note that
   * this method assumes that this code is being run locally.