step9_controller.js 44 KB

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