Exemplo n.º 1
0
  /**
   * Returns Replication Status by invoking OpenDJ <code>dsreplication</code> CLI
   *
   * @param port LDAP port number of embedded OpenDJ
   * @param passwd Directory Manager password
   * @param oo Standard output
   * @param err : Standard error
   * @return <code>dsreplication</code> CLI exit code.
   */
  public static int getReplicationStatus(
      String port, String passwd, OutputStream oo, OutputStream err) {
    Debug debug = Debug.getInstance(SetupConstants.DEBUG_NAME);
    String baseDir = SystemProperties.get(SystemProperties.CONFIG_PATH);

    String[] statusCmd = {
      "status",
      "--no-prompt",
      "-h",
      "localhost",
      "-p",
      port,
      "--adminUID",
      "admin",
      "--adminPassword",
      passwd,
      "-s",
      "--configFile",
      baseDir + "/opends/config/config.ldif"
    };
    if (debug.messageEnabled()) {
      String dbgcmd = concat(statusCmd).replaceAll(passwd, "****");
      debug.message("EmbeddedOpenDS:getReplicationStatus:exec dsreplication :" + dbgcmd);
    }
    int ret = ReplicationCliMain.mainCLI(statusCmd, false, oo, err, null);
    if (debug.messageEnabled()) {
      debug.message("EmbeddedOpenDS:getReplicationStatus:dsreplication ret:" + ret);
    }
    return ret;
  }
Exemplo n.º 2
0
  /**
   * Syncs replication data between two OpenDJ sms and user stores. $ dsreplication initialize
   * --baseDN "dc=example,dc=com" --adminUID admin --adminPassword pass --hostSource host1
   * --portSource 1389 --hostDestination host2 --portDestination 2389 --trustAll
   *
   * @param map Map of properties collected by the configurator.
   * @return status : 0 == success, !0 == failure
   */
  public static int setupReplicationInitialize(Map map) {
    String[] initializeCmd = {
      "initialize", // 0
      "--no-prompt", // 1
      "--baseDN", // 2
      Constants.DEFAULT_ROOT_SUFFIX, // 3 Placeholder
      "--adminUID", // 4
      "admin", // 5
      "--adminPassword", // 6
      "xxxxxxxx", // 7
      "--hostSource", // 8
      "localhost", // 9
      "--portSource", // 10
      "50389", // 11
      "--hostDestination", // 12
      "localhost", // 13
      "--portDestination", // 14
      "51389", // 15
      "--trustAll", // 16
      "--configFile", // 17
      "path/to/config.ldif" // 18
    };
    initializeCmd[3] = (String) map.get(SetupConstants.CONFIG_VAR_ROOT_SUFFIX);
    initializeCmd[9] = (String) map.get(SetupConstants.DS_EMB_REPL_HOST2);
    initializeCmd[11] = (String) map.get(SetupConstants.DS_EMB_REPL_ADMINPORT2);
    initializeCmd[13] = getOpenDJHostName(map);
    initializeCmd[15] = (String) map.get(SetupConstants.CONFIG_VAR_DIRECTORY_ADMIN_SERVER_PORT);
    initializeCmd[18] = getOpenDJConfigFile(map);

    Object[] params = {concat(initializeCmd)};
    SetupProgress.reportStart("emb.replcommand", params);

    initializeCmd[7] = (String) map.get(SetupConstants.CONFIG_VAR_DS_MGR_PWD);
    int ret =
        ReplicationCliMain.mainCLI(
            initializeCmd,
            false,
            SetupProgress.getOutputStream(),
            SetupProgress.getOutputStream(),
            null);

    if (ret == 0) {
      SetupProgress.reportEnd("emb.success", null);
    } else {
      SetupProgress.reportEnd("emb.failed", null);
    }
    return ret;
  }
Exemplo n.º 3
0
  /**
   * Setups replication between two OpenDJ sms and user stores. $ dsreplication enable --no-prompt
   * --host1 host1 --port1 1389 --bindDN1 "cn=Directory Manager" --bindPassword1 password
   * --replicationPort1 8989 --host2 host2 --port2 2389 --bindDN2 "cn=Directory Manager"
   * --bindPassword2 password --replicationPort2 8990 --adminUID admin --adminPassword password
   * --baseDN "dc=example,dc=com"
   *
   * @param map Map of properties collected by the configurator.
   * @return status : 0 == success, !0 == failure
   */
  public static int setupReplicationEnable(Map map) {
    String[] enableCmd = {
      "enable", // 0
      "--no-prompt", // 1
      "--host1", // 2
      "host1val", // 3
      "--port1", // 4
      "port1ival", // 5
      "--bindDN1", // 6
      "cn=Directory Manager", // 7
      "--bindPassword1", // 8
      "xxxxxxxx", // 9
      "--replicationPort1", // 10
      "8989", // 11
      "--host2", // 12
      "host2val", // 13
      "--port2", // 14
      "port2ival", // 15
      "--bindDN2", // 16
      "cn=Directory Manager", // 17
      "--bindPassword2", // 18
      "xxxxxxxx", // 19
      "--replicationPort2", // 20
      "8989", // 21
      "--adminUID", // 22
      "admin", // 23
      "--adminPassword", // 24
      "xxxxxxxx", // 25
      "--baseDN", // 26
      "dc=example,dc=com", // 27
      "--trustAll", // 28
      "--configFile", // 29
      "path/to/config.ldif" // 30
    };
    enableCmd[3] = (String) map.get(SetupConstants.DS_EMB_REPL_HOST2);
    enableCmd[5] = (String) map.get(SetupConstants.DS_EMB_REPL_ADMINPORT2);
    enableCmd[11] = (String) map.get(SetupConstants.DS_EMB_REPL_REPLPORT2);
    enableCmd[13] = getOpenDJHostName(map);
    enableCmd[15] = (String) map.get(SetupConstants.CONFIG_VAR_DIRECTORY_ADMIN_SERVER_PORT);
    enableCmd[21] = (String) map.get(SetupConstants.DS_EMB_REPL_REPLPORT1);
    enableCmd[27] = (String) map.get(SetupConstants.CONFIG_VAR_ROOT_SUFFIX);
    enableCmd[30] = getOpenDJConfigFile(map);

    Object[] params = {concat(enableCmd)};
    SetupProgress.reportStart("emb.replcommand", params);

    enableCmd[9] = (String) map.get(SetupConstants.CONFIG_VAR_DS_MGR_PWD);
    enableCmd[19] = (String) map.get(SetupConstants.CONFIG_VAR_DS_MGR_PWD);
    enableCmd[25] = (String) map.get(SetupConstants.CONFIG_VAR_DS_MGR_PWD);

    Debug debug = Debug.getInstance(SetupConstants.DEBUG_NAME);
    if (debug.messageEnabled()) {
      debug.message("EmbeddedOpenDS.setupReplicationEnable: " + "Host 1 " + enableCmd[3]);
      debug.message("EmbeddedOpenDS.setupReplicationEnable: " + "Host 2 " + enableCmd[13]);
      debug.message("EmbeddedOpenDS.setupReplicationEnable: " + "Port 1 " + enableCmd[5]);
      debug.message("EmbeddedOpenDS.setupReplicationEnable: " + "Port 2 " + enableCmd[15]);
    }
    int ret =
        ReplicationCliMain.mainCLI(
            enableCmd,
            false,
            SetupProgress.getOutputStream(),
            SetupProgress.getOutputStream(),
            null);

    if (ret == 0) {
      SetupProgress.reportEnd("emb.success", null);
    } else {
      SetupProgress.reportEnd("emb.failed", null);
    }
    return ret;
  }