step3_controller.js 66 KB

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