step3_controller.js 67 KB

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