step3_controller.js 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074
  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 lazyloading = require('utils/lazy_loading');
  20. var numberUtils = require('utils/number_utils');
  21. App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, {
  22. name: 'wizardStep3Controller',
  23. hosts: [],
  24. content: [],
  25. bootHosts: [],
  26. registeredHosts: [],
  27. /**
  28. * @typedef {{
  29. * name: string,
  30. * hosts: string[],
  31. * hostsLong: string[],
  32. * hostsNames: string[],
  33. * onSingleHost: boolean
  34. * }} checkWarning
  35. */
  36. /**
  37. * @type {checkWarning[]}
  38. */
  39. hostCheckWarnings: [],
  40. /**
  41. * @type {checkWarning[]}
  42. */
  43. repoCategoryWarnings: [],
  44. /**
  45. * @type {checkWarning[]}
  46. */
  47. diskCategoryWarnings: [],
  48. /**
  49. * @type {checkWarning[]}
  50. */
  51. thpCategoryWarnings: [],
  52. /**
  53. * @type {checkWarning[]}
  54. */
  55. jdkCategoryWarnings: null,
  56. jdkRequestIndex: null,
  57. registrationStartedAt: null,
  58. hostCheckResult: null,
  59. requestId: 0,
  60. /**
  61. * Timeout for registration
  62. * Based on <code>installOptions.manualInstall</code>
  63. * @type {number}
  64. */
  65. registrationTimeoutSecs: Em.computed.ifThenElse('content.installOptions.manualInstall', 15, 120),
  66. /**
  67. * Bootstrap calls are stopped
  68. * @type {bool}
  69. */
  70. stopBootstrap: false,
  71. /**
  72. * is Submit button disabled
  73. * @type {bool}
  74. */
  75. isSubmitDisabled: true,
  76. /**
  77. * True if bootstrap POST request failed
  78. * @type {bool}
  79. */
  80. isBootstrapFailed: false,
  81. /**
  82. * is Retry button disabled
  83. * @type {bool}
  84. */
  85. isRetryDisabled: function() {
  86. return this.get('isBackDisabled') ? this.get('isBackDisabled') : !this.get('bootHosts').filterProperty('bootStatus', 'FAILED').length;
  87. }.property('bootHosts.@each.bootStatus', 'isBackDisabled'),
  88. /**
  89. * Is Back button disabled
  90. * @return {bool}
  91. */
  92. isBackDisabled: function () {
  93. return (this.get('isRegistrationInProgress') || !this.get('isWarningsLoaded')) && !this.get('isBootstrapFailed');
  94. }.property('isRegistrationInProgress', 'isWarningsLoaded', 'isBootstrapFailed'),
  95. /**
  96. * Controller is using in Add Host Wizard
  97. * @return {bool}
  98. */
  99. isAddHostWizard: Em.computed.equal('content.controllerName', 'addHostController'),
  100. /**
  101. * @type {bool}
  102. */
  103. isLoaded: false,
  104. /**
  105. * Polls count
  106. * @type {number}
  107. */
  108. numPolls: 0,
  109. /**
  110. * Is hosts registration in progress
  111. * @type {bool}
  112. */
  113. isRegistrationInProgress: true,
  114. /**
  115. * Are some registered hosts which are not added by user
  116. * @type {bool}
  117. */
  118. hasMoreRegisteredHosts: false,
  119. /**
  120. * Contain data about installed packages on hosts
  121. * @type {Array}
  122. */
  123. hostsPackagesData: [],
  124. /**
  125. * List of installed hostnames
  126. * @type {string[]}
  127. */
  128. hostsInCluster: function () {
  129. var installedHostsName = [];
  130. var hosts = this.get('content.hosts');
  131. for (var hostName in hosts) {
  132. if (hosts[hostName].isInstalled) {
  133. installedHostsName.push(hostName);
  134. }
  135. }
  136. return installedHostsName;
  137. }.property('content.hosts'),
  138. /**
  139. * All hosts warnings
  140. * @type {object[]}
  141. */
  142. warnings: [],
  143. /**
  144. * Warnings grouped by host
  145. * @type {Ember.Enumerable}
  146. */
  147. warningsByHost: [],
  148. /**
  149. * Timeout for "warning"-requests
  150. * @type {number}
  151. */
  152. warningsTimeInterval: 60000,
  153. /**
  154. * Are hosts warnings loaded
  155. * @type {bool}
  156. */
  157. isWarningsLoaded: Em.computed.and('isJDKWarningsLoaded', 'isHostsWarningsLoaded'),
  158. /**
  159. * Check are hosts have any warnings
  160. * @type {bool}
  161. */
  162. isHostHaveWarnings: Em.computed.gt('warnings.length', 0),
  163. /**
  164. * Should warnings-box be visible
  165. * @type {bool}
  166. */
  167. isWarningsBoxVisible: function () {
  168. return (App.get('testMode')) ? true : !this.get('isRegistrationInProgress');
  169. }.property('isRegistrationInProgress'),
  170. /**
  171. * Progress value for "update hosts status" process
  172. * @type {number}
  173. */
  174. checksUpdateProgress: 0,
  175. /**
  176. *
  177. * @type {object}
  178. */
  179. checksUpdateStatus: null,
  180. /**
  181. *
  182. * @method navigateStep
  183. */
  184. navigateStep: function () {
  185. if (this.get('isLoaded')) {
  186. if (!this.get('content.installOptions.manualInstall')) {
  187. if (!this.get('wizardController').getDBProperty('bootStatus')) {
  188. this.setupBootStrap();
  189. }
  190. } else {
  191. this.set('bootHosts', this.get('hosts'));
  192. if (App.get('testMode')) {
  193. this.startHostcheck();
  194. this.get('bootHosts').setEach('cpu', '2');
  195. this.get('bootHosts').setEach('memory', '2000000');
  196. this.set('isSubmitDisabled', false);
  197. } else {
  198. this.set('registrationStartedAt', null);
  199. this.startRegistration();
  200. }
  201. }
  202. }
  203. }.observes('isLoaded'),
  204. /**
  205. * Clear controller data
  206. * @method clearStep
  207. */
  208. clearStep: function () {
  209. this.set('stopBootstrap', false);
  210. this.set('hosts', []);
  211. this.get('bootHosts').clear();
  212. this.get('wizardController').setDBProperty('bootStatus', false);
  213. this.set('isHostsWarningsLoaded', false);
  214. this.set('isJDKWarningsLoaded', false);
  215. this.set('registrationStartedAt', null);
  216. this.set('isLoaded', false);
  217. this.set('isSubmitDisabled', true);
  218. this.set('stopChecking', false);
  219. },
  220. /**
  221. * setup bootstrap data and completion callback for bootstrap call
  222. * @method setupBootStrap
  223. */
  224. setupBootStrap: function () {
  225. var self = this;
  226. var bootStrapData = JSON.stringify({
  227. 'verbose': true,
  228. 'sshKey': this.get('content.installOptions.sshKey'),
  229. 'hosts': this.getBootstrapHosts(),
  230. 'user': this.get('content.installOptions.sshUser'),
  231. 'sshPort': this.get('content.installOptions.sshPort'),
  232. 'userRunAs': App.get('supports.customizeAgentUserAccount') ? this.get('content.installOptions.agentUser') : 'root'
  233. });
  234. App.router.get(this.get('content.controllerName')).launchBootstrap(bootStrapData, function (requestId) {
  235. if (requestId == '0') {
  236. self.startBootstrap();
  237. } else if (requestId) {
  238. self.set('content.installOptions.bootRequestId', requestId);
  239. App.router.get(self.get('content.controllerName')).save('installOptions');
  240. self.startBootstrap();
  241. }
  242. });
  243. },
  244. getBootstrapHosts: function () {
  245. var hosts = this.get('content.hosts');
  246. var bootstrapHosts = [];
  247. for (var host in hosts) {
  248. if (hosts.hasOwnProperty(host)) {
  249. if (!hosts[host].isInstalled) {
  250. bootstrapHosts.push(host);
  251. }
  252. }
  253. }
  254. return bootstrapHosts;
  255. },
  256. /**
  257. * Make basic init steps
  258. * @method loadStep
  259. */
  260. loadStep: function () {
  261. var wizardController = this.get('wizardController');
  262. var previousStep = wizardController && wizardController.get('previousStep');
  263. var currentStep = wizardController && wizardController.get('currentStep');
  264. var isHostsLoaded = this.get('hosts').length !== 0;
  265. var isPrevAndCurrStepsSetted = previousStep && currentStep;
  266. var isPrevStepSmallerThenCurrent = previousStep < currentStep;
  267. if (!isHostsLoaded || isPrevStepSmallerThenCurrent ||
  268. !wizardController || !isPrevAndCurrStepsSetted) {
  269. this.disablePreviousSteps();
  270. this.clearStep();
  271. App.router.get('clusterController').loadAmbariProperties();
  272. this.loadHosts();
  273. }
  274. },
  275. /**
  276. * Loads the hostinfo from localStorage on the insertion of view. It's being called from view
  277. * @method loadHosts
  278. */
  279. loadHosts: function () {
  280. var hostsInfo = this.get('content.hosts');
  281. var hosts = [];
  282. var bootStatus = (this.get('content.installOptions.manualInstall')) ? 'DONE' : 'PENDING';
  283. if (App.get('testMode')) {
  284. bootStatus = 'REGISTERED';
  285. }
  286. for (var index in hostsInfo) {
  287. if (hostsInfo.hasOwnProperty(index) && !hostsInfo[index].isInstalled) {
  288. hosts.pushObject(App.HostInfo.create({
  289. name: hostsInfo[index].name,
  290. bootStatus: bootStatus,
  291. isChecked: false
  292. }));
  293. }
  294. }
  295. this.set('hosts', hosts);
  296. this.set('isLoaded', true);
  297. },
  298. /**
  299. * Parses and updates the content based on bootstrap API response.
  300. * @return {bool} true if polling should continue (some hosts are in "RUNNING" state); false otherwise
  301. * @method parseHostInfo
  302. */
  303. parseHostInfo: function (hostsStatusFromServer) {
  304. hostsStatusFromServer.forEach(function (_hostStatus) {
  305. var host = this.get('bootHosts').findProperty('name', _hostStatus.hostName);
  306. // check if hostname extracted from REST API data matches any hostname in content
  307. // also, make sure that bootStatus modified by isHostsRegistered call does not get overwritten
  308. // since these calls are being made in parallel
  309. if (host && !['REGISTERED', 'REGISTERING'].contains(host.get('bootStatus'))) {
  310. host.set('bootStatus', _hostStatus.status);
  311. host.set('bootLog', _hostStatus.log);
  312. }
  313. }, this);
  314. // if the data rendered by REST API has hosts in "RUNNING" state, polling will continue
  315. return this.get('bootHosts').length != 0 && this.get('bootHosts').someProperty('bootStatus', 'RUNNING');
  316. },
  317. /**
  318. * Remove list of hosts
  319. * @param {Ember.Enumerable} hosts
  320. * @return {App.ModalPopup}
  321. * @method removeHosts
  322. */
  323. removeHosts: function (hosts) {
  324. var self = this;
  325. return App.showConfirmationPopup(function () {
  326. App.router.send('removeHosts', hosts);
  327. self.hosts.removeObjects(hosts);
  328. self.stopRegistration();
  329. if (!self.hosts.length) {
  330. self.set('isSubmitDisabled', true);
  331. }
  332. }, Em.I18n.t('installer.step3.hosts.remove.popup.body'));
  333. },
  334. /**
  335. * Removes a single element on the trash icon click. Called from View
  336. * @param {object} hostInfo
  337. * @method removeHost
  338. */
  339. removeHost: function (hostInfo) {
  340. if (!this.get('isBackDisabled'))
  341. this.removeHosts([hostInfo]);
  342. },
  343. /**
  344. * Remove selected hosts (click-handler)
  345. * @return App.ModalPopup
  346. * @method removeSelectedHosts
  347. */
  348. removeSelectedHosts: function () {
  349. var selectedHosts = this.get('hosts').filterProperty('isChecked', true);
  350. return this.removeHosts(selectedHosts);
  351. },
  352. /**
  353. * Show popup with the list of hosts which are selected
  354. * @return App.ModalPopup
  355. * @method selectedHostsPopup
  356. */
  357. selectedHostsPopup: function () {
  358. var selectedHosts = this.get('hosts').filterProperty('isChecked').mapProperty('name');
  359. return App.ModalPopup.show({
  360. header: Em.I18n.t('installer.step3.selectedHosts.popup.header'),
  361. secondary: null,
  362. bodyClass: Em.View.extend({
  363. templateName: require('templates/common/items_list_popup'),
  364. items: selectedHosts,
  365. insertedItems: [],
  366. didInsertElement: function () {
  367. lazyloading.run({
  368. destination: this.get('insertedItems'),
  369. source: this.get('items'),
  370. context: this,
  371. initSize: 100,
  372. chunkSize: 500,
  373. delay: 100
  374. });
  375. }
  376. })
  377. });
  378. },
  379. /**
  380. * Retry one host {click-handler}
  381. * @param {object} hostInfo
  382. * @method retryHost
  383. */
  384. retryHost: function (hostInfo) {
  385. this.retryHosts([hostInfo]);
  386. },
  387. /**
  388. * Retry list of hosts
  389. * @param {object[]} hosts
  390. * @method retryHosts
  391. */
  392. retryHosts: function (hosts) {
  393. var self = this;
  394. var bootStrapData = JSON.stringify({
  395. 'verbose': true,
  396. 'sshKey': this.get('content.installOptions.sshKey'),
  397. 'hosts': hosts.mapProperty('name'),
  398. 'user': this.get('content.installOptions.sshUser'),
  399. 'sshPort': this.get('content.installOptions.sshPort'),
  400. 'userRunAs': App.get('supports.customizeAgentUserAccount') ? this.get('content.installOptions.agentUser') : 'root'
  401. });
  402. this.set('numPolls', 0);
  403. this.set('registrationStartedAt', null);
  404. this.set('isHostsWarningsLoaded', false);
  405. this.set('stopChecking', false);
  406. this.set('isSubmitDisabled', true);
  407. if (this.get('content.installOptions.manualInstall')) {
  408. this.startRegistration();
  409. } else {
  410. App.router.get(this.get('content.controllerName')).launchBootstrap(bootStrapData, function (requestId) {
  411. self.set('content.installOptions.bootRequestId', requestId);
  412. self.doBootstrap();
  413. });
  414. }
  415. },
  416. /**
  417. * Retry selected hosts (click-handler)
  418. * @method retrySelectedHosts
  419. */
  420. retrySelectedHosts: function () {
  421. if (!this.get('isRetryDisabled')) {
  422. var selectedHosts = this.get('bootHosts').filterProperty('bootStatus', 'FAILED');
  423. selectedHosts.forEach(function (_host) {
  424. _host.set('bootStatus', 'DONE');
  425. _host.set('bootLog', 'Retrying ...');
  426. }, this);
  427. this.retryHosts(selectedHosts);
  428. }
  429. },
  430. /**
  431. * Init bootstrap settings and start it
  432. * @method startBootstrap
  433. */
  434. startBootstrap: function () {
  435. //this.set('isSubmitDisabled', true); //TODO: uncomment after actual hookup
  436. this.set('numPolls', 0);
  437. this.set('registrationStartedAt', null);
  438. this.set('bootHosts', this.get('hosts'));
  439. this.doBootstrap();
  440. },
  441. /**
  442. * Update <code>isRegistrationInProgress</code> once
  443. * @method setRegistrationInProgressOnce
  444. */
  445. setRegistrationInProgressOnce: function () {
  446. Em.run.once(this, 'setRegistrationInProgress');
  447. }.observes('bootHosts.@each.bootStatus'),
  448. /**
  449. * Set <code>isRegistrationInProgress</code> value based on each host boot status
  450. * @method setRegistrationInProgress
  451. */
  452. setRegistrationInProgress: function () {
  453. var bootHosts = this.get('bootHosts');
  454. //if hosts aren't loaded yet then registration should be in progress
  455. var result = (bootHosts.length === 0 && !this.get('isLoaded'));
  456. for (var i = 0, l = bootHosts.length; i < l; i++) {
  457. if (bootHosts[i].get('bootStatus') !== 'REGISTERED' && bootHosts[i].get('bootStatus') !== 'FAILED') {
  458. result = true;
  459. break;
  460. }
  461. }
  462. this.set('isRegistrationInProgress', result);
  463. },
  464. /**
  465. * Disable wizard's previous steps (while registering)
  466. * @method disablePreviousSteps
  467. */
  468. disablePreviousSteps: function () {
  469. App.router.get('installerController.isStepDisabled').filter(function (step) {
  470. return step.step >= 0 && step.step <= 2;
  471. }).setEach('value', this.get('isBackDisabled'));
  472. App.router.get('addHostController.isStepDisabled').filter(function (step) {
  473. return step.step >= 0 && step.step <= 1;
  474. }).setEach('value', this.get('isBackDisabled'));
  475. }.observes('isBackDisabled'),
  476. /**
  477. * Do bootstrap calls
  478. * @method doBootstrap
  479. * @return {$.ajax|null}
  480. */
  481. doBootstrap: function () {
  482. if (this.get('stopBootstrap')) {
  483. return null;
  484. }
  485. this.incrementProperty('numPolls');
  486. return App.ajax.send({
  487. name: 'wizard.step3.bootstrap',
  488. sender: this,
  489. data: {
  490. bootRequestId: this.get('content.installOptions.bootRequestId'),
  491. numPolls: this.get('numPolls'),
  492. errorLogMessage: 'Bootstrap failed',
  493. callback: this.doBootstrap,
  494. shouldUseDefaultHandler: true
  495. },
  496. success: 'doBootstrapSuccessCallback',
  497. error: 'reloadErrorCallback'
  498. });
  499. },
  500. /**
  501. * Success-callback for each boostrap request
  502. * @param {object} data
  503. * @method doBootstrapSuccessCallback
  504. */
  505. doBootstrapSuccessCallback: function (data) {
  506. var self = this;
  507. var pollingInterval = 3000;
  508. this.reloadSuccessCallback();
  509. if (Em.isNone(data.hostsStatus)) {
  510. window.setTimeout(function () {
  511. self.doBootstrap()
  512. }, pollingInterval);
  513. } else {
  514. // in case of bootstrapping just one host, the server returns an object rather than an array, so
  515. // force into an array
  516. if (!(data.hostsStatus instanceof Array)) {
  517. data.hostsStatus = [ data.hostsStatus ];
  518. }
  519. var keepPolling = this.parseHostInfo(data.hostsStatus);
  520. // Single host : if the only hostname is invalid (data.status == 'ERROR')
  521. // Multiple hosts : if one or more hostnames are invalid
  522. // following check will mark the bootStatus as 'FAILED' for the invalid hostname
  523. var installedHosts = App.Host.find().mapProperty('hostName');
  524. var isErrorStatus = data.status == 'ERROR';
  525. this.set('isBootstrapFailed', isErrorStatus);
  526. if (isErrorStatus || data.hostsStatus.mapProperty('hostName').removeObjects(installedHosts).length != this.get('bootHosts').length) {
  527. var hosts = this.get('bootHosts');
  528. for (var i = 0; i < hosts.length; i++) {
  529. var isValidHost = data.hostsStatus.someProperty('hostName', hosts[i].get('name'));
  530. if (hosts[i].get('bootStatus') !== 'REGISTERED') {
  531. if (!isValidHost) {
  532. hosts[i].set('bootStatus', 'FAILED');
  533. hosts[i].set('bootLog', Em.I18n.t('installer.step3.hosts.bootLog.failed'));
  534. }
  535. }
  536. }
  537. }
  538. if (isErrorStatus || data.hostsStatus.someProperty('status', 'DONE') || data.hostsStatus.someProperty('status', 'FAILED')) {
  539. // kicking off registration polls after at least one host has succeeded
  540. this.startRegistration();
  541. }
  542. if (keepPolling) {
  543. window.setTimeout(function () {
  544. self.doBootstrap()
  545. }, pollingInterval);
  546. }
  547. }
  548. },
  549. /**
  550. * Start hosts registration
  551. * @method startRegistration
  552. */
  553. startRegistration: function () {
  554. if (Em.isNone(this.get('registrationStartedAt'))) {
  555. this.set('registrationStartedAt', App.dateTime());
  556. this.isHostsRegistered();
  557. }
  558. },
  559. /**
  560. * Do requests to check if hosts are already registered
  561. * @return {$.ajax|null}
  562. * @method isHostsRegistered
  563. */
  564. isHostsRegistered: function () {
  565. if (this.get('stopBootstrap')) {
  566. return null;
  567. }
  568. return App.ajax.send({
  569. name: 'wizard.step3.is_hosts_registered',
  570. sender: this,
  571. success: 'isHostsRegisteredSuccessCallback',
  572. error: 'reloadErrorCallback',
  573. data: {
  574. errorLogMessage: 'Error: Getting registered host information from the server',
  575. callback: this.isHostsRegistered,
  576. shouldUseDefaultHandler: true
  577. }
  578. });
  579. },
  580. /**
  581. * Success-callback for registered hosts request
  582. * @param {object} data
  583. * @method isHostsRegisteredSuccessCallback
  584. */
  585. isHostsRegisteredSuccessCallback: function (data) {
  586. var hosts = this.get('bootHosts');
  587. var jsonData = data;
  588. this.reloadSuccessCallback();
  589. if (!jsonData) {
  590. return;
  591. }
  592. // keep polling until all hosts have registered/failed, or registrationTimeout seconds after the last host finished bootstrapping
  593. var stopPolling = true;
  594. hosts.forEach(function (_host, index) {
  595. // Change name of first host for test mode.
  596. if (App.get('testMode')) {
  597. if (index == 0) {
  598. _host.set('name', 'localhost.localdomain');
  599. }
  600. }
  601. // actions to take depending on the host's current bootStatus
  602. // RUNNING - bootstrap is running; leave it alone
  603. // DONE - bootstrap is done; transition to REGISTERING
  604. // REGISTERING - bootstrap is done but has not registered; transition to REGISTERED if host found in polling API result
  605. // REGISTERED - bootstrap and registration is done; leave it alone
  606. // FAILED - either bootstrap or registration failed; leave it alone
  607. switch (_host.get('bootStatus')) {
  608. case 'DONE':
  609. _host.set('bootStatus', 'REGISTERING');
  610. _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
  611. // update registration timestamp so that the timeout is computed from the last host that finished bootstrapping
  612. this.set('registrationStartedAt', App.dateTime());
  613. stopPolling = false;
  614. break;
  615. case 'REGISTERING':
  616. if (jsonData.items.someProperty('Hosts.host_name', _host.name) && !jsonData.items.filterProperty('Hosts.host_name', _host.name).someProperty('Hosts.host_status', 'UNKNOWN')) {
  617. _host.set('bootStatus', 'REGISTERED');
  618. _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
  619. } else {
  620. stopPolling = false;
  621. }
  622. break;
  623. case 'RUNNING':
  624. stopPolling = false;
  625. break;
  626. case 'REGISTERED':
  627. case 'FAILED':
  628. default:
  629. break;
  630. }
  631. }, this);
  632. if (stopPolling) {
  633. this.startHostcheck();
  634. }
  635. else {
  636. if (hosts.someProperty('bootStatus', 'RUNNING') || App.dateTime() - this.get('registrationStartedAt') < this.get('registrationTimeoutSecs') * 1000) {
  637. // we want to keep polling for registration status if any of the hosts are still bootstrapping (so we check for RUNNING).
  638. var self = this;
  639. window.setTimeout(function () {
  640. self.isHostsRegistered();
  641. }, 3000);
  642. }
  643. else {
  644. // registration timed out. mark all REGISTERING hosts to FAILED
  645. hosts.filterProperty('bootStatus', 'REGISTERING').forEach(function (_host) {
  646. _host.set('bootStatus', 'FAILED');
  647. _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.failed'));
  648. });
  649. this.startHostcheck();
  650. }
  651. }
  652. },
  653. /**
  654. * Do request for all registered hosts
  655. * @return {$.ajax}
  656. * @method getAllRegisteredHosts
  657. */
  658. getAllRegisteredHosts: function () {
  659. return App.ajax.send({
  660. name: 'wizard.step3.is_hosts_registered',
  661. sender: this,
  662. success: 'getAllRegisteredHostsCallback'
  663. });
  664. }.observes('bootHosts'),
  665. /**
  666. * Success-callback for all registered hosts request
  667. * @param {object} hosts
  668. * @method getAllRegisteredHostsCallback
  669. */
  670. getAllRegisteredHostsCallback: function (hosts) {
  671. var registeredHosts = [];
  672. var hostsInCluster = this.get('hostsInCluster');
  673. var addedHosts = this.get('bootHosts').getEach('name');
  674. hosts.items.forEach(function (host) {
  675. if (!hostsInCluster.contains(host.Hosts.host_name) && !addedHosts.contains(host.Hosts.host_name)) {
  676. registeredHosts.push(host.Hosts.host_name);
  677. }
  678. });
  679. if (registeredHosts.length) {
  680. this.set('hasMoreRegisteredHosts', true);
  681. this.set('registeredHosts', registeredHosts);
  682. } else {
  683. this.set('hasMoreRegisteredHosts', false);
  684. this.set('registeredHosts', '');
  685. }
  686. },
  687. /**
  688. * Show popup with regitration error-message
  689. * @param {string} header
  690. * @param {string} message
  691. * @return {App.ModalPopup}
  692. * @method registerErrPopup
  693. */
  694. registerErrPopup: function (header, message) {
  695. return App.ModalPopup.show({
  696. header: header,
  697. secondary: false,
  698. bodyClass: Em.View.extend({
  699. template: Em.Handlebars.compile('<p>{{view.message}}</p>'),
  700. message: message
  701. })
  702. });
  703. },
  704. /**
  705. * Get JDK name from server to determine if user had setup a customized JDK path when doing 'ambari-server setup'.
  706. * The Ambari properties are different from default ambari-server setup, property 'jdk.name' will be missing if a customized jdk path is applied.
  707. * @return {$.ajax}
  708. * @method getJDKName
  709. */
  710. getJDKName: function () {
  711. return App.ajax.send({
  712. name: 'ambari.service',
  713. sender: this,
  714. data: {
  715. fields : '?fields=RootServiceComponents/properties/jdk.name,RootServiceComponents/properties/java.home,RootServiceComponents/properties/jdk_location'
  716. },
  717. success: 'getJDKNameSuccessCallback'
  718. });
  719. },
  720. /**
  721. * Success callback for JDK name, property 'jdk.name' will be missing if a customized jdk path is applied
  722. * @param {object} data
  723. * @method getJDKNameSuccessCallback
  724. */
  725. getJDKNameSuccessCallback: function (data) {
  726. this.set('needJDKCheckOnHosts', !data.RootServiceComponents.properties["jdk.name"]);
  727. this.set('jdkLocation', Em.get(data, "RootServiceComponents.properties.jdk_location"));
  728. this.set('javaHome', data.RootServiceComponents.properties["java.home"]);
  729. },
  730. doCheckJDK: function () {
  731. var hostsNames = (!this.get('content.installOptions.manualInstall')) ? this.get('bootHosts').filterProperty('bootStatus', 'REGISTERED').getEach('name').join(",") : this.get('bootHosts').getEach('name').join(",");
  732. var javaHome = this.get('javaHome');
  733. var jdkLocation = this.get('jdkLocation');
  734. App.ajax.send({
  735. name: 'wizard.step3.jdk_check',
  736. sender: this,
  737. data: {
  738. host_names: hostsNames,
  739. java_home: javaHome,
  740. jdk_location: jdkLocation
  741. },
  742. success: 'doCheckJDKsuccessCallback',
  743. error: 'doCheckJDKerrorCallback'
  744. });
  745. },
  746. doCheckJDKsuccessCallback: function (data) {
  747. if(data){
  748. this.set('jdkRequestIndex', data.href.split('/')[data.href.split('/').length - 1]);
  749. }
  750. if (this.get('jdkCategoryWarnings') == null) {
  751. // get jdk check results for all hosts
  752. App.ajax.send({
  753. name: 'wizard.step3.jdk_check.get_results',
  754. sender: this,
  755. data: {
  756. requestIndex: this.get('jdkRequestIndex')
  757. },
  758. success: 'parseJDKCheckResults'
  759. })
  760. } else {
  761. this.set('isJDKWarningsLoaded', true);
  762. }
  763. },
  764. doCheckJDKerrorCallback: function () {
  765. this.set('isJDKWarningsLoaded', true);
  766. },
  767. parseJDKCheckResults: function (data) {
  768. var jdkWarnings = [], hostsJDKContext = [], hostsJDKNames = [];
  769. // check if the request ended
  770. if (data.Requests.end_time > 0 && data.tasks) {
  771. data.tasks.forEach( function(task) {
  772. // generate warning context
  773. if (Em.get(task, "Tasks.structured_out.java_home_check.exit_code") == 1){
  774. var jdkContext = Em.I18n.t('installer.step3.hostWarningsPopup.jdk.context').format(task.Tasks.host_name);
  775. hostsJDKContext.push(jdkContext);
  776. hostsJDKNames.push(task.Tasks.host_name);
  777. }
  778. });
  779. if (hostsJDKContext.length > 0) { // java jdk warning exist
  780. var invalidJavaHome = this.get('javaHome');
  781. jdkWarnings.push({
  782. name: Em.I18n.t('installer.step3.hostWarningsPopup.jdk.name').format(invalidJavaHome),
  783. hosts: hostsJDKContext,
  784. hostsLong: hostsJDKContext,
  785. hostsNames: hostsJDKNames,
  786. category: 'jdk',
  787. onSingleHost: false
  788. });
  789. }
  790. this.set('jdkCategoryWarnings', jdkWarnings);
  791. } else {
  792. // still doing JDK check, data not ready to be parsed
  793. this.set('jdkCategoryWarnings', null);
  794. }
  795. this.doCheckJDKsuccessCallback();
  796. },
  797. /**
  798. * Check JDK issues on registered hosts.
  799. */
  800. checkHostJDK: function () {
  801. this.set('isJDKWarningsLoaded', false);
  802. this.set('jdkCategoryWarnings', null);
  803. var self = this;
  804. this.getJDKName().done( function() {
  805. if (self.get('needJDKCheckOnHosts')) {
  806. // need to do JDK check on each host
  807. self.doCheckJDK();
  808. } else {
  809. // no customized JDK path, so no need to check jdk
  810. self.set('jdkCategoryWarnings', []);
  811. self.set('isJDKWarningsLoaded', true);
  812. }
  813. });
  814. },
  815. /**
  816. * Get disk info and cpu count of booted hosts from server
  817. * @return {$.ajax}
  818. * @method getHostInfo
  819. */
  820. getHostInfo: function () {
  821. this.set('isHostsWarningsLoaded', false);
  822. // begin JDK check for each host
  823. return App.ajax.send({
  824. name: 'wizard.step3.host_info',
  825. sender: this,
  826. success: 'getHostInfoSuccessCallback',
  827. error: 'getHostInfoErrorCallback'
  828. });
  829. },
  830. startHostcheck: function() {
  831. this.set('isWarningsLoaded', false);
  832. this.getHostNameResolution();
  833. this.checkHostJDK();
  834. },
  835. getHostNameResolution: function () {
  836. if (App.get('testMode')) {
  837. this.getHostCheckSuccess();
  838. } else {
  839. var data = this.getDataForCheckRequest("host_resolution_check", true);
  840. data ? this.requestToPerformHostCheck(data) : this.stopHostCheck();
  841. }
  842. },
  843. getGeneralHostCheck: function () {
  844. if (App.get('testMode')) {
  845. this.getHostInfo();
  846. } else {
  847. var data = this.getDataForCheckRequest("last_agent_env_check,installed_packages,existing_repos,transparentHugePage", false);
  848. data ? this.requestToPerformHostCheck(data) : this.stopHostCheck();
  849. }
  850. },
  851. /**
  852. * set all fields from which depends running host check to true value
  853. * which force finish checking;
  854. */
  855. stopHostCheck: function() {
  856. this.set('stopChecking', true);
  857. this.set('isJDKWarningsLoaded', true);
  858. this.set('isHostsWarningsLoaded', true);
  859. },
  860. getHostCheckSuccess: function(response) {
  861. if (!App.get('testMode')) {
  862. this.set("requestId", response.Requests.id);
  863. }
  864. this.getHostCheckTasks();
  865. },
  866. /**
  867. * generates data for reuest to perform check
  868. * @param {string} checkExecuteList - for now supported:
  869. * <code>"last_agent_env_check"<code>
  870. * <code>"host_resolution_check"<code>
  871. * @param {boolean} addHostsParameter - define whether add hosts parameter to RequestInfo
  872. * @return {object|null}
  873. * @method getDataForCheckRequest
  874. */
  875. getDataForCheckRequest: function (checkExecuteList, addHostsParameter) {
  876. var newHosts = this.get('bootHosts').filterProperty('bootStatus', 'REGISTERED').getEach('name');
  877. var hosts = this.get('isAddHostWizard') ? [].concat.apply([], App.MasterComponent.find().mapProperty('hostNames')).concat(newHosts).uniq() : newHosts;
  878. hosts = hosts.join(',');
  879. if (hosts.length == 0) return null;
  880. var jdk_location = App.router.get('clusterController.ambariProperties.jdk_location');
  881. var RequestInfo = {
  882. "action": "check_host",
  883. "context": "Check host",
  884. "parameters": {
  885. "check_execute_list": checkExecuteList,
  886. "jdk_location" : jdk_location,
  887. "threshold": "20"
  888. }
  889. };
  890. if (addHostsParameter) {
  891. RequestInfo.parameters.hosts = hosts;
  892. }
  893. var resource_filters = {
  894. "hosts": hosts
  895. };
  896. return {
  897. RequestInfo: RequestInfo,
  898. resource_filters: resource_filters
  899. }
  900. },
  901. /**
  902. * send request to ceate tasks for performing hosts checks
  903. * @params {object} data
  904. * {
  905. * RequestInfo: {
  906. * "action": {string},
  907. * "context": {string},
  908. * "parameters": {
  909. * "check_execute_list": {string},
  910. * "jdk_location" : {string},
  911. * "threshold": {string}
  912. * "hosts": {string|undefined}
  913. * },
  914. * resource_filters: {
  915. * "hosts": {string}
  916. * }
  917. * }
  918. * @returns {$.ajax}
  919. * @method requestToPerformHostCheck
  920. */
  921. requestToPerformHostCheck: function(data) {
  922. return App.ajax.send({
  923. name: 'preinstalled.checks',
  924. sender: this,
  925. data: {
  926. RequestInfo: data.RequestInfo,
  927. resource_filters: data.resource_filters
  928. },
  929. success: "getHostCheckSuccess",
  930. error: "getHostCheckError"
  931. })
  932. },
  933. /**
  934. * send ajax request to get all tasks
  935. * @method getHostCheckTasks
  936. */
  937. getHostCheckTasks: function () {
  938. var self = this;
  939. var requestId = this.get("requestId");
  940. var checker = setTimeout(function () {
  941. if (self.get('stopChecking') == true) {
  942. clearTimeout(checker);
  943. } else {
  944. App.ajax.send({
  945. name: 'preinstalled.checks.tasks',
  946. sender: self,
  947. data: {
  948. requestId: requestId
  949. },
  950. success: 'getHostCheckTasksSuccess',
  951. error: 'getHostCheckTasksError'
  952. });
  953. }
  954. }, 1000);
  955. },
  956. /**
  957. * add warnings to host warning popup if needed
  958. * @param data {Object} - json
  959. * @method getHostCheckTasksSuccess
  960. */
  961. getHostCheckTasksSuccess: function (data) {
  962. if (!data) {
  963. return;
  964. }
  965. if (["FAILED", "COMPLETED", "TIMEDOUT"].contains(data.Requests.request_status)) {
  966. if (data.Requests.inputs.indexOf("last_agent_env_check") != -1) {
  967. this.set('stopChecking', true);
  968. this.set('hostsPackagesData', data.tasks.map(function (task) {
  969. var installed_packages = Em.get(task, 'Tasks.structured_out.installed_packages');
  970. return {
  971. hostName: Em.get(task, 'Tasks.host_name'),
  972. transparentHugePage: Em.get(task, 'Tasks.structured_out.transparentHugePage.message'),
  973. installedPackages: installed_packages ? installed_packages : []
  974. };
  975. }));
  976. this.set("hostCheckResult", data); //store the data so that it can be used later on in the getHostInfo handling logic.
  977. /**
  978. * Still need to get host info for checks that the host check does not perform currently
  979. * Such as the OS type check and the disk space check
  980. * */
  981. this.getHostInfo();
  982. } else if (data.Requests.inputs.indexOf("host_resolution_check") != -1) {
  983. this.parseHostNameResolution(data);
  984. this.getGeneralHostCheck();
  985. }
  986. } else {
  987. this.getHostCheckTasks();
  988. }
  989. },
  990. parseHostCheckWarnings: function (data) {
  991. data = App.get('testMode') ? data : this.filterHostsData(data);
  992. var warnings = [];
  993. var warning;
  994. var hosts = [];
  995. var warningCategories = {
  996. fileFoldersWarnings: {},
  997. packagesWarnings: {},
  998. processesWarnings: {},
  999. servicesWarnings: {},
  1000. usersWarnings: {},
  1001. alternativeWarnings: {}
  1002. };
  1003. var hostsPackagesData = this.get('hostsPackagesData');
  1004. data.tasks.sortPropertyLight('Tasks.host_name').forEach(function (_task) {
  1005. var hostName = _task.Tasks.host_name;
  1006. var host = {
  1007. name: hostName,
  1008. warnings: []
  1009. };
  1010. if (!_task.Tasks.structured_out || !_task.Tasks.structured_out.last_agent_env_check) {
  1011. return;
  1012. }
  1013. var lastAgentEnvCheck = _task.Tasks.structured_out.last_agent_env_check;
  1014. //parse all directories and files warnings for host
  1015. var stackFoldersAndFiles = lastAgentEnvCheck.stackFoldersAndFiles || [];
  1016. stackFoldersAndFiles.forEach(function (path) {
  1017. warning = warningCategories.fileFoldersWarnings[path.name];
  1018. if (warning) {
  1019. warning.hosts.push(hostName);
  1020. warning.hostsLong.push(hostName);
  1021. warning.onSingleHost = false;
  1022. } else {
  1023. warningCategories.fileFoldersWarnings[path.name] = warning = {
  1024. name: path.name,
  1025. hosts: [hostName],
  1026. hostsLong: [hostName],
  1027. category: 'fileFolders',
  1028. onSingleHost: true
  1029. };
  1030. }
  1031. host.warnings.push(warning);
  1032. }, this);
  1033. //parse all package warnings for host
  1034. var _hostPackagesData = hostsPackagesData.findProperty('hostName', hostName);
  1035. if (_hostPackagesData) {
  1036. _hostPackagesData.installedPackages.forEach(function (_package) {
  1037. warning = warningCategories.packagesWarnings[_package.name];
  1038. if (warning) {
  1039. warning.hosts.push(hostName);
  1040. warning.hostsLong.push(hostName);
  1041. warning.version = _package.version;
  1042. warning.onSingleHost = false;
  1043. } else {
  1044. warningCategories.packagesWarnings[_package.name] = warning = {
  1045. name: _package.name,
  1046. version: _package.version,
  1047. hosts: [hostName],
  1048. hostsLong: [hostName],
  1049. category: 'packages',
  1050. onSingleHost: true
  1051. };
  1052. }
  1053. host.warnings.push(warning);
  1054. }, this);
  1055. }
  1056. //parse all process warnings for host
  1057. var hostHealth = lastAgentEnvCheck.hostHealth;
  1058. var liveServices = null;
  1059. var javaProcs = null;
  1060. if(hostHealth) {
  1061. if(hostHealth.activeJavaProcs)
  1062. javaProcs = hostHealth.activeJavaProcs;
  1063. if(hostHealth.liveServices)
  1064. liveServices = hostHealth.liveServices;
  1065. }
  1066. if (javaProcs) {
  1067. javaProcs.forEach(function (process) {
  1068. warning = warningCategories.processesWarnings[process.pid];
  1069. if (warning) {
  1070. warning.hosts.push(hostName);
  1071. warning.hostsLong.push(hostName);
  1072. warning.onSingleHost = false;
  1073. } else {
  1074. warningCategories.processesWarnings[process.pid] = warning = {
  1075. name: (process.command.substr(0, 35) + '...'),
  1076. hosts: [hostName],
  1077. hostsLong: [hostName],
  1078. category: 'processes',
  1079. user: process.user,
  1080. pid: process.pid,
  1081. command: '<table><tr><td style="word-break: break-all;">' +
  1082. ((process.command.length < 500) ? process.command : process.command.substr(0, 230) + '...' +
  1083. '<p style="text-align: center">................</p>' +
  1084. '...' + process.command.substr(-230)) + '</td></tr></table>',
  1085. onSingleHost: true
  1086. };
  1087. }
  1088. host.warnings.push(warning);
  1089. }, this);
  1090. }
  1091. //parse all service warnings for host
  1092. if (liveServices) {
  1093. liveServices.forEach(function (service) {
  1094. if (service.status === 'Unhealthy') {
  1095. warning = warningCategories.servicesWarnings[service.name];
  1096. if (warning) {
  1097. warning.hosts.push(hostName);
  1098. warning.hostsLong.push(hostName);
  1099. warning.onSingleHost = false;
  1100. } else {
  1101. warningCategories.servicesWarnings[service.name] = warning = {
  1102. name: service.name,
  1103. hosts: [hostName],
  1104. hostsLong: [hostName],
  1105. category: 'services',
  1106. onSingleHost: true
  1107. };
  1108. }
  1109. host.warnings.push(warning);
  1110. }
  1111. }, this);
  1112. }
  1113. //parse all user warnings for host
  1114. var existingUsers = lastAgentEnvCheck.existingUsers;
  1115. if (existingUsers) {
  1116. existingUsers.forEach(function (user) {
  1117. warning = warningCategories.usersWarnings[user.userName];
  1118. if (warning) {
  1119. warning.hosts.push(hostName);
  1120. warning.hostsLong.push(hostName);
  1121. warning.onSingleHost = false;
  1122. } else {
  1123. warningCategories.usersWarnings[user.userName] = warning = {
  1124. name: user.userName,
  1125. hosts: [hostName],
  1126. hostsLong: [hostName],
  1127. category: 'users',
  1128. onSingleHost: true
  1129. };
  1130. }
  1131. host.warnings.push(warning);
  1132. }, this);
  1133. }
  1134. //parse misc warnings for host
  1135. var umask = lastAgentEnvCheck.umask;
  1136. if (umask && umask > 23) {
  1137. warning = warnings.filterProperty('category', 'misc').findProperty('name', umask);
  1138. if (warning) {
  1139. warning.hosts.push(hostName);
  1140. warning.hostsLong.push(hostName);
  1141. warning.onSingleHost = false;
  1142. } else {
  1143. warning = {
  1144. name: umask,
  1145. hosts: [hostName],
  1146. hostsLong: [hostName],
  1147. category: 'misc',
  1148. onSingleHost: true
  1149. };
  1150. warnings.push(warning);
  1151. }
  1152. host.warnings.push(warning);
  1153. }
  1154. var firewallRunning = lastAgentEnvCheck.firewallRunning;
  1155. if (firewallRunning !== null && firewallRunning) {
  1156. var name = lastAgentEnvCheck.firewallName + " Running";
  1157. warning = warnings.filterProperty('category', 'firewall').findProperty('name', name);
  1158. if (warning) {
  1159. warning.hosts.push(hostName);
  1160. warning.hostsLong.push(hostName);
  1161. warning.onSingleHost = false;
  1162. } else {
  1163. warning = {
  1164. name: name,
  1165. hosts: [hostName],
  1166. hostsLong: [hostName],
  1167. category: 'firewall',
  1168. onSingleHost: true
  1169. };
  1170. warnings.push(warning);
  1171. }
  1172. host.warnings.push(warning);
  1173. }
  1174. if (lastAgentEnvCheck.alternatives) {
  1175. lastAgentEnvCheck.alternatives.forEach(function (alternative) {
  1176. warning = warningCategories.alternativeWarnings[alternative.name];
  1177. if (warning) {
  1178. warning.hosts.push(hostName);
  1179. warning.hostsLong.push(hostName);
  1180. warning.onSingleHost = false;
  1181. } else {
  1182. warningCategories.alternativeWarnings[alternative.name] = warning = {
  1183. name: alternative.name,
  1184. target: alternative.target,
  1185. hosts: [hostName],
  1186. hostsLong: [hostName],
  1187. category: 'alternatives',
  1188. onSingleHost: true
  1189. };
  1190. }
  1191. host.warnings.push(warning);
  1192. }, this);
  1193. }
  1194. if (lastAgentEnvCheck.reverseLookup === false) {
  1195. var name = Em.I18n.t('installer.step3.hostWarningsPopup.reverseLookup.name');
  1196. warning = warnings.filterProperty('category', 'reverseLookup').findProperty('name', name);
  1197. if (warning) {
  1198. warning.hosts.push(hostName);
  1199. warning.hostsLong.push(hostName);
  1200. warning.onSingleHost = false;
  1201. } else {
  1202. warning = {
  1203. name: name,
  1204. hosts: [hostName],
  1205. hostsLong: [hostName],
  1206. category: 'reverseLookup',
  1207. onSingleHost: true
  1208. };
  1209. warnings.push(warning);
  1210. }
  1211. host.warnings.push(warning);
  1212. }
  1213. hosts.push(host);
  1214. }, this);
  1215. for (var categoryId in warningCategories) {
  1216. var category = warningCategories[categoryId];
  1217. for (var warningId in category) {
  1218. warnings.push(category[warningId]);
  1219. }
  1220. }
  1221. hosts.unshift({
  1222. name: 'All Hosts',
  1223. warnings: warnings
  1224. });
  1225. this.set('warnings', warnings);
  1226. this.set('warningsByHost', hosts);
  1227. },
  1228. /**
  1229. * Filter data for warnings parse
  1230. * is data from host in bootStrap
  1231. * @param {object} data
  1232. * @return {Object}
  1233. * @method filterBootHosts
  1234. */
  1235. filterHostsData: function (data) {
  1236. var bootHostNames = {};
  1237. this.get('bootHosts').forEach(function (bootHost) {
  1238. bootHostNames[bootHost.get('name')] = true;
  1239. });
  1240. var filteredData = {
  1241. href: data.href,
  1242. tasks: []
  1243. };
  1244. data.tasks.forEach(function (_task) {
  1245. if (bootHostNames[_task.Tasks.host_name]) {
  1246. filteredData.tasks.push(_task);
  1247. }
  1248. });
  1249. return filteredData;
  1250. },
  1251. /**
  1252. * parse warnings for host names resolution only
  1253. * @param {object} data
  1254. * @method parseHostNameResolution
  1255. */
  1256. parseHostNameResolution: function (data) {
  1257. if (!data) {
  1258. return;
  1259. }
  1260. data.tasks.forEach(function (task) {
  1261. var name = Em.I18n.t('installer.step3.hostWarningsPopup.resolution.validation.error');
  1262. var hostInfo = this.get("hostCheckWarnings").findProperty('name', name);
  1263. if (["FAILED", "COMPLETED", "TIMEDOUT"].contains(task.Tasks.status)) {
  1264. if (task.Tasks.status === "COMPLETED" && !!Em.get(task, "Tasks.structured_out.host_resolution_check.failed_count")) {
  1265. var targetHostName = Em.get(task, "Tasks.host_name");
  1266. var relatedHostNames = Em.get(task, "Tasks.structured_out.host_resolution_check.failures")
  1267. ? Em.get(task, "Tasks.structured_out.host_resolution_check.failures").mapProperty('host') : [];
  1268. var contextMessage = Em.I18n.t('installer.step3.hostWarningsPopup.resolution.validation.context').format(targetHostName, relatedHostNames.length + ' ' + Em.I18n.t('installer.step3.hostWarningsPopup.host' + (relatedHostNames.length == 1 ? '' : 's')));
  1269. var contextMessageLong = Em.I18n.t('installer.step3.hostWarningsPopup.resolution.validation.context').format(targetHostName, relatedHostNames.join(', '));
  1270. if (!hostInfo) {
  1271. hostInfo = {
  1272. name: name,
  1273. hosts: [contextMessage],
  1274. hostsLong: [contextMessageLong],
  1275. hostsNames: [targetHostName],
  1276. onSingleHost: true
  1277. };
  1278. this.get("hostCheckWarnings").push(hostInfo);
  1279. } else {
  1280. if (!hostInfo.hostsNames.contains(targetHostName)) {
  1281. hostInfo.hosts.push(contextMessage);
  1282. hostInfo.hostsLong.push(contextMessageLong);
  1283. hostInfo.hostsNames.push(targetHostName);
  1284. hostInfo.onSingleHost = false;
  1285. }
  1286. }
  1287. }
  1288. }
  1289. }, this);
  1290. },
  1291. getHostCheckError: function() {
  1292. this.getHostInfo();
  1293. },
  1294. stopChecking: false,
  1295. /**
  1296. * @method getHostCheckTasksError
  1297. */
  1298. getHostCheckTasksError: function() {
  1299. this.set('stopChecking', true);
  1300. },
  1301. /**
  1302. * Success-callback for hosts info request
  1303. * @param {object} jsonData
  1304. * @method getHostInfoSuccessCallback
  1305. */
  1306. getHostInfoSuccessCallback: function (jsonData) {
  1307. var hosts = this.get('bootHosts'),
  1308. self = this,
  1309. repoWarnings = [], hostsRepoNames = [], hostsContext = [],
  1310. diskWarnings = [], hostsDiskContext = [], hostsDiskNames = [],
  1311. thpWarnings = [], thpContext = [], thpHostsNames = [];
  1312. // parse host checks warning
  1313. var hostCheckResult = this.get("hostCheckResult");
  1314. if(hostCheckResult){
  1315. this.parseHostCheckWarnings(hostCheckResult);
  1316. this.set("hostCheckResult", null);
  1317. } else {
  1318. this.parseWarnings(jsonData);
  1319. }
  1320. this.set('isHostsWarningsLoaded', true);
  1321. hosts.forEach(function (_host) {
  1322. var host = (App.get('testMode')) ? jsonData.items[0] : jsonData.items.findProperty('Hosts.host_name', _host.name);
  1323. if (App.get('skipBootstrap')) {
  1324. self._setHostDataWithSkipBootstrap(_host);
  1325. }
  1326. else {
  1327. if (host) {
  1328. self._setHostDataFromLoadedHostInfo(_host, host);
  1329. var host_name = Em.get(host, 'Hosts.host_name');
  1330. var context = self.checkHostOSType(host.Hosts.os_family, host_name);
  1331. if (context) {
  1332. hostsContext.push(context);
  1333. hostsRepoNames.push(host_name);
  1334. }
  1335. var diskContext = self.checkHostDiskSpace(host_name, host.Hosts.disk_info);
  1336. if (diskContext) {
  1337. hostsDiskContext.push(diskContext);
  1338. hostsDiskNames.push(host_name);
  1339. }
  1340. // "Transparent Huge Pages" check
  1341. var _hostPackagesData = self.get('hostsPackagesData').findProperty('hostName', host.Hosts.host_name);
  1342. if (_hostPackagesData) {
  1343. var transparentHugePage = _hostPackagesData.transparentHugePage;
  1344. context = self.checkTHP(host_name, transparentHugePage);
  1345. } else {
  1346. context = self.checkTHP(host_name, Em.get(host, 'Hosts.last_agent_env.transparentHugePage'));
  1347. }
  1348. if (context) {
  1349. thpContext.push(context);
  1350. thpHostsNames.push(host_name);
  1351. }
  1352. }
  1353. }
  1354. });
  1355. if (hostsContext.length > 0) { // repository warning exist
  1356. repoWarnings.push({
  1357. name: Em.I18n.t('installer.step3.hostWarningsPopup.repositories.name'),
  1358. hosts: hostsContext,
  1359. hostsLong: hostsContext,
  1360. hostsNames: hostsRepoNames,
  1361. category: 'repositories',
  1362. onSingleHost: false
  1363. });
  1364. }
  1365. if (hostsDiskContext.length > 0) { // disk space warning exist
  1366. diskWarnings.push({
  1367. name: Em.I18n.t('installer.step3.hostWarningsPopup.disk.name'),
  1368. hosts: hostsDiskContext,
  1369. hostsLong: hostsDiskContext,
  1370. hostsNames: hostsDiskNames,
  1371. category: 'disk',
  1372. onSingleHost: false
  1373. });
  1374. }
  1375. if (thpContext.length > 0) { // THP warning existed
  1376. thpWarnings.push({
  1377. name: Em.I18n.t('installer.step3.hostWarningsPopup.thp.name'),
  1378. hosts: thpContext,
  1379. hostsLong: thpContext,
  1380. hostsNames: thpHostsNames,
  1381. category: 'thp',
  1382. onSingleHost: false
  1383. });
  1384. }
  1385. this.set('repoCategoryWarnings', repoWarnings);
  1386. this.set('diskCategoryWarnings', diskWarnings);
  1387. this.set('thpCategoryWarnings', thpWarnings);
  1388. this.stopRegistration();
  1389. },
  1390. /**
  1391. * Set metrics to host object
  1392. * Used when <code>App.skipBootstrap</code> is true
  1393. * @param {Ember.Object} host
  1394. * @returns {object}
  1395. * @private
  1396. * @methos _setHostDataWithSkipBootstrap
  1397. */
  1398. _setHostDataWithSkipBootstrap: function(host) {
  1399. host.set('cpu', 2);
  1400. host.set('memory', ((parseInt(2000000))).toFixed(2));
  1401. host.set('disk_info', [
  1402. {"mountpoint": "/", "type": "ext4"},
  1403. {"mountpoint": "/grid/0", "type": "ext4"},
  1404. {"mountpoint": "/grid/1", "type": "ext4"},
  1405. {"mountpoint": "/grid/2", "type": "ext4"}
  1406. ]);
  1407. return host;
  1408. },
  1409. /**
  1410. * Set loaded metrics to host object
  1411. * @param {object} host
  1412. * @param {object} hostInfo
  1413. * @returns {object}
  1414. * @method _setHostDataFromLoadedHostInfo
  1415. * @private
  1416. */
  1417. _setHostDataFromLoadedHostInfo: function(host, hostInfo) {
  1418. host.set('cpu', Em.get(hostInfo, 'Hosts.cpu_count'));
  1419. host.set('memory', ((parseInt(Em.get(hostInfo, 'Hosts.total_mem')))).toFixed(2));
  1420. host.set('disk_info', Em.get(hostInfo, 'Hosts.disk_info').filter(function (h) {
  1421. return h.mountpoint != "/boot"
  1422. }));
  1423. host.set('os_type', Em.get(hostInfo, 'Hosts.os_type'));
  1424. host.set('os_family', Em.get(hostInfo, 'Hosts.os_family'));
  1425. host.set('os_arch', Em.get(hostInfo, 'Hosts.os_arch'));
  1426. host.set('ip', Em.get(hostInfo, 'Hosts.ip'));
  1427. return host;
  1428. },
  1429. /**
  1430. * Error-callback for hosts info request
  1431. * @method getHostInfoErrorCallback
  1432. */
  1433. getHostInfoErrorCallback: function () {
  1434. this.set('isHostsWarningsLoaded', true);
  1435. this.registerErrPopup(Em.I18n.t('installer.step3.hostInformation.popup.header'), Em.I18n.t('installer.step3.hostInformation.popup.body'));
  1436. },
  1437. /**
  1438. * Enable or disable submit/retry buttons according to hosts boot statuses
  1439. * @method stopRegistration
  1440. */
  1441. stopRegistration: function () {
  1442. this.set('isSubmitDisabled', !this.get('bootHosts').someProperty('bootStatus', 'REGISTERED'));
  1443. },
  1444. /**
  1445. * Check if the 'Transparent Huge Pages' enabled.
  1446. * @param {string} transparentHugePage
  1447. * @param {string} hostName
  1448. * @return {string} error-message or empty string
  1449. * @method checkTHP
  1450. */
  1451. checkTHP: function (hostName, transparentHugePage) {
  1452. if (transparentHugePage == "always") {
  1453. return Em.I18n.t('installer.step3.hostWarningsPopup.thp.context').format(hostName);
  1454. } else {
  1455. return '';
  1456. }
  1457. },
  1458. /**
  1459. * Check if the customized os group contains the registered host os type. If not the repo on that host is invalid.
  1460. * @param {string} osType
  1461. * @param {string} hostName
  1462. * @return {string} error-message or empty string
  1463. * @method checkHostOSType
  1464. */
  1465. checkHostOSType: function (osFamily, hostName) {
  1466. if (this.get('content.stacks')) {
  1467. var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
  1468. var selectedOS = [];
  1469. var isValid = false;
  1470. if (selectedStack && selectedStack.get('operatingSystems')) {
  1471. selectedStack.get('operatingSystems').filterProperty('isSelected', true).forEach(function (os) {
  1472. selectedOS.pushObject(os.get('osType'));
  1473. if (os.get('osType') === osFamily) {
  1474. isValid = true;
  1475. }
  1476. });
  1477. }
  1478. if (isValid) {
  1479. return '';
  1480. } else {
  1481. return Em.I18n.t('installer.step3.hostWarningsPopup.repositories.context').format(hostName, osFamily, selectedOS.uniq());
  1482. }
  1483. } else {
  1484. return '';
  1485. }
  1486. },
  1487. /**
  1488. * Check if current host has enough free disk usage.
  1489. * @param {string} hostName
  1490. * @param {object} diskInfo
  1491. * @return {string} error-message or empty string
  1492. * @method checkHostDiskSpace
  1493. */
  1494. checkHostDiskSpace: function (hostName, diskInfo) {
  1495. var minFreeRootSpace = App.minDiskSpace * 1024 * 1024; //in kilobyte
  1496. var minFreeUsrLibSpace = App.minDiskSpaceUsrLib * 1024 * 1024; //in kilobyte
  1497. var warningString = '';
  1498. diskInfo.forEach(function (info) {
  1499. switch (info.mountpoint) {
  1500. case '/':
  1501. warningString = info.available < minFreeRootSpace ?
  1502. Em.I18n.t('installer.step3.hostWarningsPopup.disk.context2').format(App.minDiskSpace + 'GB', info.mountpoint) + ' ' + warningString :
  1503. warningString;
  1504. break;
  1505. case '/usr':
  1506. case '/usr/lib':
  1507. warningString = info.available < minFreeUsrLibSpace ?
  1508. Em.I18n.t('installer.step3.hostWarningsPopup.disk.context2').format(App.minDiskSpaceUsrLib + 'GB', info.mountpoint) + ' ' + warningString :
  1509. warningString;
  1510. break;
  1511. default:
  1512. break;
  1513. }
  1514. });
  1515. if (warningString) {
  1516. return Em.I18n.t('installer.step3.hostWarningsPopup.disk.context1').format(hostName) + ' ' + warningString;
  1517. } else {
  1518. return '';
  1519. }
  1520. },
  1521. /**
  1522. * Submit-click handler
  1523. * @return {App.ModalPopup|null}
  1524. * @method submit
  1525. */
  1526. submit: function () {
  1527. var self = this;
  1528. if (this.get('isHostHaveWarnings')) {
  1529. return App.showConfirmationPopup(
  1530. function () {
  1531. self.set('confirmedHosts', self.get('bootHosts'));
  1532. App.router.send('next');
  1533. },
  1534. Em.I18n.t('installer.step3.hostWarningsPopup.hostHasWarnings'));
  1535. }
  1536. else {
  1537. this.set('confirmedHosts', this.get('bootHosts'));
  1538. App.router.send('next');
  1539. }
  1540. return null;
  1541. },
  1542. /**
  1543. * Show popup with host log
  1544. * @param {object} event
  1545. * @return {App.ModalPopup}
  1546. */
  1547. hostLogPopup: function (event) {
  1548. var host = event.context;
  1549. return App.ModalPopup.show({
  1550. header: Em.I18n.t('installer.step3.hostLog.popup.header').format(host.get('name')),
  1551. secondary: null,
  1552. host: host,
  1553. bodyClass: App.WizardStep3HostLogPopupBody
  1554. });
  1555. },
  1556. /**
  1557. * Check warnings from server and put it in parsing
  1558. * @method rerunChecks
  1559. */
  1560. rerunChecks: function () {
  1561. var self = this;
  1562. var currentProgress = 0;
  1563. this.getHostNameResolution();
  1564. this.set('stopChecking', false);
  1565. this.getGeneralHostCheck();
  1566. this.checkHostJDK();
  1567. var interval = setInterval(function () {
  1568. currentProgress += 100000 / self.get('warningsTimeInterval');
  1569. if (currentProgress < 100) {
  1570. self.set('checksUpdateProgress', currentProgress);
  1571. } else {
  1572. clearInterval(interval);
  1573. App.ajax.send({
  1574. name: 'wizard.step3.rerun_checks',
  1575. sender: self,
  1576. success: 'rerunChecksSuccessCallback',
  1577. error: 'rerunChecksErrorCallback'
  1578. });
  1579. }
  1580. }, 1000);
  1581. },
  1582. /**
  1583. * Success-callback for rerun request
  1584. * @param {object} data
  1585. * @method rerunChecksSuccessCallback
  1586. */
  1587. rerunChecksSuccessCallback: function (data) {
  1588. this.set('checksUpdateProgress', 100);
  1589. this.set('checksUpdateStatus', 'SUCCESS');
  1590. this.parseWarnings(data);
  1591. },
  1592. /**
  1593. * Error-callback for rerun request
  1594. * @method rerunChecksErrorCallback
  1595. */
  1596. rerunChecksErrorCallback: function () {
  1597. this.set('checksUpdateProgress', 100);
  1598. this.set('checksUpdateStatus', 'FAILED');
  1599. },
  1600. /**
  1601. * Filter data for warnings parse
  1602. * is data from host in bootStrap
  1603. * @param {object} data
  1604. * @return {Object}
  1605. * @method filterBootHosts
  1606. */
  1607. filterBootHosts: function (data) {
  1608. var bootHostNames = {};
  1609. this.get('bootHosts').forEach(function (bootHost) {
  1610. bootHostNames[bootHost.get('name')] = true;
  1611. });
  1612. var filteredData = {
  1613. href: data.href,
  1614. items: []
  1615. };
  1616. data.items.forEach(function (host) {
  1617. if (bootHostNames[host.Hosts.host_name]) {
  1618. filteredData.items.push(host);
  1619. }
  1620. });
  1621. return filteredData;
  1622. },
  1623. /**
  1624. * Parse warnings data for each host and total
  1625. * @param {object} data
  1626. * @method parseWarnings
  1627. */
  1628. parseWarnings: function (data) {
  1629. data = App.get('testMode') ? data : this.filterBootHosts(data);
  1630. var warnings = [];
  1631. var warning;
  1632. var hosts = [];
  1633. var warningCategories = {
  1634. fileFoldersWarnings: {},
  1635. packagesWarnings: {},
  1636. processesWarnings: {},
  1637. servicesWarnings: {},
  1638. usersWarnings: {},
  1639. alternativeWarnings: {}
  1640. };
  1641. var hostsPackagesData = this.get('hostsPackagesData');
  1642. data.items.sortPropertyLight('Hosts.host_name').forEach(function (_host) {
  1643. var host = {
  1644. name: _host.Hosts.host_name,
  1645. warnings: []
  1646. };
  1647. if (!_host.Hosts.last_agent_env) {
  1648. // in some unusual circumstances when last_agent_env is not available from the _host,
  1649. // skip the _host and proceed to process the rest of the hosts.
  1650. return;
  1651. }
  1652. //parse all directories and files warnings for host
  1653. //todo: to be removed after check in new API
  1654. var stackFoldersAndFiles = _host.Hosts.last_agent_env.stackFoldersAndFiles || [];
  1655. stackFoldersAndFiles.forEach(function (path) {
  1656. warning = warningCategories.fileFoldersWarnings[path.name];
  1657. if (warning) {
  1658. warning.hosts.push(_host.Hosts.host_name);
  1659. warning.hostsLong.push(_host.Hosts.host_name);
  1660. warning.onSingleHost = false;
  1661. } else {
  1662. warningCategories.fileFoldersWarnings[path.name] = warning = {
  1663. name: path.name,
  1664. hosts: [_host.Hosts.host_name],
  1665. hostsLong: [_host.Hosts.host_name],
  1666. category: 'fileFolders',
  1667. onSingleHost: true
  1668. };
  1669. }
  1670. host.warnings.push(warning);
  1671. }, this);
  1672. //parse all package warnings for host
  1673. var _hostPackagesData = hostsPackagesData.findProperty('hostName', _host.Hosts.host_name);
  1674. if (_hostPackagesData) {
  1675. _hostPackagesData.installedPackages.forEach(function (_package) {
  1676. warning = warningCategories.packagesWarnings[_package.name];
  1677. if (warning) {
  1678. warning.hosts.push(_host.Hosts.host_name);
  1679. warning.hostsLong.push(_host.Hosts.host_name);
  1680. warning.version = _package.version;
  1681. warning.onSingleHost = false;
  1682. } else {
  1683. warningCategories.packagesWarnings[_package.name] = warning = {
  1684. name: _package.name,
  1685. version: _package.version,
  1686. hosts: [_host.Hosts.host_name],
  1687. hostsLong: [_host.Hosts.host_name],
  1688. category: 'packages',
  1689. onSingleHost: true
  1690. };
  1691. }
  1692. host.warnings.push(warning);
  1693. }, this);
  1694. }
  1695. //parse all process warnings for host
  1696. //todo: to be removed after check in new API
  1697. var javaProcs = _host.Hosts.last_agent_env.hostHealth ? _host.Hosts.last_agent_env.hostHealth.activeJavaProcs : _host.Hosts.last_agent_env.javaProcs;
  1698. if (javaProcs) {
  1699. javaProcs.forEach(function (process) {
  1700. warning = warningCategories.processesWarnings[process.pid];
  1701. if (warning) {
  1702. warning.hosts.push(_host.Hosts.host_name);
  1703. warning.hostsLong.push(_host.Hosts.host_name);
  1704. warning.onSingleHost = false;
  1705. } else {
  1706. warningCategories.processesWarnings[process.pid] = warning = {
  1707. name: (process.command.substr(0, 35) + '...'),
  1708. hosts: [_host.Hosts.host_name],
  1709. hostsLong: [_host.Hosts.host_name],
  1710. category: 'processes',
  1711. user: process.user,
  1712. pid: process.pid,
  1713. command: '<table><tr><td style="word-break: break-all;">' +
  1714. ((process.command.length < 500) ? process.command : process.command.substr(0, 230) + '...' +
  1715. '<p style="text-align: center">................</p>' +
  1716. '...' + process.command.substr(-230)) + '</td></tr></table>',
  1717. onSingleHost: true
  1718. };
  1719. }
  1720. host.warnings.push(warning);
  1721. }, this);
  1722. }
  1723. //parse all service warnings for host
  1724. //todo: to be removed after check in new API
  1725. if (_host.Hosts.last_agent_env.hostHealth && _host.Hosts.last_agent_env.hostHealth.liveServices) {
  1726. _host.Hosts.last_agent_env.hostHealth.liveServices.forEach(function (service) {
  1727. if (service.status === 'Unhealthy') {
  1728. warning = warningCategories.servicesWarnings[service.name];
  1729. if (warning) {
  1730. warning.hosts.push(_host.Hosts.host_name);
  1731. warning.hostsLong.push(_host.Hosts.host_name);
  1732. warning.onSingleHost = false;
  1733. } else {
  1734. warningCategories.servicesWarnings[service.name] = warning = {
  1735. name: service.name,
  1736. hosts: [_host.Hosts.host_name],
  1737. hostsLong: [_host.Hosts.host_name],
  1738. category: 'services',
  1739. onSingleHost: true
  1740. };
  1741. }
  1742. host.warnings.push(warning);
  1743. }
  1744. }, this);
  1745. }
  1746. //parse all user warnings for host
  1747. //todo: to be removed after check in new API
  1748. if (_host.Hosts.last_agent_env.existingUsers) {
  1749. _host.Hosts.last_agent_env.existingUsers.forEach(function (user) {
  1750. warning = warningCategories.usersWarnings[user.userName];
  1751. if (warning) {
  1752. warning.hosts.push(_host.Hosts.host_name);
  1753. warning.hostsLong.push(_host.Hosts.host_name);
  1754. warning.onSingleHost = false;
  1755. } else {
  1756. warningCategories.usersWarnings[user.userName] = warning = {
  1757. name: user.userName,
  1758. hosts: [_host.Hosts.host_name],
  1759. hostsLong: [_host.Hosts.host_name],
  1760. category: 'users',
  1761. onSingleHost: true
  1762. };
  1763. }
  1764. host.warnings.push(warning);
  1765. }, this);
  1766. }
  1767. //parse misc warnings for host
  1768. var umask = _host.Hosts.last_agent_env.umask;
  1769. if (umask && umask > 23) {
  1770. warning = warnings.filterProperty('category', 'misc').findProperty('name', umask);
  1771. if (warning) {
  1772. warning.hosts.push(_host.Hosts.host_name);
  1773. warning.hostsLong.push(_host.Hosts.host_name);
  1774. warning.onSingleHost = false;
  1775. } else {
  1776. warning = {
  1777. name: umask,
  1778. hosts: [_host.Hosts.host_name],
  1779. hostsLong: [_host.Hosts.host_name],
  1780. category: 'misc',
  1781. onSingleHost: true
  1782. };
  1783. warnings.push(warning);
  1784. }
  1785. host.warnings.push(warning);
  1786. }
  1787. var firewallRunning = _host.Hosts.last_agent_env.firewallRunning;
  1788. if (firewallRunning !== null && firewallRunning) {
  1789. var name = _host.Hosts.last_agent_env.firewallName + " Running";
  1790. warning = warnings.filterProperty('category', 'firewall').findProperty('name', name);
  1791. if (warning) {
  1792. warning.hosts.push(_host.Hosts.host_name);
  1793. warning.hostsLong.push(_host.Hosts.host_name);
  1794. warning.onSingleHost = false;
  1795. } else {
  1796. warning = {
  1797. name: name,
  1798. hosts: [_host.Hosts.host_name],
  1799. hostsLong: [_host.Hosts.host_name],
  1800. category: 'firewall',
  1801. onSingleHost: true
  1802. };
  1803. warnings.push(warning);
  1804. }
  1805. host.warnings.push(warning);
  1806. }
  1807. if (_host.Hosts.last_agent_env.alternatives) {
  1808. _host.Hosts.last_agent_env.alternatives.forEach(function (alternative) {
  1809. warning = warningCategories.alternativeWarnings[alternative.name];
  1810. if (warning) {
  1811. warning.hosts.push(_host.Hosts.host_name);
  1812. warning.hostsLong.push(_host.Hosts.host_name);
  1813. warning.onSingleHost = false;
  1814. } else {
  1815. warningCategories.alternativeWarnings[alternative.name] = warning = {
  1816. name: alternative.name,
  1817. target: alternative.target,
  1818. hosts: [_host.Hosts.host_name],
  1819. hostsLong: [_host.Hosts.host_name],
  1820. category: 'alternatives',
  1821. onSingleHost: true
  1822. };
  1823. }
  1824. host.warnings.push(warning);
  1825. }, this);
  1826. }
  1827. if (_host.Hosts.last_agent_env.reverseLookup === false) {
  1828. var name = Em.I18n.t('installer.step3.hostWarningsPopup.reverseLookup.name');
  1829. warning = warnings.filterProperty('category', 'reverseLookup').findProperty('name', name);
  1830. if (warning) {
  1831. warning.hosts.push(_host.Hosts.host_name);
  1832. warning.hostsLong.push(_host.Hosts.host_name);
  1833. warning.onSingleHost = false;
  1834. } else {
  1835. warning = {
  1836. name: name,
  1837. hosts: [_host.Hosts.host_name],
  1838. hostsLong: [_host.Hosts.host_name],
  1839. category: 'reverseLookup',
  1840. onSingleHost: true
  1841. };
  1842. warnings.push(warning);
  1843. }
  1844. host.warnings.push(warning);
  1845. }
  1846. hosts.push(host);
  1847. }, this);
  1848. for (var categoryId in warningCategories) {
  1849. var category = warningCategories[categoryId];
  1850. for (var warningId in category) {
  1851. warnings.push(category[warningId]);
  1852. }
  1853. }
  1854. hosts.unshift({
  1855. name: 'All Hosts',
  1856. warnings: warnings
  1857. });
  1858. this.set('warnings', warnings);
  1859. this.set('warningsByHost', hosts);
  1860. },
  1861. /**
  1862. * Open popup that contain hosts' warnings
  1863. * @return {App.ModalPopup}
  1864. * @method hostWarningsPopup
  1865. */
  1866. hostWarningsPopup: function () {
  1867. var self = this;
  1868. return App.ModalPopup.show({
  1869. header: Em.I18n.t('installer.step3.warnings.popup.header'),
  1870. secondary: Em.I18n.t('installer.step3.hostWarningsPopup.rerunChecks'),
  1871. primary: Em.I18n.t('common.close'),
  1872. autoHeight: false,
  1873. onPrimary: function () {
  1874. self.set('checksUpdateStatus', null);
  1875. this.hide();
  1876. },
  1877. onClose: function () {
  1878. self.set('checksUpdateStatus', null);
  1879. this.hide();
  1880. },
  1881. onSecondary: function () {
  1882. self.rerunChecks();
  1883. },
  1884. didInsertElement: function () {
  1885. this._super();
  1886. this.fitHeight();
  1887. },
  1888. footerClass: App.WizardStep3HostWarningPopupFooter,
  1889. bodyClass: App.WizardStep3HostWarningPopupBody
  1890. });
  1891. },
  1892. /**
  1893. * Show popup with registered hosts
  1894. * @return {App.ModalPopup}
  1895. * @method registeredHostsPopup
  1896. */
  1897. registeredHostsPopup: function () {
  1898. var self = this;
  1899. return App.ModalPopup.show({
  1900. header: Em.I18n.t('installer.step3.warning.registeredHosts').format(this.get('registeredHosts').length),
  1901. secondary: null,
  1902. bodyClass: Em.View.extend({
  1903. templateName: require('templates/wizard/step3/step3_registered_hosts_popup'),
  1904. message: Em.I18n.t('installer.step3.registeredHostsPopup'),
  1905. registeredHosts: self.get('registeredHosts')
  1906. })
  1907. })
  1908. }
  1909. });