step8_controller.js 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824
  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. uiConfig.pushObject({
  430. "id": "site property",
  431. "name": _config._name || _config.name,
  432. "value": _config.value,
  433. "filename": _config.filename
  434. });
  435. }, this);
  436. return uiConfig;
  437. },
  438. /**
  439. * Add dynamic properties to configs
  440. * @param {Array} configs
  441. * @method addDynamicProperties
  442. */
  443. addDynamicProperties: function (configs) {
  444. var templetonHiveProperty = this.get('content.serviceConfigProperties').someProperty('name', 'templeton.hive.properties');
  445. if (!templetonHiveProperty) {
  446. configs.pushObject({
  447. "name": "templeton.hive.properties",
  448. "templateName": ["hivemetastore_host"],
  449. "foreignKey": null,
  450. "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",
  451. "filename": "webhcat-site.xml"
  452. });
  453. }
  454. },
  455. /**
  456. * Format <code>content.hosts</code> from Object to Array
  457. * @returns {Array}
  458. * @method getRegisteredHosts
  459. */
  460. getRegisteredHosts: function () {
  461. var allHosts = this.get('content.hosts');
  462. var hosts = [];
  463. for (var hostName in allHosts) {
  464. if (allHosts.hasOwnProperty(hostName)) {
  465. if (allHosts[hostName].bootStatus == 'REGISTERED') {
  466. allHosts[hostName].hostName = allHosts[hostName].name;
  467. hosts.pushObject(allHosts[hostName]);
  468. }
  469. }
  470. }
  471. return hosts;
  472. },
  473. /**
  474. * Set all site property that are derived from other puppet-variable
  475. * @param {String} templateName
  476. * @param {String} expression
  477. * @param {String} name
  478. * @return {Object}
  479. * example: <code>{
  480. * value: '...',
  481. * overrides: [
  482. * {
  483. * value: 'v1',
  484. * hosts: ['h1', 'h2']
  485. * },
  486. * {
  487. * value: 'v2',
  488. * hosts: ['h2', 'h3']
  489. * },
  490. * ....
  491. * ]
  492. * }</code>
  493. * @method getGlobConfigValueWithOverrides
  494. */
  495. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  496. var express = expression.match(/<(.*?)>/g);
  497. var value = expression;
  498. if (express == null) {
  499. return { value: expression, overrides: []}; // if site property do not map any global property then return the value
  500. }
  501. var overrideHostToValue = {};
  502. express.forEach(function (_express) {
  503. //console.log("The value of template is: " + _express);
  504. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  505. if (this.get('configs').someProperty('name', templateName[index])) {
  506. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  507. var globalObj = this.get('configs').findProperty('name', templateName[index]);
  508. var globValue = globalObj.value;
  509. // Hack for templeton.zookeeper.hosts
  510. var preReplaceValue = null;
  511. 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
  512. preReplaceValue = value;
  513. value = this._replaceConfigValues(name, _express, value, globValue);
  514. }
  515. if (globalObj.overrides != null) {
  516. globalObj.overrides.forEach(function (override) {
  517. var ov = override.value;
  518. var hostsArray = override.hosts;
  519. hostsArray.forEach(function (host) {
  520. if (!(host in overrideHostToValue)) {
  521. overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
  522. } else {
  523. overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  524. }
  525. }, this);
  526. }, this);
  527. }
  528. } else {
  529. /*
  530. console.log("ERROR: The variable name is: " + templateName[index]);
  531. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  532. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  533. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  534. */
  535. value = null;
  536. }
  537. }, this);
  538. var valueWithOverrides = {
  539. value: value,
  540. overrides: []
  541. };
  542. var overrideValueToHostMap = {};
  543. if (!jQuery.isEmptyObject(overrideHostToValue)) {
  544. for (var host in overrideHostToValue) {
  545. var hostVal = overrideHostToValue[host];
  546. if (!(hostVal in overrideValueToHostMap)) {
  547. overrideValueToHostMap[hostVal] = [];
  548. }
  549. overrideValueToHostMap[hostVal].push(host);
  550. }
  551. }
  552. for (var val in overrideValueToHostMap) {
  553. valueWithOverrides.overrides.push({
  554. value: val,
  555. hosts: overrideValueToHostMap[val]
  556. });
  557. }
  558. return valueWithOverrides;
  559. },
  560. /**
  561. * replace some values in config property
  562. * @param {string} name
  563. * @param {string} express
  564. * @param {string} value
  565. * @param {string} globValue
  566. * @return {string}
  567. * @private
  568. * @method _replaceConfigValues
  569. */
  570. _replaceConfigValues: function (name, express, value, globValue) {
  571. return value.replace(express, globValue);
  572. },
  573. /**
  574. * Load all info about cluster to <code>clusterInfo</code> variable
  575. * @method loadClusterInfo
  576. */
  577. loadClusterInfo: function () {
  578. //Admin name
  579. var admin = this.rawContent.findProperty('config_name', 'Admin');
  580. admin.config_value = App.db.getLoginName();
  581. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  582. if (admin.config_value) {
  583. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  584. }
  585. // cluster name
  586. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  587. cluster.config_value = this.get('content.cluster.name');
  588. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  589. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  590. //hosts
  591. var newHostsCount = 0;
  592. var totalHostsCount = 0;
  593. var hosts = this.get('content.hosts');
  594. for (var hostName in hosts) {
  595. newHostsCount += ~~(!hosts[hostName].isInstalled);
  596. totalHostsCount++;
  597. }
  598. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  599. totalHostsObj.config_value = totalHostsCount + ' (' + newHostsCount + ' new)';
  600. this.get('clusterInfo').pushObject(Em.Object.create(totalHostsObj));
  601. //repo
  602. if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName'))) {
  603. this.loadRepoInfo();
  604. } else {
  605. // from install wizard
  606. var selectedStack = App.Stack.find().findProperty('isSelected');
  607. var allRepos = [];
  608. if (selectedStack && selectedStack.get('operatingSystems')) {
  609. selectedStack.get('operatingSystems').forEach(function (os) {
  610. if (os.get('isSelected')) {
  611. os.get('repositories').forEach(function(repo) {
  612. allRepos.push(Em.Object.create({
  613. base_url: repo.get('baseUrl'),
  614. os_type: repo.get('osType'),
  615. repo_id: repo.get('repoId')
  616. }));
  617. }, this);
  618. }
  619. }, this);
  620. }
  621. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  622. this.get('clusterInfo').set('repoInfo', allRepos);
  623. }
  624. },
  625. /**
  626. * Load repo info for add Service/Host wizard review page
  627. * @return {$.ajax|null}
  628. * @method loadRepoInfo
  629. */
  630. loadRepoInfo: function () {
  631. var nameVersionCombo = App.get('currentStackVersion').split('-');
  632. return App.ajax.send({
  633. name: 'cluster.load_repositories',
  634. sender: this,
  635. data: {
  636. stackName: nameVersionCombo[0],
  637. stackVersion: nameVersionCombo[1]
  638. },
  639. success: 'loadRepoInfoSuccessCallback',
  640. error: 'loadRepoInfoErrorCallback'
  641. });
  642. },
  643. /**
  644. * Save all repo base URL of all OS type to <code>repoInfo<code>
  645. * @param {object} data
  646. * @method loadRepoInfoSuccessCallback
  647. */
  648. loadRepoInfoSuccessCallback: function (data) {
  649. var allRepos = [];
  650. data.items.forEach(function (os) {
  651. os.repositories.forEach(function (repository) {
  652. allRepos.push(Em.Object.create({
  653. base_url: repository.Repositories.base_url,
  654. os_type: repository.Repositories.os_type,
  655. repo_id: repository.Repositories.repo_id
  656. }));
  657. });
  658. }, this);
  659. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  660. this.get('clusterInfo').set('repoInfo', allRepos);
  661. },
  662. /**
  663. * @param {object} request
  664. * @method loadRepoInfoErrorCallback
  665. */
  666. loadRepoInfoErrorCallback: function (request) {
  667. console.log('Error message is: ' + request.responseText);
  668. var allRepos = [];
  669. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  670. this.get('clusterInfo').set('repoInfo', allRepos);
  671. },
  672. /**
  673. * Load all info about services to <code>services</code> variable
  674. * @method loadServices
  675. */
  676. loadServices: function () {
  677. this.get('selectedServices').filterProperty('isHiddenOnSelectServicePage', false).forEach(function (service) {
  678. console.log('INFO: step8: Name of the service from getService function: ' + service.get('serviceName'));
  679. var serviceObj = Em.Object.create({
  680. service_name: service.get('serviceName'),
  681. display_name: service.get('displayNameOnSelectServicePage'),
  682. service_components: Em.A([])
  683. });
  684. service.get('serviceComponents').forEach(function (component) {
  685. // show clients for services that have only clients components
  686. if ((component.get('isClient') || component.get('isClientBehavior')) && !service.get('isClientOnlyService')) return;
  687. // skip components that was hide on assign master page
  688. if (component.get('isMaster') && !component.get('isShownOnInstallerAssignMasterPage')) return;
  689. // no HA component
  690. if (component.get('isHAComponentOnly')) return;
  691. var displayName;
  692. if (component.get('isClient')) {
  693. displayName = Em.I18n.t('common.clients')
  694. } else {
  695. // remove service name from component display name
  696. displayName = App.format.role(component.get('componentName')).replace(new RegExp('^' + service.get('serviceName') + '\\s', 'i'), '');
  697. }
  698. serviceObj.get('service_components').pushObject(Em.Object.create({
  699. component_name: component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName'),
  700. display_name: displayName,
  701. component_value: this.assignComponentHosts(component)
  702. }));
  703. }, this);
  704. if (service.get('customReviewHandler')) {
  705. for (var displayName in service.get('customReviewHandler')) {
  706. serviceObj.get('service_components').pushObject(Em.Object.create({
  707. display_name: displayName,
  708. component_value: this.assignComponentHosts(Em.Object.create({
  709. customHandler: service.get('customReviewHandler.' + displayName)
  710. }))
  711. }));
  712. }
  713. }
  714. this.get('services').pushObject(serviceObj);
  715. }, this);
  716. },
  717. /**
  718. * Set <code>component_value</code> property to <code>component</code>
  719. * @param {Em.Object} component
  720. * @return {String}
  721. * @method assignComponentHosts
  722. */
  723. assignComponentHosts: function (component) {
  724. var componentValue;
  725. if (component.get('customHandler')) {
  726. componentValue = this[component.get('customHandler')].call(this, component);
  727. }
  728. else {
  729. if (component.get('isMaster')) {
  730. componentValue = this.getMasterComponentValue(component.get('componentName'));
  731. }
  732. else {
  733. console.log(' --- ---INFO: step8: NOT component isMaster');
  734. var componentName = component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName');
  735. var hostsLength = this.get('content.slaveComponentHosts')
  736. .findProperty('componentName', componentName).hosts.length;
  737. componentValue = hostsLength + Em.I18n.t('installer.step8.host' + ((hostsLength > 1) ? 's' : ''));
  738. }
  739. }
  740. return componentValue;
  741. },
  742. getMasterComponentValue: function (componentName) {
  743. var masterComponents = this.get('content.masterComponentHosts');
  744. var hostsCount = masterComponents.filterProperty('component', componentName).length;
  745. return stringUtils.pluralize(hostsCount,
  746. masterComponents.findProperty('component', componentName).hostName,
  747. hostsCount + ' ' + Em.I18n.t('installer.step8.hosts'));
  748. },
  749. /**
  750. * Set displayed MetricsSink DB value based on DB type
  751. * @param {Ember.Object} dbComponent
  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 dispalyed Hive DB value based on DB type
  770. * @param {Ember.Object} dbComponent
  771. * @method loadHiveDbValue
  772. */
  773. loadHiveDbValue: function () {
  774. var db, serviceConfigPreoprties = this.get('wizardController').getDBProperty('serviceConfigProperties'),
  775. hiveDb = serviceConfigPreoprties.findProperty('name', 'hive_database');
  776. if (hiveDb.value === 'New MySQL Database') {
  777. return 'MySQL (New Database)';
  778. } else if (hiveDb.value === 'New PostgreSQL Database') {
  779. return 'Postgres (New Database)';
  780. }
  781. else {
  782. if (hiveDb.value === 'Existing MySQL Database') {
  783. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mysql_database');
  784. return db.value + ' (' + hiveDb.value + ')';
  785. }
  786. else {
  787. if (hiveDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  788. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_postgresql_database');
  789. return db.value + ' (' + hiveDb.value + ')';
  790. }
  791. else {
  792. if (hiveDb.value === 'Existing MSSQL Server database with integrated authentication') {
  793. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mssql_server_database');
  794. return db.value + ' (' + hiveDb.value + ')';
  795. }
  796. else {
  797. if (hiveDb.value === 'Existing MSSQL Server database with sql auth') {
  798. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mssql_server_2_database');
  799. return db.value + ' (' + hiveDb.value + ')';
  800. }
  801. else {
  802. // existing oracle database
  803. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_oracle_database');
  804. return db.value + ' (' + hiveDb.value + ')';
  805. }
  806. }
  807. }
  808. }
  809. }
  810. },
  811. /**
  812. * Set displayed HBase master value
  813. * @param {Object} hbaseMaster
  814. * @method loadHbaseMasterValue
  815. */
  816. loadHbaseMasterValue: function (hbaseMaster) {
  817. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('component', hbaseMaster.component_name);
  818. if (hbaseHostName.length == 1) {
  819. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  820. } else {
  821. hbaseMaster.set('component_value', hbaseHostName[0].hostName + " " + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  822. }
  823. },
  824. /**
  825. * Set displayed ZooKeeper Server value
  826. * @param {Object} serverComponent
  827. * @method loadZkServerValue
  828. */
  829. loadZkServerValue: function (serverComponent) {
  830. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('component', serverComponent.component_name).length;
  831. var hostSuffix;
  832. if (zkHostNames === 1) {
  833. hostSuffix = Em.I18n.t('installer.step8.host');
  834. } else {
  835. hostSuffix = Em.I18n.t('installer.step8.hosts');
  836. }
  837. serverComponent.set('component_value', zkHostNames + hostSuffix);
  838. },
  839. /**
  840. * Set displayed Oozie DB value based on DB type
  841. * @param {Object} dbComponent
  842. * @method loadOozieDbValue
  843. */
  844. loadOozieDbValue: function () {
  845. var db, oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  846. if (oozieDb.value === 'New Derby Database') {
  847. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  848. return db.value + ' (' + oozieDb.value + ')';
  849. }
  850. else {
  851. if (oozieDb.value === 'Existing MySQL Database') {
  852. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  853. return db.value + ' (' + oozieDb.value + ')';
  854. }
  855. else {
  856. if (oozieDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  857. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_postgresql_database');
  858. return db.value + ' (' + oozieDb.value + ')';
  859. }
  860. else {
  861. if (oozieDb.value === 'Existing MSSQL Server database with integrated authentication') {
  862. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_database');
  863. return db.value + ' (' + oozieDb.value + ')';
  864. }
  865. else {
  866. if (oozieDb.value === 'Existing MSSQL Server database with sql auth') {
  867. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_2_database');
  868. return db.value + ' (' + oozieDb.value + ')';
  869. }
  870. else {
  871. // existing oracle database
  872. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  873. return db.value + ' (' + oozieDb.value + ')';
  874. }
  875. }
  876. }
  877. }
  878. }
  879. },
  880. /**
  881. * Set displayed Nagion Admin value
  882. * @param {Object} nagiosAdmin
  883. * @method loadNagiosAdminValue
  884. */
  885. loadNagiosAdminValue: function () {
  886. var config = this.get('content.serviceConfigProperties');
  887. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  888. var adminEmail = config.findProperty('name', 'nagios_contact');
  889. return adminLoginName.value + ' / (' + adminEmail.value + ')';
  890. },
  891. /**
  892. * Onclick handler for <code>next</code> button
  893. * @method submit
  894. * @return {App.ModalPopup|null}
  895. */
  896. submit: function () {
  897. if (this.get('isSubmitDisabled')) return null;
  898. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  899. var self = this;
  900. return App.showConfirmationPopup(function () {
  901. self.submitProceed();
  902. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  903. } else {
  904. return this.submitProceed();
  905. }
  906. },
  907. /**
  908. * Update configurations for installed services.
  909. * Do separated PUT-request for each siteName for each service
  910. *
  911. * @param {Array} fileNamesToUpdate - file names that should be updated
  912. * @method updateConfigurations
  913. */
  914. updateConfigurations: function (fileNamesToUpdate) {
  915. var configurationController = App.router.get('mainServiceInfoConfigsController');
  916. var configs = this.get('configs').slice(0);
  917. var configsMap = [];
  918. fileNamesToUpdate.forEach(function (fileName) {
  919. if (!fileName || /^(core)/.test(fileName)) return;
  920. var tagName = 'version' + (new Date).getTime();
  921. var configsToSave = configs.filterProperty('filename', fileName);
  922. configsToSave.forEach(function (item) {
  923. item.value = App.config.trimProperty(item, false);
  924. });
  925. configsMap.push(configurationController.createSiteObj(fileName.replace(".xml", ""), tagName, configsToSave));
  926. }, this);
  927. if (!configsMap.length) return;
  928. this.applyConfigurationsToCluster(configsMap);
  929. },
  930. /**
  931. * Prepare <code>ajaxQueue</code> and start to execute it
  932. * @method submitProceed
  933. */
  934. submitProceed: function () {
  935. var self = this;
  936. this.set('isSubmitDisabled', true);
  937. this.set('isBackBtnDisabled', true);
  938. if (this.get('content.controllerName') == 'addHostController') {
  939. App.router.get('addHostController').setLowerStepsDisable(4);
  940. }
  941. // checkpoint the cluster status on the server so that the user can resume from where they left off
  942. switch (this.get('content.controllerName')) {
  943. case 'installerController':
  944. App.clusterStatus.setClusterStatus({
  945. clusterName: this.get('clusterName'),
  946. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  947. wizardControllerName: this.get('content.controllerName'),
  948. localdb: App.db.data
  949. });
  950. break;
  951. case 'addHostController':
  952. App.clusterStatus.setClusterStatus({
  953. clusterName: this.get('clusterName'),
  954. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  955. wizardControllerName: this.get('content.controllerName'),
  956. localdb: App.db.data
  957. });
  958. break;
  959. case 'addServiceController':
  960. App.clusterStatus.setClusterStatus({
  961. clusterName: this.get('clusterName'),
  962. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  963. wizardControllerName: this.get('content.controllerName'),
  964. localdb: App.db.data
  965. });
  966. break;
  967. default:
  968. break;
  969. }
  970. // delete any existing clusters to start from a clean slate
  971. // before creating a new cluster in install wizard
  972. // TODO: modify for multi-cluster support
  973. this.getExistingClusterNames().complete(function () {
  974. var clusterNames = self.get('clusterNames');
  975. if (self.get('content.controllerName') == 'installerController' && (!App.get('testMode')) && clusterNames.length) {
  976. self.deleteClusters(clusterNames);
  977. } else {
  978. self.deleteClustersCallback(null, null, {isLast: true});
  979. }
  980. });
  981. },
  982. /**
  983. * Get list of existing cluster names
  984. * @returns {object|null}
  985. * returns an array of existing cluster names.
  986. * returns an empty array if there are no existing clusters.
  987. * @method getExistingClusterNames
  988. */
  989. getExistingClusterNames: function () {
  990. return App.ajax.send({
  991. name: 'wizard.step8.existing_cluster_names',
  992. sender: this,
  993. success: 'getExistingClusterNamesSuccessCallBack',
  994. error: 'getExistingClusterNamesErrorCallback'
  995. });
  996. },
  997. /**
  998. * Save received list to <code>clusterNames</code>
  999. * @param {Object} data
  1000. * @method getExistingClusterNamesSuccessCallBack
  1001. */
  1002. getExistingClusterNamesSuccessCallBack: function (data) {
  1003. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  1004. console.log("Got existing cluster names: " + clusterNames);
  1005. this.set('clusterNames', clusterNames);
  1006. },
  1007. /**
  1008. * If error appears, set <code>clusterNames</code> to <code>[]</code>
  1009. * @method getExistingClusterNamesErrorCallback
  1010. */
  1011. getExistingClusterNamesErrorCallback: function () {
  1012. console.log("Failed to get existing cluster names");
  1013. this.set('clusterNames', []);
  1014. },
  1015. /**
  1016. * Delete cluster by name
  1017. * One request for one cluster!
  1018. * @param {string[]} clusterNames
  1019. * @method deleteClusters
  1020. */
  1021. deleteClusters: function (clusterNames) {
  1022. clusterNames.forEach(function (clusterName, index) {
  1023. App.ajax.send({
  1024. name: 'common.delete.cluster',
  1025. sender: this,
  1026. data: {
  1027. name: clusterName,
  1028. isLast: index == clusterNames.length - 1
  1029. },
  1030. success: 'deleteClustersCallback',
  1031. error: 'deleteClustersCallback'
  1032. });
  1033. }, this);
  1034. },
  1035. deleteClustersCallback: function (response, request, data) {
  1036. if (data.isLast) {
  1037. this.createCluster();
  1038. this.createSelectedServices();
  1039. if (this.get('content.controllerName') !== 'addHostController') {
  1040. if (this.get('wizardController').getDBProperty('fileNamesToUpdate') && this.get('wizardController').getDBProperty('fileNamesToUpdate').length) {
  1041. this.updateConfigurations(this.get('wizardController').getDBProperty('fileNamesToUpdate'));
  1042. }
  1043. this.createConfigurations();
  1044. this.applyConfigurationsToCluster(this.get('serviceConfigTags'));
  1045. }
  1046. this.createComponents();
  1047. this.registerHostsToCluster();
  1048. this.createConfigurationGroups();
  1049. this.createMasterHostComponents();
  1050. this.createSlaveAndClientsHostComponents();
  1051. if (this.get('content.controllerName') === 'addServiceController') {
  1052. this.createAdditionalClientComponents();
  1053. }
  1054. this.createAdditionalHostComponents();
  1055. this.set('ajaxQueueLength', this.get('ajaxRequestsQueue.queue.length'));
  1056. this.get('ajaxRequestsQueue').start();
  1057. }
  1058. },
  1059. /**
  1060. * *******************************************************************
  1061. * The following create* functions are called upon submitting Step 8.
  1062. * *******************************************************************
  1063. */
  1064. /**
  1065. * Create cluster using selected stack version
  1066. * Queued request
  1067. * @method createCluster
  1068. */
  1069. createCluster: function () {
  1070. if (this.get('content.controllerName') !== 'installerController') return;
  1071. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  1072. this.addRequestToAjaxQueue({
  1073. name: 'wizard.step8.create_cluster',
  1074. data: {
  1075. data: JSON.stringify({ "Clusters": {"version": stackVersion }})
  1076. },
  1077. success: 'createClusterSuccess'
  1078. });
  1079. },
  1080. createClusterSuccess: function (data, xhr, params) {
  1081. App.set('clusterName', params.cluster)
  1082. },
  1083. /**
  1084. * Create selected to install services
  1085. * Queued request
  1086. * Skipped if no services where selected!
  1087. * @method createSelectedServices
  1088. */
  1089. createSelectedServices: function () {
  1090. var data = this.createSelectedServicesData();
  1091. if (!data.length) return;
  1092. this.addRequestToAjaxQueue({
  1093. name: 'wizard.step8.create_selected_services',
  1094. data: {
  1095. data: JSON.stringify(data)
  1096. }
  1097. });
  1098. },
  1099. /**
  1100. * Format data for <code>createSelectedServices</code> request
  1101. * @returns {Object[]}
  1102. * @method createSelectedServicesData
  1103. */
  1104. createSelectedServicesData: function () {
  1105. return this.get('selectedServices').map(function (_service) {
  1106. return {"ServiceInfo": { "service_name": _service.get('serviceName') }};
  1107. });
  1108. },
  1109. /**
  1110. * Create components for selected services
  1111. * Queued requests
  1112. * One request for each service!
  1113. * @method createComponents
  1114. */
  1115. createComponents: function () {
  1116. var serviceComponents = App.StackServiceComponent.find();
  1117. this.get('selectedServices').forEach(function (_service) {
  1118. var serviceName = _service.get('serviceName');
  1119. var componentsData = serviceComponents.filterProperty('serviceName', serviceName).map(function (_component) {
  1120. return { "ServiceComponentInfo": { "component_name": _component.get('componentName') } };
  1121. });
  1122. // Service must be specified in terms of a query for creating multiple components at the same time.
  1123. // See AMBARI-1018.
  1124. this.addRequestToAjaxQueue({
  1125. name: 'wizard.step8.create_components',
  1126. data: {
  1127. data: JSON.stringify({"components": componentsData}),
  1128. serviceName: serviceName
  1129. }
  1130. });
  1131. }, this);
  1132. },
  1133. /**
  1134. * Error callback for new service component request
  1135. * So, if component doesn't exist we should create it
  1136. * @param {object} request
  1137. * @param {object} ajaxOptions
  1138. * @param {string} error
  1139. * @param {object} opt
  1140. * @param {object} params
  1141. * @method newServiceComponentErrorCallback
  1142. */
  1143. newServiceComponentErrorCallback: function (request, ajaxOptions, error, opt, params) {
  1144. this.addRequestToAjaxQueue({
  1145. name: 'wizard.step8.create_components',
  1146. data: {
  1147. serviceName: params.serviceName,
  1148. data: JSON.stringify({
  1149. "components": [
  1150. {
  1151. "ServiceComponentInfo": {
  1152. "component_name": params.componentName
  1153. }
  1154. }
  1155. ]
  1156. })
  1157. }
  1158. });
  1159. },
  1160. /**
  1161. * Register hosts
  1162. * Queued request
  1163. * @method registerHostsToCluster
  1164. */
  1165. registerHostsToCluster: function () {
  1166. var data = this.createRegisterHostData();
  1167. if (!data.length) return;
  1168. this.addRequestToAjaxQueue({
  1169. name: 'wizard.step8.register_host_to_cluster',
  1170. data: {
  1171. data: JSON.stringify(data)
  1172. }
  1173. });
  1174. },
  1175. /**
  1176. * Format request-data for <code>registerHostsToCluster</code>
  1177. * @returns {Object}
  1178. * @method createRegisterHostData
  1179. */
  1180. createRegisterHostData: function () {
  1181. return this.getRegisteredHosts().filterProperty('isInstalled', false).map(function (host) {
  1182. return {"Hosts": { "host_name": host.hostName}};
  1183. });
  1184. },
  1185. /**
  1186. * Register new master components
  1187. * @uses registerHostsToComponent
  1188. * @method createMasterHostComponents
  1189. */
  1190. createMasterHostComponents: function () {
  1191. // create master components for only selected services.
  1192. var selectedMasterComponents = this.get('content.masterComponentHosts').filter(function (_component) {
  1193. return this.get('selectedServices').mapProperty('serviceName').contains(_component.serviceId)
  1194. }, this);
  1195. selectedMasterComponents.mapProperty('component').uniq().forEach(function (component) {
  1196. var hostNames = selectedMasterComponents.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1197. this.registerHostsToComponent(hostNames, component);
  1198. }, this);
  1199. },
  1200. getClientsToMasterMap: function () {
  1201. var clientNames = App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName'),
  1202. clientsMap = {},
  1203. dependedComponents = App.StackServiceComponent.find().filterProperty('isMaster');
  1204. clientNames.forEach(function (clientName) {
  1205. clientsMap[clientName] = Em.A([]);
  1206. dependedComponents.forEach(function (component) {
  1207. if (component.get('dependencies').mapProperty('componentName').contains(clientName)) clientsMap[clientName].push(component.get('componentName'));
  1208. });
  1209. if (!clientsMap[clientName].length) delete clientsMap[clientName];
  1210. });
  1211. return clientsMap;
  1212. },
  1213. /**
  1214. * Register slave components and clients
  1215. * @uses registerHostsToComponent
  1216. * @method createSlaveAndClientsHostComponents
  1217. */
  1218. createSlaveAndClientsHostComponents: function () {
  1219. var masterHosts = this.get('content.masterComponentHosts');
  1220. var slaveHosts = this.get('content.slaveComponentHosts');
  1221. var clients = this.get('content.clients').filterProperty('isInstalled', false);
  1222. /**
  1223. * Determines on which hosts client should be installed (based on availability of master components on hosts)
  1224. * @type {Object}
  1225. * Format:
  1226. * <code>
  1227. * {
  1228. * CLIENT1: Em.A([MASTER1, MASTER2, ...]),
  1229. * CLIENT2: Em.A([MASTER3, MASTER1, ...])
  1230. * ...
  1231. * }
  1232. * </code>
  1233. */
  1234. var clientsToMasterMap = this.getClientsToMasterMap();
  1235. slaveHosts.forEach(function (_slave) {
  1236. if (_slave.componentName !== 'CLIENT') {
  1237. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1238. this.registerHostsToComponent(hostNames, _slave.componentName);
  1239. }
  1240. else {
  1241. clients.forEach(function (_client) {
  1242. var hostNames = _slave.hosts.mapProperty('hostName');
  1243. // The below logic to install clients to existing/New master hosts should not be applied to Add Host wizard.
  1244. // This is with the presumption that Add Host controller does not add any new Master component to the cluster
  1245. if (this.get('content.controllerName') !== 'addHostController') {
  1246. if (clientsToMasterMap[_client.component_name]) {
  1247. clientsToMasterMap[_client.component_name].forEach(function (componentName) {
  1248. masterHosts.filterProperty('component', componentName).forEach(function (_masterHost) {
  1249. hostNames.pushObject(_masterHost.hostName);
  1250. });
  1251. });
  1252. }
  1253. }
  1254. hostNames = hostNames.uniq();
  1255. this.registerHostsToComponent(hostNames, _client.component_name);
  1256. }, this);
  1257. }
  1258. }, this);
  1259. },
  1260. /**
  1261. * This function is specific to addServiceController
  1262. * Newly introduced master components requires some existing client components to be hosted along with them
  1263. */
  1264. createAdditionalClientComponents: function () {
  1265. var masterHosts = this.get('content.masterComponentHosts');
  1266. var clientsToMasterMap = this.getClientsToMasterMap();
  1267. var installedClients = [];
  1268. // Get all the installed Client components
  1269. this.get('content.services').filterProperty('isInstalled').forEach(function (_service) {
  1270. var serviceClients = App.StackServiceComponent.find().filterProperty('serviceName', _service.get('serviceName')).filterProperty('isClient');
  1271. serviceClients.forEach(function (client) {
  1272. installedClients.push(client.get('componentName'));
  1273. }, this);
  1274. }, this);
  1275. // Check if there is a dependency for being co-hosted between existing client and selected new master
  1276. installedClients.forEach(function (_clientName) {
  1277. if (clientsToMasterMap[_clientName]) {
  1278. var hostNames = [];
  1279. clientsToMasterMap[_clientName].forEach(function (componentName) {
  1280. masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1281. hostNames.pushObject(_masterHost.hostName);
  1282. }, this);
  1283. }, this);
  1284. hostNames = hostNames.uniq();
  1285. if (hostNames.length > 0) {
  1286. this.get('content.additionalClients').pushObject({hostNames: hostNames, componentName: _clientName});
  1287. // If a dependency for being co-hosted is derived between existing client and selected new master but that
  1288. // dependency is already satisfied in the cluster then disregard the derived dependency
  1289. this.removeClientsFromList(_clientName, hostNames);
  1290. this.registerHostsToComponent(hostNames, _clientName);
  1291. }
  1292. }
  1293. }, this);
  1294. },
  1295. /**
  1296. *
  1297. * @param clientName
  1298. * @param hostList
  1299. */
  1300. removeClientsFromList: function (clientName, hostList) {
  1301. var clientHosts = [];
  1302. var installedHosts = this.get('content.hosts');
  1303. for (var hostName in installedHosts) {
  1304. if (installedHosts[hostName].isInstalled) {
  1305. if (installedHosts[hostName].hostComponents.mapProperty('HostRoles.component_name').contains(clientName)) {
  1306. clientHosts.push(hostName);
  1307. }
  1308. }
  1309. }
  1310. if (clientHosts.length > 0) {
  1311. clientHosts.forEach(function (hostName) {
  1312. if (hostList.contains(hostName)) {
  1313. hostList.splice(hostList.indexOf(hostName), 1);
  1314. }
  1315. }, this);
  1316. }
  1317. },
  1318. /**
  1319. * Register additional components
  1320. * Based on availability of some services
  1321. * @uses registerHostsToComponent
  1322. * @method createAdditionalHostComponents
  1323. */
  1324. createAdditionalHostComponents: function () {
  1325. var masterHosts = this.get('content.masterComponentHosts');
  1326. // add MySQL Server if Hive is selected
  1327. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  1328. var gangliaService = this.get('content.services').filterProperty('isSelected').findProperty('serviceName', 'GANGLIA');
  1329. if (gangliaService) {
  1330. var hosts = this.getRegisteredHosts();
  1331. if (gangliaService.get('isInstalled')) {
  1332. hosts = hosts.filterProperty('isInstalled', false);
  1333. }
  1334. if (hosts.length) {
  1335. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  1336. }
  1337. }
  1338. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1339. if (hiveService) {
  1340. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1341. if (hiveDb.value == "New MySQL Database") {
  1342. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1343. } else if (hiveDb.value === "New PostgreSQL Database") {
  1344. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'POSTGRESQL_SERVER');
  1345. }
  1346. }
  1347. },
  1348. /**
  1349. * Register component to hosts
  1350. * Queued request
  1351. * @param {String[]} hostNames
  1352. * @param {String} componentName
  1353. * @method registerHostsToComponent
  1354. */
  1355. registerHostsToComponent: function (hostNames, componentName) {
  1356. if (!hostNames.length) return;
  1357. var queryStr = '';
  1358. hostNames.forEach(function (hostName) {
  1359. queryStr += 'Hosts/host_name=' + hostName + '|';
  1360. });
  1361. //slice off last symbol '|'
  1362. queryStr = queryStr.slice(0, -1);
  1363. var data = {
  1364. "RequestInfo": {
  1365. "query": queryStr
  1366. },
  1367. "Body": {
  1368. "host_components": [
  1369. {
  1370. "HostRoles": {
  1371. "component_name": componentName
  1372. }
  1373. }
  1374. ]
  1375. }
  1376. };
  1377. this.addRequestToAjaxQueue({
  1378. name: 'wizard.step8.register_host_to_component',
  1379. data: {
  1380. data: JSON.stringify(data)
  1381. }
  1382. });
  1383. },
  1384. /**
  1385. * Compare generated config object with current configs that were filled
  1386. * on "Customize Services" page.
  1387. *
  1388. * @param {Object} properties - generated by createSiteObj|createCoreSiteObj
  1389. * @param {Array} configs - current configs to compare
  1390. * @return {Boolean}
  1391. * @method isConfigsChanged
  1392. **/
  1393. isConfigsChanged: function (properties, configs) {
  1394. var isChanged = false;
  1395. for (var property in properties) {
  1396. var config = configs.findProperty('name', property);
  1397. // if config not found then it's looks like a new config
  1398. if (!config) {
  1399. isChanged = true;
  1400. } else {
  1401. if (!config.hasInitialValue || config.isNotDefaultValue) {
  1402. isChanged = true;
  1403. }
  1404. }
  1405. }
  1406. return isChanged;
  1407. },
  1408. /**
  1409. * Create config objects for cluster and services
  1410. * @method createConfigurations
  1411. */
  1412. createConfigurations: function () {
  1413. var selectedServices = this.get('selectedServices');
  1414. var coreSiteObject = this.createCoreSiteObj();
  1415. var tag = 'version1';
  1416. var clusterSiteObj = this.createSiteObj('cluster-env', tag);
  1417. if (this.get('content.controllerName') == 'installerController') {
  1418. this.get('serviceConfigTags').pushObject(clusterSiteObj);
  1419. }
  1420. if (this.get('content.controllerName') == 'addServiceController') {
  1421. tag = 'version' + (new Date).getTime();
  1422. coreSiteObject.tag = tag;
  1423. var coreSiteConfigs = this.get('configs').filterProperty('filename', 'core-site.xml');
  1424. if (this.isConfigsChanged(coreSiteObject.properties, coreSiteConfigs)) {
  1425. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1426. }
  1427. }
  1428. selectedServices.forEach(function (service) {
  1429. Object.keys(service.get('configTypes')).forEach(function (type) {
  1430. if (!this.get('serviceConfigTags').someProperty('type', type)) {
  1431. var serviceVersionNotes = Em.I18n.t('dashboard.configHistory.table.notes.default').format(service.get('displayName'));
  1432. if (service.get('serviceName') === 'MAPREDUCE' && (type === 'capacity-scheduler' || type === 'mapred-queue-acls')) {
  1433. return;
  1434. } else if (type === 'core-site') {
  1435. coreSiteObject.service_config_version_note = serviceVersionNotes;
  1436. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1437. } else if (type === 'storm-site') {
  1438. var obj = this.createStormSiteObj(tag);
  1439. obj.service_config_version_note = serviceVersionNotes;
  1440. this.get('serviceConfigTags').pushObject(obj);
  1441. } else {
  1442. var obj = this.createSiteObj(type, tag);
  1443. obj.service_config_version_note = serviceVersionNotes;
  1444. this.get('serviceConfigTags').pushObject(obj);
  1445. }
  1446. }
  1447. }, this);
  1448. }, this);
  1449. },
  1450. /**
  1451. * Send <code>serviceConfigTags</code> to server
  1452. * Queued request
  1453. * One request for each service config tag
  1454. * @param serviceConfigTags
  1455. * @method applyConfigurationsToCluster
  1456. */
  1457. applyConfigurationsToCluster: function (serviceConfigTags) {
  1458. var allServices = this.get('installedServices').concat(this.get('selectedServices'));
  1459. var allConfigData = [];
  1460. allServices.forEach(function (service) {
  1461. var serviceConfigData = [];
  1462. Object.keys(service.get('configTypesRendered')).forEach(function (type) {
  1463. var serviceConfigTag = serviceConfigTags.findProperty('type', type);
  1464. if (serviceConfigTag) {
  1465. serviceConfigData.pushObject(serviceConfigTag);
  1466. }
  1467. }, this);
  1468. if (serviceConfigData.length) {
  1469. allConfigData.pushObject(JSON.stringify({
  1470. Clusters: {
  1471. desired_config: serviceConfigData
  1472. }
  1473. }));
  1474. }
  1475. }, this);
  1476. var clusterConfig = serviceConfigTags.findProperty('type', 'cluster-env');
  1477. if (clusterConfig) {
  1478. allConfigData.pushObject(JSON.stringify({
  1479. Clusters: {
  1480. desired_config: [clusterConfig]
  1481. }
  1482. }));
  1483. }
  1484. this.addRequestToAjaxQueue({
  1485. name: 'common.across.services.configurations',
  1486. data: {
  1487. data: '[' + allConfigData.toString() + ']'
  1488. }
  1489. });
  1490. },
  1491. /**
  1492. * Create and update config groups
  1493. * @method createConfigurationGroups
  1494. */
  1495. createConfigurationGroups: function () {
  1496. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1497. var clusterName = this.get('clusterName');
  1498. var sendData = [];
  1499. var updateData = [];
  1500. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1501. var timeTag = (new Date).getTime();
  1502. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1503. if (groupsToDelete && groupsToDelete.length > 0) {
  1504. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1505. }
  1506. configGroups.forEach(function (configGroup) {
  1507. var groupConfigs = [];
  1508. var groupData = {
  1509. "cluster_name": clusterName,
  1510. "group_name": configGroup.name,
  1511. "tag": configGroup.service.id,
  1512. "description": configGroup.description,
  1513. "hosts": [],
  1514. "desired_configs": []
  1515. };
  1516. configGroup.hosts.forEach(function (hostName) {
  1517. groupData.hosts.push({"host_name": hostName});
  1518. });
  1519. // get properties that was created for non-default config group
  1520. configGroup.properties = configGroup.properties.concat(this.get('customNonDefaultGroupConfigs').filterProperty('group', configGroup.name));
  1521. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1522. configGroup.properties.forEach(function (property) {
  1523. groupConfigs.push(Em.Object.create(property));
  1524. });
  1525. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1526. // check for group from installed service
  1527. if (configGroup.isForInstalledService === true) {
  1528. // if group is a new one, create it
  1529. if (!configGroup.id) {
  1530. sendData.push({"ConfigGroup": groupData});
  1531. } else if (configGroup.isForUpdate){
  1532. // update an existing group
  1533. groupData.id = configGroup.id;
  1534. updateData.push({"ConfigGroup": groupData});
  1535. }
  1536. } else {
  1537. sendData.push({"ConfigGroup": groupData});
  1538. }
  1539. //each group should have unique tag to prevent overriding configs from common sites
  1540. timeTag++;
  1541. }, this);
  1542. if (sendData.length > 0) {
  1543. this.applyConfigurationGroups(sendData);
  1544. }
  1545. if (updateData.length > 0) {
  1546. this.applyInstalledServicesConfigurationGroup(updateData);
  1547. }
  1548. },
  1549. /**
  1550. * Create new config groups request
  1551. * Queued request
  1552. * @param {Object[]} sendData
  1553. * @method applyConfigurationGroups
  1554. */
  1555. applyConfigurationGroups: function (sendData) {
  1556. this.addRequestToAjaxQueue({
  1557. name: 'wizard.step8.apply_configuration_groups',
  1558. data: {
  1559. data: JSON.stringify(sendData)
  1560. }
  1561. });
  1562. },
  1563. /**
  1564. * Update existed config groups
  1565. * Separated request for each group
  1566. * @param {Object[]} updateData
  1567. * @method applyInstalledServicesConfigurationGroup
  1568. */
  1569. applyInstalledServicesConfigurationGroup: function (updateData) {
  1570. updateData.forEach(function (item) {
  1571. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1572. });
  1573. },
  1574. /**
  1575. * Delete selected config groups
  1576. * @param {Object[]} groupsToDelete
  1577. * @method removeInstalledServicesConfigurationGroups
  1578. */
  1579. removeInstalledServicesConfigurationGroups: function (groupsToDelete) {
  1580. groupsToDelete.forEach(function (item) {
  1581. App.config.deleteConfigGroup(Em.Object.create(item));
  1582. });
  1583. },
  1584. /**
  1585. * proxyuser configs which depend on service
  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 (_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. });