示例#1
0
  @Override
  public void replicate(ConfigManager manager, ConfigRequest request) throws IOException {
    if (!request.applies(AuthCodes.FEATURE)) {
      return;
    }
    if (!m_authCodes.isEnabled()) {
      return;
    }

    Set<Location> locations = request.locations(manager);
    Address fs = manager.getAddressManager().getSingleAddress(FreeswitchFeature.ACC_EVENT_ADDRESS);
    Domain domain = manager.getDomainManager().getDomain();
    for (Location location : locations) {
      AuthCodeSettings settings = m_authCodes.getSettings();
      File dir = manager.getLocationDataDirectory(location);
      boolean enabled = manager.getFeatureManager().isFeatureEnabled(AuthCodes.FEATURE);
      ConfigUtils.enableCfengineClass(dir, "sipxacccode.cfdat", enabled, "sipxacccode");
      Writer flat = new FileWriter(new File(dir, "sipxacccode.properties.part"));
      try {
        writeConfig(flat, settings, domain, fs.getPort());
      } finally {
        IOUtils.closeQuietly(flat);
      }
    }
  }
示例#2
0
  @Override
  public void replicate(ConfigManager manager, ConfigRequest request) throws IOException {
    if (!request.applies(
        DialPlanContext.FEATURE,
        Ivr.FEATURE,
        Mwi.FEATURE,
        RestServer.FEATURE,
        ImBot.FEATURE,
        FreeswitchFeature.FEATURE,
        AdminContext.FEATURE,
        ApacheManager.FEATURE,
        ImManager.FEATURE)) {
      return;
    }
    Set<Location> locations = request.locations(manager);
    FeatureManager featureManager = manager.getFeatureManager();
    Address adminApi = manager.getAddressManager().getSingleAddress(AdminContext.HTTP_ADDRESS_AUTH);
    Address apacheApi = manager.getAddressManager().getSingleAddress(ApacheManager.HTTPS_ADDRESS);
    Address restApi = manager.getAddressManager().getSingleAddress(RestServer.HTTP_API);
    Address imApi = manager.getAddressManager().getSingleAddress(ImManager.XMLRPC_ADDRESS);
    Address imbotApi = manager.getAddressManager().getSingleAddress(ImBot.REST_API);
    Address fsEvent = manager.getAddressManager().getSingleAddress(FreeswitchFeature.EVENT_ADDRESS);
    IvrSettings settings = m_ivr.getSettings();
    Domain domain = manager.getDomainManager().getDomain();
    List<Location> mwiLocations =
        manager.getFeatureManager().getLocationsForEnabledFeature(Mwi.FEATURE);
    int mwiPort = m_mwi.getSettings().getHttpApiPort();
    for (Location location : locations) {
      File dir = manager.getLocationDataDirectory(location);
      boolean enabled = featureManager.isFeatureEnabled(Ivr.FEATURE, location);

      ConfigUtils.enableCfengineClass(dir, "sipxivr.cfdat", enabled, "sipxivr");
      if (!enabled) {
        continue;
      }
      File f = new File(dir, "sipxivr.properties.part");
      Writer wtr = new FileWriter(f);
      Set<String> mwiAddresses = new LinkedHashSet<String>();
      mwiAddresses.add(location.getAddress());
      for (Location mwiLocation : mwiLocations) {
        mwiAddresses.add(mwiLocation.getAddress());
      }
      try {
        write(
            wtr,
            settings,
            domain,
            location,
            StringUtils.join(mwiAddresses, ","),
            mwiPort,
            restApi,
            adminApi,
            apacheApi,
            imApi,
            imbotApi,
            fsEvent);
      } finally {
        IOUtils.closeQuietly(wtr);
      }
    }
  }