step3_controller.js 44 KB

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