private Map<String, ServiceModule> parseCommonServicesDirectory(File commonServicesRoot) throws AmbariException {
    Map<String, ServiceModule> commonServiceModules = new HashMap<>();

    if(commonServicesRoot != null) {
      File[] commonServiceFiles = commonServicesRoot.listFiles(StackDirectory.FILENAME_FILTER);
      for (File commonService : commonServiceFiles) {
        if (commonService.isFile()) {
          continue;
        }
        for (File serviceFolder : commonService.listFiles(StackDirectory.FILENAME_FILTER)) {
          ServiceDirectory serviceDirectory = new CommonServiceDirectory(serviceFolder.getPath());
          ServiceMetainfoXml metaInfoXml = serviceDirectory.getMetaInfoFile();
          if (metaInfoXml != null) {
            if (metaInfoXml.isValid()) {
              for (ServiceInfo serviceInfo : metaInfoXml.getServices()) {
                ServiceModule serviceModule = new ServiceModule(stackContext, serviceInfo, serviceDirectory, true);

                String commonServiceKey = serviceInfo.getName() + StackManager.PATH_DELIMITER + serviceInfo.getVersion();
                commonServiceModules.put(commonServiceKey, serviceModule);
              }
            } else {
              ServiceModule serviceModule = new ServiceModule(stackContext, new ServiceInfo(), serviceDirectory, true);
              serviceModule.setValid(false);
              serviceModule.addErrors(metaInfoXml.getErrors());
              commonServiceModules.put(metaInfoXml.getSchemaVersion(), serviceModule);
              metaInfoXml.setSchemaVersion(null);
            }
          }
        }
      }
    }
    return commonServiceModules;
  }
Parse the specified common services root directory

@param commonServicesRoot  the common services root directory to parse
@return map of common service id which contains name and version to common service module.
@throws AmbariException if unable to parse all common services
ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java