step9_controller.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231
  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 serviceComponents = require('data/service_components');
  20. App.WizardStep9Controller = Em.Controller.extend({
  21. name: 'wizardStep9Controller',
  22. /**
  23. * Array of host Objects that are successfully registered on "Confirm Host Options" page
  24. * <code>
  25. * {
  26. * name: {String} host name.
  27. * status: {String} Current status of the host. This field is used in the step 9 view to set the css class of the
  28. * host progress bar and set the appropriate message. Possible values: info, warning, failed, heartbeat_lost and success
  29. * logTasks: {Array} Tasks that are scheduled on the host for the current request.
  30. * message: {String} Message to be shown in front of the host name.
  31. * progress: {Int} Progress of the tasks on the host. Amount of tasks completed for all the tasks scheduled on the host.
  32. * isNoTasksForInstall: {Boolean} Gets set when no task is scheduled for the host on install phase.
  33. * }
  34. * </code>
  35. */
  36. hosts: [],
  37. /*
  38. * Indicate whether to show the message(that there are no hosts to display) instead of list of hosts
  39. */
  40. isAnyHostDisplayed: true,
  41. /**
  42. * overall progress of <Install,Start and Test> page shown as progress bar on the top of the page
  43. */
  44. progress: '0',
  45. /*
  46. * json file for the mock data to be used in mock mode
  47. */
  48. mockDataPrefix: '/data/wizard/deploy/5_hosts',
  49. /*
  50. * Current Request data polled from the API: api/v1/clusters/{clusterName}/requests/{RequestId}?fields=tasks/Tasks/command,
  51. * tasks/Tasks/exit_code,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,
  52. * tasks/Tasks/status&minimal_response=true
  53. */
  54. polledData: [],
  55. /*
  56. * This flag is only used in UI mock mode as a counter for number of polls.
  57. */
  58. numPolls: 1,
  59. // Interval in milliseconds between API calls While polling the request status for Install and, Start and Test tasks
  60. POLL_INTERVAL: 4000,
  61. /**
  62. * Array of objects
  63. * <code>
  64. * {
  65. * hostName: {String} Name of host that has stopped heartbeating to ambari-server
  66. * componentNames: {Sting} Name of all components that are on the host
  67. * }
  68. * </code>
  69. */
  70. hostsWithHeartbeatLost: [],
  71. // Flag is set in the start all services error callback function
  72. startCallFailed: false,
  73. /*
  74. * Status of the page. Possible values: <info, warning, failed and success>.
  75. * This property is used in the step-9 view for displaying the appropriate color of the overall progress bar and
  76. * the appropriate result message at the bottom of the page
  77. */
  78. status: 'info',
  79. /**
  80. * This computed property is used to determine if the Next button and back button on the page should be disabled. The property is
  81. * used in the template to grey out Next and Back buttons. Although clicking on the greyed out button do trigger the event and
  82. * calls submit and back function of the controller.
  83. */
  84. isSubmitDisabled: function () {
  85. var validStates = ['STARTED', 'START FAILED'];
  86. var controllerName = this.get('content.controllerName');
  87. if (controllerName == 'addHostController' || controllerName == 'addServiceController') {
  88. validStates.push('INSTALL FAILED');
  89. }
  90. return !validStates.contains(this.get('content.cluster.status'));
  91. }.property('content.cluster.status'),
  92. /**
  93. * This function is called when a click event happens on Next button of <Install, Start and Test> page
  94. */
  95. submit: function () {
  96. if (!this.get('isSubmitDisabled')) {
  97. App.router.send('next');
  98. }
  99. },
  100. /**
  101. * This function is called when a click event happens on back button of <Install, Start and Test> page
  102. */
  103. back: function () {
  104. if (!this.get('isSubmitDisabled')) {
  105. App.router.send('back');
  106. }
  107. },
  108. /**
  109. * Observer function: Enables previous steps link if install task failed in installer wizard.
  110. */
  111. togglePreviousSteps: function () {
  112. if (App.testMode) {
  113. return;
  114. } else if ('INSTALL FAILED' === this.get('content.cluster.status') && this.get('content.controllerName') == 'installerController') {
  115. App.router.get('installerController').setStepsEnable();
  116. } else {
  117. App.router.get('installerController').setLowerStepsDisable(9);
  118. }
  119. }.observes('content.cluster.status', 'content.controllerName'),
  120. /*
  121. * Computed property to determine if the Retry button should be made visible on the page.
  122. */
  123. showRetry: function () {
  124. return this.get('content.cluster.status') == 'INSTALL FAILED';
  125. }.property('content.cluster.status'),
  126. /**
  127. * Ember Object with the controllerbinding as this controller. This object also contains
  128. * <code>
  129. * hostStatus: {String} A valid status of a host.
  130. * Used to filter hosts in that status.
  131. * hostsCount: {Int} Dynamic count of hosts displayed in the category label
  132. * label : {String} status and hosts in that status displayed which consists as a category on the page
  133. * isActive: {boolean} Gets set when the category is selected/clicked by the user
  134. * itemClass: {computed property} Binds the category link to active class when user clicks on the link
  135. * </code>
  136. */
  137. categoryObject: Em.Object.extend({
  138. hostsCount: function () {
  139. var category = this;
  140. var hosts = this.get('controller.hosts').filter(function (_host) {
  141. if (category.get('hostStatus') == 'inProgress') {
  142. return (_host.get('status') == 'info' || _host.get('status') == 'pending' || _host.get('status') == 'in_progress');
  143. } else if (category.get('hostStatus') == 'failed') {
  144. return (_host.get('status') == 'failed' || _host.get('status') == 'heartbeat_lost');
  145. } else {
  146. return (_host.get('status') == category.get('hostStatus'));
  147. }
  148. }, this);
  149. return hosts.get('length');
  150. }.property('controller.hosts.@each.status'),
  151. label: function () {
  152. return "%@ (%@)".fmt(this.get('value'), this.get('hostsCount'));
  153. }.property('value', 'hostsCount')
  154. }),
  155. /**
  156. * computed property creates the category objects on the load of the page and sets 'All' as the active category
  157. * @Returns: All created categories which are binded and iterated in the template
  158. */
  159. categories: function () {
  160. var self = this;
  161. self.categoryObject.reopen({
  162. controller: self,
  163. isActive: function () {
  164. return this.get('controller.category') == this;
  165. }.property('controller.category'),
  166. itemClass: function () {
  167. return this.get('isActive') ? 'active' : '';
  168. }.property('isActive')
  169. });
  170. var categories = [
  171. self.categoryObject.create({value: Em.I18n.t('common.all'), hostStatus: 'all', hostsCount: function () {
  172. return this.get('controller.hosts.length');
  173. }.property('controller.hosts.length') }),
  174. self.categoryObject.create({value: Em.I18n.t('installer.step9.hosts.status.label.inProgress'), hostStatus: 'inProgress'}),
  175. self.categoryObject.create({value: Em.I18n.t('installer.step9.hosts.status.label.warning'), hostStatus: 'warning'}),
  176. self.categoryObject.create({value: Em.I18n.t('common.success'), hostStatus: 'success'}),
  177. self.categoryObject.create({value: Em.I18n.t('common.fail'), hostStatus: 'failed', last: true })
  178. ];
  179. this.set('category', categories.get('firstObject'));
  180. return categories;
  181. }.property(),
  182. /**
  183. * Registered as an handlebar action in step-9 template. Invoked whenever click event occurs on a category label
  184. * @param event: {categoryObject}
  185. */
  186. selectCategory: function (event) {
  187. this.set('category', event.context);
  188. },
  189. /**
  190. * Present clicked/selected {categoryObject} on the page
  191. */
  192. category: false,
  193. /**
  194. * Observer function: Calls {hostStatusUpdates} function once with change in a host status from any registered hosts.
  195. */
  196. hostStatusObserver: function () {
  197. Ember.run.once(this, 'hostStatusUpdates');
  198. }.observes('hosts.@each.status'),
  199. /**
  200. * Updates the hosts mapping to the category selected and updates entire page status
  201. */
  202. hostStatusUpdates: function () {
  203. this.updateVisibleHosts();
  204. this.updateStatus();
  205. },
  206. /**
  207. * Observer function: Updates {visibleHosts Array} of this controller whenever category is changed
  208. */
  209. updateVisibleHosts: function () {
  210. var targetStatus = this.get('category.hostStatus');
  211. var isAnyHostDisplayed = false;
  212. if (targetStatus === 'all') {
  213. isAnyHostDisplayed = true;
  214. this.get('hosts').setEach('isVisible', true);
  215. } else {
  216. this.get('hosts').forEach(function (_host) {
  217. var isVisible = false;
  218. var status = _host.get('status');
  219. if (targetStatus == 'inProgress') {
  220. isVisible = (status == 'info' || status == 'pending' || status == 'in_progress');
  221. } else if (targetStatus === 'failed') {
  222. isVisible = (status === 'failed' || status === 'heartbeat_lost');
  223. } else {
  224. isVisible = (status == targetStatus);
  225. }
  226. isAnyHostDisplayed = (isAnyHostDisplayed || isVisible);
  227. _host.set('isVisible', isVisible);
  228. }, this)
  229. }
  230. this.set('isAnyHostDisplayed', isAnyHostDisplayed);
  231. }.observes('category'),
  232. /**
  233. * A flag that gets set with installation failure.
  234. */
  235. installFailed: false,
  236. /**
  237. * Observer function: Updates {status} field of the controller.
  238. */
  239. updateStatus: function () {
  240. var status = 'info';
  241. if (this.get('hosts').someProperty('status', 'failed')
  242. || this.get('hosts').someProperty('status', 'heartbeat_lost')
  243. || this.get('startCallFailed')) {
  244. status = 'failed';
  245. } else if (this.get('hosts').someProperty('status', 'warning')) {
  246. if (this.isStepFailed()) {
  247. status = 'failed';
  248. } else {
  249. status = 'warning';
  250. }
  251. } else if (this.get('progress') == '100' && this.get('content.cluster.status') !== 'INSTALL FAILED') {
  252. status = 'success';
  253. }
  254. this.set('status', status);
  255. }.observes('progress'),
  256. /**
  257. * Incremental flag that triggers an event in step 9 view to change the tasks related data and icons of hosts.
  258. */
  259. logTasksChangesCounter: 0,
  260. /**
  261. * navigateStep is called by App.WizardStep9View's didInsertElement and "retry" from router.
  262. * content.cluster.status can be:
  263. * PENDING: set upon successful transition from step 1 to step 2
  264. * INSTALLED: set upon successful completion of install phase as well as successful invocation of start services API
  265. * STARTED: set up on successful completion of start phase
  266. * INSTALL FAILED: set up upon encountering a failure in install phase
  267. * START FAILED: set upon unsuccessful invocation of start services API and also upon encountering a failure
  268. * during start phase
  269. * content.cluster.isCompleted
  270. * set to false upon successful transition from step 1 to step 2
  271. * set to true upon successful start of services in this step
  272. * note: looks like this is the same thing as checking content.cluster.status == 'STARTED'
  273. */
  274. navigateStep: function () {
  275. if (App.testMode) {
  276. // this is for repeatedly testing out installs in test mode
  277. this.set('content.cluster.status', 'PENDING');
  278. this.set('content.cluster.isCompleted', false);
  279. this.set('content.cluster.requestId', 1);
  280. }
  281. var clusterStatus = this.get('content.cluster.status');
  282. console.log('navigateStep: clusterStatus = ' + clusterStatus);
  283. if (this.get('content.cluster.isCompleted') === false) {
  284. // the cluster has not yet successfully installed and started
  285. if (clusterStatus === 'INSTALL FAILED') {
  286. this.loadStep();
  287. this.loadLogData(this.get('content.cluster.requestId'));
  288. } else if (clusterStatus === 'START FAILED') {
  289. this.loadStep();
  290. this.loadLogData(this.get('content.cluster.requestId'));
  291. } else {
  292. // handle PENDING, INSTALLED
  293. this.loadStep();
  294. this.loadLogData(this.get('content.cluster.requestId'));
  295. this.startPolling();
  296. }
  297. } else {
  298. // handle STARTED
  299. // the cluster has successfully installed and started
  300. this.loadStep();
  301. this.loadLogData(this.get('content.cluster.requestId'));
  302. this.set('progress', '100');
  303. }
  304. },
  305. /**
  306. * This is called on initial page load, refreshes and retry event.
  307. * clears all in memory stale data for retry event.
  308. */
  309. clearStep: function () {
  310. this.get('hosts').clear();
  311. this.set('hostsWithHeartbeatLost', []);
  312. this.set('startCallFailed',false);
  313. this.set('status', 'info');
  314. this.set('progress', '0');
  315. this.set('numPolls', 1);
  316. },
  317. /**
  318. * This is called on initial page load, refreshes and retry event.
  319. */
  320. loadStep: function () {
  321. console.log("TRACE: Loading step9: Install, Start and Test");
  322. this.clearStep();
  323. this.loadHosts();
  324. },
  325. /**
  326. * Reset status and message of all hosts when retry install
  327. */
  328. resetHostsForRetry: function () {
  329. var hosts = this.get('content.hosts');
  330. for (var name in hosts) {
  331. hosts[name].status = "pending";
  332. hosts[name].message = 'Waiting';
  333. hosts[name].isNoTasksForInstall = false;
  334. }
  335. this.set('content.hosts', hosts);
  336. },
  337. /**
  338. * Sets the {hosts} array for the controller
  339. */
  340. loadHosts: function () {
  341. var hosts = this.get('content.hosts');
  342. for (var index in hosts) {
  343. if (hosts[index].bootStatus === 'REGISTERED') {
  344. var hostInfo = App.HostInfo.create({
  345. name: hosts[index].name,
  346. status: (hosts[index].status) ? hosts[index].status : 'info',
  347. logTasks: [],
  348. message: (hosts[index].message) ? hosts[index].message : 'Waiting',
  349. progress: 0,
  350. isNoTasksForInstall: false
  351. });
  352. this.get('hosts').pushObject(hostInfo);
  353. }
  354. }
  355. },
  356. /**
  357. *
  358. * @param polledData: sets the {polledData} object of the controller
  359. */
  360. replacePolledData: function (polledData) {
  361. this.polledData.clear();
  362. this.set('polledData', polledData);
  363. },
  364. /**
  365. *
  366. * @param task
  367. * @returns {String} The appropriate message for the host as per the running task.
  368. */
  369. displayMessage: function (task) {
  370. var role = App.format.role(task.role);
  371. switch (task.command) {
  372. case 'INSTALL':
  373. switch (task.status) {
  374. case 'PENDING':
  375. return Em.I18n.t('installer.step9.serviceStatus.install.pending') + role;
  376. case 'QUEUED' :
  377. return Em.I18n.t('installer.step9.serviceStatus.install.queued') + role;
  378. case 'IN_PROGRESS':
  379. return Em.I18n.t('installer.step9.serviceStatus.install.inProgress') + role;
  380. case 'COMPLETED' :
  381. return Em.I18n.t('installer.step9.serviceStatus.install.completed') + role;
  382. case 'FAILED':
  383. return Em.I18n.t('installer.step9.serviceStatus.install.failed') + role;
  384. }
  385. case 'UNINSTALL':
  386. switch (task.status) {
  387. case 'PENDING':
  388. return Em.I18n.t('installer.step9.serviceStatus.uninstall.pending') + role;
  389. case 'QUEUED' :
  390. return Em.I18n.t('installer.step9.serviceStatus.uninstall.queued') + role;
  391. case 'IN_PROGRESS':
  392. return Em.I18n.t('installer.step9.serviceStatus.uninstall.inProgress') + role;
  393. case 'COMPLETED' :
  394. return Em.I18n.t('installer.step9.serviceStatus.uninstall.completed') + role;
  395. case 'FAILED':
  396. return Em.I18n.t('installer.step9.serviceStatus.uninstall.failed') + role;
  397. }
  398. case 'START' :
  399. switch (task.status) {
  400. case 'PENDING':
  401. return Em.I18n.t('installer.step9.serviceStatus.start.pending') + role;
  402. case 'QUEUED' :
  403. return Em.I18n.t('installer.step9.serviceStatus.start.queued') + role;
  404. case 'IN_PROGRESS':
  405. return Em.I18n.t('installer.step9.serviceStatus.start.inProgress') + role;
  406. case 'COMPLETED' :
  407. return role + Em.I18n.t('installer.step9.serviceStatus.start.completed');
  408. case 'FAILED':
  409. return role + Em.I18n.t('installer.step9.serviceStatus.start.failed');
  410. }
  411. case 'STOP' :
  412. switch (task.status) {
  413. case 'PENDING':
  414. return Em.I18n.t('installer.step9.serviceStatus.stop.pending') + role;
  415. case 'QUEUED' :
  416. return Em.I18n.t('installer.step9.serviceStatus.stop.queued') + role;
  417. case 'IN_PROGRESS':
  418. return Em.I18n.t('installer.step9.serviceStatus.stop.inProgress') + role;
  419. case 'COMPLETED' :
  420. return role + Em.I18n.t('installer.step9.serviceStatus.stop.completed');
  421. case 'FAILED':
  422. return role + Em.I18n.t('installer.step9.serviceStatus.stop.failed');
  423. }
  424. case 'EXECUTE' :
  425. case 'SERVICE_CHECK' :
  426. switch (task.status) {
  427. case 'PENDING':
  428. return Em.I18n.t('installer.step9.serviceStatus.execute.pending') + role;
  429. case 'QUEUED' :
  430. return Em.I18n.t('installer.step9.serviceStatus.execute.queued') + role;
  431. case 'IN_PROGRESS':
  432. return Em.I18n.t('installer.step9.serviceStatus.execute.inProgress') + role;
  433. case 'COMPLETED' :
  434. return role + Em.I18n.t('installer.step9.serviceStatus.execute.completed');
  435. case 'FAILED':
  436. return role + Em.I18n.t('installer.step9.serviceStatus.execute.failed');
  437. }
  438. case 'ABORT' :
  439. switch (task.status) {
  440. case 'PENDING':
  441. return Em.I18n.t('installer.step9.serviceStatus.abort.pending') + role;
  442. case 'QUEUED' :
  443. return Em.I18n.t('installer.step9.serviceStatus.abort.queued') + role;
  444. case 'IN_PROGRESS':
  445. return Em.I18n.t('installer.step9.serviceStatus.abort.inProgress') + role;
  446. case 'COMPLETED' :
  447. return role + Em.I18n.t('installer.step9.serviceStatus.abort.completed');
  448. case 'FAILED':
  449. return role + Em.I18n.t('installer.step9.serviceStatus.abort.failed');
  450. }
  451. }
  452. return '';
  453. },
  454. /**
  455. * Run start/check services after installation phase.
  456. * Does Ajax call to start all services
  457. */
  458. launchStartServices: function () {
  459. var data = {
  460. "RequestInfo": {
  461. "context": Em.I18n.t("requestInfo.startServices")
  462. },
  463. "Body": {
  464. "ServiceInfo": { "state": "STARTED" }
  465. }
  466. };
  467. var name = 'wizard.step9.installer.launch_start_services';
  468. if (this.get('content.controllerName') === 'addHostController') {
  469. var hostnames = [];
  470. for (var hostname in this.get('wizardController').getDBProperty('hosts')) {
  471. hostnames.push(hostname);
  472. }
  473. data = {
  474. "RequestInfo": {
  475. "context": Em.I18n.t("requestInfo.startHostComponents"),
  476. "query": "HostRoles/component_name.in(" + App.get('components.slaves').join(',') + ")&HostRoles/state=INSTALLED&HostRoles/host_name.in(" + hostnames.join(',') + ")"
  477. },
  478. "Body": {
  479. "HostRoles": { "state": "STARTED" }
  480. }
  481. };
  482. name = 'wizard.step9.add_host.launch_start_services';
  483. }
  484. data = JSON.stringify(data);
  485. if (App.testMode) {
  486. this.set('numPolls', 6);
  487. }
  488. App.ajax.send({
  489. name: name,
  490. sender: this,
  491. data: {
  492. data: data,
  493. cluster: this.get('content.cluster.name')
  494. },
  495. success: 'launchStartServicesSuccessCallback',
  496. error: 'launchStartServicesErrorCallback'
  497. });
  498. },
  499. /**
  500. * Success callback function for start services task.
  501. * @param jsonData: {json object} Contains Request id to poll.
  502. */
  503. launchStartServicesSuccessCallback: function (jsonData) {
  504. var clusterStatus = {};
  505. if (jsonData) {
  506. console.log("TRACE: Step9 -> In success function for the startService call");
  507. console.log("TRACE: Step9 -> value of the received data is: " + jsonData);
  508. var requestId = jsonData.Requests.id;
  509. console.log('requestId is: ' + requestId);
  510. clusterStatus = {
  511. status: 'INSTALLED',
  512. requestId: requestId,
  513. isStartError: false,
  514. isCompleted: false
  515. };
  516. this.hostHasClientsOnly(false);
  517. this.saveClusterStatus(clusterStatus);
  518. } else {
  519. console.log('ERROR: Error occurred in parsing JSON data');
  520. this.hostHasClientsOnly(true);
  521. clusterStatus = {
  522. status: 'STARTED',
  523. isStartError: false,
  524. isCompleted: true
  525. };
  526. this.saveClusterStatus(clusterStatus);
  527. this.set('status', 'success');
  528. this.set('progress', '100');
  529. }
  530. // We need to do recovery if there is a browser crash
  531. App.clusterStatus.setClusterStatus({
  532. clusterState: 'SERVICE_STARTING_3',
  533. wizardControllerName: this.get('content.controllerName'),
  534. localdb: App.db.data
  535. });
  536. if (jsonData) {
  537. this.startPolling();
  538. }
  539. },
  540. /**
  541. * This function will be called for Add host wizard only.
  542. * @param jsonError: {boolean} Boolean is true when API to start services returns 200 ok and no json data
  543. */
  544. hostHasClientsOnly: function (jsonError) {
  545. this.get('hosts').forEach(function (host) {
  546. var OnlyClients = true;
  547. var tasks = host.get('logTasks');
  548. tasks.forEach(function (task) {
  549. var component = serviceComponents.findProperty('component_name', task.Tasks.role);
  550. if (!(component && component.isClient)) {
  551. OnlyClients = false;
  552. }
  553. });
  554. if (OnlyClients || jsonError) {
  555. host.set('status', 'success');
  556. host.set('progress', '100');
  557. }
  558. });
  559. },
  560. /**
  561. * Error callback function for start services task.
  562. */
  563. launchStartServicesErrorCallback: function (jqXHR) {
  564. console.log("ERROR");
  565. this.set('startCallFailed',true);
  566. var clusterStatus = {
  567. status: 'INSTALL FAILED',
  568. isStartError: false,
  569. isCompleted: false
  570. };
  571. this.saveClusterStatus(clusterStatus);
  572. this.get('hosts').forEach(function (host) {
  573. host.set('progress', '100');
  574. });
  575. this.set('progress','100');
  576. var params = {
  577. cluster: this.get('content.cluster.name')
  578. };
  579. if (this.get('content.controllerName') === 'addHostController') {
  580. params.name = 'wizard.step9.add_host.launch_start_services';
  581. } else {
  582. params.name = 'wizard.step9.installer.launch_start_services';
  583. }
  584. var opt = App.formatRequest.call(App.urls[params.name], params);
  585. App.ajax.defaultErrorHandler(jqXHR,opt.url,opt.type);
  586. },
  587. /**
  588. * marks a host's status as "success" if all tasks are in COMPLETED state
  589. */
  590. onSuccessPerHost: function (actions, contentHost) {
  591. if (actions.everyProperty('Tasks.status', 'COMPLETED') && this.get('content.cluster.status') === 'INSTALLED') {
  592. contentHost.set('status', 'success');
  593. }
  594. },
  595. /**
  596. * marks a host's status as "warning" if at least one of the tasks is FAILED, ABORTED, or TIMEDOUT and marks host's status as "failed" if at least one master component install task is FAILED.
  597. * note that if the master failed to install because of ABORTED or TIMEDOUT, we don't mark it as failed, because this would mark all hosts as "failed" and makes it difficult for the user
  598. * to find which host FAILED occurred on, if any
  599. * @param actions {Array} of tasks retrieved from polled data
  600. * @param contentHost {Object} A host object
  601. */
  602. onErrorPerHost: function (actions, contentHost) {
  603. if (!actions) return;
  604. if (actions.someProperty('Tasks.status', 'FAILED') || actions.someProperty('Tasks.status', 'ABORTED') || actions.someProperty('Tasks.status', 'TIMEDOUT')) {
  605. contentHost.set('status', 'warning');
  606. }
  607. if ((this.get('content.cluster.status') === 'PENDING' && actions.someProperty('Tasks.status', 'FAILED')) || (this.isMasterFailed(actions))) {
  608. contentHost.get('status') !== 'heartbeat_lost' ? contentHost.set('status', 'failed') : '';
  609. }
  610. },
  611. /**
  612. *
  613. * @param polledData : Json data polled from API.
  614. * @returns {boolean} true if there is at least one FAILED task of master component install
  615. */
  616. isMasterFailed: function (polledData) {
  617. var result = false;
  618. polledData.filterProperty('Tasks.command', 'INSTALL').filterProperty('Tasks.status', 'FAILED').mapProperty('Tasks.role').forEach(
  619. function (role) {
  620. if (!App.get('components.slaves').contains(role)) {
  621. result = true;
  622. }
  623. }
  624. );
  625. return result;
  626. },
  627. /**
  628. * Mark a host status as in_progress if the any task on the host if either in IN_PROGRESS, QUEUED or PENDONG state.
  629. * @param actions {Array} of tasks retrieved from polled data
  630. * @param contentHost {Object} A host object
  631. */
  632. onInProgressPerHost: function (actions, contentHost) {
  633. var runningAction = actions.findProperty('Tasks.status', 'IN_PROGRESS');
  634. if (runningAction === undefined || runningAction === null) {
  635. runningAction = actions.findProperty('Tasks.status', 'QUEUED');
  636. }
  637. if (runningAction === undefined || runningAction === null) {
  638. runningAction = actions.findProperty('Tasks.status', 'PENDING');
  639. }
  640. if (runningAction !== null && runningAction !== undefined) {
  641. contentHost.set('status', 'in_progress');
  642. contentHost.set('message', this.displayMessage(runningAction.Tasks));
  643. }
  644. },
  645. /**
  646. * calculate progress of tasks per host
  647. * @param actions
  648. * @param contentHost
  649. * @return {Number}
  650. */
  651. progressPerHost: function (actions, contentHost) {
  652. var progress = 0;
  653. var actionsPerHost = actions.length;
  654. var completedActions = 0;
  655. var queuedActions = 0;
  656. var inProgressActions = 0;
  657. actions.forEach(function (action) {
  658. completedActions += +(['COMPLETED', 'FAILED', 'ABORTED', 'TIMEDOUT'].contains(action.Tasks.status));
  659. queuedActions += +(action.Tasks.status === 'QUEUED');
  660. inProgressActions += +(action.Tasks.status === 'IN_PROGRESS');
  661. }, this);
  662. /** for the install phase (PENDING), % completed per host goes up to 33%; floor(100 / 3)
  663. * for the start phase (INSTALLED), % completed starts from 34%
  664. * when task in queued state means it's completed on 9%
  665. * in progress - 35%
  666. * completed - 100%
  667. */
  668. switch (this.get('content.cluster.status')) {
  669. case 'PENDING':
  670. progress = actionsPerHost ? (Math.ceil(((queuedActions * 0.09) + (inProgressActions * 0.35) + completedActions ) / actionsPerHost * 33)) : 33;
  671. break;
  672. case 'INSTALLED':
  673. progress = actionsPerHost ? (34 + Math.ceil(((queuedActions * 0.09) + (inProgressActions * 0.35) + completedActions ) / actionsPerHost * 66)) : 100;
  674. break;
  675. default:
  676. progress = 100;
  677. break;
  678. }
  679. contentHost.set('progress', progress.toString());
  680. return progress;
  681. },
  682. /**
  683. *
  684. * @param polledData : Josn data retrieved from API
  685. * @returns {Boolean} : Has step completed successfully
  686. */
  687. isSuccess: function (polledData) {
  688. return polledData.everyProperty('Tasks.status', 'COMPLETED');
  689. },
  690. /**
  691. * return true if:
  692. * 1. any of the master/client components failed to install
  693. * OR
  694. * 2. at least 50% of the slave host components for the particular service component fails to install
  695. */
  696. isStepFailed: function () {
  697. var failed = false;
  698. var polledData = this.get('polledData');
  699. polledData.filterProperty('Tasks.command', 'INSTALL').mapProperty('Tasks.role').uniq().forEach(function (role) {
  700. if (failed) {
  701. return;
  702. }
  703. var actionsPerRole = polledData.filterProperty('Tasks.role', role);
  704. if (App.get('components.slaves').contains(role)) {
  705. // check slave components for success factor.
  706. // partial failure for slave components are allowed.
  707. var actionsFailed = actionsPerRole.filterProperty('Tasks.status', 'FAILED');
  708. var actionsAborted = actionsPerRole.filterProperty('Tasks.status', 'ABORTED');
  709. var actionsTimedOut = actionsPerRole.filterProperty('Tasks.status', 'TIMEDOUT');
  710. if ((((actionsFailed.length + actionsAborted.length + actionsTimedOut.length) / actionsPerRole.length) * 100) > 50) {
  711. failed = true;
  712. }
  713. } else if (actionsPerRole.someProperty('Tasks.status', 'FAILED') || actionsPerRole.someProperty('Tasks.status', 'ABORTED') ||
  714. actionsPerRole.someProperty('Tasks.status', 'TIMEDOUT')) {
  715. // check non-salve components (i.e., masters and clients). all of these must be successfully installed.
  716. failed = true;
  717. }
  718. }, this);
  719. return failed;
  720. },
  721. /**
  722. * polling from ui stops only when no action has 'PENDING', 'QUEUED' or 'IN_PROGRESS' status
  723. * Makes a state transition
  724. * PENDING -> INSTALLED
  725. * PENDING -> INSTALL FAILED
  726. * INSTALLED -> STARTED
  727. * INSTALLED -> START_FAILED
  728. * @param polledData json data retrieved from API
  729. * @returns {Boolean} true if polling should stop; false otherwise
  730. */
  731. finishState: function (polledData) {
  732. if (this.get('content.cluster.status') === 'INSTALLED') {
  733. return this.isServicesStarted(polledData);
  734. } else if (this.get('content.cluster.status') === 'PENDING') {
  735. return this.isServicesInstalled(polledData);
  736. } else if (this.get('content.cluster.status') === 'INSTALL FAILED' || this.get('content.cluster.status') === 'START FAILED'
  737. || this.get('content.cluster.status') === 'STARTED') {
  738. this.set('progress', '100');
  739. return true;
  740. }
  741. return false;
  742. },
  743. /**
  744. * @param polledData Josn data retrieved from API
  745. * @returns {boolean} Has "Start All Services" request completed successfully
  746. */
  747. isServicesStarted: function (polledData) {
  748. var clusterStatus = {};
  749. if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
  750. this.set('progress', '100');
  751. clusterStatus = {
  752. status: 'INSTALLED',
  753. requestId: this.get('content.cluster.requestId'),
  754. isCompleted: true
  755. };
  756. if (this.isSuccess(polledData)) {
  757. clusterStatus.status = 'STARTED';
  758. var serviceStartTime = App.dateTime();
  759. clusterStatus.installTime = ((parseInt(serviceStartTime) - parseInt(this.get('content.cluster.installStartTime'))) / 60000).toFixed(2);
  760. } else {
  761. clusterStatus.status = 'START FAILED'; // 'START FAILED' implies to step10 that installation was successful but start failed
  762. }
  763. this.saveClusterStatus(clusterStatus);
  764. this.saveInstalledHosts(this);
  765. return true;
  766. }
  767. return false;
  768. },
  769. /**
  770. * @param polledData Josn data retrieved from API
  771. * @returns {boolean} Has "Install All Services" request completed successfully
  772. */
  773. isServicesInstalled: function (polledData) {
  774. var clusterStatus = {};
  775. if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
  776. clusterStatus = {
  777. status: 'PENDING',
  778. requestId: this.get('content.cluster.requestId'),
  779. isCompleted: false
  780. };
  781. if (this.get('status') === 'failed') {
  782. clusterStatus.status = 'INSTALL FAILED';
  783. this.saveClusterStatus(clusterStatus);
  784. this.set('progress', '100');
  785. this.get('hosts').forEach(function (host) {
  786. host.set('progress', '100');
  787. });
  788. this.isAllComponentsInstalled();
  789. } else {
  790. this.set('progress', '34');
  791. if (this.get('content.controllerName') === 'installerController') {
  792. this.isAllComponentsInstalled();
  793. } else {
  794. this.launchStartServices();
  795. }
  796. }
  797. this.saveInstalledHosts(this);
  798. return true;
  799. }
  800. return false;
  801. },
  802. /**
  803. * This is done at HostRole level.
  804. * @param tasksPerHost {Array}
  805. * @param host {Object}
  806. */
  807. setLogTasksStatePerHost: function (tasksPerHost, host) {
  808. tasksPerHost.forEach(function (_task) {
  809. var task = host.logTasks.findProperty('Tasks.id', _task.Tasks.id);
  810. if (task) {
  811. task.Tasks.status = _task.Tasks.status;
  812. task.Tasks.exit_code = _task.Tasks.exit_code;
  813. } else {
  814. host.logTasks.pushObject(_task);
  815. }
  816. }, this);
  817. },
  818. /**
  819. * Parses the Json data retrieved from API and sets the task on the host of {hosts} array binded to template
  820. * @param polledData Json data retrieved from API
  821. * @returns {Boolean} True if stage transition is completed.
  822. * On true, polling will be stopped.
  823. */
  824. parseHostInfo: function (polledData) {
  825. console.log('TRACE: Entering host info function');
  826. var self = this;
  827. var totalProgress = 0;
  828. var tasksData = polledData.tasks;
  829. console.log("The value of tasksData is: ", tasksData);
  830. if (!tasksData) {
  831. console.log("Step9: ERROR: NO tasks available to process");
  832. }
  833. var requestId = this.get('content.cluster.requestId');
  834. tasksData.setEach('Tasks.request_id', requestId);
  835. if (polledData.Requests && polledData.Requests.id && polledData.Requests.id != requestId) {
  836. // We don't want to use non-current requestId's tasks data to
  837. // determine the current install status.
  838. // Also, we don't want to keep polling if it is not the
  839. // current requestId.
  840. return false;
  841. }
  842. this.replacePolledData(tasksData);
  843. var tasksHostMap = {};
  844. tasksData.forEach(function (task) {
  845. if (tasksHostMap[task.Tasks.host_name]) {
  846. tasksHostMap[task.Tasks.host_name].push(task);
  847. } else {
  848. tasksHostMap[task.Tasks.host_name] = [task];
  849. }
  850. });
  851. this.get('hosts').forEach(function (_host) {
  852. var actionsPerHost = tasksHostMap[_host.name] || []; // retrieved from polled Data
  853. if (actionsPerHost.length === 0) {
  854. if (this.get('content.cluster.status') === 'PENDING' || this.get('content.cluster.status') === 'INSTALL FAILED') {
  855. _host.set('progress', '33');
  856. _host.set('isNoTasksForInstall', true);
  857. _host.set('status', 'pending');
  858. }
  859. if (this.get('content.cluster.status') === 'INSTALLED' || this.get('content.cluster.status') === 'FAILED') {
  860. _host.set('progress', '100');
  861. _host.set('status', 'success');
  862. }
  863. console.log("INFO: No task is hosted on the host");
  864. } else {
  865. _host.set('isNoTasksForInstall', false);
  866. }
  867. this.setLogTasksStatePerHost(actionsPerHost, _host);
  868. this.onSuccessPerHost(actionsPerHost, _host); // every action should be a success
  869. this.onErrorPerHost(actionsPerHost, _host); // any action should be a failure
  870. this.onInProgressPerHost(actionsPerHost, _host); // current running action for a host
  871. totalProgress += self.progressPerHost(actionsPerHost, _host);
  872. if (_host.get('progress') == '33' && _host.get('status') != 'failed' && _host.get('status') != 'warning') {
  873. _host.set('message', this.t('installer.step9.host.status.nothingToInstall'));
  874. _host.set('status', 'pending');
  875. }
  876. }, this);
  877. this.set('logTasksChangesCounter', this.get('logTasksChangesCounter') + 1);
  878. totalProgress = Math.floor(totalProgress / this.get('hosts.length'));
  879. this.set('progress', totalProgress.toString());
  880. console.log("INFO: right now the progress is: " + this.get('progress'));
  881. return this.finishState(tasksData);
  882. },
  883. /**
  884. * starts polling to the API.
  885. */
  886. startPolling: function () {
  887. this.set('isSubmitDisabled', true);
  888. this.doPolling();
  889. },
  890. /**
  891. *
  892. * @param requestId {Int} Request Id received on triggering install/start command successfully
  893. * @returns {string} URL to poll to track the result of the triggered command
  894. */
  895. getUrl: function (requestId) {
  896. var clusterName = this.get('content.cluster.name');
  897. var requestId = requestId || this.get('content.cluster.requestId');
  898. var url = App.apiPrefix + '/clusters/' + clusterName + '/requests/' + requestId + '?fields=tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true';
  899. console.log("URL for step9 is: " + url);
  900. return url;
  901. },
  902. /**
  903. * This function calls API just once to fetch log data of all tasks.
  904. * @param requestId {Int} Request Id received on triggering install/start command successfully
  905. */
  906. loadLogData: function (requestId) {
  907. var url = this.getUrl(requestId);
  908. var requestsId = this.get('wizardController').getDBProperty('cluster').oldRequestsId;
  909. if (App.testMode) {
  910. this.POLL_INTERVAL = 1;
  911. }
  912. requestsId.forEach(function (requestId) {
  913. url = this.getUrl(requestId);
  914. if (App.testMode) {
  915. this.POLL_INTERVAL = 1;
  916. url = this.get('mockDataPrefix') + '/poll_' + this.numPolls + '.json';
  917. }
  918. this.getLogsByRequest(url, false);
  919. }, this);
  920. },
  921. /**
  922. * {Number}
  923. * <code>taskId</code> of current open task
  924. */
  925. currentOpenTaskId: 0,
  926. /**
  927. * {Number}
  928. * <code>requestId</code> of current open task
  929. */
  930. currentOpenTaskRequestId: 0,
  931. /**
  932. * Load form server <code>stderr, stdout</code> of current open task
  933. */
  934. loadCurrentTaskLog: function () {
  935. var taskId = this.get('currentOpenTaskId');
  936. var requestId = this.get('currentOpenTaskRequestId');
  937. var clusterName = this.get('content.cluster.name');
  938. if (!taskId) {
  939. console.log('taskId is null.');
  940. return;
  941. }
  942. App.ajax.send({
  943. name: 'background_operations.get_by_task',
  944. sender: this,
  945. data: {
  946. 'taskId': taskId,
  947. 'requestId': requestId,
  948. 'clusterName': clusterName,
  949. 'sync': true
  950. },
  951. success: 'loadCurrentTaskLogSuccessCallback',
  952. error: 'loadCurrentTaskLogErrorCallback'
  953. });
  954. },
  955. /**
  956. * success callback function for getting log data of the opened task
  957. * @param data json object
  958. */
  959. loadCurrentTaskLogSuccessCallback: function (data) {
  960. var taskId = this.get('currentOpenTaskId');
  961. if (taskId) {
  962. var currentTask = this.get('hosts').findProperty('name', data.Tasks.host_name).get('logTasks').findProperty('Tasks.id', data.Tasks.id);
  963. if (currentTask) {
  964. currentTask.Tasks.stderr = data.Tasks.stderr;
  965. currentTask.Tasks.stdout = data.Tasks.stdout;
  966. }
  967. }
  968. this.set('logTasksChangesCounter', this.get('logTasksChangesCounter') + 1);
  969. },
  970. /**
  971. * Error callback function for getting log data of the opened task
  972. */
  973. loadCurrentTaskLogErrorCallback: function () {
  974. this.set('currentOpenTaskId', 0);
  975. },
  976. /**
  977. * Function polls the API to retrieve data for the request.
  978. * @param url {string} url to poll
  979. * @param polling {Boolean} whether to continue polling for status or not
  980. */
  981. getLogsByRequest: function (url, polling) {
  982. var self = this;
  983. $.ajax({
  984. type: 'GET',
  985. url: url,
  986. async: true,
  987. timeout: App.timeout,
  988. dataType: 'text',
  989. success: function (data) {
  990. var parsedData = jQuery.parseJSON(data);
  991. console.log("TRACE: In success function for the GET logs data");
  992. console.log("TRACE: Step9 -> The value is: ", parsedData);
  993. var result = self.parseHostInfo(parsedData);
  994. if (!polling) {
  995. if (self.get('content.cluster.status') === 'INSTALL FAILED') {
  996. self.isAllComponentsInstalled();
  997. }
  998. return;
  999. }
  1000. if (result !== true) {
  1001. window.setTimeout(function () {
  1002. if (self.get('currentOpenTaskId')) {
  1003. self.loadCurrentTaskLog();
  1004. }
  1005. self.doPolling();
  1006. }, self.POLL_INTERVAL);
  1007. }
  1008. },
  1009. error: function (request, ajaxOptions, error) {
  1010. console.log("TRACE: STep9 -> In error function for the GET logs data");
  1011. console.log("TRACE: STep9 -> value of the url is: " + url);
  1012. console.log("TRACE: STep9 -> error code status is: " + request.status);
  1013. },
  1014. statusCode: require('data/statusCodes')
  1015. }).retry({times: App.maxRetries, timeout: App.timeout}).then(null,
  1016. function () {
  1017. App.showReloadPopup();
  1018. console.log('Install services all retries failed');
  1019. }
  1020. );
  1021. },
  1022. /**
  1023. * Delegates the function call to {getLogsByRequest} with appropriate params
  1024. */
  1025. doPolling: function () {
  1026. var url = this.getUrl();
  1027. if (App.testMode) {
  1028. this.numPolls++;
  1029. url = this.get('mockDataPrefix') + '/poll_' + this.get('numPolls') + '.json';
  1030. }
  1031. this.getLogsByRequest(url, true);
  1032. },
  1033. /**
  1034. * Check that all components are in INSTALLED state before issuing start command
  1035. */
  1036. isAllComponentsInstalled: function () {
  1037. if (this.get('content.controllerName') !== 'installerController') {
  1038. return;
  1039. }
  1040. var name = 'wizard.step9.installer.get_host_status';
  1041. App.ajax.send({
  1042. name: name,
  1043. sender: this,
  1044. data: {
  1045. cluster: this.get('content.cluster.name')
  1046. },
  1047. success: 'isAllComponentsInstalledSuccessCallback',
  1048. error: 'isAllComponentsInstalledErrorCallback'
  1049. });
  1050. },
  1051. /**
  1052. * Success callback function for API checking host state and host_components state.
  1053. * @param jsonData {Object}
  1054. */
  1055. isAllComponentsInstalledSuccessCallback: function (jsonData) {
  1056. var clusterStatus = {
  1057. status: 'INSTALL FAILED',
  1058. isStartError: true,
  1059. isCompleted: false
  1060. };
  1061. var hostsWithHeartbeatLost = [];
  1062. jsonData.items.filterProperty('Hosts.host_state', 'HEARTBEAT_LOST').forEach(function (host) {
  1063. var hostComponentObj = {hostName: host.Hosts.host_name};
  1064. var componentArr = [];
  1065. host.host_components.forEach(function (_hostComponent) {
  1066. var componentName = App.format.role(_hostComponent.HostRoles.component_name);
  1067. componentArr.pushObject(componentName);
  1068. }, this);
  1069. hostComponentObj.componentNames = this.getComponentMessage(componentArr);
  1070. hostsWithHeartbeatLost.pushObject(hostComponentObj);
  1071. }, this);
  1072. this.set('hostsWithHeartbeatLost', hostsWithHeartbeatLost);
  1073. if (hostsWithHeartbeatLost.length) {
  1074. this.get('hosts').forEach(function (host) {
  1075. if (hostsWithHeartbeatLost.someProperty(('hostName'), host.get('name'))) {
  1076. host.set('status', 'heartbeat_lost');
  1077. } else if (host.get('status') !== 'failed' && host.get('status') !== 'warning') {
  1078. host.set('message', Em.I18n.t('installer.step9.host.status.startAborted'));
  1079. }
  1080. host.set('progress', '100');
  1081. });
  1082. this.set('progress', '100');
  1083. this.saveClusterStatus(clusterStatus);
  1084. } else if (this.get('content.cluster.status') === 'PENDING') {
  1085. this.launchStartServices();
  1086. }
  1087. },
  1088. /**
  1089. * Error callback function for API checking host state and host_components state
  1090. */
  1091. isAllComponentsInstalledErrorCallback: function () {
  1092. console.log("ERROR");
  1093. var clusterStatus = {
  1094. status: 'INSTALL FAILED',
  1095. isStartError: true,
  1096. isCompleted: false
  1097. };
  1098. this.set('progress', '100');
  1099. this.get('hosts').forEach(function (host) {
  1100. if (host.get('status') !== 'failed' && host.get('status') !== 'warning') {
  1101. host.set('message', Em.I18n.t('installer.step9.host.status.startAborted'));
  1102. host.set('progress', '100');
  1103. }
  1104. });
  1105. this.saveClusterStatus(clusterStatus);
  1106. },
  1107. /**
  1108. * @param componentArr {Array} Array of components
  1109. * @returns {String} Formatted string of components to display on the UI.
  1110. */
  1111. getComponentMessage: function (componentArr) {
  1112. var label;
  1113. componentArr.forEach(function (_component) {
  1114. if (_component === componentArr[0]) {
  1115. label = _component;
  1116. } else if (_component !== componentArr[componentArr.length - 1]) { // [clients.length - 1]
  1117. label = label + ' ' + _component;
  1118. if (_component !== componentArr[componentArr.length - 2]) {
  1119. label = label + ',';
  1120. }
  1121. } else {
  1122. label = label + ' ' + Em.I18n.t('and') + ' ' + _component;
  1123. }
  1124. }, this);
  1125. return label;
  1126. },
  1127. /**
  1128. * save cluster status in the parentController and localdb
  1129. * @param clusterStatus {Object}
  1130. */
  1131. saveClusterStatus: function(clusterStatus) {
  1132. if (!App.testMode) {
  1133. App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
  1134. } else {
  1135. this.set('content.cluster',clusterStatus);
  1136. }
  1137. },
  1138. /**
  1139. * save cluster status in the parentController and localdb
  1140. * @param context
  1141. */
  1142. saveInstalledHosts: function(context) {
  1143. if (!App.testMode) {
  1144. App.router.get(this.get('content.controllerName')).saveInstalledHosts(context)
  1145. }
  1146. }
  1147. });