step3_controller.js 46 KB

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