step3_controller.js 46 KB

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