step8_controller.js 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var stringUtils = require('utils/string_utils');
  20. App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wizardDeployProgressControllerMixin, {
  21. name: 'wizardStep8Controller',
  22. /**
  23. * List of raw data about cluster that should be displayed
  24. * @type {Array}
  25. */
  26. rawContent: [
  27. {
  28. config_name: 'Admin',
  29. display_name: 'Admin Name',
  30. config_value: ''
  31. },
  32. {
  33. config_name: 'cluster',
  34. display_name: 'Cluster Name',
  35. config_value: ''
  36. },
  37. {
  38. config_name: 'hosts',
  39. display_name: 'Total Hosts',
  40. config_value: ''
  41. },
  42. {
  43. config_name: 'Repo',
  44. display_name: 'Local Repository',
  45. config_value: ''
  46. }
  47. ],
  48. /**
  49. * List of data about cluster (based on formatted <code>rawContent</code>)
  50. * @type {Object[]}
  51. */
  52. clusterInfo: [],
  53. /**
  54. * List of services with components assigned to hosts
  55. * @type {Object[]}
  56. */
  57. services: [],
  58. /**
  59. * @type {Object[]}
  60. */
  61. configs: [],
  62. /**
  63. * All configs
  64. * @type {Array}
  65. */
  66. configMapping: function () {
  67. return App.config.get('configMapping').all(true);
  68. }.property('App.config.configMapping'),
  69. /**
  70. *
  71. */
  72. slaveComponentConfig: null,
  73. /**
  74. * Should Submit button be disabled
  75. * @type {bool}
  76. */
  77. isSubmitDisabled: false,
  78. /**
  79. * Should Back button be disabled
  80. * @type {bool}
  81. */
  82. isBackBtnDisabled: false,
  83. /**
  84. * This flag when turned to true launches deploy progress bar
  85. */
  86. isDeployStarted: function() {
  87. this.get('isSubmitDisabled');
  88. }.property('isSubmitDisabled'),
  89. /**
  90. * Is error appears while <code>ajaxQueue</code> executes
  91. * @type {bool}
  92. */
  93. hasErrorOccurred: false,
  94. /**
  95. * Are services installed
  96. * Used to hide Deploy Progress Bar
  97. * @type {bool}
  98. */
  99. servicesInstalled: false,
  100. /**
  101. * List of service config tags
  102. * @type {Object[]}
  103. */
  104. serviceConfigTags: [],
  105. /**
  106. * Is cluster security enabled
  107. * @type {bool}
  108. */
  109. securityEnabled: function () {
  110. return App.router.get('mainAdminSecurityController.securityEnabled');
  111. }.property('App.router.mainAdminSecurityController.securityEnabled'),
  112. /**
  113. * Selected config group
  114. * @type {Object}
  115. */
  116. selectedConfigGroup: null,
  117. /**
  118. * List of config groups
  119. * @type {Object[]}
  120. */
  121. configGroups: [],
  122. /**
  123. * List of selected but not installed services
  124. * @type {Object[]}
  125. */
  126. selectedServices: function () {
  127. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
  128. }.property('content.services.@each.isSelected','content.services.@each.isInstalled').cacheable(),
  129. /**
  130. * List of installed services
  131. * @type {Object[]}
  132. */
  133. installedServices: function () {
  134. return this.get('content.services').filterProperty('isInstalled');
  135. }.property('content.services').cacheable(),
  136. /**
  137. * Current cluster name
  138. * @type {string}
  139. */
  140. clusterName: function () {
  141. return this.get('content.cluster.name');
  142. }.property('content.cluster.name'),
  143. /**
  144. * List of existing cluster names
  145. * @type {string[]}
  146. */
  147. clusterNames: [],
  148. /**
  149. * Clear current step data
  150. * @method clearStep
  151. */
  152. clearStep: function () {
  153. this.get('services').clear();
  154. this.get('configs').clear();
  155. this.get('clusterInfo').clear();
  156. this.get('serviceConfigTags').clear();
  157. this.set('servicesInstalled', false);
  158. this.set('ajaxQueueLength', 0);
  159. this.set('ajaxRequestsQueue', App.ajaxQueue.create());
  160. this.set('ajaxRequestsQueue.finishedCallback', this.ajaxQueueFinished);
  161. },
  162. /**
  163. * Load current step data
  164. * @method loadStep
  165. */
  166. loadStep: function () {
  167. console.log("TRACE: Loading step8: Review Page");
  168. this.clearStep();
  169. if (this.get('content.serviceConfigProperties')) {
  170. this.formatProperties();
  171. this.loadConfigs();
  172. if (this.get('content.controllerName') != 'installerController' && this.get('securityEnabled')) {
  173. this.prepareSecureConfigs();
  174. this.get('content.services').filterProperty('isSelected', true)
  175. .mapProperty('serviceName').forEach(function (serviceName) {
  176. var config = this.get('secureConfigs').findProperty('serviceName', serviceName);
  177. if (config) {
  178. this.setPrincipalValue(serviceName, config.name);
  179. }
  180. }, this);
  181. }
  182. }
  183. this.loadClusterInfo();
  184. this.loadServices();
  185. this.set('isSubmitDisabled', false);
  186. this.set('isBackBtnDisabled', false);
  187. },
  188. /**
  189. * replace whitespace character with coma between directories
  190. * @method formatProperties
  191. */
  192. formatProperties: function () {
  193. this.get('content.serviceConfigProperties').forEach(function (_configProperty) {
  194. _configProperty.value = App.config.trimProperty(_configProperty, false);
  195. });
  196. },
  197. /**
  198. * Remove unused Sink configs
  199. * @param {Ember.Enumerable} configs
  200. * @returns {Ember.Enumerable}
  201. * @method removeSinkConfigs
  202. */
  203. removeSinkConfigs: function (configs) {
  204. var sinkDb = configs.findProperty('name', 'sink_database');
  205. var sinkDbType = configs.findProperty('name', 'sink_database_type');
  206. if (sinkDbType) {
  207. var sink_properties = Em.A([]);
  208. switch (sinkDb.value) {
  209. case 'Existing MSSQL Server database with integrated authentication':
  210. configs.findProperty('name', 'sink.dbservername').value = configs.findProperty('name', 'sink_existing_mssql_server_host').value;
  211. sinkDbType.value = 'mssql';
  212. sink_properties = Em.A(['sink_existing_mssql_server_2_database', 'sink_existing_mssql_server_2_host']);
  213. break;
  214. case 'Existing MSSQL Server database with sql auth':
  215. configs.findProperty('name', 'sink.dbservername').value = configs.findProperty('name', 'sink_existing_mssql_server_2_host').value;
  216. sinkDbType.value = 'mssql';
  217. sink_properties = Em.A(['sink_existing_mssql_server_database', 'sink_existing_mssql_server_host']);
  218. break;
  219. }
  220. sink_properties.forEach(function (property) {
  221. configs = configs.without(configs.findProperty('name', property));
  222. });
  223. }
  224. return configs;
  225. },
  226. /**
  227. * Remove unused Hive configs
  228. * @param {Ember.Enumerable} configs
  229. * @returns {Ember.Enumerable}
  230. * @method removeHiveConfigs
  231. */
  232. removeHiveConfigs: function (configs) {
  233. var hiveDb = configs.findProperty('name', 'hive_database');
  234. var hiveDbType = configs.findProperty('name', 'hive_database_type');
  235. if (hiveDbType) {
  236. var hive_properties = Em.A([]);
  237. switch (hiveDb.value) {
  238. case 'New MySQL Database':
  239. if (configs.someProperty('name', 'hive_ambari_host')) {
  240. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value;
  241. hiveDbType.value = 'mysql';
  242. }
  243. hive_properties = Em.A(['hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host',
  244. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database',
  245. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host',
  246. 'hive_existing_mssql_server_2_database', 'hive_existing_mssql_server_2_host']);
  247. break;
  248. case 'New PostgreSQL Database':
  249. if (configs.someProperty('name', 'hive_ambari_host')) {
  250. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value;
  251. hiveDbType.value = 'postgres';
  252. }
  253. hive_properties = Em.A(['hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host',
  254. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']);
  255. break;
  256. case 'Existing MySQL Database':
  257. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mysql_host').value;
  258. hiveDbType.value = 'mysql';
  259. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  260. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database',
  261. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host',
  262. 'hive_existing_mssql_server_2_database', 'hive_existing_mssql_server_2_host']);
  263. break;
  264. case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
  265. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_postgresql_host').value;
  266. hiveDbType.value = 'postgres';
  267. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  268. 'hive_existing_oracle_database', 'hive_existing_mysql_host', 'hive_existing_mysql_database',
  269. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host',
  270. 'hive_existing_mssql_server_2_database', 'hive_existing_mssql_server_2_host']);
  271. break;
  272. case 'Existing MSSQL Server database with integrated authentication':
  273. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_2_host').value;
  274. hiveDbType.value = 'mssql';
  275. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  276. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database',
  277. 'hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_mssql_server_database',
  278. 'hive_existing_mssql_server_host', 'hive_existing_mssql_server_2_database', 'hive_existing_mssql_server_2_host']);
  279. break;
  280. case 'Existing MSSQL Server database with sql auth':
  281. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_host').value;
  282. hiveDbType.value = 'mssql';
  283. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  284. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database',
  285. 'hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_mssql_server_database',
  286. 'hive_existing_mssql_server_host', 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host']);
  287. break;
  288. default:
  289. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_oracle_host').value;
  290. hiveDbType.value = 'oracle';
  291. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_mysql_host',
  292. 'hive_existing_mysql_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database',
  293. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host',
  294. 'hive_existing_mssql_server_2_database', 'hive_existing_mssql_server_2_host']);
  295. break;
  296. }
  297. hive_properties.forEach(function (property) {
  298. configs = configs.without(configs.findProperty('name', property));
  299. });
  300. }
  301. return configs;
  302. },
  303. /**
  304. * Remove unused Oozie configs
  305. * @param {Ember.Enumerable} configs
  306. * @returns {Ember.Enumerable}
  307. * @method removeOozieConfigs
  308. */
  309. removeOozieConfigs: function (configs) {
  310. var oozieDb = configs.findProperty('name', 'oozie_database');
  311. var oozieDbType = configs.findProperty('name', 'oozie_database_type');
  312. if (oozieDbType) {
  313. var oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database']);
  314. switch (oozieDb.value) {
  315. case 'New Derby Database':
  316. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_ambari_host').value;
  317. oozieDbType.value = 'derby';
  318. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_mysql_host',
  319. 'oozie_existing_mysql_database', 'oozie_existing_oracle_host', 'oozie_existing_oracle_database',
  320. 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database',
  321. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  322. 'oozie_existing_mssql_server_2_database', 'oozie_existing_mssql_server_2_host']);
  323. break;
  324. case 'Existing MySQL Database':
  325. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  326. oozieDbType.value = 'mysql';
  327. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_oracle_host',
  328. 'oozie_existing_oracle_database', 'oozie_derby_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database',
  329. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  330. 'oozie_existing_mssql_server_2_database', 'oozie_existing_mssql_server_2_host']);
  331. break;
  332. case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
  333. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_postgresql_host').value;
  334. oozieDbType.value = 'postgresql';
  335. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_oracle_host',
  336. 'oozie_existing_oracle_database', 'oozie_existing_mysql_host', 'oozie_existing_mysql_database',
  337. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  338. 'oozie_existing_mssql_server_2_database', 'oozie_existing_mssql_server_2_host']);
  339. break;
  340. case 'Existing MSSQL Server database with integrated authentication':
  341. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  342. oozieDbType.value = 'mssql';
  343. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'oozie_existing_oracle_host',
  344. 'oozie_existing_oracle_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database',
  345. 'oozie_existing_mysql_host', 'oozie_existing_mysql_database',
  346. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  347. 'oozie_existing_mssql_server_2_database', 'oozie_existing_mssql_server_2_host']);
  348. break;
  349. case 'Existing MSSQL Server database with sql auth':
  350. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  351. oozieDbType.value = 'mssql';
  352. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'oozie_existing_oracle_host',
  353. 'oozie_existing_oracle_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database',
  354. 'oozie_existing_mysql_host', 'oozie_existing_mysql_database',
  355. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  356. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host']);
  357. break;
  358. default:
  359. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_oracle_host').value;
  360. oozieDbType.value = 'oracle';
  361. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_mysql_host',
  362. 'oozie_existing_mysql_database', 'oozie_derby_database', 'oozie_existing_postgresql_host',
  363. 'oozie_existing_postgresql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  364. 'oozie_existing_mssql_server_2_database', 'oozie_existing_mssql_server_2_host']);
  365. break;
  366. }
  367. oozie_properties.forEach(function (property) {
  368. configs = configs.without(configs.findProperty('name', property));
  369. });
  370. }
  371. return configs;
  372. },
  373. /**
  374. * Load all site properties
  375. * @method loadConfigs
  376. */
  377. loadConfigs: function () {
  378. //storedConfigs contains custom configs as well
  379. var configs = this.get('content.serviceConfigProperties');
  380. if (configs.someProperty('name', 'hive_database')) {
  381. configs = this.removeHiveConfigs(configs);
  382. }
  383. if (configs.someProperty('name', 'sink_database')) {
  384. configs = this.removeSinkConfigs(configs);
  385. }
  386. if (configs.someProperty('name', 'oozie_database')) {
  387. configs = this.removeOozieConfigs(configs);
  388. }
  389. configs.forEach(function (_config) {
  390. _config.value = (typeof _config.value === "boolean") ? _config.value.toString() : _config.value;
  391. });
  392. var mappedConfigs = App.config.excludeUnsupportedConfigs(this.get('configMapping'), this.get('selectedServices').mapProperty('serviceName'));
  393. var uiConfigs = this.loadUiSideConfigs(mappedConfigs);
  394. var customGroupConfigs = [];
  395. var allConfigs = configs.concat(uiConfigs).filter(function (config) {
  396. if (config.group) {
  397. customGroupConfigs.push(config);
  398. return false;
  399. } else {
  400. return true;
  401. }
  402. });
  403. this.set('customNonDefaultGroupConfigs', customGroupConfigs);
  404. this.set('configs', allConfigs);
  405. },
  406. /**
  407. * Load UI configs
  408. * @param {Array} configMapping
  409. * @return {Array}
  410. * @method loadUiSideConfigs
  411. */
  412. loadUiSideConfigs: function (configMapping) {
  413. var uiConfig = [];
  414. var configs = configMapping.filterProperty('foreignKey', null);
  415. this.addDynamicProperties(configs);
  416. configs.forEach(function (_config) {
  417. var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
  418. uiConfig.pushObject({
  419. "id": "site property",
  420. "name": _config.name,
  421. "value": valueWithOverrides.value,
  422. "filename": _config.filename,
  423. "overrides": valueWithOverrides.overrides
  424. });
  425. }, this);
  426. var dependentConfig = $.extend(true, [], configMapping.filterProperty('foreignKey'));
  427. dependentConfig.forEach(function (_config) {
  428. App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config);
  429. if(!_config.noMatchSoSkipThisConfig)
  430. uiConfig.pushObject({
  431. "id": "site property",
  432. "name": _config._name || _config.name,
  433. "value": _config.value,
  434. "filename": _config.filename
  435. });
  436. }, this);
  437. return uiConfig;
  438. },
  439. /**
  440. * Add dynamic properties to configs
  441. * @param {Array} configs
  442. * @method addDynamicProperties
  443. */
  444. addDynamicProperties: function (configs) {
  445. var templetonHiveProperty = this.get('content.serviceConfigProperties').someProperty('name', 'templeton.hive.properties');
  446. if (!templetonHiveProperty) {
  447. configs.pushObject({
  448. "name": "templeton.hive.properties",
  449. "templateName": ["hivemetastore_host"],
  450. "foreignKey": null,
  451. "value": "hive.metastore.local=false,hive.metastore.uris=thrift://<templateName[0]>:9083,hive.metastore.sasl.enabled=yes,hive.metastore.execute.setugi=true,hive.metastore.warehouse.dir=/apps/hive/warehouse",
  452. "filename": "webhcat-site.xml"
  453. });
  454. }
  455. },
  456. /**
  457. * Format <code>content.hosts</code> from Object to Array
  458. * @returns {Array}
  459. * @method getRegisteredHosts
  460. */
  461. getRegisteredHosts: function () {
  462. var allHosts = this.get('content.hosts');
  463. var hosts = [];
  464. for (var hostName in allHosts) {
  465. if (allHosts.hasOwnProperty(hostName)) {
  466. if (allHosts[hostName].bootStatus == 'REGISTERED') {
  467. allHosts[hostName].hostName = allHosts[hostName].name;
  468. hosts.pushObject(allHosts[hostName]);
  469. }
  470. }
  471. }
  472. return hosts;
  473. },
  474. /**
  475. * Set all site property that are derived from other puppet-variable
  476. * @param {String} templateName
  477. * @param {String} expression
  478. * @param {String} name
  479. * @return {Object}
  480. * example: <code>{
  481. * value: '...',
  482. * overrides: [
  483. * {
  484. * value: 'v1',
  485. * hosts: ['h1', 'h2']
  486. * },
  487. * {
  488. * value: 'v2',
  489. * hosts: ['h2', 'h3']
  490. * },
  491. * ....
  492. * ]
  493. * }</code>
  494. * @method getGlobConfigValueWithOverrides
  495. */
  496. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  497. var express = expression.match(/<(.*?)>/g);
  498. var value = expression;
  499. if (express == null) {
  500. return { value: expression, overrides: []}; // if site property do not map any global property then return the value
  501. }
  502. var overrideHostToValue = {};
  503. express.forEach(function (_express) {
  504. //console.log("The value of template is: " + _express);
  505. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  506. if (this.get('configs').someProperty('name', templateName[index])) {
  507. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  508. var globalObj = this.get('configs').findProperty('name', templateName[index]);
  509. var globValue = globalObj.value;
  510. // Hack for templeton.zookeeper.hosts
  511. var preReplaceValue = null;
  512. if (value !== null) { // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
  513. preReplaceValue = value;
  514. value = this._replaceConfigValues(name, _express, value, globValue);
  515. }
  516. if (globalObj.overrides != null) {
  517. globalObj.overrides.forEach(function (override) {
  518. var ov = override.value;
  519. var hostsArray = override.hosts;
  520. hostsArray.forEach(function (host) {
  521. if (!(host in overrideHostToValue)) {
  522. overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
  523. } else {
  524. overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  525. }
  526. }, this);
  527. }, this);
  528. }
  529. } else {
  530. /*
  531. console.log("ERROR: The variable name is: " + templateName[index]);
  532. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  533. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  534. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  535. */
  536. value = null;
  537. }
  538. }, this);
  539. var valueWithOverrides = {
  540. value: value,
  541. overrides: []
  542. };
  543. var overrideValueToHostMap = {};
  544. if (!jQuery.isEmptyObject(overrideHostToValue)) {
  545. for (var host in overrideHostToValue) {
  546. var hostVal = overrideHostToValue[host];
  547. if (!(hostVal in overrideValueToHostMap)) {
  548. overrideValueToHostMap[hostVal] = [];
  549. }
  550. overrideValueToHostMap[hostVal].push(host);
  551. }
  552. }
  553. for (var val in overrideValueToHostMap) {
  554. valueWithOverrides.overrides.push({
  555. value: val,
  556. hosts: overrideValueToHostMap[val]
  557. });
  558. }
  559. return valueWithOverrides;
  560. },
  561. /**
  562. * replace some values in config property
  563. * @param {string} name
  564. * @param {string} express
  565. * @param {string} value
  566. * @param {string} globValue
  567. * @return {string}
  568. * @private
  569. * @method _replaceConfigValues
  570. */
  571. _replaceConfigValues: function (name, express, value, globValue) {
  572. return value.replace(express, globValue);
  573. },
  574. /**
  575. * Load all info about cluster to <code>clusterInfo</code> variable
  576. * @method loadClusterInfo
  577. */
  578. loadClusterInfo: function () {
  579. //Admin name
  580. var admin = this.rawContent.findProperty('config_name', 'Admin');
  581. admin.config_value = App.db.getLoginName();
  582. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  583. if (admin.config_value) {
  584. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  585. }
  586. // cluster name
  587. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  588. cluster.config_value = this.get('content.cluster.name');
  589. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  590. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  591. //hosts
  592. var newHostsCount = 0;
  593. var totalHostsCount = 0;
  594. var hosts = this.get('content.hosts');
  595. for (var hostName in hosts) {
  596. newHostsCount += ~~(!hosts[hostName].isInstalled);
  597. totalHostsCount++;
  598. }
  599. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  600. totalHostsObj.config_value = totalHostsCount + ' (' + newHostsCount + ' new)';
  601. this.get('clusterInfo').pushObject(Em.Object.create(totalHostsObj));
  602. //repo
  603. if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName'))) {
  604. this.loadRepoInfo();
  605. } else {
  606. // from install wizard
  607. var selectedStack = App.Stack.find().findProperty('isSelected');
  608. var allRepos = [];
  609. if (selectedStack && selectedStack.get('operatingSystems')) {
  610. selectedStack.get('operatingSystems').forEach(function (os) {
  611. if (os.get('isSelected')) {
  612. os.get('repositories').forEach(function(repo) {
  613. allRepos.push(Em.Object.create({
  614. base_url: repo.get('baseUrl'),
  615. os_type: repo.get('osType'),
  616. repo_id: repo.get('repoId')
  617. }));
  618. }, this);
  619. }
  620. }, this);
  621. }
  622. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  623. this.get('clusterInfo').set('repoInfo', allRepos);
  624. }
  625. },
  626. /**
  627. * Load repo info for add Service/Host wizard review page
  628. * @return {$.ajax|null}
  629. * @method loadRepoInfo
  630. */
  631. loadRepoInfo: function () {
  632. var nameVersionCombo = App.get('currentStackVersion').split('-');
  633. return App.ajax.send({
  634. name: 'cluster.load_repositories',
  635. sender: this,
  636. data: {
  637. stackName: nameVersionCombo[0],
  638. stackVersion: nameVersionCombo[1]
  639. },
  640. success: 'loadRepoInfoSuccessCallback',
  641. error: 'loadRepoInfoErrorCallback'
  642. });
  643. },
  644. /**
  645. * Save all repo base URL of all OS type to <code>repoInfo<code>
  646. * @param {object} data
  647. * @method loadRepoInfoSuccessCallback
  648. */
  649. loadRepoInfoSuccessCallback: function (data) {
  650. var allRepos = [];
  651. data.items.forEach(function (os) {
  652. os.repositories.forEach(function (repository) {
  653. allRepos.push(Em.Object.create({
  654. base_url: repository.Repositories.base_url,
  655. os_type: repository.Repositories.os_type,
  656. repo_id: repository.Repositories.repo_id
  657. }));
  658. });
  659. }, this);
  660. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  661. this.get('clusterInfo').set('repoInfo', allRepos);
  662. },
  663. /**
  664. * @param {object} request
  665. * @method loadRepoInfoErrorCallback
  666. */
  667. loadRepoInfoErrorCallback: function (request) {
  668. console.log('Error message is: ' + request.responseText);
  669. var allRepos = [];
  670. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  671. this.get('clusterInfo').set('repoInfo', allRepos);
  672. },
  673. /**
  674. * Load all info about services to <code>services</code> variable
  675. * @method loadServices
  676. */
  677. loadServices: function () {
  678. this.get('selectedServices').filterProperty('isHiddenOnSelectServicePage', false).forEach(function (service) {
  679. console.log('INFO: step8: Name of the service from getService function: ' + service.get('serviceName'));
  680. var serviceObj = Em.Object.create({
  681. service_name: service.get('serviceName'),
  682. display_name: service.get('displayNameOnSelectServicePage'),
  683. service_components: Em.A([])
  684. });
  685. service.get('serviceComponents').forEach(function (component) {
  686. // show clients for services that have only clients components
  687. if ((component.get('isClient') || component.get('isRequiredOnAllHosts')) && !service.get('isClientOnlyService')) return;
  688. // skip components that was hide on assign master page
  689. if (component.get('isMaster') && !component.get('isShownOnInstallerAssignMasterPage')) return;
  690. // no HA component
  691. if (component.get('isHAComponentOnly')) return;
  692. var displayName;
  693. if (component.get('isClient')) {
  694. displayName = Em.I18n.t('common.clients')
  695. } else {
  696. // remove service name from component display name
  697. displayName = App.format.role(component.get('componentName')).replace(new RegExp('^' + service.get('serviceName') + '\\s', 'i'), '');
  698. }
  699. serviceObj.get('service_components').pushObject(Em.Object.create({
  700. component_name: component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName'),
  701. display_name: displayName,
  702. component_value: this.assignComponentHosts(component)
  703. }));
  704. }, this);
  705. if (service.get('customReviewHandler')) {
  706. for (var displayName in service.get('customReviewHandler')) {
  707. serviceObj.get('service_components').pushObject(Em.Object.create({
  708. display_name: displayName,
  709. component_value: this.assignComponentHosts(Em.Object.create({
  710. customHandler: service.get('customReviewHandler.' + displayName)
  711. }))
  712. }));
  713. }
  714. }
  715. this.get('services').pushObject(serviceObj);
  716. }, this);
  717. },
  718. /**
  719. * Set <code>component_value</code> property to <code>component</code>
  720. * @param {Em.Object} component
  721. * @return {String}
  722. * @method assignComponentHosts
  723. */
  724. assignComponentHosts: function (component) {
  725. var componentValue;
  726. if (component.get('customHandler')) {
  727. componentValue = this[component.get('customHandler')].call(this, component);
  728. }
  729. else {
  730. if (component.get('isMaster')) {
  731. componentValue = this.getMasterComponentValue(component.get('componentName'));
  732. }
  733. else {
  734. console.log(' --- ---INFO: step8: NOT component isMaster');
  735. var componentName = component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName');
  736. var hostsLength = this.get('content.slaveComponentHosts')
  737. .findProperty('componentName', componentName).hosts.length;
  738. componentValue = hostsLength + Em.I18n.t('installer.step8.host' + ((hostsLength > 1) ? 's' : ''));
  739. }
  740. }
  741. return componentValue;
  742. },
  743. getMasterComponentValue: function (componentName) {
  744. var masterComponents = this.get('content.masterComponentHosts');
  745. var hostsCount = masterComponents.filterProperty('component', componentName).length;
  746. return stringUtils.pluralize(hostsCount,
  747. masterComponents.findProperty('component', componentName).hostName,
  748. hostsCount + ' ' + Em.I18n.t('installer.step8.hosts'));
  749. },
  750. /**
  751. * Set displayed MetricsSink DB value based on DB type
  752. * @method loadSinkDbValue
  753. */
  754. loadSinkDbValue: function () {
  755. var db, serviceConfigProperties = this.get('wizardController').getDBProperty('serviceConfigProperties'),
  756. sinkDb = serviceConfigProperties.findProperty('name', 'sink_database');
  757. if (sinkDb.value === 'Existing MSSQL Server database with integrated authentication') {
  758. db = serviceConfigProperties.findProperty('name', 'sink_existing_mssql_server_database');
  759. return db.value + ' (' + sinkDb.value + ')';
  760. }
  761. else {
  762. if (sinkDb.value === 'Existing MSSQL Server database with sql auth') {
  763. db = serviceConfigProperties.findProperty('name', 'sink_existing_mssql_server_2_database');
  764. return db.value + ' (' + sinkDb.value + ')';
  765. }
  766. }
  767. },
  768. /**
  769. * Set displayed Hive DB value based on DB type
  770. * @method loadHiveDbValue
  771. */
  772. loadHiveDbValue: function () {
  773. var db, serviceConfigPreoprties = this.get('wizardController').getDBProperty('serviceConfigProperties'),
  774. hiveDb = serviceConfigPreoprties.findProperty('name', 'hive_database');
  775. if (hiveDb.value === 'New MySQL Database') {
  776. return 'MySQL (New Database)';
  777. } else if (hiveDb.value === 'New PostgreSQL Database') {
  778. return 'Postgres (New Database)';
  779. }
  780. else {
  781. if (hiveDb.value === 'Existing MySQL Database') {
  782. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mysql_database');
  783. return db.value + ' (' + hiveDb.value + ')';
  784. }
  785. else {
  786. if (hiveDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  787. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_postgresql_database');
  788. return db.value + ' (' + hiveDb.value + ')';
  789. }
  790. else {
  791. if (hiveDb.value === 'Existing MSSQL Server database with integrated authentication') {
  792. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mssql_server_database');
  793. return db.value + ' (' + hiveDb.value + ')';
  794. }
  795. else {
  796. if (hiveDb.value === 'Existing MSSQL Server database with sql auth') {
  797. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mssql_server_2_database');
  798. return db.value + ' (' + hiveDb.value + ')';
  799. }
  800. else {
  801. // existing oracle database
  802. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_oracle_database');
  803. return db.value + ' (' + hiveDb.value + ')';
  804. }
  805. }
  806. }
  807. }
  808. }
  809. },
  810. /**
  811. * Set displayed HBase master value
  812. * @param {Object} hbaseMaster
  813. * @method loadHbaseMasterValue
  814. */
  815. loadHbaseMasterValue: function (hbaseMaster) {
  816. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('component', hbaseMaster.component_name);
  817. if (hbaseHostName.length == 1) {
  818. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  819. } else {
  820. hbaseMaster.set('component_value', hbaseHostName[0].hostName + " " + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  821. }
  822. },
  823. /**
  824. * Set displayed ZooKeeper Server value
  825. * @param {Object} serverComponent
  826. * @method loadZkServerValue
  827. */
  828. loadZkServerValue: function (serverComponent) {
  829. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('component', serverComponent.component_name).length;
  830. var hostSuffix;
  831. if (zkHostNames === 1) {
  832. hostSuffix = Em.I18n.t('installer.step8.host');
  833. } else {
  834. hostSuffix = Em.I18n.t('installer.step8.hosts');
  835. }
  836. serverComponent.set('component_value', zkHostNames + hostSuffix);
  837. },
  838. /**
  839. * Set displayed Oozie DB value based on DB type
  840. * @method loadOozieDbValue
  841. */
  842. loadOozieDbValue: function () {
  843. var db, oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  844. if (oozieDb.value === 'New Derby Database') {
  845. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  846. return db.value + ' (' + oozieDb.value + ')';
  847. }
  848. else {
  849. if (oozieDb.value === 'Existing MySQL Database') {
  850. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  851. return db.value + ' (' + oozieDb.value + ')';
  852. }
  853. else {
  854. if (oozieDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  855. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_postgresql_database');
  856. return db.value + ' (' + oozieDb.value + ')';
  857. }
  858. else {
  859. if (oozieDb.value === 'Existing MSSQL Server database with integrated authentication') {
  860. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_database');
  861. return db.value + ' (' + oozieDb.value + ')';
  862. }
  863. else {
  864. if (oozieDb.value === 'Existing MSSQL Server database with sql auth') {
  865. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_2_database');
  866. return db.value + ' (' + oozieDb.value + ')';
  867. }
  868. else {
  869. // existing oracle database
  870. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  871. return db.value + ' (' + oozieDb.value + ')';
  872. }
  873. }
  874. }
  875. }
  876. }
  877. },
  878. /**
  879. * Set displayed Nagion Admin value
  880. * @method loadNagiosAdminValue
  881. */
  882. loadNagiosAdminValue: function () {
  883. var config = this.get('content.serviceConfigProperties');
  884. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  885. var adminEmail = config.findProperty('name', 'nagios_contact');
  886. return adminLoginName.value + ' / (' + adminEmail.value + ')';
  887. },
  888. /**
  889. * Onclick handler for <code>next</code> button
  890. * @method submit
  891. * @return {App.ModalPopup|null}
  892. */
  893. submit: function () {
  894. if (this.get('isSubmitDisabled')) return null;
  895. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  896. var self = this;
  897. return App.showConfirmationPopup(function () {
  898. self.submitProceed();
  899. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  900. } else {
  901. return this.submitProceed();
  902. }
  903. },
  904. /**
  905. * Update configurations for installed services.
  906. * Do separated PUT-request for each siteName for each service
  907. *
  908. * @param {Array} fileNamesToUpdate - file names that should be updated
  909. * @method updateConfigurations
  910. */
  911. updateConfigurations: function (fileNamesToUpdate) {
  912. var configurationController = App.router.get('mainServiceInfoConfigsController');
  913. var configs = this.get('configs').slice(0);
  914. var configsMap = [];
  915. fileNamesToUpdate.forEach(function (fileName) {
  916. if (!fileName || /^(core)/.test(fileName)) return;
  917. var tagName = 'version' + (new Date).getTime();
  918. var configsToSave = configs.filterProperty('filename', fileName);
  919. configsToSave.forEach(function (item) {
  920. item.value = App.config.trimProperty(item, false);
  921. });
  922. configsMap.push(configurationController.createSiteObj(fileName.replace(".xml", ""), tagName, configsToSave));
  923. }, this);
  924. if (!configsMap.length) return;
  925. this.applyConfigurationsToCluster(configsMap);
  926. },
  927. /**
  928. * Prepare <code>ajaxQueue</code> and start to execute it
  929. * @method submitProceed
  930. */
  931. submitProceed: function () {
  932. var self = this;
  933. this.set('isSubmitDisabled', true);
  934. this.set('isBackBtnDisabled', true);
  935. if (this.get('content.controllerName') == 'addHostController') {
  936. App.router.get('addHostController').setLowerStepsDisable(4);
  937. }
  938. // checkpoint the cluster status on the server so that the user can resume from where they left off
  939. switch (this.get('content.controllerName')) {
  940. case 'installerController':
  941. App.clusterStatus.setClusterStatus({
  942. clusterName: this.get('clusterName'),
  943. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  944. wizardControllerName: this.get('content.controllerName'),
  945. localdb: App.db.data
  946. });
  947. break;
  948. case 'addHostController':
  949. App.clusterStatus.setClusterStatus({
  950. clusterName: this.get('clusterName'),
  951. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  952. wizardControllerName: this.get('content.controllerName'),
  953. localdb: App.db.data
  954. });
  955. break;
  956. case 'addServiceController':
  957. App.clusterStatus.setClusterStatus({
  958. clusterName: this.get('clusterName'),
  959. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  960. wizardControllerName: this.get('content.controllerName'),
  961. localdb: App.db.data
  962. });
  963. break;
  964. default:
  965. break;
  966. }
  967. // delete any existing clusters to start from a clean slate
  968. // before creating a new cluster in install wizard
  969. // TODO: modify for multi-cluster support
  970. this.getExistingClusterNames().complete(function () {
  971. var clusterNames = self.get('clusterNames');
  972. if (self.get('content.controllerName') == 'installerController' && (!App.get('testMode')) && clusterNames.length) {
  973. self.deleteClusters(clusterNames);
  974. } else {
  975. self.deleteClustersCallback(null, null, {isLast: true});
  976. }
  977. });
  978. },
  979. /**
  980. * Get list of existing cluster names
  981. * @returns {object|null}
  982. * returns an array of existing cluster names.
  983. * returns an empty array if there are no existing clusters.
  984. * @method getExistingClusterNames
  985. */
  986. getExistingClusterNames: function () {
  987. return App.ajax.send({
  988. name: 'wizard.step8.existing_cluster_names',
  989. sender: this,
  990. success: 'getExistingClusterNamesSuccessCallBack',
  991. error: 'getExistingClusterNamesErrorCallback'
  992. });
  993. },
  994. /**
  995. * Save received list to <code>clusterNames</code>
  996. * @param {Object} data
  997. * @method getExistingClusterNamesSuccessCallBack
  998. */
  999. getExistingClusterNamesSuccessCallBack: function (data) {
  1000. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  1001. console.log("Got existing cluster names: " + clusterNames);
  1002. this.set('clusterNames', clusterNames);
  1003. },
  1004. /**
  1005. * If error appears, set <code>clusterNames</code> to <code>[]</code>
  1006. * @method getExistingClusterNamesErrorCallback
  1007. */
  1008. getExistingClusterNamesErrorCallback: function () {
  1009. console.log("Failed to get existing cluster names");
  1010. this.set('clusterNames', []);
  1011. },
  1012. /**
  1013. * Delete cluster by name
  1014. * One request for one cluster!
  1015. * @param {string[]} clusterNames
  1016. * @method deleteClusters
  1017. */
  1018. deleteClusters: function (clusterNames) {
  1019. clusterNames.forEach(function (clusterName, index) {
  1020. App.ajax.send({
  1021. name: 'common.delete.cluster',
  1022. sender: this,
  1023. data: {
  1024. name: clusterName,
  1025. isLast: index == clusterNames.length - 1
  1026. },
  1027. success: 'deleteClustersCallback',
  1028. error: 'deleteClustersCallback'
  1029. });
  1030. }, this);
  1031. },
  1032. deleteClustersCallback: function (response, request, data) {
  1033. if (data.isLast) {
  1034. this.createCluster();
  1035. this.createSelectedServices();
  1036. if (this.get('content.controllerName') !== 'addHostController') {
  1037. if (this.get('wizardController').getDBProperty('fileNamesToUpdate') && this.get('wizardController').getDBProperty('fileNamesToUpdate').length) {
  1038. this.updateConfigurations(this.get('wizardController').getDBProperty('fileNamesToUpdate'));
  1039. }
  1040. this.createConfigurations();
  1041. this.applyConfigurationsToCluster(this.get('serviceConfigTags'));
  1042. }
  1043. this.createComponents();
  1044. this.registerHostsToCluster();
  1045. this.createConfigurationGroups();
  1046. this.createMasterHostComponents();
  1047. this.createSlaveAndClientsHostComponents();
  1048. if (this.get('content.controllerName') === 'addServiceController') {
  1049. this.createAdditionalClientComponents();
  1050. }
  1051. this.createAdditionalHostComponents();
  1052. this.set('ajaxQueueLength', this.get('ajaxRequestsQueue.queue.length'));
  1053. this.get('ajaxRequestsQueue').start();
  1054. }
  1055. },
  1056. /**
  1057. * *******************************************************************
  1058. * The following create* functions are called upon submitting Step 8.
  1059. * *******************************************************************
  1060. */
  1061. /**
  1062. * Create cluster using selected stack version
  1063. * Queued request
  1064. * @method createCluster
  1065. */
  1066. createCluster: function () {
  1067. if (this.get('content.controllerName') !== 'installerController') return;
  1068. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  1069. this.addRequestToAjaxQueue({
  1070. name: 'wizard.step8.create_cluster',
  1071. data: {
  1072. data: JSON.stringify({ "Clusters": {"version": stackVersion }})
  1073. },
  1074. success: 'createClusterSuccess'
  1075. });
  1076. },
  1077. createClusterSuccess: function (data, xhr, params) {
  1078. App.set('clusterName', params.cluster)
  1079. },
  1080. /**
  1081. * Create selected to install services
  1082. * Queued request
  1083. * Skipped if no services where selected!
  1084. * @method createSelectedServices
  1085. */
  1086. createSelectedServices: function () {
  1087. var data = this.createSelectedServicesData();
  1088. if (!data.length) return;
  1089. this.addRequestToAjaxQueue({
  1090. name: 'wizard.step8.create_selected_services',
  1091. data: {
  1092. data: JSON.stringify(data)
  1093. }
  1094. });
  1095. },
  1096. /**
  1097. * Format data for <code>createSelectedServices</code> request
  1098. * @returns {Object[]}
  1099. * @method createSelectedServicesData
  1100. */
  1101. createSelectedServicesData: function () {
  1102. return this.get('selectedServices').map(function (_service) {
  1103. return {"ServiceInfo": { "service_name": _service.get('serviceName') }};
  1104. });
  1105. },
  1106. /**
  1107. * Create components for selected services
  1108. * Queued requests
  1109. * One request for each service!
  1110. * @method createComponents
  1111. */
  1112. createComponents: function () {
  1113. var serviceComponents = App.StackServiceComponent.find();
  1114. this.get('selectedServices').forEach(function (_service) {
  1115. var serviceName = _service.get('serviceName');
  1116. var componentsData = serviceComponents.filterProperty('serviceName', serviceName).map(function (_component) {
  1117. return { "ServiceComponentInfo": { "component_name": _component.get('componentName') } };
  1118. });
  1119. // Service must be specified in terms of a query for creating multiple components at the same time.
  1120. // See AMBARI-1018.
  1121. this.addRequestToAjaxQueue({
  1122. name: 'wizard.step8.create_components',
  1123. data: {
  1124. data: JSON.stringify({"components": componentsData}),
  1125. serviceName: serviceName
  1126. }
  1127. });
  1128. }, this);
  1129. },
  1130. /**
  1131. * Error callback for new service component request
  1132. * So, if component doesn't exist we should create it
  1133. * @param {object} request
  1134. * @param {object} ajaxOptions
  1135. * @param {string} error
  1136. * @param {object} opt
  1137. * @param {object} params
  1138. * @method newServiceComponentErrorCallback
  1139. */
  1140. newServiceComponentErrorCallback: function (request, ajaxOptions, error, opt, params) {
  1141. this.addRequestToAjaxQueue({
  1142. name: 'wizard.step8.create_components',
  1143. data: {
  1144. serviceName: params.serviceName,
  1145. data: JSON.stringify({
  1146. "components": [
  1147. {
  1148. "ServiceComponentInfo": {
  1149. "component_name": params.componentName
  1150. }
  1151. }
  1152. ]
  1153. })
  1154. }
  1155. });
  1156. },
  1157. /**
  1158. * Register hosts
  1159. * Queued request
  1160. * @method registerHostsToCluster
  1161. */
  1162. registerHostsToCluster: function () {
  1163. var data = this.createRegisterHostData();
  1164. if (!data.length) return;
  1165. this.addRequestToAjaxQueue({
  1166. name: 'wizard.step8.register_host_to_cluster',
  1167. data: {
  1168. data: JSON.stringify(data)
  1169. }
  1170. });
  1171. },
  1172. /**
  1173. * Format request-data for <code>registerHostsToCluster</code>
  1174. * @returns {Object}
  1175. * @method createRegisterHostData
  1176. */
  1177. createRegisterHostData: function () {
  1178. return this.getRegisteredHosts().filterProperty('isInstalled', false).map(function (host) {
  1179. return {"Hosts": { "host_name": host.hostName}};
  1180. });
  1181. },
  1182. /**
  1183. * Register new master components
  1184. * @uses registerHostsToComponent
  1185. * @method createMasterHostComponents
  1186. */
  1187. createMasterHostComponents: function () {
  1188. // create master components for only selected services.
  1189. var selectedMasterComponents = this.get('content.masterComponentHosts').filter(function (_component) {
  1190. return this.get('selectedServices').mapProperty('serviceName').contains(_component.serviceId)
  1191. }, this);
  1192. selectedMasterComponents.mapProperty('component').uniq().forEach(function (component) {
  1193. var hostNames = selectedMasterComponents.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1194. this.registerHostsToComponent(hostNames, component);
  1195. }, this);
  1196. },
  1197. getClientsToMasterMap: function () {
  1198. var clientNames = App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName'),
  1199. clientsMap = {},
  1200. dependedComponents = App.StackServiceComponent.find().filterProperty('isMaster');
  1201. clientNames.forEach(function (clientName) {
  1202. clientsMap[clientName] = Em.A([]);
  1203. dependedComponents.forEach(function (component) {
  1204. if (component.get('dependencies').mapProperty('componentName').contains(clientName)) clientsMap[clientName].push(component.get('componentName'));
  1205. });
  1206. if (!clientsMap[clientName].length) delete clientsMap[clientName];
  1207. });
  1208. return clientsMap;
  1209. },
  1210. /**
  1211. * Register slave components and clients
  1212. * @uses registerHostsToComponent
  1213. * @method createSlaveAndClientsHostComponents
  1214. */
  1215. createSlaveAndClientsHostComponents: function () {
  1216. var masterHosts = this.get('content.masterComponentHosts');
  1217. var slaveHosts = this.get('content.slaveComponentHosts');
  1218. var clients = this.get('content.clients').filterProperty('isInstalled', false);
  1219. /**
  1220. * Determines on which hosts client should be installed (based on availability of master components on hosts)
  1221. * @type {Object}
  1222. * Format:
  1223. * <code>
  1224. * {
  1225. * CLIENT1: Em.A([MASTER1, MASTER2, ...]),
  1226. * CLIENT2: Em.A([MASTER3, MASTER1, ...])
  1227. * ...
  1228. * }
  1229. * </code>
  1230. */
  1231. var clientsToMasterMap = this.getClientsToMasterMap();
  1232. slaveHosts.forEach(function (_slave) {
  1233. if (_slave.componentName !== 'CLIENT') {
  1234. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1235. this.registerHostsToComponent(hostNames, _slave.componentName);
  1236. }
  1237. else {
  1238. clients.forEach(function (_client) {
  1239. var hostNames = _slave.hosts.mapProperty('hostName');
  1240. // The below logic to install clients to existing/New master hosts should not be applied to Add Host wizard.
  1241. // This is with the presumption that Add Host controller does not add any new Master component to the cluster
  1242. if (this.get('content.controllerName') !== 'addHostController') {
  1243. if (clientsToMasterMap[_client.component_name]) {
  1244. clientsToMasterMap[_client.component_name].forEach(function (componentName) {
  1245. masterHosts.filterProperty('component', componentName).forEach(function (_masterHost) {
  1246. hostNames.pushObject(_masterHost.hostName);
  1247. });
  1248. });
  1249. }
  1250. }
  1251. hostNames = hostNames.uniq();
  1252. this.registerHostsToComponent(hostNames, _client.component_name);
  1253. }, this);
  1254. }
  1255. }, this);
  1256. },
  1257. /**
  1258. * This function is specific to addServiceController
  1259. * Newly introduced master components requires some existing client components to be hosted along with them
  1260. */
  1261. createAdditionalClientComponents: function () {
  1262. var masterHosts = this.get('content.masterComponentHosts');
  1263. var clientsToMasterMap = this.getClientsToMasterMap();
  1264. var installedClients = [];
  1265. // Get all the installed Client components
  1266. this.get('content.services').filterProperty('isInstalled').forEach(function (_service) {
  1267. var serviceClients = App.StackServiceComponent.find().filterProperty('serviceName', _service.get('serviceName')).filterProperty('isClient');
  1268. serviceClients.forEach(function (client) {
  1269. installedClients.push(client.get('componentName'));
  1270. }, this);
  1271. }, this);
  1272. // Check if there is a dependency for being co-hosted between existing client and selected new master
  1273. installedClients.forEach(function (_clientName) {
  1274. if (clientsToMasterMap[_clientName]) {
  1275. var hostNames = [];
  1276. clientsToMasterMap[_clientName].forEach(function (componentName) {
  1277. masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1278. hostNames.pushObject(_masterHost.hostName);
  1279. }, this);
  1280. }, this);
  1281. hostNames = hostNames.uniq();
  1282. if (hostNames.length > 0) {
  1283. this.get('content.additionalClients').pushObject({hostNames: hostNames, componentName: _clientName});
  1284. // If a dependency for being co-hosted is derived between existing client and selected new master but that
  1285. // dependency is already satisfied in the cluster then disregard the derived dependency
  1286. this.removeClientsFromList(_clientName, hostNames);
  1287. this.registerHostsToComponent(hostNames, _clientName);
  1288. }
  1289. }
  1290. }, this);
  1291. },
  1292. /**
  1293. *
  1294. * @param clientName
  1295. * @param hostList
  1296. */
  1297. removeClientsFromList: function (clientName, hostList) {
  1298. var clientHosts = [];
  1299. var installedHosts = this.get('content.hosts');
  1300. for (var hostName in installedHosts) {
  1301. if (installedHosts[hostName].isInstalled) {
  1302. if (installedHosts[hostName].hostComponents.mapProperty('HostRoles.component_name').contains(clientName)) {
  1303. clientHosts.push(hostName);
  1304. }
  1305. }
  1306. }
  1307. if (clientHosts.length > 0) {
  1308. clientHosts.forEach(function (hostName) {
  1309. if (hostList.contains(hostName)) {
  1310. hostList.splice(hostList.indexOf(hostName), 1);
  1311. }
  1312. }, this);
  1313. }
  1314. },
  1315. /**
  1316. * Register additional components
  1317. * Based on availability of some services
  1318. * @uses registerHostsToComponent
  1319. * @method createAdditionalHostComponents
  1320. */
  1321. createAdditionalHostComponents: function () {
  1322. var masterHosts = this.get('content.masterComponentHosts');
  1323. // add all components with cardinality == ALL of selected services
  1324. var registeredHosts = this.getRegisteredHosts();
  1325. var notInstalledHosts = registeredHosts.filterProperty('isInstalled', false);
  1326. this.get('content.services').filterProperty('isSelected').forEach(function (service) {
  1327. service.get('serviceComponents').filterProperty('isRequiredOnAllHosts').forEach(function (component) {
  1328. if (service.get('isInstalled') && notInstalledHosts.length) {
  1329. this.registerHostsToComponent(notInstalledHosts.mapProperty('hostName'), component.get('componentName'));
  1330. } else if (!service.get('isInstalled') && registeredHosts.length) {
  1331. this.registerHostsToComponent(registeredHosts.mapProperty('hostName'), component.get('componentName'));
  1332. }
  1333. }, this);
  1334. }, this);
  1335. // add MySQL Server if Hive is selected
  1336. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1337. if (hiveService) {
  1338. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1339. if (hiveDb.value == "New MySQL Database") {
  1340. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1341. } else if (hiveDb.value === "New PostgreSQL Database") {
  1342. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'POSTGRESQL_SERVER');
  1343. }
  1344. }
  1345. },
  1346. /**
  1347. * Register component to hosts
  1348. * Queued request
  1349. * @param {String[]} hostNames
  1350. * @param {String} componentName
  1351. * @method registerHostsToComponent
  1352. */
  1353. registerHostsToComponent: function (hostNames, componentName) {
  1354. if (!hostNames.length) return;
  1355. var queryStr = '';
  1356. hostNames.forEach(function (hostName) {
  1357. queryStr += 'Hosts/host_name=' + hostName + '|';
  1358. });
  1359. //slice off last symbol '|'
  1360. queryStr = queryStr.slice(0, -1);
  1361. var data = {
  1362. "RequestInfo": {
  1363. "query": queryStr
  1364. },
  1365. "Body": {
  1366. "host_components": [
  1367. {
  1368. "HostRoles": {
  1369. "component_name": componentName
  1370. }
  1371. }
  1372. ]
  1373. }
  1374. };
  1375. this.addRequestToAjaxQueue({
  1376. name: 'wizard.step8.register_host_to_component',
  1377. data: {
  1378. data: JSON.stringify(data)
  1379. }
  1380. });
  1381. },
  1382. /**
  1383. * Compare generated config object with current configs that were filled
  1384. * on "Customize Services" page.
  1385. *
  1386. * @param {Object} properties - generated by createSiteObj|createCoreSiteObj
  1387. * @param {Array} configs - current configs to compare
  1388. * @return {Boolean}
  1389. * @method isConfigsChanged
  1390. **/
  1391. isConfigsChanged: function (properties, configs) {
  1392. var isChanged = false;
  1393. for (var property in properties) {
  1394. var config = configs.findProperty('name', property);
  1395. // if config not found then it's looks like a new config
  1396. if (!config) {
  1397. isChanged = true;
  1398. } else {
  1399. if (!config.hasInitialValue || config.isNotDefaultValue) {
  1400. isChanged = true;
  1401. }
  1402. }
  1403. }
  1404. return isChanged;
  1405. },
  1406. /**
  1407. * Create config objects for cluster and services
  1408. * @method createConfigurations
  1409. */
  1410. createConfigurations: function () {
  1411. var selectedServices = this.get('selectedServices');
  1412. var coreSiteObject = this.createCoreSiteObj();
  1413. var tag = 'version1';
  1414. var clusterSiteObj = this.createSiteObj('cluster-env', tag);
  1415. if (this.get('content.controllerName') == 'installerController') {
  1416. this.get('serviceConfigTags').pushObject(clusterSiteObj);
  1417. }
  1418. if (this.get('content.controllerName') == 'addServiceController') {
  1419. tag = 'version' + (new Date).getTime();
  1420. coreSiteObject.tag = tag;
  1421. var coreSiteConfigs = this.get('configs').filterProperty('filename', 'core-site.xml');
  1422. if (this.isConfigsChanged(coreSiteObject.properties, coreSiteConfigs)) {
  1423. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1424. }
  1425. }
  1426. selectedServices.forEach(function (service) {
  1427. Object.keys(service.get('configTypes')).forEach(function (type) {
  1428. if (!this.get('serviceConfigTags').someProperty('type', type)) {
  1429. var serviceVersionNotes = Em.I18n.t('dashboard.configHistory.table.notes.default').format(service.get('displayName'));
  1430. if (service.get('serviceName') === 'MAPREDUCE' && (type === 'capacity-scheduler' || type === 'mapred-queue-acls')) {
  1431. return;
  1432. } else if (type === 'core-site') {
  1433. coreSiteObject.service_config_version_note = serviceVersionNotes;
  1434. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1435. } else if (type === 'storm-site') {
  1436. var obj = this.createStormSiteObj(tag);
  1437. obj.service_config_version_note = serviceVersionNotes;
  1438. this.get('serviceConfigTags').pushObject(obj);
  1439. } else {
  1440. var obj = this.createSiteObj(type, tag);
  1441. obj.service_config_version_note = serviceVersionNotes;
  1442. this.get('serviceConfigTags').pushObject(obj);
  1443. }
  1444. }
  1445. }, this);
  1446. }, this);
  1447. this.createNotification();
  1448. },
  1449. /**
  1450. * Send <code>serviceConfigTags</code> to server
  1451. * Queued request
  1452. * One request for each service config tag
  1453. * @param serviceConfigTags
  1454. * @method applyConfigurationsToCluster
  1455. */
  1456. applyConfigurationsToCluster: function (serviceConfigTags) {
  1457. var allServices = this.get('installedServices').concat(this.get('selectedServices'));
  1458. var allConfigData = [];
  1459. allServices.forEach(function (service) {
  1460. var serviceConfigData = [];
  1461. Object.keys(service.get('configTypesRendered')).forEach(function (type) {
  1462. var serviceConfigTag = serviceConfigTags.findProperty('type', type);
  1463. if (serviceConfigTag) {
  1464. serviceConfigData.pushObject(serviceConfigTag);
  1465. }
  1466. }, this);
  1467. if (serviceConfigData.length) {
  1468. allConfigData.pushObject(JSON.stringify({
  1469. Clusters: {
  1470. desired_config: serviceConfigData
  1471. }
  1472. }));
  1473. }
  1474. }, this);
  1475. var clusterConfig = serviceConfigTags.findProperty('type', 'cluster-env');
  1476. if (clusterConfig) {
  1477. allConfigData.pushObject(JSON.stringify({
  1478. Clusters: {
  1479. desired_config: [clusterConfig]
  1480. }
  1481. }));
  1482. }
  1483. this.addRequestToAjaxQueue({
  1484. name: 'common.across.services.configurations',
  1485. data: {
  1486. data: '[' + allConfigData.toString() + ']'
  1487. }
  1488. });
  1489. },
  1490. /**
  1491. * Create and update config groups
  1492. * @method createConfigurationGroups
  1493. */
  1494. createConfigurationGroups: function () {
  1495. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1496. var clusterName = this.get('clusterName');
  1497. var sendData = [];
  1498. var updateData = [];
  1499. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1500. var timeTag = (new Date).getTime();
  1501. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1502. if (groupsToDelete && groupsToDelete.length > 0) {
  1503. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1504. }
  1505. configGroups.forEach(function (configGroup) {
  1506. var groupConfigs = [];
  1507. var groupData = {
  1508. "cluster_name": clusterName,
  1509. "group_name": configGroup.name,
  1510. "tag": configGroup.service.id,
  1511. "description": configGroup.description,
  1512. "hosts": [],
  1513. "desired_configs": []
  1514. };
  1515. configGroup.hosts.forEach(function (hostName) {
  1516. groupData.hosts.push({"host_name": hostName});
  1517. });
  1518. // get properties that was created for non-default config group
  1519. configGroup.properties = configGroup.properties.concat(this.get('customNonDefaultGroupConfigs').filterProperty('group', configGroup.name));
  1520. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1521. configGroup.properties.forEach(function (property) {
  1522. groupConfigs.push(Em.Object.create(property));
  1523. });
  1524. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1525. // check for group from installed service
  1526. if (configGroup.isForInstalledService === true) {
  1527. // if group is a new one, create it
  1528. if (!configGroup.id) {
  1529. sendData.push({"ConfigGroup": groupData});
  1530. } else if (configGroup.isForUpdate){
  1531. // update an existing group
  1532. groupData.id = configGroup.id;
  1533. updateData.push({"ConfigGroup": groupData});
  1534. }
  1535. } else {
  1536. sendData.push({"ConfigGroup": groupData});
  1537. }
  1538. //each group should have unique tag to prevent overriding configs from common sites
  1539. timeTag++;
  1540. }, this);
  1541. if (sendData.length > 0) {
  1542. this.applyConfigurationGroups(sendData);
  1543. }
  1544. if (updateData.length > 0) {
  1545. this.applyInstalledServicesConfigurationGroup(updateData);
  1546. }
  1547. },
  1548. /**
  1549. * Create new config groups request
  1550. * Queued request
  1551. * @param {Object[]} sendData
  1552. * @method applyConfigurationGroups
  1553. */
  1554. applyConfigurationGroups: function (sendData) {
  1555. this.addRequestToAjaxQueue({
  1556. name: 'wizard.step8.apply_configuration_groups',
  1557. data: {
  1558. data: JSON.stringify(sendData)
  1559. }
  1560. });
  1561. },
  1562. /**
  1563. * Update existed config groups
  1564. * Separated request for each group
  1565. * @param {Object[]} updateData
  1566. * @method applyInstalledServicesConfigurationGroup
  1567. */
  1568. applyInstalledServicesConfigurationGroup: function (updateData) {
  1569. updateData.forEach(function (item) {
  1570. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1571. });
  1572. },
  1573. /**
  1574. * Delete selected config groups
  1575. * @param {Object[]} groupsToDelete
  1576. * @method removeInstalledServicesConfigurationGroups
  1577. */
  1578. removeInstalledServicesConfigurationGroups: function (groupsToDelete) {
  1579. groupsToDelete.forEach(function (item) {
  1580. App.config.deleteConfigGroup(Em.Object.create(item));
  1581. });
  1582. },
  1583. /**
  1584. * proxyuser configs which depend on service
  1585. * @type {{serviceName: string, user: string}[]}
  1586. */
  1587. optionalCoreSiteConfigs: [
  1588. {
  1589. serviceName: 'OOZIE',
  1590. user: 'oozie_user'
  1591. },
  1592. {
  1593. serviceName: 'HIVE',
  1594. user: 'hive_user'
  1595. },
  1596. {
  1597. serviceName: 'HIVE',
  1598. user: 'hcat_user'
  1599. },
  1600. {
  1601. serviceName: 'FALCON',
  1602. user: 'falcon_user'
  1603. }
  1604. ],
  1605. /**
  1606. * push proxyuser properties to core-site if they required by dependencies
  1607. * @param coreSiteObj
  1608. * @param installedAndSelectedServices
  1609. * @return {Object}
  1610. */
  1611. resolveProxyuserDependecies: function (coreSiteObj, installedAndSelectedServices) {
  1612. var coreSiteProperties = {};
  1613. var optionalCoreSiteConfigs = this.get('optionalCoreSiteConfigs');
  1614. var proxyuserGroup = this.get('configs').findProperty('name', 'proxyuser_group');
  1615. coreSiteObj.forEach(function (_coreSiteObj) {
  1616. //proxyuser_group property should be added only if proxyuser properties are used
  1617. if (proxyuserGroup && _coreSiteObj.name === proxyuserGroup.name) return;
  1618. // exclude some configs if service wasn't selected
  1619. var addProperty = optionalCoreSiteConfigs.every(function (config) {
  1620. var userValue = this.get('configs').someProperty('name', config.user) ? this.get('configs').findProperty('name', config.user).value : null
  1621. return (installedAndSelectedServices.someProperty('serviceName', config.serviceName) ||
  1622. (_coreSiteObj.name != 'hadoop.proxyuser.' + userValue + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + userValue + '.groups'))
  1623. }, this);
  1624. if (addProperty) {
  1625. coreSiteProperties[_coreSiteObj.name] = _coreSiteObj.value;
  1626. }
  1627. }, this);
  1628. if (!App.isEmptyObject(coreSiteProperties) && proxyuserGroup) {
  1629. coreSiteProperties[proxyuserGroup.name] = proxyuserGroup.value;
  1630. }
  1631. return coreSiteProperties;
  1632. },
  1633. /**
  1634. * Create Core Site object
  1635. * @returns {{type: string, tag: string, properties: {}}}
  1636. * @method createCoreSiteObj
  1637. */
  1638. createCoreSiteObj: function () {
  1639. var installedAndSelectedServices = Em.A([]);
  1640. installedAndSelectedServices.pushObjects(this.get('installedServices'));
  1641. installedAndSelectedServices.pushObjects(this.get('selectedServices'));
  1642. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml'),
  1643. coreSiteProperties = this.resolveProxyuserDependecies(coreSiteObj, installedAndSelectedServices),
  1644. isGLUSTERFSSelected = installedAndSelectedServices.someProperty('serviceName', 'GLUSTERFS');
  1645. coreSiteObj.forEach(function (_coreSiteObj) {
  1646. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1647. coreSiteProperties[_coreSiteObj.name] =
  1648. this.get('configs').someProperty('name', 'fs_glusterfs_default_name') ?
  1649. this.get('configs').findProperty('name', 'fs_glusterfs_default_name').value : null;
  1650. }
  1651. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1652. coreSiteProperties[_coreSiteObj.name] =
  1653. this.get('configs').someProperty('name', 'glusterfs_defaultFS_name') ?
  1654. this.get('configs').findProperty('name', 'glusterfs_defaultFS_name').value : null;
  1655. }
  1656. }, this);
  1657. var attributes = App.router.get('mainServiceInfoConfigsController').getConfigAttributes(coreSiteObj);
  1658. var configObj = {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1659. if (attributes) {
  1660. configObj['properties_attributes'] = attributes;
  1661. }
  1662. return configObj;
  1663. },
  1664. /**
  1665. * Create siteObj for custom service with it own configs
  1666. * @param {string} site
  1667. * @param tag
  1668. * @returns {{type: string, tag: string, properties: {}}}
  1669. * @method createSiteObj
  1670. */
  1671. createSiteObj: function (site, tag) {
  1672. var properties = {};
  1673. var configs = this.get('configs').filterProperty('filename', site + '.xml');
  1674. var attributes = App.router.get('mainServiceInfoConfigsController').getConfigAttributes(configs);
  1675. configs.forEach(function (_configProperty) {
  1676. var heapsizeExceptions = ['hadoop_heapsize', 'yarn_heapsize', 'nodemanager_heapsize', 'resourcemanager_heapsize', 'apptimelineserver_heapsize', 'jobhistory_heapsize'];
  1677. // do not pass any globals whose name ends with _host or _hosts
  1678. if (_configProperty.isRequiredByAgent !== false) {
  1679. // append "m" to JVM memory options except for heapsizeExtensions
  1680. if (/_heapsize|_newsize|_maxnewsize|_permsize|_maxpermsize$/.test(_configProperty.name) && !heapsizeExceptions.contains(_configProperty.name) && !(_configProperty.value).endsWith("m")) {
  1681. properties[_configProperty.name] = _configProperty.value + "m";
  1682. } else {
  1683. properties[_configProperty.name] = _configProperty.value;
  1684. }
  1685. }
  1686. }, this);
  1687. var configObj = {"type": site, "tag": tag, "properties": properties };
  1688. if (attributes) {
  1689. configObj['properties_attributes'] = attributes;
  1690. }
  1691. return configObj;
  1692. },
  1693. /**
  1694. * Create site obj for Storm
  1695. * Some config-properties should be modified in custom way
  1696. * @param tag
  1697. * @returns {{type: string, tag: string, properties: {}}}
  1698. * @method createStormSiteObj
  1699. */
  1700. createStormSiteObj: function (tag) {
  1701. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1702. var stormProperties = {};
  1703. configs.forEach(function (_configProperty) {
  1704. if (_configProperty.name == "storm.zookeeper.servers") {
  1705. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1706. } else {
  1707. stormProperties[_configProperty.name] = _configProperty.value;
  1708. }
  1709. }, this);
  1710. return {type: 'storm-site', tag: tag, properties: stormProperties};
  1711. },
  1712. /**
  1713. * Create one Alert Notification (if user select this on step7)
  1714. * Only for Install Wizard and stack >= 2!
  1715. * @method createNotification
  1716. */
  1717. createNotification: function () {
  1718. if (this.get('content.controllerName') !== 'installerController' || !App.get('isHadoop2Stack')) return;
  1719. var miscConfigs = this.get('configs').filterProperty('serviceName', 'MISC'),
  1720. createNotification = miscConfigs.findProperty('name', 'create_notification').value;
  1721. if (createNotification === 'yes') {
  1722. var properties = {},
  1723. names = [
  1724. 'ambari.dispatch.recipients',
  1725. 'mail.smtp.host',
  1726. 'mail.smtp.port',
  1727. 'mail.smtp.from',
  1728. 'mail.smtp.starttls.enable',
  1729. 'mail.smtp.startssl.enable'
  1730. ];
  1731. if (miscConfigs.findProperty('name', 'smtp_use_auth').value == 'true') { // yes, it's not converted to boolean
  1732. names.pushObjects(['ambari.dispatch.credential.username', 'ambari.dispatch.credential.password']);
  1733. }
  1734. var customConfigNames = miscConfigs.filterProperty('displayType', 'advanced').filterProperty('filename', '').mapProperty('name');
  1735. if (customConfigNames) {
  1736. names.pushObjects(customConfigNames);
  1737. }
  1738. names.forEach(function (name) {
  1739. properties[name] = miscConfigs.findProperty('name', name).value;
  1740. });
  1741. //properties['mail.smtp.starttls.enable'] = miscConfigs.findProperty('').value;
  1742. var apiObject = {
  1743. AlertTarget: {
  1744. name: 'Initial Notification',
  1745. description: 'Notification created during cluster installing',
  1746. global: true,
  1747. notification_type: 'EMAIL',
  1748. alert_states: ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN'],
  1749. properties: properties
  1750. }
  1751. };
  1752. this.addRequestToAjaxQueue({
  1753. name: 'alerts.create_alert_notification',
  1754. data: {
  1755. data: apiObject
  1756. }
  1757. });
  1758. }
  1759. }
  1760. });