step3_controller.js 66 KB

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