wizardInputs.cpp 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  1. /*#############################################################################
  2. Copyright (C) 2011 HPCC Systems.
  3. All rights reserved. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. #############################################################################*/
  14. /////////////////////////////////////////////////////////////////////////////
  15. //
  16. // WizardInputs.cpp : implementation file
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "wizardInputs.hpp"
  20. #include "XMLTags.h"
  21. #include "jencrypt.hpp"
  22. #include "buildset.hpp"
  23. #include "build-config.h"
  24. #define STANDARD_CONFIGXMLDIR COMPONENTFILES_DIR"/configxml/"
  25. #define STANDARD_CONFIG_BUILDSETFILE "buildset.xml"
  26. #define STANDARD_CONFIG_DIR CONFIG_DIR
  27. #define STANDARD_CONFIG_ALGORITHMFILE "genenvrules.conf"
  28. //---------------------------------------------------------------------------
  29. // CWizardInputs
  30. //---------------------------------------------------------------------------
  31. CWizardInputs::CWizardInputs(const char* xmlArg,const char *service,
  32. IPropertyTree * cfg,
  33. MapStringTo<StringBuffer>* dirMap): m_service(service),
  34. m_cfg(cfg), m_overrideDirs(dirMap)
  35. {
  36. m_pXml.setown(createPTreeFromXMLString(xmlArg && *xmlArg ? xmlArg : "<XmlArgs/>"));
  37. }
  38. //----------------------------------------------------------------------
  39. CWizardInputs::~CWizardInputs()
  40. {
  41. m_pXml.clear();
  42. HashIterator info(m_invalidServerCombo);
  43. for(info.first();info.isValid();info.next())
  44. {
  45. StringArray *a = *m_invalidServerCombo.mapToValue(&info.query());
  46. delete a;
  47. }
  48. HashIterator iter(m_compIpMap);
  49. ForEach(iter)
  50. {
  51. IMapping &cur = iter.query();
  52. CInstDetails* pInfo = m_compIpMap.mapToValue(&cur);
  53. pInfo->Release();
  54. }
  55. HashIterator sIter(m_compForTopology);
  56. for(sIter.first();sIter.isValid();sIter.next())
  57. {
  58. StringArray* a = *m_compForTopology.mapToValue(&sIter.query());
  59. delete a;
  60. }
  61. }
  62. //-----------------------------------------------------------------------
  63. // SetEnvironment
  64. //-----------------------------------------------------------------------
  65. void CWizardInputs::setEnvironment()
  66. {
  67. StringBuffer xpath;
  68. if(m_pXml->hasProp("@ipList"))
  69. formIPList(m_pXml->queryProp("@ipList"), m_ipaddress);
  70. if(m_pXml->hasProp("@roxieNodes"))
  71. m_roxieNodes = atoi(m_pXml->queryProp("@roxieNodes"));
  72. if(m_pXml->hasProp("@thorNodes"))
  73. m_thorNodes = atoi(m_pXml->queryProp("@thorNodes"));
  74. if(m_pXml->hasProp("@dbuser"))
  75. m_dbuser = m_pXml->queryProp("@dbuser");
  76. if(m_pXml->hasProp("@dbpassword"))
  77. m_dbpassword = m_pXml->queryProp("@dbpassword");
  78. m_thorSlavesPerNode = 1;
  79. if(m_pXml->hasProp("@slavesPerNode"))
  80. m_thorSlavesPerNode = atoi( m_pXml->queryProp("@slavesPerNode"));
  81. if (m_thorSlavesPerNode < 1)
  82. m_thorSlavesPerNode = 1;
  83. xpath.clear().appendf("Software/EspProcess/EspService[@name='%s']/LocalConfFile", m_service.str());
  84. const char* pConfFile = m_cfg->queryProp(xpath.str());
  85. xpath.clear().appendf("Software/EspProcess/EspService[@name='%s']/LocalEnvConfFile", m_service.str());
  86. const char* pEnvConfFile = m_cfg->queryProp(xpath.str());
  87. if (pConfFile && *pConfFile && pEnvConfFile && *pEnvConfFile)
  88. {
  89. Owned<IProperties> pParams = createProperties(pConfFile);
  90. Owned<IProperties> pEnvParams = createProperties(pEnvConfFile);
  91. StringBuffer sb, fileName;
  92. fileName.append((pEnvParams->queryProp("path")!= NULL ? (sb.clear().append(pEnvParams->queryProp("path")).append("/componentfiles/configxml/")) : STANDARD_CONFIGXMLDIR));
  93. fileName.append((pParams->queryProp("buildset") != NULL ? (sb.clear().append(pParams->queryProp("buildset"))) : STANDARD_CONFIG_BUILDSETFILE));
  94. if(fileName.length() && checkFileExists(fileName.str()))
  95. m_buildSetTree.setown(createPTreeFromXMLFile(fileName.str()));
  96. else
  97. throw MakeStringException( -1 , "The buildSetFile %s does not exists", fileName.str());
  98. fileName.clear().append((pEnvParams->queryProp("configs") != NULL ? (sb.clear().append(pEnvParams->queryProp("configs")).append("/")): STANDARD_CONFIG_DIR));
  99. fileName.append((pParams->queryProp("wizardalgorithm") != NULL ? (sb.clear().append(pParams->queryProp("wizardalgorithm"))) : STANDARD_CONFIG_ALGORITHMFILE));
  100. if(fileName.length() && checkFileExists(fileName.str()))
  101. m_algProp.setown(createProperties(fileName.str()));
  102. else
  103. throw MakeStringException( -1 , "The algorithm file %s does not exists", fileName.str());
  104. }
  105. setWizardRules();
  106. setTopologyParam();
  107. }
  108. void CWizardInputs::setWizardRules()
  109. {
  110. const char* roxieRedTypes[] = {"Full", "Circular", "None", "Overloaded"};
  111. m_roxieAgentRedType.clear().append("Circular");
  112. m_roxieAgentRedChannels = 2;
  113. m_roxieAgentRedOffset = 1;
  114. m_genOptForAllComps = GENOPTIONAL_ALL;
  115. if(m_algProp)
  116. {
  117. Owned<IPropertyIterator> iter = m_algProp->getIterator();
  118. StringBuffer prop;
  119. ForEach(*iter)
  120. {
  121. m_algProp->getProp(iter->getPropKey(), prop.clear());
  122. if(prop.length() && prop.charAt(prop.length()-1) == ',')
  123. prop.setCharAt((prop.length()-1),' ');
  124. if(!strcmp(iter->getPropKey(), "max_comps_per_node"))
  125. {
  126. m_maxCompOnNode = atoi(prop.str());
  127. }
  128. else if(!strcmp(iter->getPropKey(), "avoid_combo"))
  129. {
  130. StringArray pairValue;
  131. DelimToStringArray(prop.str(), pairValue, ",");
  132. if( pairValue.ordinality() > 0)
  133. {
  134. for( unsigned i = 0; i < pairValue.ordinality() ; i++)
  135. {
  136. StringArray eachpair;
  137. DelimToStringArray(pairValue.item(i), eachpair, "-");
  138. if(eachpair.ordinality() == 2 )
  139. {
  140. StringArray* serverCompArr = 0;
  141. ForEachItemIn(x, eachpair)
  142. {
  143. StringArrayPtr* pairServerArr = m_invalidServerCombo.getValue(eachpair.item(x));
  144. if(pairServerArr)
  145. {
  146. serverCompArr = (*pairServerArr);
  147. serverCompArr->append(x == 0 ? eachpair.item(1): eachpair.item(0));
  148. }
  149. else
  150. {
  151. serverCompArr = new StringArray();
  152. serverCompArr->append(x == 0 ? eachpair.item(1): eachpair.item(0));
  153. m_invalidServerCombo.setValue(eachpair.item(x),serverCompArr);
  154. serverCompArr->kill();
  155. }
  156. }
  157. }
  158. }
  159. }
  160. }
  161. else if(!strcmp (iter->getPropKey(),"do_not_generate"))
  162. DelimToStringArray(prop.str(), m_doNotGenComp, ",");
  163. else if(!strcmp (iter->getPropKey(),"comps_on_all_nodes"))
  164. DelimToStringArray(prop.str(), m_compOnAllNodes, ",");
  165. else if(!strcmp (iter->getPropKey(),"do_not_gen_optional"))
  166. {
  167. DelimToStringArray(prop.str(), m_doNotGenOptOnComps, ",");
  168. if (m_doNotGenOptOnComps.length() == 0)
  169. m_genOptForAllComps = GENOPTIONAL_ALL;
  170. else if (m_doNotGenOptOnComps.length() == 1 && !strcmp(m_doNotGenOptOnComps.item(0), "all"))
  171. m_genOptForAllComps = GENOPTIONAL_NONE;
  172. else
  173. m_genOptForAllComps = GENOPTIONAL_COMPS;
  174. }
  175. else if(!strcmp(iter->getPropKey(), "topology_for_comps"))
  176. DelimToStringArray(prop.str(), m_clusterForTopology, ",");
  177. else if (!strcmp(iter->getPropKey(), "roxie_agent_redundancy"))
  178. {
  179. StringArray sbarr;
  180. DelimToStringArray(prop.str(), sbarr, ",");
  181. if (sbarr.length() > 1)
  182. {
  183. int type = atoi(sbarr.item(0));
  184. if (type == 0)
  185. continue;
  186. if (type > 0 && type < 5)
  187. m_roxieAgentRedType.clear().append(roxieRedTypes[type]);
  188. else
  189. continue;
  190. m_roxieAgentRedChannels = atoi(sbarr.item(1));
  191. if (m_roxieAgentRedChannels <= 0)
  192. m_roxieAgentRedChannels = 1;
  193. if (sbarr.length() > 2)
  194. {
  195. m_roxieAgentRedOffset = atoi(sbarr.item(2));
  196. if (m_roxieAgentRedOffset <= 0)
  197. m_roxieAgentRedOffset = 1;
  198. }
  199. else
  200. m_roxieAgentRedOffset = 0;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. CInstDetails* CWizardInputs::getServerIPMap(const char* compName, const char* buildSetName,const IPropertyTree* pEnvTree, unsigned numOfNodes)
  207. {
  208. StringBuffer xPath;
  209. xPath.appendf("./Programs/Build/BuildSet[@name=\"%s\"]",buildSetName);
  210. IPropertyTree* pBuildSet = pEnvTree->queryPropTree(xPath.str());
  211. CInstDetails* instDetails = NULL;
  212. if(pBuildSet)
  213. {
  214. if(m_doNotGenComp.find(buildSetName) != NotFound)
  215. return instDetails;
  216. if(m_compOnAllNodes.find(buildSetName) != NotFound)
  217. return instDetails;
  218. if(m_ipaddress.ordinality() == 1)
  219. {
  220. instDetails = new CInstDetails(compName, m_ipaddress.item(0));
  221. m_compIpMap.setValue(buildSetName,instDetails);
  222. return instDetails;
  223. }
  224. else
  225. {
  226. for(unsigned x = 0; x < numOfNodes ; x++)
  227. {
  228. unsigned numOfIPSAlreadyTaken = getCntForAlreadyAssignedIPS();
  229. if( numOfIPSAlreadyTaken < m_ipaddress.ordinality())
  230. {
  231. addToCompIPMap(buildSetName, m_ipaddress.item(numOfIPSAlreadyTaken), compName);
  232. }
  233. else
  234. {
  235. applyOverlappingRules(compName, buildSetName);
  236. }
  237. }
  238. if(m_compIpMap.find(buildSetName) != NULL)
  239. {
  240. instDetails = m_compIpMap.getValue(buildSetName);
  241. if( (instDetails->getIpAssigned()).ordinality() != numOfNodes)
  242. throw MakeStringException(-1, "Cannot assign [%d] number of nodes for [%s] cluster due to insufficient IP Addresses available after applying given set of rules. Please enter different value", numOfNodes, buildSetName);
  243. else{
  244. return m_compIpMap.getValue(buildSetName);
  245. }
  246. }
  247. }
  248. return instDetails;
  249. }
  250. return NULL;
  251. }
  252. void CWizardInputs::applyOverlappingRules(const char* compName,const char* buildSetName)
  253. {
  254. StringArray dontAssign , ignoredForOverlap;
  255. bool assignedIP = false;
  256. CInstDetails* compPtr = NULL;
  257. if(m_invalidServerCombo.find(buildSetName) != NULL)
  258. {
  259. StringArray* serverCompArr = 0;
  260. StringArrayPtr* pairServerArr = m_invalidServerCombo.getValue(buildSetName);
  261. if(pairServerArr)
  262. serverCompArr = (*pairServerArr);
  263. for(unsigned i = 0 ; i < serverCompArr->ordinality() ; i++)
  264. {
  265. compPtr = m_compIpMap.getValue(serverCompArr->item(i));
  266. if(compPtr)
  267. {
  268. StringArray& ipArr = compPtr->getIpAssigned();
  269. ForEachItemIn(i, ipArr)
  270. dontAssign.append(ipArr.item(i));
  271. }
  272. }
  273. }
  274. //Since Roxie and thor might already have some ips asssigned we need to ignore those too.
  275. if(m_compIpMap.find(buildSetName) != NULL)
  276. {
  277. compPtr = m_compIpMap.getValue(buildSetName);
  278. StringArray& ipArr = compPtr->getIpAssigned();
  279. ForEachItemIn(i, ipArr)
  280. dontAssign.append(ipArr.item(i));
  281. }
  282. for(unsigned ii = 0; ii < m_ipaddress.ordinality() ; ii++)
  283. {
  284. count_t ipAssignedCount = 0;
  285. ipAssignedCount = getNumOfInstForIP(m_ipaddress.item(ii));
  286. if(dontAssign.ordinality() > 0)
  287. {
  288. if( dontAssign.find(m_ipaddress.item(ii)) == NotFound)
  289. {
  290. if(ipAssignedCount >= m_maxCompOnNode )
  291. {
  292. ignoredForOverlap.append(m_ipaddress.item(ii));
  293. }
  294. else
  295. {
  296. assignedIP = true;
  297. addToCompIPMap(buildSetName, m_ipaddress.item(ii), compName);
  298. break;
  299. }
  300. }
  301. }
  302. else
  303. {
  304. if(ipAssignedCount >= m_maxCompOnNode )
  305. {
  306. ignoredForOverlap.append(m_ipaddress.item(ii));
  307. }
  308. else
  309. {
  310. assignedIP = true;
  311. addToCompIPMap(buildSetName, m_ipaddress.item(ii), compName);
  312. break;
  313. }
  314. }
  315. }
  316. if(!assignedIP && ignoredForOverlap.ordinality() > 0)
  317. {
  318. addToCompIPMap(buildSetName, ignoredForOverlap.item(0), compName);
  319. }
  320. }
  321. count_t CWizardInputs::getNumOfInstForIP(StringBuffer ip)
  322. {
  323. count_t cnt = 0;
  324. HashIterator ips(m_compIpMap);
  325. ForEach(ips)
  326. {
  327. CInstDetails* comp = m_compIpMap.mapToValue(&ips.query());
  328. StringArray& ipArray = comp->getIpAssigned();
  329. if(ipArray.find(ip) != NotFound)
  330. cnt++;
  331. }
  332. return cnt;
  333. }
  334. bool CWizardInputs::generateEnvironment(StringBuffer& envXml)
  335. {
  336. if(m_algProp)
  337. {
  338. Owned<IPropertyTree> pEnvTree = createEnvironment();
  339. if(pEnvTree)
  340. {
  341. toXML(pEnvTree,envXml, 0, XML_SortTags | XML_Format);
  342. }
  343. }
  344. else
  345. {
  346. DBGLOG("not yet decided");//use default algorithm
  347. }
  348. return true;
  349. }
  350. IPropertyTree* CWizardInputs::createEnvironment()
  351. {
  352. StringBuffer xpath, sbTemp, name ;
  353. sbTemp.clear().appendf("<%s><%s></%s>", XML_HEADER, XML_TAG_ENVIRONMENT, XML_TAG_ENVIRONMENT);
  354. IPropertyTree* pNewEnvTree = createPTreeFromXMLString(sbTemp.str());
  355. IPropertyTree* pSettings = pNewEnvTree->addPropTree(XML_TAG_ENVSETTINGS, createPTree());
  356. xpath.clear().appendf("%s/%s/%s[%s='%s']/LocalEnvFile", XML_TAG_SOFTWARE, XML_TAG_ESPPROCESS, XML_TAG_ESPSERVICE, XML_ATTR_NAME, m_service.str());
  357. const char* pConfFile = m_cfg->queryProp(xpath.str());
  358. xpath.clear().appendf("%s/%s/%s[%s='%s']/LocalEnvConfFile", XML_TAG_SOFTWARE, XML_TAG_ESPPROCESS, XML_TAG_ESPSERVICE, XML_ATTR_NAME, m_service.str());
  359. const char* tmp = m_cfg->queryProp(xpath.str());
  360. if (tmp && *tmp)
  361. {
  362. Owned<IProperties> pParams = createProperties(tmp);
  363. Owned<IPropertyIterator> iter = pParams->getIterator();
  364. ForEach(*iter)
  365. {
  366. StringBuffer prop;
  367. pParams->getProp(iter->getPropKey(), prop);
  368. pSettings->addProp(iter->getPropKey(), prop.length() ? prop.str():"");
  369. }
  370. }
  371. Owned<IPropertyTree> pProgramTree = createPTreeFromIPT(m_buildSetTree);
  372. pNewEnvTree->addPropTree(XML_TAG_PROGRAMS, createPTreeFromIPT(pProgramTree->queryPropTree("./"XML_TAG_PROGRAMS)));
  373. Owned<IPropertyTree> pCompTree = createPTree(XML_TAG_HARDWARE);
  374. generateHardwareHeaders(pNewEnvTree, sbTemp, false, pCompTree);
  375. pCompTree->removeProp(XML_TAG_COMPUTER);
  376. xpath.clear().appendf("./%s/%s", XML_TAG_COMPUTERTYPE, XML_ATTR_MEMORY);
  377. pCompTree->removeProp(xpath.str());
  378. xpath.clear().appendf("./%s/%s", XML_TAG_COMPUTERTYPE, XML_ATTR_NICSPEED);
  379. pCompTree->removeProp(xpath.str());
  380. xpath.clear().append(XML_TAG_SWITCH).append("/").append(XML_ATTR_NAME);
  381. pCompTree->setProp(xpath.str(), "Switch") ;
  382. xpath.clear().append(XML_TAG_DOMAIN).append("/").append(XML_ATTR_NAME);
  383. pCompTree->setProp(xpath.str(), "localdomain");
  384. xpath.clear().append(XML_TAG_DOMAIN).append("/").append(XML_ATTR_PASSWORD);
  385. pCompTree->setProp(xpath.str(), m_pXml->queryProp("@password"));
  386. xpath.clear().append(XML_TAG_DOMAIN).append("/").append(XML_ATTR_USERNAME);
  387. pCompTree->setProp(xpath.str(), m_pXml->queryProp("@username"));
  388. xpath.clear().appendf("./%s/@snmpSecurityString", XML_TAG_DOMAIN);
  389. pCompTree->removeProp(xpath.str());
  390. xpath.clear().append(XML_TAG_COMPUTERTYPE).append("/").append(XML_ATTR_COMPUTERTYPE);
  391. pCompTree->setProp(xpath.str(), "linuxmachine");
  392. xpath.clear().append(XML_TAG_COMPUTERTYPE).append("/").append(XML_ATTR_MANUFACTURER);
  393. pCompTree->setProp(xpath.str(), "unknown");
  394. xpath.clear().append(XML_TAG_COMPUTERTYPE).append("/").append(XML_ATTR_NAME);
  395. pCompTree->setProp(xpath.str(), "linuxmachine");
  396. xpath.clear().append(XML_TAG_COMPUTERTYPE).append("/").append(XML_ATTR_OPSYS);
  397. pCompTree->setProp(xpath.str(), "linux");
  398. for(unsigned i = 0; i < m_ipaddress.ordinality(); i++)
  399. {
  400. IPropertyTree* pComputer = pCompTree->addPropTree(XML_TAG_COMPUTER,createPTree());
  401. name.clear().appendf("node%03d", (i + 1));
  402. pComputer->addProp(XML_ATTR_COMPUTERTYPE, "linuxmachine");
  403. pComputer->addProp(XML_ATTR_DOMAIN, "localdomain");
  404. pComputer->addProp(XML_ATTR_NAME, name.str());
  405. pComputer->addProp(XML_ATTR_NETADDRESS, m_ipaddress.item(i));
  406. }
  407. pNewEnvTree->addPropTree(XML_TAG_HARDWARE, createPTreeFromIPT(pCompTree));
  408. //Before we generate software tree check for dependencies of component for do_not_generate ,roxie, thor
  409. checkForDependencies();
  410. generateSoftwareTree(pNewEnvTree);
  411. return pNewEnvTree;
  412. }
  413. void CWizardInputs::generateSoftwareTree(IPropertyTree* pNewEnvTree)
  414. {
  415. StringBuffer xpath , sbNewName;
  416. if(m_buildSetTree)
  417. {
  418. bool ovrLog = true, ovrRun = true;
  419. if (m_overrideDirs && m_overrideDirs->count() > 0)
  420. {
  421. HashIterator iter(*m_overrideDirs);
  422. ForEach(iter)
  423. {
  424. IMapping &cur = iter.query();
  425. StringBuffer* dirvalue = m_overrideDirs->mapToValue(&cur);
  426. const char * key = (const char*)cur.getKey();
  427. xpath.clear().appendf(XML_TAG_SOFTWARE"/Directories/Category[@name='%s']", key);
  428. if (!strcmp(key, "log"))
  429. ovrLog = false;
  430. else if (!strcmp(key, "run"))
  431. ovrRun = false;
  432. IPropertyTree* pDir = m_buildSetTree->queryPropTree(xpath.str());
  433. if (pDir)
  434. pDir->setProp("@dir", dirvalue->str());
  435. else
  436. {
  437. pDir = m_buildSetTree->queryPropTree(XML_TAG_SOFTWARE"/Directories/")->addPropTree("Category", createPTree());
  438. pDir->setProp(XML_ATTR_NAME, (const char*)cur.getKey());
  439. pDir->setProp("@dir", dirvalue->str());
  440. }
  441. }
  442. }
  443. pNewEnvTree->addPropTree(XML_TAG_SOFTWARE,createPTreeFromIPT(m_buildSetTree->queryPropTree("./"XML_TAG_SOFTWARE)));
  444. xpath.clear().appendf("%s/%s/%s[%s='%s']/LocalEnvConfFile", XML_TAG_SOFTWARE, XML_TAG_ESPPROCESS, XML_TAG_ESPSERVICE, XML_ATTR_NAME, m_service.str());
  445. const char* tmp = m_cfg->queryProp(xpath.str());
  446. if (tmp && *tmp)
  447. {
  448. Owned<IProperties> pParams = createProperties(tmp);
  449. updateDirsWithConfSettings(pNewEnvTree, pParams, ovrLog, ovrRun);
  450. }
  451. xpath.clear().appendf("./%s/%s/%s", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET);
  452. Owned<IPropertyTreeIterator> buildSetInsts = m_buildSetTree->getElements(xpath.str());
  453. ForEach(*buildSetInsts)
  454. {
  455. IPropertyTree* pBuildSet = &buildSetInsts->query();
  456. StringBuffer buildSetPath, compName, assignedIP, sbl;
  457. const char* buildSetName = pBuildSet->queryProp(XML_ATTR_NAME);
  458. const char* xsdFileName = pBuildSet->queryProp(XML_ATTR_SCHEMA);
  459. const char* processName = pBuildSet->queryProp(XML_ATTR_PROCESS_NAME);
  460. StringBuffer deployable = pBuildSet->queryProp("@"TAG_DEPLOYABLE);
  461. unsigned numOfIpNeeded = 1;
  462. if(m_doNotGenComp.find(buildSetName) != NotFound )
  463. continue;
  464. if(processName && *processName && buildSetName && * buildSetName && xsdFileName && *xsdFileName)
  465. {
  466. Owned<IPropertyTree> pSchema = loadSchema(m_buildSetTree->queryPropTree("./"XML_TAG_PROGRAMS"/"XML_TAG_BUILD"[1]"), pBuildSet, buildSetPath, NULL);
  467. IPropertyTree* pCompTree;
  468. if (m_genOptForAllComps == GENOPTIONAL_ALL || (m_genOptForAllComps == GENOPTIONAL_COMPS && m_doNotGenOptOnComps.find(buildSetName) == NotFound ))
  469. pCompTree = generateTreeFromXsd(pNewEnvTree, pSchema, processName, false);
  470. else if (m_genOptForAllComps == GENOPTIONAL_NONE || (m_genOptForAllComps == GENOPTIONAL_COMPS && m_doNotGenOptOnComps.find(buildSetName) != NotFound ))
  471. pCompTree = generateTreeFromXsd(pNewEnvTree, pSchema, processName, false, false, 0, false);
  472. //Check for my in buildset before appending my to name like mysql
  473. sbNewName.clear();
  474. if( strstr(buildSetName ,"my") == NULL && ( strcmp(buildSetName, "topology") != 0) )
  475. sbNewName.append("my");
  476. addComponentToEnv(pNewEnvTree, buildSetName, sbNewName, pCompTree);
  477. if(!strcmp(processName, XML_TAG_ESPSERVICE) || !strcmp(processName, XML_TAG_PLUGINPROCESS))
  478. {
  479. processName = buildSetName;
  480. }
  481. if(strcmp(deployable,"no") != 0)
  482. {
  483. if(m_compOnAllNodes.find(buildSetName) != NotFound)
  484. {
  485. for(unsigned i = 0; i < m_ipaddress.ordinality(); i++)
  486. {
  487. sbl.clear().appendf("s").append(i+1);
  488. assignedIP.clear().append(m_ipaddress.item(i));
  489. addInstanceToTree(pNewEnvTree, assignedIP, processName, buildSetName,sbl.str());
  490. }
  491. }
  492. else if(numOfIpNeeded > 0)
  493. {
  494. if(!strcmp(buildSetName, "roxie"))
  495. numOfIpNeeded = m_roxieNodes;
  496. else if(!strcmp(buildSetName, "thor"))
  497. numOfIpNeeded = m_thorNodes + 1;
  498. CInstDetails* pInstDetail = getServerIPMap(sbNewName.str(), buildSetName, pNewEnvTree, numOfIpNeeded);
  499. if(pInstDetail)
  500. {
  501. if(!strcmp(buildSetName, "roxie") || !strcmp(buildSetName, "thor" ))
  502. {
  503. addRoxieThorClusterToEnv(pNewEnvTree, pInstDetail, buildSetName);
  504. }
  505. else
  506. {
  507. StringArray& ipArr = pInstDetail->getIpAssigned();
  508. ForEachItemIn(x, ipArr)
  509. {
  510. assignedIP.clear().append(ipArr.item(x));
  511. addInstanceToTree(pNewEnvTree, assignedIP, processName, buildSetName, "s1");
  512. }
  513. }
  514. }
  515. }
  516. }
  517. }
  518. }
  519. getEspBindingInformation(pNewEnvTree);
  520. addTopology(pNewEnvTree);
  521. getDefaultsForWizard(pNewEnvTree);
  522. }
  523. }
  524. void CWizardInputs::addInstanceToTree(IPropertyTree* pNewEnvTree, StringBuffer attrName, const char* processName, const char* buildSetName, const char* instName)
  525. {
  526. StringBuffer sb, sbl, compName, xpath, nodeName;
  527. xpath.clear().appendf("./%s/%s[%s=\"%s\"]", XML_TAG_HARDWARE, XML_TAG_COMPUTER, XML_ATTR_NETADDRESS, attrName.str());
  528. IPropertyTree* pHardTemp = pNewEnvTree->queryPropTree(xpath.str());
  529. if(pHardTemp)
  530. nodeName.clear().append(pHardTemp->queryProp("./"XML_ATTR_NAME));//NodeName
  531. xpath.clear().appendf("./%s/%s[%s=\"%s\"]", XML_TAG_SOFTWARE, processName, XML_ATTR_BUILDSET, buildSetName);
  532. IPropertyTree* pComp = pNewEnvTree->queryPropTree(xpath.str());
  533. compName.clear().append(pComp->queryProp(XML_ATTR_NAME));//compName
  534. sb.clear().appendf("<Instance buildSet=\"%s\" compName=\"%s\" ><Instance name=\"%s\" /></Instance>", buildSetName, compName.str(), nodeName.str());
  535. Owned<IPropertyTree> pInstance = createPTreeFromXMLString(sb.str());
  536. if(pInstance)
  537. addInstanceToCompTree(pNewEnvTree, pInstance, sbl.clear(), sb.clear(),NULL);
  538. xpath.clear().appendf("./%s/%s[%s=\"%s\"]/%s[%s=\"%s\"]", XML_TAG_SOFTWARE, processName, XML_ATTR_NAME, compName.str(), XML_TAG_INSTANCE, XML_ATTR_COMPUTER, nodeName.str());
  539. IPropertyTree* pInst = pNewEnvTree->queryPropTree(xpath.str());
  540. if(pInst)
  541. {
  542. pInst->addProp(XML_ATTR_NAME, instName);
  543. }
  544. }
  545. void CWizardInputs::getDefaultsForWizard(IPropertyTree* pNewEnvTree)
  546. {
  547. StringBuffer xpath, tempName, value;
  548. Owned<IPropertyTree> pBuildTree = createPTreeFromIPT(pNewEnvTree->queryPropTree("./"XML_TAG_PROGRAMS));
  549. xpath.clear().appendf("./%s/%s/", XML_TAG_BUILD, XML_TAG_BUILDSET);
  550. Owned<IPropertyTreeIterator> buildSetInsts = pBuildTree->getElements(xpath.str());
  551. bool genOptional = true;
  552. ForEach(*buildSetInsts)
  553. {
  554. IPropertyTree* pBuildSet = &buildSetInsts->query();
  555. StringBuffer buildSetPath, compName;
  556. const char* buildSetName = pBuildSet->queryProp(XML_ATTR_NAME);
  557. const char* xsdFileName = pBuildSet->queryProp(XML_ATTR_SCHEMA);
  558. const char* processName = pBuildSet->queryProp(XML_ATTR_PROCESS_NAME);
  559. if(processName && *processName && buildSetName && * buildSetName && xsdFileName && *xsdFileName)
  560. {
  561. Owned<IPropertyTree> pSchema = loadSchema(pBuildTree->queryPropTree("./"XML_TAG_BUILD"[1]"), pBuildSet, buildSetPath, NULL);
  562. if (m_genOptForAllComps == GENOPTIONAL_ALL || (m_genOptForAllComps == GENOPTIONAL_COMPS && m_doNotGenOptOnComps.find(buildSetName) == NotFound ))
  563. genOptional = true;
  564. else if (m_genOptForAllComps == GENOPTIONAL_NONE || (m_genOptForAllComps == GENOPTIONAL_COMPS && m_doNotGenOptOnComps.find(buildSetName) != NotFound ))
  565. genOptional = false;
  566. Owned<IPropertyTree> pCompTree = generateTreeFromXsd(pNewEnvTree, pSchema, processName, true, true, this, genOptional);
  567. xpath.clear().appendf("./%s/%s/[%s=\"%s\"]", XML_TAG_SOFTWARE, processName, XML_ATTR_BUILDSET, buildSetName);
  568. IPropertyTree* pSWCompTree = pNewEnvTree->queryPropTree(xpath.str());
  569. if(pSWCompTree && pCompTree)
  570. {
  571. Owned<IAttributeIterator> iAttr = pCompTree->getAttributes();
  572. ForEach(*iAttr)
  573. {
  574. if( pSWCompTree->hasProp(iAttr->queryName()) && strcmp(iAttr->queryName(), "@buildSet") != 0)
  575. {
  576. if (!strcmp(iAttr->queryName(), XML_ATTR_NAME))
  577. {
  578. StringBuffer sbxpath, sbnew, sbMsg;
  579. sbnew.clear().append(iAttr->queryValue());
  580. sbxpath.clear().append(processName);
  581. getUniqueName(pNewEnvTree, sbnew, sbxpath.str(), XML_TAG_SOFTWARE);
  582. bool ret = checkComponentReferences(pNewEnvTree, pSWCompTree, pSWCompTree->queryProp(iAttr->queryName()), sbMsg, sbnew.str());
  583. if (ret)
  584. pSWCompTree->setProp(iAttr->queryName(), iAttr->queryValue());
  585. }
  586. else
  587. pSWCompTree->setProp(iAttr->queryName(), iAttr->queryValue());
  588. }
  589. }
  590. //Now adding elements
  591. Owned<IPropertyTreeIterator> iterElems = pCompTree->getElements("*");
  592. ForEach (*iterElems)
  593. {
  594. IPropertyTree* pElem = &iterElems->query();
  595. Owned<IAttributeIterator> iAttr = pElem->getAttributes();
  596. ForEach(*iAttr)
  597. {
  598. IPropertyTree* pNewSubElem = pSWCompTree->queryPropTree(pElem->queryName());
  599. if (!pNewSubElem)
  600. {
  601. pNewSubElem = pSWCompTree->addPropTree(pElem->queryName(), createPTreeFromIPT(pElem));
  602. break;
  603. }
  604. else
  605. {
  606. Owned<IPropertyTreeIterator> srcElems = pSWCompTree->getElements(pElem->queryName());
  607. IPropertyTree* pSrcElem = NULL;
  608. ForEach(*srcElems)
  609. {
  610. pSrcElem = &srcElems->query();
  611. Owned<IAttributeIterator> iAttrElem = pElem->getAttributes();
  612. ForEach(*iAttrElem)
  613. {
  614. const char* attrName = iAttrElem->queryName();
  615. if (pSrcElem->hasProp(attrName))
  616. pSrcElem->setProp(attrName, iAttrElem->queryValue());
  617. Owned<IPropertyTreeIterator> iterSubElems = pElem->getElements("*");
  618. ForEach (*iterSubElems)
  619. {
  620. IPropertyTree* pSubElem = &iterSubElems->query();
  621. Owned<IPropertyTreeIterator> srcSubElems = pSWCompTree->getElements(pSubElem->queryName());
  622. IPropertyTree* pSrcSubElem = NULL;
  623. ForEach(*srcSubElems)
  624. {
  625. pSrcSubElem = &srcSubElems->query();
  626. Owned<IAttributeIterator> iAttrElem = pSubElem->getAttributes();
  627. ForEach(*iAttrElem)
  628. {
  629. const char* attrName = iAttrElem->queryName();
  630. if (pSrcSubElem->hasProp(attrName))
  631. pSrcSubElem->setProp(attrName, iAttrElem->queryValue());
  632. }
  633. }
  634. }
  635. }
  636. }
  637. }
  638. }
  639. }
  640. }
  641. }
  642. }
  643. }
  644. void CWizardInputs::addToCompIPMap(const char* buildSetName, const char* value, const char* compName)
  645. {
  646. CInstDetails* pInst = NULL;
  647. if(m_compIpMap.find(buildSetName) != NULL)
  648. {
  649. pInst = m_compIpMap.getValue(buildSetName);
  650. (pInst->getIpAssigned()).append(value);
  651. }
  652. else
  653. {
  654. pInst = new CInstDetails();
  655. pInst->setParams(compName, value);
  656. m_compIpMap.setValue(buildSetName, pInst);
  657. }
  658. }
  659. unsigned CWizardInputs::getCntForAlreadyAssignedIPS()
  660. {
  661. unsigned cnt = 0;
  662. HashIterator ips(m_compIpMap);
  663. ForEach(ips)
  664. {
  665. CInstDetails* comp = m_compIpMap.mapToValue(&ips.query());
  666. StringArray& ipArray = comp->getIpAssigned();
  667. cnt += ipArray.length();
  668. }
  669. return cnt;
  670. }
  671. void CWizardInputs::addRoxieThorClusterToEnv(IPropertyTree* pNewEnvTree, CInstDetails* pInstDetails, const char* buildSetName)
  672. {
  673. StringBuffer xmlForRoxieServer, xmlForRoxieSlave, xpath, compName, computerName, msg;
  674. if(!strcmp(buildSetName, "roxie"))
  675. {
  676. //Before proceeding remove the roxieserver already added to env via xsd.
  677. xpath.clear().appendf("./%s/%s/%s", XML_TAG_SOFTWARE, XML_TAG_ROXIECLUSTER, XML_ATTR_NAME);
  678. compName.clear().append(pNewEnvTree->queryProp(xpath.str()));
  679. xmlForRoxieServer.clear().appendf("<RoxieData type=\"RoxieFarm\" parentName=\"\" roxieName=\"%s\" >", compName.str());
  680. if (m_roxieNodes == 1)
  681. xmlForRoxieSlave.clear().appendf("<RoxieData type=\"None\" val1=\"undefined\" val2=\"undefined\" roxieName=\"%s\" >", compName.str());
  682. else
  683. xmlForRoxieSlave.clear().appendf("<RoxieData type=\"%s\" val1=\"%d\" val2=\"%d\" roxieName=\"%s\" >",
  684. m_roxieAgentRedType.str(),
  685. m_roxieAgentRedChannels, m_roxieAgentRedOffset, compName.str());
  686. if(pInstDetails)
  687. {
  688. StringArray& ipAssignedToComp = pInstDetails->getIpAssigned();
  689. ForEachItemIn(i, ipAssignedToComp)
  690. {
  691. xpath.clear().appendf("./%s/%s/[%s=\"%s\"]", XML_TAG_HARDWARE, XML_TAG_COMPUTER, XML_ATTR_NETADDRESS, ipAssignedToComp.item(i));
  692. IPropertyTree* pHardTemp = pNewEnvTree->queryPropTree(xpath.str());
  693. if(pHardTemp){
  694. xmlForRoxieServer.appendf("<Component name=\"%s\" />", pHardTemp->queryProp("./@name"));
  695. xmlForRoxieSlave.appendf("<Computer name=\"%s\" />", pHardTemp->queryProp("./@name"));
  696. }
  697. }
  698. xmlForRoxieServer.append("</RoxieData>");
  699. xmlForRoxieSlave.append("</RoxieData>");
  700. handleRoxieOperation(pNewEnvTree, "AddRoxieFarm", xmlForRoxieServer.str());
  701. handleRoxieOperation(pNewEnvTree, "RoxieSlaveConfig" ,xmlForRoxieSlave.str());
  702. }
  703. xpath.clear().appendf("./%s/%s[%s=\"%s\"]/%s[%s=\"\"]", XML_TAG_SOFTWARE, XML_TAG_ROXIECLUSTER, XML_ATTR_NAME, compName.str(), XML_TAG_ROXIE_SERVER, XML_ATTR_NETADDRESS);
  704. pNewEnvTree->removeProp(xpath.str());
  705. }
  706. else if(!strcmp(buildSetName, "thor"))
  707. {
  708. //We need only one master
  709. StringBuffer masterIP, xml;
  710. xpath.clear().appendf("./%s/%s/%s", XML_TAG_SOFTWARE, XML_TAG_THORCLUSTER, XML_ATTR_NAME);
  711. compName.clear().append(pNewEnvTree->queryProp(xpath.str()));
  712. if(pInstDetails)
  713. {
  714. StringArray& ipAssignedToComp = pInstDetails->getIpAssigned();
  715. if(!ipAssignedToComp.empty())
  716. masterIP.clear().append(ipAssignedToComp.item(0));
  717. xpath.clear().appendf("./%s/%s[%s=\"%s\"]", XML_TAG_HARDWARE, XML_TAG_COMPUTER, XML_ATTR_NETADDRESS, masterIP.str());
  718. IPropertyTree* pHardTemp = pNewEnvTree->queryPropTree(xpath.str());
  719. if(pHardTemp)
  720. xml.clear().appendf("<ThorData type=\"Master\" name=\"%s\" validateComputers=\"false\" skipExisting=\"false\" > <Computer name=\"%s\" /></ThorData>", compName.str(), pHardTemp->queryProp("./@name"));
  721. handleThorTopologyOp(pNewEnvTree, "Add", xml.str(), msg);
  722. //Now add Slave
  723. xml.clear().appendf("<ThorData type=\"Slave\" name=\"%s\" validateComputers=\"false\" slavesPerNode=\"%d\" skipExisting=\"false\" >", compName.str(), m_thorSlavesPerNode);
  724. unsigned numOfNodes = ipAssignedToComp.ordinality() == 1 ? 0 : 1;
  725. for( ; numOfNodes < ipAssignedToComp.ordinality() ; numOfNodes++)
  726. {
  727. xpath.clear().appendf("./%s/%s[%s=\"%s\"]", XML_TAG_HARDWARE, XML_TAG_COMPUTER, XML_ATTR_NETADDRESS, ipAssignedToComp.item(numOfNodes));
  728. IPropertyTree* pHardTemp = pNewEnvTree->queryPropTree(xpath.str());
  729. if(pHardTemp)
  730. xml.appendf("<Computer name=\"%s\" />", pHardTemp->queryProp("./@name"));
  731. }
  732. xml.append("</ThorData>");
  733. handleThorTopologyOp(pNewEnvTree, "Add" , xml.str(), msg);
  734. }
  735. }
  736. }
  737. void CWizardInputs::getEspBindingInformation(IPropertyTree* pNewEnvTree)
  738. {
  739. StringBuffer xpath, sbDefn, xmlArg, compName, sbNewName;
  740. Owned<IPropertyTreeIterator> espProcessIter = pNewEnvTree->getElements("./"XML_TAG_SOFTWARE"/"XML_TAG_ESPPROCESS);
  741. ForEach(*espProcessIter)
  742. {
  743. IPropertyTree* pEspProcess = &espProcessIter->query();
  744. compName.clear().append(pEspProcess->queryProp(XML_ATTR_NAME));
  745. xpath.clear().appendf("./%s/%s/%s[@processName=\"%s\"]", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET, XML_TAG_ESPSERVICE);
  746. Owned<IPropertyTreeIterator> espServiceIter = pNewEnvTree->getElements(xpath.str());
  747. bool genOptional = true;
  748. ForEach (*espServiceIter)
  749. {
  750. IPropertyTree* pEspService = &espServiceIter->query();
  751. if(pEspService)
  752. {
  753. StringBuffer espServiceName;
  754. espServiceName.appendf("my%s", pEspService->queryProp("@name"));
  755. xpath.clear().appendf("./%s/%s[%s=\"%s\"]", XML_TAG_SOFTWARE, XML_TAG_ESPSERVICE, XML_ATTR_NAME, espServiceName.str());
  756. IPropertyTree* pEspServiceInSWTree = pNewEnvTree->queryPropTree(xpath.str());
  757. if(pEspServiceInSWTree)
  758. {
  759. xpath.clear().append("./Properties/@defaultPort");
  760. const char* port = pEspService->queryProp(xpath.str());
  761. xpath.clear().append("./Properties/@defaultResourcesBasedn");
  762. const char* resourceBasedn = pEspService->queryProp(xpath.str());
  763. const char* buildSetName = pEspService->queryProp(XML_ATTR_NAME);
  764. const char* processName = pEspService->queryProp(XML_ATTR_PROCESS_NAME);
  765. if (m_genOptForAllComps == GENOPTIONAL_ALL || (m_genOptForAllComps == GENOPTIONAL_COMPS && m_doNotGenOptOnComps.find(buildSetName) == NotFound ))
  766. genOptional = true;
  767. else if (m_genOptForAllComps == GENOPTIONAL_NONE || (m_genOptForAllComps == GENOPTIONAL_COMPS && m_doNotGenOptOnComps.find(buildSetName) != NotFound ))
  768. genOptional = false;
  769. StringBuffer buildSetPath;
  770. Owned<IPropertyTree> pSchema = loadSchema(pNewEnvTree->queryPropTree("./Programs/Build[1]"), pEspService, buildSetPath, NULL);
  771. xmlArg.clear().appendf("<EspServiceBindings type=\"EspBinding\" compName=\"%s\" > <Item name=\"%s\" params=\"pcType=EspProcess::pcName=%s::subType=EspBinding::subTypeKey=%s \"/></EspServiceBindings>", compName.str(), espServiceName.str(), compName.str(), espServiceName.str());
  772. addEspBindingInformation(xmlArg, pNewEnvTree, sbNewName, NULL);
  773. xpath.clear().appendf("./%s/%s/%s/[%s=\"\"]", XML_TAG_SOFTWARE, XML_TAG_ESPPROCESS, XML_TAG_ESPBINDING, XML_ATTR_SERVICE);
  774. IPropertyTree* pEspBindingInfo = pNewEnvTree->queryPropTree(xpath.str());
  775. pEspBindingInfo->setProp(XML_ATTR_NAME,(espServiceName.toLowerCase()).str());
  776. pEspBindingInfo->setProp(XML_ATTR_SERVICE,(espServiceName.toLowerCase()).str());
  777. pEspBindingInfo->setProp(XML_ATTR_PORT, port );
  778. pEspBindingInfo->setProp("@resourcesBasedn",resourceBasedn);
  779. xpath.clear().appendf("%s/%s[%s=\"%s\"]/Properties", XML_TAG_SOFTWARE, XML_TAG_ESPSERVICE, XML_ATTR_NAME, (espServiceName.toLowerCase()).str());
  780. IPropertyTree* pSvcProps = pNewEnvTree->queryPropTree(xpath.str());
  781. Owned<IPropertyTree> pCompTree = generateTreeFromXsd(pNewEnvTree, pSchema, processName, true, false, 0, genOptional);
  782. Owned<IPropertyTreeIterator> i = pSvcProps->getElements("Authenticate");
  783. ForEach(*i)
  784. {
  785. IPropertyTree* pAuthCopy = createPTreeFromIPT(&i->query());
  786. mergeAttributes(pAuthCopy, pCompTree->queryPropTree("Authenticate"));
  787. IPropertyTree* pNewNode = pEspBindingInfo->addPropTree("Authenticate", pAuthCopy);
  788. }
  789. i.setown( pSvcProps->getElements("AuthenticateFeature") );
  790. ForEach(*i)
  791. {
  792. IPropertyTree* pAuthCopy = createPTreeFromIPT(&i->query());
  793. //Adding authentication to true for espbinding.
  794. pAuthCopy->addProp("@authenticate","Yes");
  795. mergeAttributes(pAuthCopy, pCompTree->queryPropTree("AuthenticateFeature"));
  796. IPropertyTree* pNewNode = pEspBindingInfo->addPropTree("AuthenticateFeature", pAuthCopy);
  797. }
  798. i.setown( pSvcProps->getElements("AuthenticateSetting") );
  799. ForEach(*i)
  800. {
  801. IPropertyTree* pAuthCopy = createPTreeFromIPT(&i->query());
  802. mergeAttributes(pAuthCopy, pCompTree->queryPropTree("AuthenticateSetting"));
  803. IPropertyTree* pNewNode = pEspBindingInfo->addPropTree("AuthenticateSetting", pAuthCopy);
  804. }
  805. }
  806. }
  807. }
  808. }
  809. }
  810. void CWizardInputs::addTopology(IPropertyTree* pNewEnvTree)
  811. {
  812. StringBuffer xpath;
  813. if(!pNewEnvTree->hasProp("./"XML_TAG_SOFTWARE"/"XML_TAG_TOPOLOGY))
  814. pNewEnvTree->addPropTree("./"XML_TAG_SOFTWARE"/"XML_TAG_TOPOLOGY, createPTree());
  815. HashIterator sIter(m_compForTopology);
  816. for(sIter.first();sIter.isValid();sIter.next())
  817. {
  818. IMapping &cur = sIter.query();
  819. IPropertyTree* pCluster = createTopologyForComp(pNewEnvTree,(const char *) cur.getKey());
  820. if(pCluster)
  821. pNewEnvTree->addPropTree("./"XML_TAG_SOFTWARE"/"XML_TAG_TOPOLOGY"/Cluster", pCluster);
  822. }
  823. }
  824. IPropertyTree* CWizardInputs::createTopologyForComp(IPropertyTree* pNewEnvTree, const char* component)
  825. {
  826. StringBuffer xmlTag, xpath , compName, clusterStr;
  827. if(!strcmp(component, "roxie"))
  828. xmlTag.clear().append(XML_TAG_ROXIECLUSTER);
  829. else if(!strcmp(component, "thor"))
  830. xmlTag.clear().append(XML_TAG_THORCLUSTER);
  831. else if(!strcmp(component, "hthor"))
  832. xmlTag.clear().append("hthor");
  833. xpath.clear().appendf("./%s/%s[1]/%s", XML_TAG_SOFTWARE, xmlTag.str(), XML_ATTR_NAME);
  834. clusterStr.clear().appendf("<Cluster name=\"%s\" prefix=\"%s\"></Cluster>", component, component);
  835. IPropertyTree* pCluster = createPTreeFromXMLString(clusterStr.str());
  836. if(pCluster)
  837. {
  838. if(pNewEnvTree->hasProp(xpath.str()))
  839. {
  840. IPropertyTree* pComponent = pCluster->addPropTree(xmlTag.str(), createPTree());
  841. pComponent->addProp(XML_ATTR_PROCESS, pNewEnvTree->queryProp(xpath.str()));
  842. }
  843. if(m_compForTopology.find(component) != NULL)
  844. {
  845. StringArray* clusterCompEle = 0;
  846. StringArrayPtr* clusterPair = m_compForTopology.getValue(component);
  847. if(clusterPair)
  848. {
  849. clusterCompEle = (*clusterPair);
  850. for(unsigned i = 0 ; i < clusterCompEle->ordinality() ; i++)
  851. {
  852. const char* eachClusterElem = clusterCompEle->item(i);
  853. xpath.clear().appendf("./%s/%s/%s[%s=\"%s\"]", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET, XML_ATTR_NAME, eachClusterElem);
  854. IPropertyTree* pBuildset = pNewEnvTree->queryPropTree(xpath.str());
  855. if(pBuildset)
  856. {
  857. const char* processName = pBuildset->queryProp(XML_ATTR_PROCESS_NAME);
  858. if(processName && *processName)
  859. {
  860. IPropertyTree* pElement = pCluster->addPropTree(processName,createPTree());
  861. xpath.clear().appendf("./%s/%s[1]/%s", XML_TAG_SOFTWARE, processName, XML_ATTR_NAME);
  862. if(pElement && pNewEnvTree->hasProp(xpath.str()))
  863. pElement->addProp(XML_ATTR_PROCESS, pNewEnvTree->queryProp(xpath.str()));
  864. }
  865. }
  866. }
  867. }
  868. clusterCompEle->kill();
  869. }
  870. return pCluster;
  871. }
  872. else
  873. return NULL;
  874. }
  875. void CWizardInputs::checkForDependencies()
  876. {
  877. StringBuffer xpath;
  878. if(m_buildSetTree)
  879. {
  880. xpath.clear().appendf("./%s/%s/%s", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET);
  881. Owned<IPropertyTreeIterator> buildSetInsts = m_buildSetTree->getElements(xpath.str());
  882. ForEach(*buildSetInsts)
  883. {
  884. IPropertyTree* pBuildSet = &buildSetInsts->query();
  885. const char* buildSetName = pBuildSet->queryProp(XML_ATTR_NAME);
  886. unsigned numOfNodesNeeded = 1;
  887. if((!strcmp(buildSetName,"roxie") && m_roxieNodes == 0 )|| (!strcmp(buildSetName,"thor")&& m_thorNodes == 0)){
  888. numOfNodesNeeded = 0;
  889. m_doNotGenComp.append(buildSetName);
  890. }
  891. if(numOfNodesNeeded == 0 || (m_doNotGenComp.find(buildSetName) != NotFound))
  892. {
  893. if(m_compForTopology.find(buildSetName) != NULL )
  894. m_compForTopology.remove(buildSetName);
  895. checkAndAddDependComponent(buildSetName);
  896. }
  897. }
  898. }
  899. }
  900. void CWizardInputs::checkAndAddDependComponent(const char* key)
  901. {
  902. StringBuffer paramEntry(key);
  903. paramEntry.append("_dependencies");
  904. if(m_algProp)
  905. {
  906. if(m_algProp->hasProp(paramEntry.str()))
  907. {
  908. StringArray sArray;
  909. DelimToStringArray(m_algProp->queryProp(paramEntry.str()), sArray, ";");
  910. ForEachItemIn(x, sArray)
  911. {
  912. if(m_doNotGenComp.find(sArray.item(x)) == NotFound)
  913. {
  914. m_doNotGenComp.append(sArray.item(x));
  915. checkAndAddDependComponent(sArray.item(x));
  916. }
  917. }
  918. }
  919. }
  920. }
  921. unsigned CWizardInputs::getNumOfNodes(const char* compName)
  922. {
  923. if(m_compIpMap.find(compName) != NULL)
  924. {
  925. CInstDetails* pInst = NULL;
  926. pInst = m_compIpMap.getValue(compName);
  927. StringArray& ipArr = pInst->getIpAssigned();
  928. return ipArr.ordinality();
  929. }
  930. return 0;
  931. }
  932. void CWizardInputs::setTopologyParam()
  933. {
  934. if(m_clusterForTopology.ordinality() > 0)
  935. {
  936. StringBuffer topologySec;
  937. ForEachItemIn(x, m_clusterForTopology)
  938. {
  939. topologySec.clear().appendf("%s_topology",m_clusterForTopology.item(x));
  940. const char * elemForCluster = m_algProp->queryProp(topologySec.str());
  941. if(elemForCluster && *elemForCluster)
  942. {
  943. StringArray* compClusterArr = new StringArray();
  944. StringArray clusterElemArr;
  945. DelimToStringArray( elemForCluster, clusterElemArr, ",");
  946. ForEachItemIn(y, clusterElemArr)
  947. compClusterArr->append(clusterElemArr.item(y));
  948. m_compForTopology.setValue(m_clusterForTopology.item(x),compClusterArr);
  949. }
  950. }
  951. }
  952. }