step3_controller.js 45 KB

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