step3_controller.js 46 KB

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