wizardInputs.cpp 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  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. {
  498. numOfIpNeeded = m_thorNodes;
  499. if (m_thorNodes < m_ipaddress.ordinality())
  500. numOfIpNeeded += 1;
  501. }
  502. CInstDetails* pInstDetail = getServerIPMap(sbNewName.str(), buildSetName, pNewEnvTree, numOfIpNeeded);
  503. if(pInstDetail)
  504. {
  505. if(!strcmp(buildSetName, "roxie") || !strcmp(buildSetName, "thor" ))
  506. {
  507. addRoxieThorClusterToEnv(pNewEnvTree, pInstDetail, buildSetName);
  508. }
  509. else
  510. {
  511. StringArray& ipArr = pInstDetail->getIpAssigned();
  512. ForEachItemIn(x, ipArr)
  513. {
  514. assignedIP.clear().append(ipArr.item(x));
  515. addInstanceToTree(pNewEnvTree, assignedIP, processName, buildSetName, "s1");
  516. }
  517. }
  518. }
  519. }
  520. }
  521. }
  522. }
  523. getEspBindingInformation(pNewEnvTree);
  524. addTopology(pNewEnvTree);
  525. getDefaultsForWizard(pNewEnvTree);
  526. }
  527. }
  528. void CWizardInputs::addInstanceToTree(IPropertyTree* pNewEnvTree, StringBuffer attrName, const char* processName, const char* buildSetName, const char* instName)
  529. {
  530. StringBuffer sb, sbl, compName, xpath, nodeName;
  531. xpath.clear().appendf("./%s/%s[%s=\"%s\"]", XML_TAG_HARDWARE, XML_TAG_COMPUTER, XML_ATTR_NETADDRESS, attrName.str());
  532. IPropertyTree* pHardTemp = pNewEnvTree->queryPropTree(xpath.str());
  533. if(pHardTemp)
  534. nodeName.clear().append(pHardTemp->queryProp("./"XML_ATTR_NAME));//NodeName
  535. xpath.clear().appendf("./%s/%s[%s=\"%s\"]", XML_TAG_SOFTWARE, processName, XML_ATTR_BUILDSET, buildSetName);
  536. IPropertyTree* pComp = pNewEnvTree->queryPropTree(xpath.str());
  537. compName.clear().append(pComp->queryProp(XML_ATTR_NAME));//compName
  538. sb.clear().appendf("<Instance buildSet=\"%s\" compName=\"%s\" ><Instance name=\"%s\" /></Instance>", buildSetName, compName.str(), nodeName.str());
  539. Owned<IPropertyTree> pInstance = createPTreeFromXMLString(sb.str());
  540. if(pInstance)
  541. addInstanceToCompTree(pNewEnvTree, pInstance, sbl.clear(), sb.clear(),NULL);
  542. 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());
  543. IPropertyTree* pInst = pNewEnvTree->queryPropTree(xpath.str());
  544. if(pInst)
  545. {
  546. pInst->addProp(XML_ATTR_NAME, instName);
  547. }
  548. }
  549. void CWizardInputs::getDefaultsForWizard(IPropertyTree* pNewEnvTree)
  550. {
  551. StringBuffer xpath, tempName, value;
  552. Owned<IPropertyTree> pBuildTree = createPTreeFromIPT(pNewEnvTree->queryPropTree("./"XML_TAG_PROGRAMS));
  553. xpath.clear().appendf("./%s/%s/", XML_TAG_BUILD, XML_TAG_BUILDSET);
  554. Owned<IPropertyTreeIterator> buildSetInsts = pBuildTree->getElements(xpath.str());
  555. bool genOptional = true;
  556. ForEach(*buildSetInsts)
  557. {
  558. IPropertyTree* pBuildSet = &buildSetInsts->query();
  559. StringBuffer buildSetPath, compName;
  560. const char* buildSetName = pBuildSet->queryProp(XML_ATTR_NAME);
  561. const char* xsdFileName = pBuildSet->queryProp(XML_ATTR_SCHEMA);
  562. const char* processName = pBuildSet->queryProp(XML_ATTR_PROCESS_NAME);
  563. if(processName && *processName && buildSetName && * buildSetName && xsdFileName && *xsdFileName)
  564. {
  565. Owned<IPropertyTree> pSchema = loadSchema(pBuildTree->queryPropTree("./"XML_TAG_BUILD"[1]"), pBuildSet, buildSetPath, NULL);
  566. if (m_genOptForAllComps == GENOPTIONAL_ALL || (m_genOptForAllComps == GENOPTIONAL_COMPS && m_doNotGenOptOnComps.find(buildSetName) == NotFound ))
  567. genOptional = true;
  568. else if (m_genOptForAllComps == GENOPTIONAL_NONE || (m_genOptForAllComps == GENOPTIONAL_COMPS && m_doNotGenOptOnComps.find(buildSetName) != NotFound ))
  569. genOptional = false;
  570. Owned<IPropertyTree> pCompTree = generateTreeFromXsd(pNewEnvTree, pSchema, processName, true, true, this, genOptional);
  571. xpath.clear().appendf("./%s/%s/[%s=\"%s\"]", XML_TAG_SOFTWARE, processName, XML_ATTR_BUILDSET, buildSetName);
  572. IPropertyTree* pSWCompTree = pNewEnvTree->queryPropTree(xpath.str());
  573. if(pSWCompTree && pCompTree)
  574. {
  575. Owned<IAttributeIterator> iAttr = pCompTree->getAttributes();
  576. ForEach(*iAttr)
  577. {
  578. if( pSWCompTree->hasProp(iAttr->queryName()) && strcmp(iAttr->queryName(), "@buildSet") != 0)
  579. {
  580. if (!strcmp(iAttr->queryName(), XML_ATTR_NAME))
  581. {
  582. StringBuffer sbxpath, sbnew, sbMsg;
  583. sbnew.clear().append(iAttr->queryValue());
  584. sbxpath.clear().append(processName);
  585. getUniqueName(pNewEnvTree, sbnew, sbxpath.str(), XML_TAG_SOFTWARE);
  586. bool ret = checkComponentReferences(pNewEnvTree, pSWCompTree, pSWCompTree->queryProp(iAttr->queryName()), sbMsg, sbnew.str());
  587. if (ret)
  588. pSWCompTree->setProp(iAttr->queryName(), iAttr->queryValue());
  589. }
  590. else
  591. pSWCompTree->setProp(iAttr->queryName(), iAttr->queryValue());
  592. }
  593. }
  594. //Now adding elements
  595. Owned<IPropertyTreeIterator> iterElems = pCompTree->getElements("*");
  596. ForEach (*iterElems)
  597. {
  598. IPropertyTree* pElem = &iterElems->query();
  599. Owned<IAttributeIterator> iAttr = pElem->getAttributes();
  600. ForEach(*iAttr)
  601. {
  602. IPropertyTree* pNewSubElem = pSWCompTree->queryPropTree(pElem->queryName());
  603. if (!pNewSubElem)
  604. {
  605. pNewSubElem = pSWCompTree->addPropTree(pElem->queryName(), createPTreeFromIPT(pElem));
  606. break;
  607. }
  608. else
  609. {
  610. Owned<IPropertyTreeIterator> srcElems = pSWCompTree->getElements(pElem->queryName());
  611. IPropertyTree* pSrcElem = NULL;
  612. ForEach(*srcElems)
  613. {
  614. pSrcElem = &srcElems->query();
  615. Owned<IAttributeIterator> iAttrElem = pElem->getAttributes();
  616. ForEach(*iAttrElem)
  617. {
  618. const char* attrName = iAttrElem->queryName();
  619. if (pSrcElem->hasProp(attrName))
  620. pSrcElem->setProp(attrName, iAttrElem->queryValue());
  621. Owned<IPropertyTreeIterator> iterSubElems = pElem->getElements("*");
  622. ForEach (*iterSubElems)
  623. {
  624. IPropertyTree* pSubElem = &iterSubElems->query();
  625. Owned<IPropertyTreeIterator> srcSubElems = pSWCompTree->getElements(pSubElem->queryName());
  626. IPropertyTree* pSrcSubElem = NULL;
  627. ForEach(*srcSubElems)
  628. {
  629. pSrcSubElem = &srcSubElems->query();
  630. Owned<IAttributeIterator> iAttrElem = pSubElem->getAttributes();
  631. ForEach(*iAttrElem)
  632. {
  633. const char* attrName = iAttrElem->queryName();
  634. if (pSrcSubElem->hasProp(attrName))
  635. pSrcSubElem->setProp(attrName, iAttrElem->queryValue());
  636. }
  637. }
  638. }
  639. }
  640. }
  641. }
  642. }
  643. }
  644. }
  645. }
  646. }
  647. }
  648. void CWizardInputs::addToCompIPMap(const char* buildSetName, const char* value, const char* compName)
  649. {
  650. CInstDetails* pInst = NULL;
  651. if(m_compIpMap.find(buildSetName) != NULL)
  652. {
  653. pInst = m_compIpMap.getValue(buildSetName);
  654. (pInst->getIpAssigned()).append(value);
  655. }
  656. else
  657. {
  658. pInst = new CInstDetails();
  659. pInst->setParams(compName, value);
  660. m_compIpMap.setValue(buildSetName, pInst);
  661. }
  662. }
  663. unsigned CWizardInputs::getCntForAlreadyAssignedIPS()
  664. {
  665. unsigned cnt = 0;
  666. HashIterator ips(m_compIpMap);
  667. ForEach(ips)
  668. {
  669. CInstDetails* comp = m_compIpMap.mapToValue(&ips.query());
  670. StringArray& ipArray = comp->getIpAssigned();
  671. cnt += ipArray.length();
  672. }
  673. return cnt;
  674. }
  675. void CWizardInputs::addRoxieThorClusterToEnv(IPropertyTree* pNewEnvTree, CInstDetails* pInstDetails, const char* buildSetName)
  676. {
  677. StringBuffer xmlForRoxieServer, xmlForRoxieSlave, xpath, compName, computerName, msg;
  678. if(!strcmp(buildSetName, "roxie"))
  679. {
  680. //Before proceeding remove the roxieserver already added to env via xsd.
  681. xpath.clear().appendf("./%s/%s/%s", XML_TAG_SOFTWARE, XML_TAG_ROXIECLUSTER, XML_ATTR_NAME);
  682. compName.clear().append(pNewEnvTree->queryProp(xpath.str()));
  683. xmlForRoxieServer.clear().appendf("<RoxieData type=\"RoxieFarm\" parentName=\"\" roxieName=\"%s\" >", compName.str());
  684. if (m_roxieNodes == 1)
  685. xmlForRoxieSlave.clear().appendf("<RoxieData type=\"None\" val1=\"undefined\" val2=\"undefined\" roxieName=\"%s\" >", compName.str());
  686. else
  687. xmlForRoxieSlave.clear().appendf("<RoxieData type=\"%s\" val1=\"%d\" val2=\"%d\" roxieName=\"%s\" >",
  688. m_roxieAgentRedType.str(),
  689. m_roxieAgentRedChannels, m_roxieAgentRedOffset, compName.str());
  690. if(pInstDetails)
  691. {
  692. StringArray& ipAssignedToComp = pInstDetails->getIpAssigned();
  693. ForEachItemIn(i, ipAssignedToComp)
  694. {
  695. xpath.clear().appendf("./%s/%s/[%s=\"%s\"]", XML_TAG_HARDWARE, XML_TAG_COMPUTER, XML_ATTR_NETADDRESS, ipAssignedToComp.item(i));
  696. IPropertyTree* pHardTemp = pNewEnvTree->queryPropTree(xpath.str());
  697. if(pHardTemp){
  698. xmlForRoxieServer.appendf("<Component name=\"%s\" />", pHardTemp->queryProp("./@name"));
  699. xmlForRoxieSlave.appendf("<Computer name=\"%s\" />", pHardTemp->queryProp("./@name"));
  700. }
  701. }
  702. xmlForRoxieServer.append("</RoxieData>");
  703. xmlForRoxieSlave.append("</RoxieData>");
  704. handleRoxieOperation(pNewEnvTree, "AddRoxieFarm", xmlForRoxieServer.str());
  705. handleRoxieOperation(pNewEnvTree, "RoxieSlaveConfig" ,xmlForRoxieSlave.str());
  706. }
  707. 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);
  708. pNewEnvTree->removeProp(xpath.str());
  709. }
  710. else if(!strcmp(buildSetName, "thor"))
  711. {
  712. //We need only one master
  713. StringBuffer masterIP, xml;
  714. xpath.clear().appendf("./%s/%s/%s", XML_TAG_SOFTWARE, XML_TAG_THORCLUSTER, XML_ATTR_NAME);
  715. compName.clear().append(pNewEnvTree->queryProp(xpath.str()));
  716. if(pInstDetails)
  717. {
  718. StringArray& ipAssignedToComp = pInstDetails->getIpAssigned();
  719. if(!ipAssignedToComp.empty())
  720. masterIP.clear().append(ipAssignedToComp.item(0));
  721. xpath.clear().appendf("./%s/%s[%s=\"%s\"]", XML_TAG_HARDWARE, XML_TAG_COMPUTER, XML_ATTR_NETADDRESS, masterIP.str());
  722. IPropertyTree* pHardTemp = pNewEnvTree->queryPropTree(xpath.str());
  723. if(pHardTemp)
  724. xml.clear().appendf("<ThorData type=\"Master\" name=\"%s\" validateComputers=\"false\" skipExisting=\"false\" > <Computer name=\"%s\" /></ThorData>", compName.str(), pHardTemp->queryProp("./@name"));
  725. handleThorTopologyOp(pNewEnvTree, "Add", xml.str(), msg);
  726. //Now add Slave
  727. xml.clear().appendf("<ThorData type=\"Slave\" name=\"%s\" validateComputers=\"false\" slavesPerNode=\"%d\" skipExisting=\"false\" >", compName.str(), m_thorSlavesPerNode);
  728. unsigned numOfNodes = ipAssignedToComp.ordinality() == 1 || m_thorNodes == m_ipaddress.ordinality()? 0 : 1;
  729. for( ; numOfNodes < ipAssignedToComp.ordinality() ; numOfNodes++)
  730. {
  731. xpath.clear().appendf("./%s/%s[%s=\"%s\"]", XML_TAG_HARDWARE, XML_TAG_COMPUTER, XML_ATTR_NETADDRESS, ipAssignedToComp.item(numOfNodes));
  732. IPropertyTree* pHardTemp = pNewEnvTree->queryPropTree(xpath.str());
  733. if(pHardTemp)
  734. xml.appendf("<Computer name=\"%s\" />", pHardTemp->queryProp("./@name"));
  735. }
  736. xml.append("</ThorData>");
  737. handleThorTopologyOp(pNewEnvTree, "Add" , xml.str(), msg);
  738. }
  739. }
  740. }
  741. void CWizardInputs::getEspBindingInformation(IPropertyTree* pNewEnvTree)
  742. {
  743. StringBuffer xpath, sbDefn, xmlArg, compName, sbNewName;
  744. Owned<IPropertyTreeIterator> espProcessIter = pNewEnvTree->getElements("./"XML_TAG_SOFTWARE"/"XML_TAG_ESPPROCESS);
  745. ForEach(*espProcessIter)
  746. {
  747. IPropertyTree* pEspProcess = &espProcessIter->query();
  748. compName.clear().append(pEspProcess->queryProp(XML_ATTR_NAME));
  749. xpath.clear().appendf("./%s/%s/%s[@processName=\"%s\"]", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET, XML_TAG_ESPSERVICE);
  750. Owned<IPropertyTreeIterator> espServiceIter = pNewEnvTree->getElements(xpath.str());
  751. bool genOptional = true;
  752. ForEach (*espServiceIter)
  753. {
  754. IPropertyTree* pEspService = &espServiceIter->query();
  755. if(pEspService)
  756. {
  757. StringBuffer espServiceName;
  758. espServiceName.appendf("my%s", pEspService->queryProp("@name"));
  759. xpath.clear().appendf("./%s/%s[%s=\"%s\"]", XML_TAG_SOFTWARE, XML_TAG_ESPSERVICE, XML_ATTR_NAME, espServiceName.str());
  760. IPropertyTree* pEspServiceInSWTree = pNewEnvTree->queryPropTree(xpath.str());
  761. if(pEspServiceInSWTree)
  762. {
  763. xpath.clear().append("./Properties/@defaultPort");
  764. const char* port = pEspService->queryProp(xpath.str());
  765. xpath.clear().append("./Properties/@defaultResourcesBasedn");
  766. const char* resourceBasedn = pEspService->queryProp(xpath.str());
  767. const char* buildSetName = pEspService->queryProp(XML_ATTR_NAME);
  768. const char* processName = pEspService->queryProp(XML_ATTR_PROCESS_NAME);
  769. if (m_genOptForAllComps == GENOPTIONAL_ALL || (m_genOptForAllComps == GENOPTIONAL_COMPS && m_doNotGenOptOnComps.find(buildSetName) == NotFound ))
  770. genOptional = true;
  771. else if (m_genOptForAllComps == GENOPTIONAL_NONE || (m_genOptForAllComps == GENOPTIONAL_COMPS && m_doNotGenOptOnComps.find(buildSetName) != NotFound ))
  772. genOptional = false;
  773. StringBuffer buildSetPath;
  774. Owned<IPropertyTree> pSchema = loadSchema(pNewEnvTree->queryPropTree("./Programs/Build[1]"), pEspService, buildSetPath, NULL);
  775. 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());
  776. addEspBindingInformation(xmlArg, pNewEnvTree, sbNewName, NULL);
  777. xpath.clear().appendf("./%s/%s/%s/[%s=\"\"]", XML_TAG_SOFTWARE, XML_TAG_ESPPROCESS, XML_TAG_ESPBINDING, XML_ATTR_SERVICE);
  778. IPropertyTree* pEspBindingInfo = pNewEnvTree->queryPropTree(xpath.str());
  779. pEspBindingInfo->setProp(XML_ATTR_NAME,(espServiceName.toLowerCase()).str());
  780. pEspBindingInfo->setProp(XML_ATTR_SERVICE,(espServiceName.toLowerCase()).str());
  781. pEspBindingInfo->setProp(XML_ATTR_PORT, port );
  782. pEspBindingInfo->setProp("@resourcesBasedn",resourceBasedn);
  783. xpath.clear().appendf("%s/%s[%s=\"%s\"]/Properties", XML_TAG_SOFTWARE, XML_TAG_ESPSERVICE, XML_ATTR_NAME, (espServiceName.toLowerCase()).str());
  784. IPropertyTree* pSvcProps = pNewEnvTree->queryPropTree(xpath.str());
  785. Owned<IPropertyTree> pCompTree = generateTreeFromXsd(pNewEnvTree, pSchema, processName, true, false, 0, genOptional);
  786. Owned<IPropertyTreeIterator> i = pSvcProps->getElements("Authenticate");
  787. ForEach(*i)
  788. {
  789. IPropertyTree* pAuthCopy = createPTreeFromIPT(&i->query());
  790. mergeAttributes(pAuthCopy, pCompTree->queryPropTree("Authenticate"));
  791. IPropertyTree* pNewNode = pEspBindingInfo->addPropTree("Authenticate", pAuthCopy);
  792. }
  793. i.setown( pSvcProps->getElements("AuthenticateFeature") );
  794. ForEach(*i)
  795. {
  796. IPropertyTree* pAuthCopy = createPTreeFromIPT(&i->query());
  797. //Adding authentication to true for espbinding.
  798. pAuthCopy->addProp("@authenticate","Yes");
  799. mergeAttributes(pAuthCopy, pCompTree->queryPropTree("AuthenticateFeature"));
  800. IPropertyTree* pNewNode = pEspBindingInfo->addPropTree("AuthenticateFeature", pAuthCopy);
  801. }
  802. i.setown( pSvcProps->getElements("AuthenticateSetting") );
  803. ForEach(*i)
  804. {
  805. IPropertyTree* pAuthCopy = createPTreeFromIPT(&i->query());
  806. mergeAttributes(pAuthCopy, pCompTree->queryPropTree("AuthenticateSetting"));
  807. IPropertyTree* pNewNode = pEspBindingInfo->addPropTree("AuthenticateSetting", pAuthCopy);
  808. }
  809. }
  810. }
  811. }
  812. }
  813. }
  814. void CWizardInputs::addTopology(IPropertyTree* pNewEnvTree)
  815. {
  816. StringBuffer xpath;
  817. if(!pNewEnvTree->hasProp("./"XML_TAG_SOFTWARE"/"XML_TAG_TOPOLOGY))
  818. pNewEnvTree->addPropTree("./"XML_TAG_SOFTWARE"/"XML_TAG_TOPOLOGY, createPTree());
  819. HashIterator sIter(m_compForTopology);
  820. for(sIter.first();sIter.isValid();sIter.next())
  821. {
  822. IMapping &cur = sIter.query();
  823. IPropertyTree* pCluster = createTopologyForComp(pNewEnvTree,(const char *) cur.getKey());
  824. if(pCluster)
  825. pNewEnvTree->addPropTree("./"XML_TAG_SOFTWARE"/"XML_TAG_TOPOLOGY"/Cluster", pCluster);
  826. }
  827. }
  828. IPropertyTree* CWizardInputs::createTopologyForComp(IPropertyTree* pNewEnvTree, const char* component)
  829. {
  830. StringBuffer xmlTag, xpath , compName, clusterStr;
  831. if(!strcmp(component, "roxie"))
  832. xmlTag.clear().append(XML_TAG_ROXIECLUSTER);
  833. else if(!strcmp(component, "thor"))
  834. xmlTag.clear().append(XML_TAG_THORCLUSTER);
  835. else if(!strcmp(component, "hthor"))
  836. xmlTag.clear().append("hthor");
  837. xpath.clear().appendf("./%s/%s[1]/%s", XML_TAG_SOFTWARE, xmlTag.str(), XML_ATTR_NAME);
  838. clusterStr.clear().appendf("<Cluster name=\"%s\" prefix=\"%s\"></Cluster>", component, component);
  839. IPropertyTree* pCluster = createPTreeFromXMLString(clusterStr.str());
  840. if(pCluster)
  841. {
  842. if(pNewEnvTree->hasProp(xpath.str()))
  843. {
  844. IPropertyTree* pComponent = pCluster->addPropTree(xmlTag.str(), createPTree());
  845. pComponent->addProp(XML_ATTR_PROCESS, pNewEnvTree->queryProp(xpath.str()));
  846. }
  847. if(m_compForTopology.find(component) != NULL)
  848. {
  849. StringArray* clusterCompEle = 0;
  850. StringArrayPtr* clusterPair = m_compForTopology.getValue(component);
  851. if(clusterPair)
  852. {
  853. clusterCompEle = (*clusterPair);
  854. for(unsigned i = 0 ; i < clusterCompEle->ordinality() ; i++)
  855. {
  856. const char* eachClusterElem = clusterCompEle->item(i);
  857. xpath.clear().appendf("./%s/%s/%s[%s=\"%s\"]", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET, XML_ATTR_NAME, eachClusterElem);
  858. IPropertyTree* pBuildset = pNewEnvTree->queryPropTree(xpath.str());
  859. if(pBuildset)
  860. {
  861. const char* processName = pBuildset->queryProp(XML_ATTR_PROCESS_NAME);
  862. if(processName && *processName)
  863. {
  864. IPropertyTree* pElement = pCluster->addPropTree(processName,createPTree());
  865. xpath.clear().appendf("./%s/%s[1]/%s", XML_TAG_SOFTWARE, processName, XML_ATTR_NAME);
  866. if(pElement && pNewEnvTree->hasProp(xpath.str()))
  867. pElement->addProp(XML_ATTR_PROCESS, pNewEnvTree->queryProp(xpath.str()));
  868. }
  869. }
  870. }
  871. }
  872. clusterCompEle->kill();
  873. }
  874. return pCluster;
  875. }
  876. else
  877. return NULL;
  878. }
  879. void CWizardInputs::checkForDependencies()
  880. {
  881. StringBuffer xpath;
  882. if(m_buildSetTree)
  883. {
  884. xpath.clear().appendf("./%s/%s/%s", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET);
  885. Owned<IPropertyTreeIterator> buildSetInsts = m_buildSetTree->getElements(xpath.str());
  886. ForEach(*buildSetInsts)
  887. {
  888. IPropertyTree* pBuildSet = &buildSetInsts->query();
  889. const char* buildSetName = pBuildSet->queryProp(XML_ATTR_NAME);
  890. unsigned numOfNodesNeeded = 1;
  891. if((!strcmp(buildSetName,"roxie") && m_roxieNodes == 0 )|| (!strcmp(buildSetName,"thor")&& m_thorNodes == 0)){
  892. numOfNodesNeeded = 0;
  893. m_doNotGenComp.append(buildSetName);
  894. }
  895. if(numOfNodesNeeded == 0 || (m_doNotGenComp.find(buildSetName) != NotFound))
  896. {
  897. if(m_compForTopology.find(buildSetName) != NULL )
  898. m_compForTopology.remove(buildSetName);
  899. checkAndAddDependComponent(buildSetName);
  900. }
  901. }
  902. }
  903. }
  904. void CWizardInputs::checkAndAddDependComponent(const char* key)
  905. {
  906. StringBuffer paramEntry(key);
  907. paramEntry.append("_dependencies");
  908. if(m_algProp)
  909. {
  910. if(m_algProp->hasProp(paramEntry.str()))
  911. {
  912. StringArray sArray;
  913. DelimToStringArray(m_algProp->queryProp(paramEntry.str()), sArray, ";");
  914. ForEachItemIn(x, sArray)
  915. {
  916. if(m_doNotGenComp.find(sArray.item(x)) == NotFound)
  917. {
  918. m_doNotGenComp.append(sArray.item(x));
  919. checkAndAddDependComponent(sArray.item(x));
  920. }
  921. }
  922. }
  923. }
  924. }
  925. unsigned CWizardInputs::getNumOfNodes(const char* compName)
  926. {
  927. if(m_compIpMap.find(compName) != NULL)
  928. {
  929. CInstDetails* pInst = NULL;
  930. pInst = m_compIpMap.getValue(compName);
  931. StringArray& ipArr = pInst->getIpAssigned();
  932. return ipArr.ordinality();
  933. }
  934. return 0;
  935. }
  936. void CWizardInputs::setTopologyParam()
  937. {
  938. if(m_clusterForTopology.ordinality() > 0)
  939. {
  940. StringBuffer topologySec;
  941. ForEachItemIn(x, m_clusterForTopology)
  942. {
  943. topologySec.clear().appendf("%s_topology",m_clusterForTopology.item(x));
  944. const char * elemForCluster = m_algProp->queryProp(topologySec.str());
  945. if(elemForCluster && *elemForCluster)
  946. {
  947. StringArray* compClusterArr = new StringArray();
  948. StringArray clusterElemArr;
  949. DelimToStringArray( elemForCluster, clusterElemArr, ",");
  950. ForEachItemIn(y, clusterElemArr)
  951. compClusterArr->append(clusterElemArr.item(y));
  952. m_compForTopology.setValue(m_clusterForTopology.item(x),compClusterArr);
  953. }
  954. }
  955. }
  956. }