private void populateServiceAdvisors(ObjectNode root) {
    ArrayNode services = (ArrayNode) root.get(SERVICES_PROPERTY);
    Iterator<JsonNode> servicesIter = services.elements();

    ObjectNode version = (ObjectNode) root.get("Versions");
    String stackName = version.get("stack_name").asText();
    String stackVersion = version.get("stack_version").asText();

    while (servicesIter.hasNext()) {
      JsonNode service = servicesIter.next();
      ObjectNode serviceVersion = (ObjectNode) service.get(STACK_SERVICES_PROPERTY);
      String serviceName = serviceVersion.get("service_name").asText();
      try {
        ServiceInfo serviceInfo = metaInfo.getService(stackName, stackVersion, serviceName);
        if (serviceInfo.getAdvisorFile() != null) {
          serviceVersion.put("advisor_name", serviceInfo.getAdvisorName());
          serviceVersion.put("advisor_path", serviceInfo.getAdvisorFile().getAbsolutePath());
        }
      } catch (Exception e) {
        LOG.error("Error adding service advisor information to services.json", e);
      }
    }
  }
Retrieves the Ambari configuration if exists and adds it to services.json

@param root The JSON document that will become service.json when passed to the stack advisor engine
ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java