step3_controller.js 44 KB

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