step3_controller.js 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094
  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. * 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. /**
  1535. * Submit-click handler
  1536. * Disable 'Next' button while it is already under process. (using Router's property 'nextBtnClickInProgress')
  1537. * @return {App.ModalPopup|null}
  1538. * @method submit
  1539. */
  1540. submit: function () {
  1541. var self = this;
  1542. if(App.get('router.nextBtnClickInProgress')){
  1543. return;
  1544. }
  1545. if (this.get('isHostHaveWarnings')) {
  1546. return App.showConfirmationPopup(
  1547. function () {
  1548. self.set('confirmedHosts', self.get('bootHosts'));
  1549. App.set('router.nextBtnClickInProgress', true);
  1550. App.get('router').send('next');
  1551. },
  1552. Em.I18n.t('installer.step3.hostWarningsPopup.hostHasWarnings'));
  1553. }
  1554. else {
  1555. this.set('confirmedHosts', this.get('bootHosts'));
  1556. App.set('router.nextBtnClickInProgress', true);
  1557. App.get('router').send('next');
  1558. }
  1559. return null;
  1560. },
  1561. /**
  1562. * Show popup with host log
  1563. * @param {object} event
  1564. * @return {App.ModalPopup}
  1565. */
  1566. hostLogPopup: function (event) {
  1567. var host = event.context;
  1568. return App.ModalPopup.show({
  1569. header: Em.I18n.t('installer.step3.hostLog.popup.header').format(host.get('name')),
  1570. secondary: null,
  1571. host: host,
  1572. bodyClass: App.WizardStep3HostLogPopupBody
  1573. });
  1574. },
  1575. /**
  1576. * Check warnings from server and put it in parsing
  1577. * @method rerunChecks
  1578. */
  1579. rerunChecks: function () {
  1580. var self = this;
  1581. var currentProgress = 0;
  1582. this.getHostNameResolution();
  1583. this.set('stopChecking', false);
  1584. this.getGeneralHostCheck();
  1585. this.checkHostJDK();
  1586. var interval = setInterval(function () {
  1587. currentProgress += 100000 / self.get('warningsTimeInterval');
  1588. if (currentProgress < 100) {
  1589. self.set('checksUpdateProgress', currentProgress);
  1590. } else {
  1591. clearInterval(interval);
  1592. App.ajax.send({
  1593. name: 'wizard.step3.rerun_checks',
  1594. sender: self,
  1595. success: 'rerunChecksSuccessCallback',
  1596. error: 'rerunChecksErrorCallback'
  1597. });
  1598. }
  1599. }, 1000);
  1600. },
  1601. /**
  1602. * Success-callback for rerun request
  1603. * @param {object} data
  1604. * @method rerunChecksSuccessCallback
  1605. */
  1606. rerunChecksSuccessCallback: function (data) {
  1607. this.set('checksUpdateProgress', 100);
  1608. this.set('checksUpdateStatus', 'SUCCESS');
  1609. this.parseWarnings(data);
  1610. },
  1611. /**
  1612. * Error-callback for rerun request
  1613. * @method rerunChecksErrorCallback
  1614. */
  1615. rerunChecksErrorCallback: function () {
  1616. this.set('checksUpdateProgress', 100);
  1617. this.set('checksUpdateStatus', 'FAILED');
  1618. },
  1619. /**
  1620. * Filter data for warnings parse
  1621. * is data from host in bootStrap
  1622. * @param {object} data
  1623. * @return {Object}
  1624. * @method filterBootHosts
  1625. */
  1626. filterBootHosts: function (data) {
  1627. var bootHostNames = {};
  1628. this.get('bootHosts').forEach(function (bootHost) {
  1629. bootHostNames[bootHost.get('name')] = true;
  1630. });
  1631. var filteredData = {
  1632. href: data.href,
  1633. items: []
  1634. };
  1635. data.items.forEach(function (host) {
  1636. if (bootHostNames[host.Hosts.host_name]) {
  1637. filteredData.items.push(host);
  1638. }
  1639. });
  1640. return filteredData;
  1641. },
  1642. /**
  1643. * Parse warnings data for each host and total
  1644. * @param {object} data
  1645. * @method parseWarnings
  1646. */
  1647. parseWarnings: function (data) {
  1648. data = App.get('testMode') ? data : this.filterBootHosts(data);
  1649. var warnings = [];
  1650. var warning;
  1651. var hosts = [];
  1652. var warningCategories = {
  1653. fileFoldersWarnings: {},
  1654. packagesWarnings: {},
  1655. processesWarnings: {},
  1656. servicesWarnings: {},
  1657. usersWarnings: {},
  1658. alternativeWarnings: {}
  1659. };
  1660. var hostsPackagesData = this.get('hostsPackagesData');
  1661. data.items.sortPropertyLight('Hosts.host_name').forEach(function (_host) {
  1662. var host = {
  1663. name: _host.Hosts.host_name,
  1664. warnings: []
  1665. };
  1666. if (!_host.Hosts.last_agent_env) {
  1667. // in some unusual circumstances when last_agent_env is not available from the _host,
  1668. // skip the _host and proceed to process the rest of the hosts.
  1669. return;
  1670. }
  1671. //parse all directories and files warnings for host
  1672. //todo: to be removed after check in new API
  1673. var stackFoldersAndFiles = _host.Hosts.last_agent_env.stackFoldersAndFiles || [];
  1674. stackFoldersAndFiles.forEach(function (path) {
  1675. warning = warningCategories.fileFoldersWarnings[path.name];
  1676. if (warning) {
  1677. warning.hosts.push(_host.Hosts.host_name);
  1678. warning.hostsLong.push(_host.Hosts.host_name);
  1679. warning.onSingleHost = false;
  1680. } else {
  1681. warningCategories.fileFoldersWarnings[path.name] = warning = {
  1682. name: path.name,
  1683. hosts: [_host.Hosts.host_name],
  1684. hostsLong: [_host.Hosts.host_name],
  1685. category: 'fileFolders',
  1686. onSingleHost: true
  1687. };
  1688. }
  1689. host.warnings.push(warning);
  1690. }, this);
  1691. //parse all package warnings for host
  1692. var _hostPackagesData = hostsPackagesData.findProperty('hostName', _host.Hosts.host_name);
  1693. if (_hostPackagesData) {
  1694. _hostPackagesData.installedPackages.forEach(function (_package) {
  1695. warning = warningCategories.packagesWarnings[_package.name];
  1696. if (warning) {
  1697. warning.hosts.push(_host.Hosts.host_name);
  1698. warning.hostsLong.push(_host.Hosts.host_name);
  1699. warning.version = _package.version;
  1700. warning.onSingleHost = false;
  1701. } else {
  1702. warningCategories.packagesWarnings[_package.name] = warning = {
  1703. name: _package.name,
  1704. version: _package.version,
  1705. hosts: [_host.Hosts.host_name],
  1706. hostsLong: [_host.Hosts.host_name],
  1707. category: 'packages',
  1708. onSingleHost: true
  1709. };
  1710. }
  1711. host.warnings.push(warning);
  1712. }, this);
  1713. }
  1714. //parse all process warnings for host
  1715. //todo: to be removed after check in new API
  1716. var javaProcs = _host.Hosts.last_agent_env.hostHealth ? _host.Hosts.last_agent_env.hostHealth.activeJavaProcs : _host.Hosts.last_agent_env.javaProcs;
  1717. if (javaProcs) {
  1718. javaProcs.forEach(function (process) {
  1719. warning = warningCategories.processesWarnings[process.pid];
  1720. if (warning) {
  1721. warning.hosts.push(_host.Hosts.host_name);
  1722. warning.hostsLong.push(_host.Hosts.host_name);
  1723. warning.onSingleHost = false;
  1724. } else {
  1725. warningCategories.processesWarnings[process.pid] = warning = {
  1726. name: (process.command.substr(0, 35) + '...'),
  1727. hosts: [_host.Hosts.host_name],
  1728. hostsLong: [_host.Hosts.host_name],
  1729. category: 'processes',
  1730. user: process.user,
  1731. pid: process.pid,
  1732. command: '<table><tr><td style="word-break: break-all;">' +
  1733. ((process.command.length < 500) ? process.command : process.command.substr(0, 230) + '...' +
  1734. '<p style="text-align: center">................</p>' +
  1735. '...' + process.command.substr(-230)) + '</td></tr></table>',
  1736. onSingleHost: true
  1737. };
  1738. }
  1739. host.warnings.push(warning);
  1740. }, this);
  1741. }
  1742. //parse all service warnings for host
  1743. //todo: to be removed after check in new API
  1744. if (_host.Hosts.last_agent_env.hostHealth && _host.Hosts.last_agent_env.hostHealth.liveServices) {
  1745. _host.Hosts.last_agent_env.hostHealth.liveServices.forEach(function (service) {
  1746. if (service.status === 'Unhealthy') {
  1747. warning = warningCategories.servicesWarnings[service.name];
  1748. if (warning) {
  1749. warning.hosts.push(_host.Hosts.host_name);
  1750. warning.hostsLong.push(_host.Hosts.host_name);
  1751. warning.onSingleHost = false;
  1752. } else {
  1753. warningCategories.servicesWarnings[service.name] = warning = {
  1754. name: service.name,
  1755. hosts: [_host.Hosts.host_name],
  1756. hostsLong: [_host.Hosts.host_name],
  1757. category: 'services',
  1758. onSingleHost: true
  1759. };
  1760. }
  1761. host.warnings.push(warning);
  1762. }
  1763. }, this);
  1764. }
  1765. //parse all user warnings for host
  1766. //todo: to be removed after check in new API
  1767. if (_host.Hosts.last_agent_env.existingUsers) {
  1768. _host.Hosts.last_agent_env.existingUsers.forEach(function (user) {
  1769. warning = warningCategories.usersWarnings[user.name];
  1770. if (warning) {
  1771. warning.hosts.push(_host.Hosts.host_name);
  1772. warning.hostsLong.push(_host.Hosts.host_name);
  1773. warning.onSingleHost = false;
  1774. } else {
  1775. warningCategories.usersWarnings[user.name] = warning = {
  1776. name: user.name,
  1777. hosts: [_host.Hosts.host_name],
  1778. hostsLong: [_host.Hosts.host_name],
  1779. category: 'users',
  1780. onSingleHost: true
  1781. };
  1782. }
  1783. host.warnings.push(warning);
  1784. }, this);
  1785. }
  1786. //parse misc warnings for host
  1787. var umask = _host.Hosts.last_agent_env.umask;
  1788. if (umask && umask > 23) {
  1789. warning = warnings.filterProperty('category', 'misc').findProperty('name', umask);
  1790. if (warning) {
  1791. warning.hosts.push(_host.Hosts.host_name);
  1792. warning.hostsLong.push(_host.Hosts.host_name);
  1793. warning.onSingleHost = false;
  1794. } else {
  1795. warning = {
  1796. name: umask,
  1797. hosts: [_host.Hosts.host_name],
  1798. hostsLong: [_host.Hosts.host_name],
  1799. category: 'misc',
  1800. onSingleHost: true
  1801. };
  1802. warnings.push(warning);
  1803. }
  1804. host.warnings.push(warning);
  1805. }
  1806. var firewallRunning = _host.Hosts.last_agent_env.firewallRunning;
  1807. if (firewallRunning !== null && firewallRunning) {
  1808. var name = _host.Hosts.last_agent_env.firewallName + " Running";
  1809. warning = warnings.filterProperty('category', 'firewall').findProperty('name', name);
  1810. if (warning) {
  1811. warning.hosts.push(_host.Hosts.host_name);
  1812. warning.hostsLong.push(_host.Hosts.host_name);
  1813. warning.onSingleHost = false;
  1814. } else {
  1815. warning = {
  1816. name: name,
  1817. hosts: [_host.Hosts.host_name],
  1818. hostsLong: [_host.Hosts.host_name],
  1819. category: 'firewall',
  1820. onSingleHost: true
  1821. };
  1822. warnings.push(warning);
  1823. }
  1824. host.warnings.push(warning);
  1825. }
  1826. if (_host.Hosts.last_agent_env.alternatives) {
  1827. _host.Hosts.last_agent_env.alternatives.forEach(function (alternative) {
  1828. warning = warningCategories.alternativeWarnings[alternative.name];
  1829. if (warning) {
  1830. warning.hosts.push(_host.Hosts.host_name);
  1831. warning.hostsLong.push(_host.Hosts.host_name);
  1832. warning.onSingleHost = false;
  1833. } else {
  1834. warningCategories.alternativeWarnings[alternative.name] = warning = {
  1835. name: alternative.name,
  1836. target: alternative.target,
  1837. hosts: [_host.Hosts.host_name],
  1838. hostsLong: [_host.Hosts.host_name],
  1839. category: 'alternatives',
  1840. onSingleHost: true
  1841. };
  1842. }
  1843. host.warnings.push(warning);
  1844. }, this);
  1845. }
  1846. if (_host.Hosts.last_agent_env.reverseLookup === false) {
  1847. var name = Em.I18n.t('installer.step3.hostWarningsPopup.reverseLookup.name');
  1848. warning = warnings.filterProperty('category', 'reverseLookup').findProperty('name', name);
  1849. if (warning) {
  1850. warning.hosts.push(_host.Hosts.host_name);
  1851. warning.hostsLong.push(_host.Hosts.host_name);
  1852. warning.onSingleHost = false;
  1853. } else {
  1854. warning = {
  1855. name: name,
  1856. hosts: [_host.Hosts.host_name],
  1857. hostsLong: [_host.Hosts.host_name],
  1858. category: 'reverseLookup',
  1859. onSingleHost: true
  1860. };
  1861. warnings.push(warning);
  1862. }
  1863. host.warnings.push(warning);
  1864. }
  1865. hosts.push(host);
  1866. }, this);
  1867. for (var categoryId in warningCategories) {
  1868. var category = warningCategories[categoryId];
  1869. for (var warningId in category) {
  1870. warnings.push(category[warningId]);
  1871. }
  1872. }
  1873. hosts.unshift({
  1874. name: 'All Hosts',
  1875. warnings: warnings
  1876. });
  1877. this.set('warnings', warnings);
  1878. this.set('warningsByHost', hosts);
  1879. },
  1880. /**
  1881. * Open popup that contain hosts' warnings
  1882. * @return {App.ModalPopup}
  1883. * @method hostWarningsPopup
  1884. */
  1885. hostWarningsPopup: function () {
  1886. var self = this;
  1887. return App.ModalPopup.show({
  1888. header: Em.I18n.t('installer.step3.warnings.popup.header'),
  1889. secondary: Em.I18n.t('installer.step3.hostWarningsPopup.rerunChecks'),
  1890. primary: Em.I18n.t('common.close'),
  1891. autoHeight: false,
  1892. onPrimary: function () {
  1893. self.set('checksUpdateStatus', null);
  1894. this.hide();
  1895. },
  1896. onClose: function () {
  1897. self.set('checksUpdateStatus', null);
  1898. this.hide();
  1899. },
  1900. onSecondary: function () {
  1901. self.rerunChecks();
  1902. },
  1903. didInsertElement: function () {
  1904. this._super();
  1905. this.fitHeight();
  1906. },
  1907. footerClass: App.WizardStep3HostWarningPopupFooter,
  1908. bodyClass: App.WizardStep3HostWarningPopupBody
  1909. });
  1910. },
  1911. /**
  1912. * Show popup with registered hosts
  1913. * @return {App.ModalPopup}
  1914. * @method registeredHostsPopup
  1915. */
  1916. registeredHostsPopup: function () {
  1917. var self = this;
  1918. return App.ModalPopup.show({
  1919. header: Em.I18n.t('installer.step3.warning.registeredHosts').format(this.get('registeredHosts').length),
  1920. secondary: null,
  1921. bodyClass: Em.View.extend({
  1922. templateName: require('templates/wizard/step3/step3_registered_hosts_popup'),
  1923. message: Em.I18n.t('installer.step3.registeredHostsPopup'),
  1924. registeredHosts: self.get('registeredHosts')
  1925. })
  1926. })
  1927. }
  1928. });