Explorar el Código

Merge pull request #2093 from garonsky/issue-1881-configmgr-component-no-longer-in-use-msg

ISSUE:1881 ConfigMgr-notify user if component is not part of install

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman hace 13 años
padre
commit
d3f8adbd85

+ 4 - 0
deployment/deploy/XMLTags.h

@@ -28,6 +28,7 @@
 #define XML_TAG_PROGRAMS               "Programs"
 #define XML_TAG_DATA                   "Data"
 #define XML_TAG_ENVSETTINGS            "EnvSettings"
+#define XML_TAG_DIRECTORIES            "Directories"
 
 #define XML_TAG_ATTRIBUTESERVER        "AttributeServer"
 #define XML_TAG_ATTRSERVERINSTANCE     "AttrServerInstance"
@@ -80,6 +81,9 @@
 #define XML_TAG_TOPOLOGY               "Topology"
 #define XML_TAG_VERSION                "Version"
 #define XML_TAG_ROXIECLUSTER           "RoxieCluster"
+#define XML_TAG_LOCALENVFILE           "LocalEnvFile"
+#define XML_TAG_LOCALCONFFILE          "LocalConfFile"
+#define XML_TAG_LOCALENVCONFFILE       "LocalEnvConfFile"
 
 #define XML_ATTR_AGENTPORT             "@agentPort"
 #define XML_ATTR_ATTRSERVER            "@attrServer"

+ 63 - 18
esp/services/WsDeploy/WsDeployService.cpp

@@ -34,6 +34,7 @@
 #define STANDARD_CONFIG_BACKUPDIR CONFIG_DIR"/backup"
 #define STANDARD_CONFIG_SOURCEDIR CONFIG_DIR
 #define STANDARD_CONFIG_BUILDSETFILE "buildset.xml"
+#define STANDARD_CONFIG_CONFIGXML_DIR "/componentfiles/configxml/"
 
 #define DEFAULT_DIRECTORIES "<Directories name=\""DIR_NAME"\">\
       <Category dir=\""EXEC_PREFIX"/log/[NAME]/[INST]\" name=\"log\"/>\
@@ -196,6 +197,59 @@ void expandRange(IPropertyTree* pComputers)
   }
 }
 
+CConfigHelper::CConfigHelper()
+{
+}
+
+CConfigHelper::~CConfigHelper()
+{
+}
+
+void CConfigHelper::init(const IPropertyTree *cfg, const char* esp_name)
+{
+  StringBuffer xpath;
+
+  xpath.clear().appendf("%s/%s/%s[%s='%s']/%s",XML_TAG_SOFTWARE, XML_TAG_ESPPROCESS, XML_TAG_ESPSERVICE, XML_ATTR_NAME, esp_name, XML_TAG_LOCALCONFFILE);
+  m_strConfFile = cfg->queryProp(xpath.str());
+
+  xpath.clear().appendf("%s/%s/%s[%s='%s']/%s",XML_TAG_SOFTWARE, XML_TAG_ESPPROCESS, XML_TAG_ESPSERVICE, XML_ATTR_NAME, esp_name, XML_TAG_LOCALENVCONFFILE);
+  m_strEnvConfFile = cfg->queryProp(xpath.str());
+
+  if (m_strConfFile.length() > 0 && m_strEnvConfFile.length() > 0)
+  {
+    Owned<IProperties> pParams = createProperties(m_strConfFile);
+    Owned<IProperties> pEnvParams = createProperties(m_strEnvConfFile);
+
+    m_strConfigXMLDir = pEnvParams->queryProp(TAG_PATH);
+
+    if ( m_strConfigXMLDir.length() == 0)
+    {
+      m_strConfigXMLDir = INSTALL_DIR;
+    }
+
+    m_strBuildSetFileName = pParams->queryProp(TAG_BUILDSET);
+
+    m_strBuildSetFilePath.append(m_strConfigXMLDir).append(STANDARD_CONFIG_CONFIGXML_DIR).append( m_strBuildSetFileName.length() > 0 ? m_strBuildSetFileName : STANDARD_CONFIG_BUILDSETFILE);
+    m_pDefBldSet.set(createPTreeFromXMLFile(m_strBuildSetFilePath.str()));
+  }
+}
+
+bool CConfigHelper::isInBuildSet(const char* comp_process_name, const char* comp_name) const
+{
+  StringBuffer xpath;
+
+  xpath.appendf("./%s/%s/%s[%s=\"%s\"][%s=\"%s\"]", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET, XML_ATTR_PROCESS_NAME, comp_process_name, XML_ATTR_NAME, comp_name);
+
+  if (strcmp(XML_TAG_DIRECTORIES,comp_name) != 0 && m_pDefBldSet->queryPropTree(xpath.str()) == NULL)
+  {
+     return false;
+  }
+  else
+  {
+     return true;
+  }
+}
+
 CWsDeployExCE::~CWsDeployExCE()
 {
     m_pCfg.clear();
@@ -249,6 +303,8 @@ void CWsDeployExCE::init(IPropertyTree *cfg, const char *process, const char *se
   StringBuffer xpath;
   m_envFile.clear();
 
+  m_configHelper.init(cfg,service);
+
   xpath.clear().appendf("Software/EspProcess/EspService[@name='%s']/LocalEnvConfFile", service);
   const char* tmp = cfg->queryProp(xpath.str());
   if (tmp && *tmp)
@@ -2993,6 +3049,11 @@ bool CWsDeployFileInfo::displaySettings(IEspContext &context, IEspDisplaySetting
       const char* buildSetName = pBuildSet->queryProp(XML_ATTR_NAME);
       const char* processName = pBuildSet->queryProp(XML_ATTR_PROCESS_NAME);
 
+      if ( m_pService->m_configHelper.isInBuildSet(pszCompType,buildSetName) == false )
+      {
+        throw MakeStringException(-1, "Component '%s' named '%s' not in build set. Component may be incompatible with the current version.", pszCompType, pszCompName);
+      }
+
       StringBuffer buildSetPath;
       Owned<IPropertyTree> pSchema = loadSchema(pEnvRoot->queryPropTree("./Programs/Build[1]"), pBuildSet, buildSetPath, m_Environment);
 
@@ -5847,26 +5908,11 @@ void CWsDeployFileInfo::initFileInfo(bool createOrOverwrite)
     StringBuffer s("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Environment></Environment>");
     Owned<IPropertyTree> pNewTree = createPTreeFromXMLString(s);
 
-    xpath.clear().appendf("Software/EspProcess/EspService[@name='%s']/LocalConfFile", m_pService->getName());
-    const char* pConfFile = m_pService->getCfg()->queryProp(xpath.str());
-    xpath.clear().appendf("Software/EspProcess/EspService[@name='%s']/LocalEnvConfFile", m_pService->getName());
-    const char* pEnvConfFile = m_pService->getCfg()->queryProp(xpath.str());
-    StringBuffer bldSetFile;
-
-    if( pConfFile && *pConfFile && pEnvConfFile && *pEnvConfFile)
+    if ( strlen(m_pService->m_configHelper.getBuildSetFilePath()) > 0 )
     {
-      Owned<IProperties> pParams = createProperties(pConfFile);
-      Owned<IProperties> pEnvParams = createProperties(pEnvConfFile);
-      const char* dirName = pEnvParams->queryProp("path");
-      const char* fileName = pParams->queryProp("buildset");
-
-      if (dirName && *dirName)
-      {
-        bldSetFile.append(dirName).append("/componentfiles/configxml/").append((fileName && *fileName)? fileName : STANDARD_CONFIG_BUILDSETFILE);
-
         try
         {
-          Owned<IPropertyTree> pDefBldSet = createPTreeFromXMLFile(bldSetFile);
+          Owned<IPropertyTree> pDefBldSet = createPTreeFromXMLFile( m_pService->m_configHelper.getBuildSetFilePath() );
           pNewTree->addPropTree(XML_TAG_PROGRAMS, createPTreeFromIPT(pDefBldSet->queryPropTree("./Programs")));
           pNewTree->addPropTree(XML_TAG_SOFTWARE, createPTreeFromIPT(pDefBldSet->queryPropTree("./Software")));
         }
@@ -5874,7 +5920,6 @@ void CWsDeployFileInfo::initFileInfo(bool createOrOverwrite)
         {
           e->Release();
         }
-      }
     }
 
     if(!pNewTree->queryPropTree(XML_TAG_SOFTWARE))

+ 43 - 0
esp/services/WsDeploy/WsDeployService.hpp

@@ -679,6 +679,48 @@ private:
     StringBuffer m_ip;
 };
 
+
+class CConfigHelper
+{
+public:
+
+  CConfigHelper();
+  virtual ~CConfigHelper();
+
+  void init(const IPropertyTree *cfg, const char* esp_name);
+
+  bool isInBuildSet(const char* comp_process_name, const char* comp_name) const;
+
+  const char* getConfigXMLDir() const
+  {
+    return m_strConfigXMLDir.toCharArray();
+  };
+  const char* getBuildSetFileName() const
+  {
+    return m_strBuildSetFileName.toCharArray();
+  };
+  const char* getEnvConfFile() const
+  {
+    return m_strEnvConfFile.toCharArray();
+  };
+  const char* getConfFile() const
+  {
+    return m_strConfFile.toCharArray();
+  };
+  const char* getBuildSetFilePath() const
+  {
+    return m_strBuildSetFilePath.toCharArray();
+  };
+
+protected:
+  Owned<IPropertyTree> m_pDefBldSet;
+  StringBuffer  m_strConfigXMLDir;
+  StringBuffer  m_strBuildSetFileName;
+  StringBuffer  m_strEnvConfFile;
+  StringBuffer  m_strConfFile;
+  StringBuffer  m_strBuildSetFilePath;
+};
+
 class CWsDeployExCE : public CWsDeploy
 {
 public:
@@ -732,6 +774,7 @@ public:
     const char* getBackupDir() { return m_backupDir.str(); }
     const char* getProcessName() { return m_process.str(); }
     const char* getSourceDir() { return m_sourceDir.str(); }
+    CConfigHelper m_configHelper;
 
 private:
   virtual void getWizOptions(StringBuffer& sb);