step3_controller.js 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225
  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. App.WizardStep3Controller = Em.Controller.extend({
  21. name: 'wizardStep3Controller',
  22. hosts: [],
  23. content: [],
  24. bootHosts: [],
  25. registeredHosts: [],
  26. registrationStartedAt: null,
  27. registrationTimeoutSecs: function(){
  28. if(this.get('content.installOptions.manualInstall')){
  29. return 15;
  30. }
  31. return 120;
  32. }.property('content.installOptions.manualInstall'),
  33. stopBootstrap: false,
  34. isSubmitDisabled: true,
  35. categoryObject: Em.Object.extend({
  36. hostsCount: function () {
  37. var category = this;
  38. var hosts = this.get('controller.hosts').filter(function(_host) {
  39. if (_host.get('bootStatus') == category.get('hostsBootStatus')) {
  40. return true;
  41. } else {
  42. return (_host.get('bootStatus') == 'DONE' && category.get('hostsBootStatus') == 'REGISTERING');
  43. }
  44. }, this);
  45. return hosts.get('length');
  46. }.property('controller.hosts.@each.bootStatus'), // 'hosts.@each.bootStatus'
  47. label: function () {
  48. return "%@ (%@)".fmt(this.get('value'), this.get('hostsCount'));
  49. }.property('value', 'hostsCount')
  50. }),
  51. getCategory: function(field, value){
  52. return this.get('categories').find(function(item){
  53. return item.get(field) == value;
  54. });
  55. },
  56. categories: function () {
  57. var self = this;
  58. self.categoryObject.reopen({
  59. controller: self,
  60. isActive: function(){
  61. return this.get('controller.category') == this;
  62. }.property('controller.category'),
  63. itemClass: function(){
  64. return this.get('isActive') ? 'active' : '';
  65. }.property('isActive')
  66. });
  67. var categories = [
  68. self.categoryObject.create({value: Em.I18n.t('common.all'), hostsCount: function () {
  69. return this.get('controller.hosts.length');
  70. }.property('controller.hosts.length') }),
  71. self.categoryObject.create({value: Em.I18n.t('installer.step3.hosts.status.installing'), hostsBootStatus: 'RUNNING'}),
  72. self.categoryObject.create({value: Em.I18n.t('installer.step3.hosts.status.registering'), hostsBootStatus: 'REGISTERING'}),
  73. self.categoryObject.create({value: Em.I18n.t('common.success'), hostsBootStatus: 'REGISTERED' }),
  74. self.categoryObject.create({value: Em.I18n.t('common.fail'), hostsBootStatus: 'FAILED', last: true })
  75. ];
  76. this.set('category', categories.get('firstObject'));
  77. return categories;
  78. }.property(),
  79. category: false,
  80. allChecked: false,
  81. onAllChecked: function () {
  82. var hosts = this.get('visibleHosts');
  83. hosts.setEach('isChecked', this.get('allChecked'));
  84. }.observes('allChecked'),
  85. noHostsSelected: function () {
  86. return !(this.hosts.someProperty('isChecked', true));
  87. }.property('hosts.@each.isChecked'),
  88. isRetryDisabled: true,
  89. isLoaded: false,
  90. navigateStep: function () {
  91. if(this.get('isLoaded')){
  92. if (this.get('content.installOptions.manualInstall') !== true) {
  93. if (!this.get('wizardController').getDBProperty('bootStatus')) {
  94. this.startBootstrap();
  95. }
  96. } else {
  97. this.set('bootHosts', this.get('hosts'));
  98. if (App.testMode) {
  99. this.getHostInfo();
  100. this.get('bootHosts').setEach('bootStatus', 'REGISTERED');
  101. this.get('bootHosts').setEach('cpu', '2');
  102. this.get('bootHosts').setEach('memory', '2000000');
  103. this.set('isSubmitDisabled', false);
  104. } else {
  105. this.set('registrationStartedAt', null);
  106. this.get('bootHosts').setEach('bootStatus', 'DONE');
  107. this.startRegistration();
  108. }
  109. }
  110. }
  111. }.observes('isLoaded'),
  112. clearStep: function () {
  113. this.set('stopBootstrap', false);
  114. this.set('hosts', []);
  115. this.get('bootHosts').clear();
  116. this.get('wizardController').setDBProperty('bootStatus', false);
  117. this.set('isSubmitDisabled', true);
  118. this.set('isRetryDisabled', true);
  119. },
  120. loadStep: function () {
  121. console.log("TRACE: Loading step3: Confirm Hosts");
  122. this.set('registrationStartedAt', null);
  123. this.set('isLoaded', false);
  124. this.disablePreviousSteps();
  125. this.clearStep();
  126. this.loadHosts();
  127. // hosts.setEach('bootStatus', 'RUNNING');
  128. },
  129. /* Loads the hostinfo from localStorage on the insertion of view. It's being called from view */
  130. loadHosts: function () {
  131. var hostsInfo = this.get('content.hosts');
  132. var hosts = [];
  133. for (var index in hostsInfo) {
  134. var hostInfo = App.HostInfo.create({
  135. name: hostsInfo[index].name,
  136. bootStatus: hostsInfo[index].bootStatus,
  137. isChecked: false
  138. });
  139. hosts.pushObject(hostInfo);
  140. }
  141. if(hosts.length > 200) {
  142. lazyloading.run({
  143. destination: this.get('hosts'),
  144. source: hosts,
  145. context: this,
  146. initSize: 100,
  147. chunkSize: 150,
  148. delay: 50
  149. });
  150. } else {
  151. this.set('hosts', hosts);
  152. this.set('isLoaded', true);
  153. }
  154. },
  155. /**
  156. * Parses and updates the content based on bootstrap API response.
  157. * Returns true if polling should continue (some hosts are in "RUNNING" state); false otherwise
  158. */
  159. parseHostInfo: function (hostsStatusFromServer) {
  160. hostsStatusFromServer.forEach(function (_hostStatus) {
  161. var host = this.get('bootHosts').findProperty('name', _hostStatus.hostName);
  162. // check if hostname extracted from REST API data matches any hostname in content
  163. // also, make sure that bootStatus modified by isHostsRegistered call does not get overwritten
  164. // since these calls are being made in parallel
  165. if (host && !['REGISTERED', 'REGISTERING'].contains(host.get('bootStatus'))) {
  166. host.set('bootStatus', _hostStatus.status);
  167. host.set('bootLog', _hostStatus.log);
  168. }
  169. }, this);
  170. // if the data rendered by REST API has hosts in "RUNNING" state, polling will continue
  171. return this.get('bootHosts').length != 0 && this.get('bootHosts').someProperty('bootStatus', 'RUNNING');
  172. },
  173. filterByCategory: function () {
  174. var category = this.get('category.hostsBootStatus');
  175. if (category) {
  176. this.get('hosts').forEach(function (host) {
  177. host.set('isVisible', (category === host.get('bootStatus')));
  178. });
  179. } else { // if (this.get('category') === 'All Hosts')
  180. this.get('hosts').setEach('isVisible', true);
  181. }
  182. }.observes('category', 'hosts.@each.bootStatus'),
  183. /* Returns the current set of visible hosts on view (All, Succeeded, Failed) */
  184. visibleHosts: function () {
  185. return this.get('hosts').filterProperty('isVisible');
  186. }.property('hosts.@each.isVisible'),
  187. removeHosts: function (hosts) {
  188. var self = this;
  189. App.showConfirmationPopup(function() {
  190. App.router.send('removeHosts', hosts);
  191. self.hosts.removeObjects(hosts);
  192. if (!self.hosts.length) {
  193. self.set('isSubmitDisabled', true);
  194. }
  195. },Em.I18n.t('installer.step3.hosts.remove.popup.body'));
  196. },
  197. /* Removes a single element on the trash icon click. Called from View */
  198. removeHost: function (hostInfo) {
  199. this.removeHosts([hostInfo]);
  200. },
  201. removeSelectedHosts: function () {
  202. if (!this.get('noHostsSelected')) {
  203. var selectedHosts = this.get('visibleHosts').filterProperty('isChecked', true);
  204. selectedHosts.forEach(function (_hostInfo) {
  205. console.log('Removing: ' + _hostInfo.name);
  206. });
  207. this.removeHosts(selectedHosts);
  208. }
  209. },
  210. retryHost: function (hostInfo) {
  211. this.retryHosts([hostInfo]);
  212. },
  213. retryHosts: function (hosts) {
  214. this.selectAllCategory();
  215. var bootStrapData = JSON.stringify({'verbose': true, 'sshKey': this.get('content.installOptions.sshKey'), 'hosts': hosts.mapProperty('name'), 'user': this.get('content.installOptions.sshUser')});
  216. this.numPolls = 0;
  217. if (this.get('content.installOptions.manualInstall') !== true) {
  218. var requestId = App.router.get('installerController').launchBootstrap(bootStrapData);
  219. this.set('content.installOptions.bootRequestId', requestId);
  220. this.set('registrationStartedAt', null);
  221. this.doBootstrap();
  222. } else {
  223. this.set('registrationStartedAt', null);
  224. this.get('bootHosts').setEach('bootStatus', 'DONE');
  225. this.startRegistration();
  226. }
  227. },
  228. retrySelectedHosts: function () {
  229. //to display all hosts
  230. this.set('category', 'All');
  231. if (!this.get('isRetryDisabled')) {
  232. this.set('isRetryDisabled', true);
  233. var selectedHosts = this.get('bootHosts').filterProperty('bootStatus', 'FAILED');
  234. selectedHosts.forEach(function (_host) {
  235. _host.set('bootStatus', 'RUNNING');
  236. _host.set('bootLog', 'Retrying ...');
  237. }, this);
  238. this.retryHosts(selectedHosts);
  239. }
  240. },
  241. numPolls: 0,
  242. startBootstrap: function () {
  243. //this.set('isSubmitDisabled', true); //TODO: uncomment after actual hookup
  244. this.numPolls = 0;
  245. this.set('registrationStartedAt', null);
  246. this.set('bootHosts', this.get('hosts'));
  247. this.get('bootHosts').setEach('bootStatus', 'PENDING');
  248. this.doBootstrap();
  249. },
  250. isRegistrationInProgress: true,
  251. setRegistrationInProgress: function () {
  252. var bootHosts = this.get('bootHosts');
  253. //if hosts aren't loaded yet then registration should be in progress
  254. var result = (bootHosts.length === 0);
  255. for (var i = 0, l = bootHosts.length; i < l; i++) {
  256. if (bootHosts[i].get('bootStatus') !== 'REGISTERED' && bootHosts[i].get('bootStatus') !== 'FAILED') {
  257. result = true;
  258. break;
  259. }
  260. }
  261. this.set('isRegistrationInProgress', result);
  262. }.observes('bootHosts.@each.bootStatus'),
  263. disablePreviousSteps: function () {
  264. App.router.get('installerController.isStepDisabled').filter(function (step) {
  265. if (step.step >= 0 && step.step <= 2) return true;
  266. }).setEach('value', this.get('isRegistrationInProgress'));
  267. if (this.get('isRegistrationInProgress')) {
  268. this.set('isSubmitDisabled', true);
  269. }
  270. }.observes('isRegistrationInProgress'),
  271. doBootstrap: function () {
  272. if (this.get('stopBootstrap')) {
  273. return;
  274. }
  275. this.numPolls++;
  276. App.ajax.send({
  277. name: 'wizard.step3.bootstrap',
  278. sender: this,
  279. data: {
  280. bootRequestId: this.get('content.installOptions.bootRequestId'),
  281. numPolls: this.numPolls
  282. },
  283. success: 'doBootstrapSuccessCallback'
  284. }).
  285. retry({
  286. times: App.maxRetries,
  287. timeout: App.timeout
  288. }).
  289. then(
  290. null,
  291. function () {
  292. App.showReloadPopup();
  293. console.log('Bootstrap failed');
  294. }
  295. );
  296. },
  297. doBootstrapSuccessCallback: function (data) {
  298. var self = this;
  299. var pollingInterval = 3000;
  300. if (data.hostsStatus === undefined) {
  301. console.log('Invalid response, setting timeout');
  302. window.setTimeout(function () {
  303. self.doBootstrap()
  304. }, pollingInterval);
  305. } else {
  306. // in case of bootstrapping just one host, the server returns an object rather than an array, so
  307. // force into an array
  308. if (!(data.hostsStatus instanceof Array)) {
  309. data.hostsStatus = [ data.hostsStatus ];
  310. }
  311. console.log("TRACE: In success function for the GET bootstrap call");
  312. var keepPolling = this.parseHostInfo(data.hostsStatus);
  313. // Single host : if the only hostname is invalid (data.status == 'ERROR')
  314. // Multiple hosts : if one or more hostnames are invalid
  315. // following check will mark the bootStatus as 'FAILED' for the invalid hostname
  316. if (data.status == 'ERROR' || data.hostsStatus.length != this.get('bootHosts').length) {
  317. var hosts = this.get('bootHosts');
  318. for (var i = 0; i < hosts.length; i++) {
  319. var isValidHost = data.hostsStatus.someProperty('hostName', hosts[i].get('name'));
  320. if(hosts[i].get('bootStatus') !== 'REGISTERED'){
  321. if (!isValidHost) {
  322. hosts[i].set('bootStatus', 'FAILED');
  323. hosts[i].set('bootLog', Em.I18n.t('installer.step3.hosts.bootLog.failed'));
  324. }
  325. }
  326. }
  327. }
  328. if (data.status == 'ERROR' || data.hostsStatus.someProperty('status', 'DONE') || data.hostsStatus.someProperty('status', 'FAILED')) {
  329. // kicking off registration polls after at least one host has succeeded
  330. this.startRegistration();
  331. }
  332. if (keepPolling) {
  333. window.setTimeout(function () {
  334. self.doBootstrap()
  335. }, pollingInterval);
  336. }
  337. }
  338. },
  339. startRegistration: function () {
  340. if (this.get('registrationStartedAt') == null) {
  341. this.set('registrationStartedAt', new Date().getTime());
  342. console.log('registration started at ' + this.get('registrationStartedAt'));
  343. this.isHostsRegistered();
  344. }
  345. },
  346. isHostsRegistered: function () {
  347. if (this.get('stopBootstrap')) {
  348. return;
  349. }
  350. App.ajax.send({
  351. name: 'wizard.step3.is_hosts_registered',
  352. sender: this,
  353. success: 'isHostsRegisteredSuccessCallback'
  354. }).
  355. retry({
  356. times: App.maxRetries,
  357. timeout: App.timeout
  358. }).
  359. then(
  360. null,
  361. function () {
  362. App.showReloadPopup();
  363. console.log('Error: Getting registered host information from the server');
  364. }
  365. );
  366. },
  367. isHostsRegisteredSuccessCallback: function (data) {
  368. console.log('registration attempt...');
  369. var hosts = this.get('bootHosts');
  370. var jsonData = data;
  371. if (!jsonData) {
  372. console.warn("Error: jsonData is null");
  373. return;
  374. }
  375. // keep polling until all hosts have registered/failed, or registrationTimeout seconds after the last host finished bootstrapping
  376. var stopPolling = true;
  377. hosts.forEach(function (_host, index) {
  378. // Change name of first host for test mode.
  379. if (App.testMode) {
  380. if (index == 0) {
  381. _host.set('name', 'localhost.localdomain');
  382. }
  383. }
  384. // actions to take depending on the host's current bootStatus
  385. // RUNNING - bootstrap is running; leave it alone
  386. // DONE - bootstrap is done; transition to REGISTERING
  387. // REGISTERING - bootstrap is done but has not registered; transition to REGISTERED if host found in polling API result
  388. // REGISTERED - bootstrap and registration is done; leave it alone
  389. // FAILED - either bootstrap or registration failed; leave it alone
  390. switch (_host.get('bootStatus')) {
  391. case 'DONE':
  392. _host.set('bootStatus', 'REGISTERING');
  393. _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
  394. // update registration timestamp so that the timeout is computed from the last host that finished bootstrapping
  395. this.set('registrationStartedAt', new Date().getTime());
  396. stopPolling = false;
  397. break;
  398. case 'REGISTERING':
  399. if (jsonData.items.someProperty('Hosts.host_name', _host.name)) {
  400. _host.set('bootStatus', 'REGISTERED');
  401. _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
  402. } else {
  403. stopPolling = false;
  404. }
  405. break;
  406. case 'RUNNING':
  407. stopPolling = false;
  408. break;
  409. case 'REGISTERED':
  410. case 'FAILED':
  411. default:
  412. break;
  413. }
  414. }, this);
  415. if (stopPolling) {
  416. this.getHostInfo();
  417. } else if (hosts.someProperty('bootStatus', 'RUNNING') || new Date().getTime() - this.get('registrationStartedAt') < this.get('registrationTimeoutSecs') * 1000) {
  418. // we want to keep polling for registration status if any of the hosts are still bootstrapping (so we check for RUNNING).
  419. var self = this;
  420. window.setTimeout(function () {
  421. self.isHostsRegistered();
  422. }, 3000);
  423. } else {
  424. // registration timed out. mark all REGISTERING hosts to FAILED
  425. console.log('registration timed out');
  426. hosts.filterProperty('bootStatus', 'REGISTERING').forEach(function (_host) {
  427. _host.set('bootStatus', 'FAILED');
  428. _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.failed'));
  429. });
  430. this.getHostInfo();
  431. }
  432. },
  433. hasMoreRegisteredHosts: false,
  434. getAllRegisteredHosts: function() {
  435. App.ajax.send({
  436. name: 'wizard.step3.is_hosts_registered',
  437. sender: this,
  438. success: 'getAllRegisteredHostsCallback'
  439. });
  440. }.observes('bootHosts'),
  441. hostsInCluster: function() {
  442. return App.Host.find().getEach('hostName');
  443. }.property().volatile(),
  444. getAllRegisteredHostsCallback: function(hosts) {
  445. var registeredHosts = [];
  446. var hostsInCluster = this.get('hostsInCluster');
  447. var addedHosts = this.get('bootHosts').getEach('name');
  448. hosts.items.forEach(function(host){
  449. if (!hostsInCluster.contains(host.Hosts.host_name) && !addedHosts.contains(host.Hosts.host_name)) {
  450. registeredHosts.push(host.Hosts.host_name);
  451. }
  452. });
  453. if(registeredHosts.length) {
  454. this.set('hasMoreRegisteredHosts',true);
  455. this.set('registeredHosts',registeredHosts);
  456. } else {
  457. this.set('hasMoreRegisteredHosts',false);
  458. this.set('registeredHosts','');
  459. }
  460. },
  461. registerErrPopup: function (header, message) {
  462. App.ModalPopup.show({
  463. header: header,
  464. secondary: false,
  465. bodyClass: Ember.View.extend({
  466. template: Ember.Handlebars.compile('<p>{{view.message}}</p>'),
  467. message: message
  468. })
  469. });
  470. },
  471. /**
  472. * Get disk info and cpu count of booted hosts from server
  473. */
  474. getHostInfo: function () {
  475. App.ajax.send({
  476. name: 'wizard.step3.host_info',
  477. sender: this,
  478. success: 'getHostInfoSuccessCallback',
  479. error: 'getHostInfoErrorCallback'
  480. });
  481. },
  482. getHostInfoSuccessCallback: function (jsonData) {
  483. var hosts = this.get('bootHosts');
  484. var self = this;
  485. this.parseWarnings(jsonData);
  486. var repoWarnings = [];
  487. var hostsContext = [];
  488. hosts.forEach(function (_host) {
  489. var host = (App.testMode) ? jsonData.items[0] : jsonData.items.findProperty('Hosts.host_name', _host.name);
  490. if (App.skipBootstrap) {
  491. _host.cpu = 2;
  492. _host.memory = ((parseInt(2000000))).toFixed(2);
  493. _host.disk_info = [{"mountpoint": "/", "type":"ext4"},{"mountpoint": "/grid/0", "type":"ext4"}, {"mountpoint": "/grid/1", "type":"ext4"}, {"mountpoint": "/grid/2", "type":"ext4"}];
  494. } else if (host) {
  495. _host.cpu = host.Hosts.cpu_count;
  496. _host.memory = ((parseInt(host.Hosts.total_mem))).toFixed(2);
  497. _host.disk_info = host.Hosts.disk_info;
  498. _host.os_type = host.Hosts.os_type;
  499. _host.os_arch = host.Hosts.os_arch;
  500. _host.ip = host.Hosts.ip;
  501. var context = self.checkHostOSType(host.Hosts.os_type, host.Hosts.host_name);
  502. if(context) {
  503. hostsContext.push(context);
  504. }
  505. }
  506. });
  507. if (hostsContext.length > 0) { // warning exist
  508. var repoWarning = {
  509. name: Em.I18n.t('installer.step3.hostWarningsPopup.repositories.name'),
  510. hosts: hostsContext,
  511. category: 'repositories',
  512. onSingleHost: false
  513. };
  514. repoWarnings.push(repoWarning);
  515. }
  516. this.set('repoCategoryWarnings', repoWarnings);
  517. this.set('bootHosts', hosts);
  518. this.stopRegistration();
  519. },
  520. getHostInfoErrorCallback: function () {
  521. console.log('INFO: Getting host information(cpu_count and total_mem) from the server failed');
  522. this.registerErrPopup(Em.I18n.t('installer.step3.hostInformation.popup.header'), Em.I18n.t('installer.step3.hostInformation.popup.body'));
  523. },
  524. stopRegistration: function () {
  525. this.set('isSubmitDisabled', !this.get('bootHosts').someProperty('bootStatus', 'REGISTERED'));
  526. this.set('isRetryDisabled', !this.get('bootHosts').someProperty('bootStatus', 'FAILED'));
  527. },
  528. /**
  529. * Check if the customized os group contains the registered host os type. If not the repo on that host is invalid.
  530. */
  531. checkHostOSType: function (osType, hostName) {
  532. if(this.get('content.stacks')){
  533. var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
  534. var selectedOS = [];
  535. var isValid = false;
  536. if (selectedStack && selectedStack.operatingSystems) {
  537. selectedStack.get('operatingSystems').filterProperty('selected', true).forEach( function(os) {
  538. selectedOS.pushObject(os.osType);
  539. if ( os.osType == osType) {
  540. isValid = true;
  541. }
  542. });
  543. }
  544. if (!isValid) {
  545. console.log('WARNING: Getting host os type does NOT match the user selected os group in step1. ' +
  546. 'Host Name: '+ hostName + '. Host os type:' + osType + '. Selected group:' + selectedOS);
  547. return Em.I18n.t('installer.step3.hostWarningsPopup.repositories.context').format(hostName, osType, selectedOS);
  548. } else {
  549. return null;
  550. }
  551. }else{
  552. return null;
  553. }
  554. },
  555. selectCategory: function(event, context){
  556. this.set('category', event.context);
  557. },
  558. selectAllCategory: function(){
  559. this.set('category', this.get('categories').get('firstObject'));
  560. },
  561. submit: function () {
  562. if (!this.get('isSubmitDisabled')) {
  563. if(this.get('isHostHaveWarnings')) {
  564. var self = this;
  565. App.showConfirmationPopup(
  566. function(){
  567. self.set('content.hosts', self.get('bootHosts'));
  568. App.router.send('next');
  569. },
  570. Em.I18n.t('installer.step3.hostWarningsPopup.hostHasWarnings'));
  571. }
  572. else {
  573. this.set('content.hosts', this.get('bootHosts'));
  574. App.router.send('next');
  575. }
  576. }
  577. },
  578. hostLogPopup: function (event, context) {
  579. var host = event.context;
  580. App.ModalPopup.show({
  581. header: Em.I18n.t('installer.step3.hostLog.popup.header').format(host.get('name')),
  582. secondary: null,
  583. bodyClass: Ember.View.extend({
  584. templateName: require('templates/wizard/step3_host_log_popup'),
  585. host: host,
  586. didInsertElement: function () {
  587. var self = this;
  588. var button = $(this.get('element')).find('.textTrigger');
  589. button.click(function () {
  590. if (self.get('isTextArea')) {
  591. $(this).text(Em.I18n.t('installer.step3.hostLogPopup.highlight'));
  592. } else {
  593. $(this).text(Em.I18n.t('installer.step3.hostLogPopup.copy'));
  594. }
  595. self.set('isTextArea', !self.get('isTextArea'));
  596. });
  597. $(this.get('element')).find('.content-area').mouseenter(
  598. function () {
  599. var element = $(this);
  600. element.css('border', '1px solid #dcdcdc');
  601. button.css('visibility', 'visible');
  602. }).mouseleave(
  603. function () {
  604. var element = $(this);
  605. element.css('border', 'none');
  606. button.css('visibility', 'hidden');
  607. })
  608. },
  609. isTextArea: false,
  610. textArea: Em.TextArea.extend({
  611. didInsertElement: function () {
  612. var element = $(this.get('element'));
  613. element.width($(this.get('parentView').get('element')).width() - 10);
  614. element.height($(this.get('parentView').get('element')).height());
  615. element.select();
  616. element.css('resize', 'none');
  617. },
  618. readOnly: true,
  619. value: function () {
  620. return this.get('content');
  621. }.property('content')
  622. })
  623. })
  624. });
  625. },
  626. /**
  627. * check warnings from server and put it in parsing
  628. */
  629. rerunChecks: function () {
  630. var self = this;
  631. var currentProgress = 0;
  632. var interval = setInterval(function () {
  633. currentProgress += 100000 / self.get('warningsTimeInterval');
  634. if (currentProgress < 100) {
  635. self.set('checksUpdateProgress', currentProgress);
  636. } else {
  637. clearInterval(interval);
  638. App.ajax.send({
  639. name: 'wizard.step3.rerun_checks',
  640. sender: self,
  641. success: 'rerunChecksSuccessCallback',
  642. error: 'rerunChecksErrorCallback'
  643. });
  644. }
  645. }, 1000);
  646. },
  647. rerunChecksSuccessCallback: function (data) {
  648. this.set('checksUpdateProgress', 100);
  649. this.set('checksUpdateStatus', 'SUCCESS');
  650. this.parseWarnings(data);
  651. },
  652. rerunChecksErrorCallback: function () {
  653. this.set('checksUpdateProgress', 100);
  654. this.set('checksUpdateStatus', 'FAILED');
  655. console.log('INFO: Getting host information(last_agent_env) from the server failed');
  656. },
  657. warnings: [],
  658. warningsByHost: [],
  659. warningsTimeInterval: 60000,
  660. /**
  661. * check are hosts have any warnings
  662. */
  663. isHostHaveWarnings: function(){
  664. return this.get('warnings.length') > 0;
  665. }.property('warnings'),
  666. isWarningsBoxVisible: function(){
  667. return (App.testMode) ? true : !this.get('isRegistrationInProgress');
  668. }.property('isRegistrationInProgress'),
  669. checksUpdateProgress:0,
  670. checksUpdateStatus: null,
  671. /**
  672. * filter data for warnings parse
  673. * is data from host in bootStrap
  674. * @param data
  675. * @return {Object}
  676. */
  677. filterBootHosts: function (data) {
  678. var bootHostNames = this.get('bootHosts').mapProperty('name');
  679. var filteredData = {
  680. href: data.href,
  681. items: []
  682. };
  683. data.items.forEach(function (host) {
  684. if (bootHostNames.contains(host.Hosts.host_name)) {
  685. filteredData.items.push(host);
  686. }
  687. });
  688. return filteredData;
  689. },
  690. /**
  691. * parse warnings data for each host and total
  692. * @param data
  693. */
  694. parseWarnings: function (data) {
  695. data = App.testMode ? data : this.filterBootHosts(data);
  696. var warnings = [];
  697. var warning;
  698. var hosts = [];
  699. data.items.sort(function (a, b) {
  700. if (a.Hosts.host_name > b.Hosts.host_name) {
  701. return 1;
  702. }
  703. if (a.Hosts.host_name < b.Hosts.host_name) {
  704. return -1;
  705. }
  706. return 0;
  707. });
  708. data.items.forEach(function (_host) {
  709. var host = {
  710. name: _host.Hosts.host_name,
  711. warnings: []
  712. }
  713. if (!_host.Hosts.last_agent_env) {
  714. // in some unusual circumstances when last_agent_env is not available from the _host,
  715. // skip the _host and proceed to process the rest of the hosts.
  716. console.log("last_agent_env is missing for " + _host.Hosts.host_name + ". Skipping _host check.");
  717. return;
  718. }
  719. //parse all directories and files warnings for host
  720. //todo: to be removed after check in new API
  721. var stackFoldersAndFiles = _host.Hosts.last_agent_env.stackFoldersAndFiles || _host.Hosts.last_agent_env.paths;
  722. stackFoldersAndFiles.forEach(function (path) {
  723. warning = warnings.filterProperty('category', 'fileFolders').findProperty('name', path.name);
  724. if (warning) {
  725. warning.hosts.push(_host.Hosts.host_name);
  726. warning.onSingleHost = false;
  727. } else {
  728. warning = {
  729. name: path.name,
  730. hosts: [_host.Hosts.host_name],
  731. category: 'fileFolders',
  732. onSingleHost: true
  733. }
  734. warnings.push(warning);
  735. }
  736. host.warnings.push(warning);
  737. }, this);
  738. //parse all package warnings for host
  739. _host.Hosts.last_agent_env.installedPackages.forEach(function (_package) {
  740. warning = warnings.filterProperty('category', 'packages').findProperty('name', _package.name);
  741. if (warning) {
  742. warning.hosts.push(_host.Hosts.host_name);
  743. warning.version = _package.version,
  744. warning.onSingleHost = false;
  745. } else {
  746. warning = {
  747. name: _package.name,
  748. version: _package.version,
  749. hosts: [_host.Hosts.host_name],
  750. category: 'packages',
  751. onSingleHost: true
  752. }
  753. warnings.push(warning);
  754. }
  755. host.warnings.push(warning);
  756. }, this);
  757. //parse all process warnings for host
  758. //todo: to be removed after check in new API
  759. var javaProcs = _host.Hosts.last_agent_env.hostHealth ? _host.Hosts.last_agent_env.hostHealth.activeJavaProcs : _host.Hosts.last_agent_env.javaProcs;
  760. javaProcs.forEach(function (process) {
  761. warning = warnings.filterProperty('category', 'processes').findProperty('pid', process.pid);
  762. if (warning) {
  763. warning.hosts.push(_host.Hosts.host_name);
  764. warning.onSingleHost = false;
  765. } else {
  766. warning = {
  767. name: (process.command.substr(0, 35) + '...'),
  768. hosts: [_host.Hosts.host_name],
  769. category: 'processes',
  770. user: process.user,
  771. pid: process.pid,
  772. command: '<table><tr><td style="word-break: break-all;">' +
  773. ((process.command.length < 500) ? process.command : process.command.substr(0, 230) + '...' +
  774. '<p style="text-align: center">................</p>' +
  775. '...' + process.command.substr(-230)) + '</td></tr></table>',
  776. onSingleHost: true
  777. }
  778. warnings.push(warning);
  779. }
  780. host.warnings.push(warning);
  781. }, this);
  782. //parse all service warnings for host
  783. //todo: to be removed after check in new API
  784. if (_host.Hosts.last_agent_env.hostHealth && _host.Hosts.last_agent_env.hostHealth.liveServices) {
  785. _host.Hosts.last_agent_env.hostHealth.liveServices.forEach(function (service) {
  786. if (service.status === 'Unhealthy') {
  787. warning = warnings.filterProperty('category', 'services').findProperty('name', service.name);
  788. if (warning) {
  789. warning.hosts.push(_host.Hosts.host_name);
  790. warning.onSingleHost = false;
  791. } else {
  792. warning = {
  793. name: service.name,
  794. hosts: [_host.Hosts.host_name],
  795. category: 'services',
  796. onSingleHost: true
  797. }
  798. warnings.push(warning);
  799. }
  800. host.warnings.push(warning);
  801. }
  802. }, this);
  803. }
  804. //parse all user warnings for host
  805. //todo: to be removed after check in new API
  806. if (_host.Hosts.last_agent_env.existingUsers) {
  807. _host.Hosts.last_agent_env.existingUsers.forEach(function (user) {
  808. warning = warnings.filterProperty('category', 'users').findProperty('name', user.userName);
  809. if (warning) {
  810. warning.hosts.push(_host.Hosts.host_name);
  811. warning.onSingleHost = false;
  812. } else {
  813. warning = {
  814. name: user.userName,
  815. hosts: [_host.Hosts.host_name],
  816. category: 'users',
  817. onSingleHost: true
  818. }
  819. warnings.push(warning);
  820. }
  821. host.warnings.push(warning);
  822. }, this);
  823. }
  824. //parse misc warnings for host
  825. var umask = _host.Hosts.last_agent_env.umask;
  826. if (umask && umask !== 18) {
  827. warning = warnings.filterProperty('category', 'misc').findProperty('name', umask);
  828. if (warning) {
  829. warning.hosts.push(_host.Hosts.host_name);
  830. warning.onSingleHost = false;
  831. } else {
  832. warning = {
  833. name: umask,
  834. hosts: [_host.Hosts.host_name],
  835. category: 'misc',
  836. onSingleHost: true
  837. }
  838. warnings.push(warning);
  839. }
  840. host.warnings.push(warning);
  841. }
  842. var firewallRunning = _host.Hosts.last_agent_env.iptablesIsRunning;
  843. if (firewallRunning!==null && firewallRunning) {
  844. var name = Em.I18n.t('installer.step3.hostWarningsPopup.firewall.name');
  845. warning = warnings.filterProperty('category', 'firewall').findProperty('name', name);
  846. if (warning) {
  847. warning.hosts.push(_host.Hosts.host_name);
  848. warning.onSingleHost = false;
  849. } else {
  850. warning = {
  851. name: name,
  852. hosts: [_host.Hosts.host_name],
  853. category: 'firewall',
  854. onSingleHost: true
  855. }
  856. warnings.push(warning);
  857. }
  858. host.warnings.push(warning);
  859. }
  860. hosts.push(host);
  861. }, this);
  862. warnings.forEach(function (warn) {
  863. if (warn.hosts.length < 11) {
  864. warn.hostsList = warn.hosts.join('<br>')
  865. } else {
  866. warn.hostsList = warn.hosts.slice(0,10).join('<br>') + '<br> ' + Em.I18n.t('installer.step3.hostWarningsPopup.moreHosts').format(warn.hosts.length - 10);
  867. }
  868. });
  869. hosts.unshift({
  870. name: 'All Hosts',
  871. warnings: warnings
  872. });
  873. this.set('warnings', warnings);
  874. this.set('warningsByHost', hosts);
  875. },
  876. /**
  877. * open popup that contain hosts' warnings
  878. * @param event
  879. */
  880. hostWarningsPopup: function(event){
  881. var self = this;
  882. var repoCategoryWarnings = this.get('repoCategoryWarnings');
  883. App.ModalPopup.show({
  884. header: Em.I18n.t('installer.step3.warnings.popup.header'),
  885. secondary: Em.I18n.t('installer.step3.hostWarningsPopup.rerunChecks'),
  886. primary: Em.I18n.t('common.close'),
  887. onPrimary: function () {
  888. self.set('checksUpdateStatus', null);
  889. this.hide();
  890. },
  891. onClose: function(){
  892. self.set('checksUpdateStatus', null);
  893. this.hide();
  894. },
  895. onSecondary: function() {
  896. self.rerunChecks();
  897. },
  898. didInsertElement: function () {
  899. this.fitHeight();
  900. },
  901. footerClass: Ember.View.extend({
  902. templateName: require('templates/wizard/step3_host_warning_popup_footer'),
  903. classNames: ['modal-footer', 'host-checks-update'],
  904. progressWidth: function(){
  905. return 'width:'+App.router.get('wizardStep3Controller.checksUpdateProgress')+'%';
  906. }.property('App.router.wizardStep3Controller.checksUpdateProgress'),
  907. isUpdateInProgress: function(){
  908. if((App.router.get('wizardStep3Controller.checksUpdateProgress') > 0) &&
  909. (App.router.get('wizardStep3Controller.checksUpdateProgress') < 100)){
  910. return true;
  911. }
  912. }.property('App.router.wizardStep3Controller.checksUpdateProgress'),
  913. updateStatusClass:function(){
  914. var status = App.router.get('wizardStep3Controller.checksUpdateStatus');
  915. if(status === 'SUCCESS'){
  916. return 'text-success';
  917. } else if(status === 'FAILED'){
  918. return 'text-error';
  919. } else {
  920. return null;
  921. }
  922. }.property('App.router.wizardStep3Controller.checksUpdateStatus'),
  923. updateStatus:function(){
  924. var status = App.router.get('wizardStep3Controller.checksUpdateStatus');
  925. if(status === 'SUCCESS'){
  926. return Em.I18n.t('installer.step3.warnings.updateChecks.success');
  927. } else if(status === 'FAILED'){
  928. return Em.I18n.t('installer.step3.warnings.updateChecks.failed');
  929. } else {
  930. return null;
  931. }
  932. }.property('App.router.wizardStep3Controller.checksUpdateStatus')
  933. }),
  934. bodyClass: Ember.View.extend({
  935. templateName: require('templates/wizard/step3_host_warnings_popup'),
  936. classNames: ['host-check'],
  937. didInsertElement: function () {
  938. Ember.run.next(this, function () {
  939. App.tooltip(this.$("[rel='HostsListTooltip']"), {html: true, placement: "right"});
  940. App.tooltip(this.$('#process .warning-name'), {html: true, placement: "top"});
  941. })
  942. }.observes('content'),
  943. warningsByHost: function () {
  944. return App.router.get('wizardStep3Controller.warningsByHost');
  945. }.property('App.router.wizardStep3Controller.warningsByHost'),
  946. warnings: function () {
  947. return App.router.get('wizardStep3Controller.warnings');
  948. }.property('App.router.wizardStep3Controller.warnings'),
  949. categories: function () {
  950. return this.get('warningsByHost').mapProperty('name');
  951. }.property('warningsByHost'),
  952. category: 'All Hosts',
  953. categoryWarnings: function () {
  954. return this.get('warningsByHost').findProperty('name', this.get('category')).warnings
  955. }.property('warningsByHost', 'category'),
  956. content: function () {
  957. var categoryWarnings = this.get('categoryWarnings');
  958. return [
  959. Ember.Object.create({
  960. warnings: repoCategoryWarnings,
  961. title: Em.I18n.t('installer.step3.hostWarningsPopup.repositories'),
  962. message: Em.I18n.t('installer.step3.hostWarningsPopup.repositories.message'),
  963. type: Em.I18n.t('common.issues'),
  964. emptyName: Em.I18n.t('installer.step3.hostWarningsPopup.empty.repositories'),
  965. action: Em.I18n.t('installer.step3.hostWarningsPopup.action.invalid'),
  966. category: 'repositories'
  967. }),
  968. Ember.Object.create({
  969. warnings: categoryWarnings.filterProperty('category', 'firewall'),
  970. title: Em.I18n.t('installer.step3.hostWarningsPopup.firewall'),
  971. message: Em.I18n.t('installer.step3.hostWarningsPopup.firewall.message'),
  972. type: Em.I18n.t('common.issues'),
  973. emptyName: Em.I18n.t('installer.step3.hostWarningsPopup.empty.firewall'),
  974. action: Em.I18n.t('installer.step3.hostWarningsPopup.action.running'),
  975. category: 'firewall'
  976. }),
  977. Ember.Object.create({
  978. warnings: categoryWarnings.filterProperty('category', 'processes'),
  979. title: Em.I18n.t('installer.step3.hostWarningsPopup.process'),
  980. message: Em.I18n.t('installer.step3.hostWarningsPopup.processes.message'),
  981. type: Em.I18n.t('common.process'),
  982. emptyName: Em.I18n.t('installer.step3.hostWarningsPopup.empty.processes'),
  983. action: Em.I18n.t('installer.step3.hostWarningsPopup.action.running'),
  984. category: 'process'
  985. }),
  986. Ember.Object.create({
  987. warnings: categoryWarnings.filterProperty('category', 'packages'),
  988. title: Em.I18n.t('installer.step3.hostWarningsPopup.package'),
  989. message: Em.I18n.t('installer.step3.hostWarningsPopup.packages.message'),
  990. type: Em.I18n.t('common.package'),
  991. emptyName: Em.I18n.t('installer.step3.hostWarningsPopup.empty.packages'),
  992. action: Em.I18n.t('installer.step3.hostWarningsPopup.action.installed'),
  993. category: 'package'
  994. }),
  995. Ember.Object.create({
  996. warnings: categoryWarnings.filterProperty('category', 'fileFolders'),
  997. title: Em.I18n.t('installer.step3.hostWarningsPopup.fileAndFolder'),
  998. message: Em.I18n.t('installer.step3.hostWarningsPopup.fileFolders.message'),
  999. type: Em.I18n.t('common.path'),
  1000. emptyName: Em.I18n.t('installer.step3.hostWarningsPopup.empty.filesAndFolders'),
  1001. action: Em.I18n.t('installer.step3.hostWarningsPopup.action.exists'),
  1002. category: 'fileFolders'
  1003. }),
  1004. Ember.Object.create({
  1005. warnings: categoryWarnings.filterProperty('category', 'services'),
  1006. title: Em.I18n.t('installer.step3.hostWarningsPopup.service'),
  1007. message: Em.I18n.t('installer.step3.hostWarningsPopup.services.message'),
  1008. type: Em.I18n.t('common.service'),
  1009. emptyName: Em.I18n.t('installer.step3.hostWarningsPopup.empty.services'),
  1010. action: Em.I18n.t('installer.step3.hostWarningsPopup.action.notRunning'),
  1011. category: 'service'
  1012. }),
  1013. Ember.Object.create({
  1014. warnings: categoryWarnings.filterProperty('category', 'users'),
  1015. title: Em.I18n.t('installer.step3.hostWarningsPopup.user'),
  1016. message: Em.I18n.t('installer.step3.hostWarningsPopup.users.message'),
  1017. type: Em.I18n.t('common.user'),
  1018. emptyName: Em.I18n.t('installer.step3.hostWarningsPopup.empty.users'),
  1019. action: Em.I18n.t('installer.step3.hostWarningsPopup.action.exists'),
  1020. category: 'user'
  1021. }),
  1022. Ember.Object.create({
  1023. warnings: categoryWarnings.filterProperty('category', 'misc'),
  1024. title: Em.I18n.t('installer.step3.hostWarningsPopup.misc'),
  1025. message: Em.I18n.t('installer.step3.hostWarningsPopup.misc.message'),
  1026. type: Em.I18n.t('installer.step3.hostWarningsPopup.misc.umask'),
  1027. emptyName: Em.I18n.t('installer.step3.hostWarningsPopup.empty.misc'),
  1028. action: Em.I18n.t('installer.step3.hostWarningsPopup.action.exists'),
  1029. category: 'misc'
  1030. })
  1031. ]
  1032. }.property('category', 'warningsByHost'),
  1033. showHostsPopup: function (hosts) {
  1034. $('.tooltip').hide();
  1035. App.ModalPopup.show({
  1036. header: Em.I18n.t('installer.step3.hostWarningsPopup.allHosts'),
  1037. bodyClass: Ember.View.extend({
  1038. hosts: hosts.context,
  1039. template: Ember.Handlebars.compile('<ul>{{#each host in view.hosts}}<li>{{host}}</li>{{/each}}</ul>')
  1040. }),
  1041. secondary: null
  1042. });
  1043. },
  1044. onToggleBlock: function (category) {
  1045. this.$('#' + category.context.category).toggle('blind', 500);
  1046. },
  1047. warningsNotice: function () {
  1048. var warnings = this.get('warnings');
  1049. var warningsByHost = self.get('warningsByHost').slice();
  1050. warningsByHost.shift();
  1051. var issuesNumber = warnings.length + repoCategoryWarnings.length;
  1052. var issues = issuesNumber + ' ' + (issuesNumber.length === 1 ? Em.I18n.t('installer.step3.hostWarningsPopup.issue') : Em.I18n.t('installer.step3.hostWarningsPopup.issues'));
  1053. var repoHostsNumber = (repoCategoryWarnings.length > 0 ? repoCategoryWarnings[0].hosts.length : 0);
  1054. var hostsNumber = repoHostsNumber + warningsByHost.length - warningsByHost.filterProperty('warnings.length', 0).length;
  1055. var hosts = hostsNumber + ' ' + (hostsNumber === 1 ? Em.I18n.t('installer.step3.hostWarningsPopup.host') : Em.I18n.t('installer.step3.hostWarningsPopup.hosts'));
  1056. return Em.I18n.t('installer.step3.hostWarningsPopup.summary').format(issues, hosts);
  1057. }.property('warnings', 'warningsByHost'),
  1058. /**
  1059. * generate detailed content to show it in new window
  1060. */
  1061. contentInDetails: function () {
  1062. var content = this.get('content');
  1063. var warningsByHost = this.get('warningsByHost').slice();
  1064. warningsByHost.shift();
  1065. var newContent = '';
  1066. newContent += Em.I18n.t('installer.step3.hostWarningsPopup.report.header') + new Date;
  1067. newContent += Em.I18n.t('installer.step3.hostWarningsPopup.report.hosts');
  1068. newContent += warningsByHost.filterProperty('warnings.length').mapProperty('name').join(' ');
  1069. if (content.findProperty('category', 'fileFolders').warnings.length) {
  1070. newContent += Em.I18n.t('installer.step3.hostWarningsPopup.report.fileFolders');
  1071. newContent += content.findProperty('category', 'fileFolders').warnings.mapProperty('name').join(' ');
  1072. }
  1073. if (content.findProperty('category', 'process').warnings.length) {
  1074. newContent += Em.I18n.t('installer.step3.hostWarningsPopup.report.process');
  1075. content.findProperty('category', 'process').warnings.forEach(function (process, i) {
  1076. process.hosts.forEach(function (host, j) {
  1077. if (!!i || !!j) {
  1078. newContent += ',';
  1079. }
  1080. newContent += '(' + host + ',' + process.user + ',' + process.pid + ')';
  1081. });
  1082. });
  1083. }
  1084. if (content.findProperty('category', 'package').warnings.length) {
  1085. newContent += Em.I18n.t('installer.step3.hostWarningsPopup.report.package');
  1086. newContent += content.findProperty('category', 'package').warnings.mapProperty('name').join(' ');
  1087. }
  1088. if (content.findProperty('category', 'service').warnings.length) {
  1089. newContent += Em.I18n.t('installer.step3.hostWarningsPopup.report.service');
  1090. newContent += content.findProperty('category', 'service').warnings.mapProperty('name').join(' ');
  1091. }
  1092. if (content.findProperty('category', 'user').warnings.length) {
  1093. newContent += Em.I18n.t('installer.step3.hostWarningsPopup.report.user');
  1094. newContent += content.findProperty('category', 'user').warnings.mapProperty('name').join(' ');
  1095. }
  1096. newContent += '</p>';
  1097. return newContent;
  1098. }.property('content', 'warningsByHost'),
  1099. /**
  1100. * open new browser tab with detailed content
  1101. */
  1102. openWarningsInDialog: function(){
  1103. var newWindow = window.open('');
  1104. var newDocument = newWindow.document;
  1105. newDocument.write(this.get('contentInDetails'));
  1106. newWindow.focus();
  1107. }
  1108. })
  1109. })
  1110. },
  1111. registeredHostsPopup: function(){
  1112. var self = this;
  1113. App.ModalPopup.show({
  1114. header: Em.I18n.t('installer.step3.warning.registeredHosts').format(this.get('registeredHosts').length),
  1115. secondary: null,
  1116. bodyClass: Ember.View.extend({
  1117. templateName: require('templates/wizard/step3_registered_hosts_popup'),
  1118. message: Em.I18n.t('installer.step3.registeredHostsPopup'),
  1119. registeredHosts: self.get('registeredHosts')
  1120. })
  1121. })
  1122. },
  1123. back: function () {
  1124. if (this.get('isRegistrationInProgress')) {
  1125. return;
  1126. }
  1127. App.router.send('back');
  1128. }
  1129. });