step3_controller.js 66 KB

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