step9_controller.js 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  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'));
  102. }.property('content.cluster.status'),
  103. /**
  104. * Observer function: Enables previous steps link if install task failed in installer wizard.
  105. * @method togglePreviousSteps
  106. */
  107. togglePreviousSteps: function () {
  108. if (App.get('testMode')) {
  109. return;
  110. }
  111. var installerController = App.router.get('installerController');
  112. if ('INSTALL FAILED' === this.get('content.cluster.status') && this.get('content.controllerName') == 'installerController') {
  113. installerController.setStepsEnable();
  114. } else {
  115. installerController.setLowerStepsDisable(9);
  116. }
  117. }.observes('content.cluster.status', 'content.controllerName'),
  118. /**
  119. * Computed property to determine if the Retry button should be made visible on the page.
  120. * @type {bool}
  121. */
  122. showRetry: function () {
  123. return this.get('content.cluster.status') == 'INSTALL FAILED';
  124. }.property('content.cluster.status'),
  125. /**
  126. * Observer function: Calls {hostStatusUpdates} function once with change in a host status from any registered hosts.
  127. * @method hostStatusObserver
  128. */
  129. hostStatusObserver: function () {
  130. Em.run.once(this, 'updateStatus');
  131. }.observes('hosts.@each.status'),
  132. /**
  133. * A flag that gets set with installation failure.
  134. * @type {bool}
  135. */
  136. installFailed: false,
  137. /**
  138. * Incremental flag that triggers an event in step 9 view to change the tasks related data and icons of hosts.
  139. * @type {number}
  140. */
  141. logTasksChangesCounter: 0,
  142. /**
  143. * <code>taskId</code> of current open task
  144. * @type {number}
  145. */
  146. currentOpenTaskId: 0,
  147. /**
  148. * <code>requestId</code> of current open task
  149. * @type {number}
  150. */
  151. currentOpenTaskRequestId: 0,
  152. /**
  153. * True if stage transition is completed.
  154. * On true, polling will be stopped.
  155. * @type {bool}s
  156. */
  157. parseHostInfo: false,
  158. isPolling: true,
  159. changeParseHostInfo: function (value) {
  160. this.set('parseHostInfo', value);
  161. this.parseHostInfoPolling();
  162. },
  163. parseHostInfoPolling: function () {
  164. var self = this;
  165. var result = this.get('parseHostInfo');
  166. if (!this.get('isPolling')) {
  167. if (this.get('content.cluster.status') === 'INSTALL FAILED') {
  168. this.isAllComponentsInstalled();
  169. }
  170. return;
  171. }
  172. if (result !== true) {
  173. window.setTimeout(function () {
  174. if (self.get('currentOpenTaskId')) {
  175. self.loadCurrentTaskLog();
  176. }
  177. if (App.router.loggedIn) {
  178. self.doPolling();
  179. }
  180. }, this.get('POLL_INTERVAL'));
  181. }
  182. },
  183. /**
  184. * Observer function: Updates {status} field of the controller.
  185. * @method updateStatus
  186. */
  187. updateStatus: function () {
  188. var status = 'info';
  189. if (this.get('hosts').someProperty('status', 'failed')
  190. || this.get('hosts').someProperty('status', 'heartbeat_lost')
  191. || this.get('startCallFailed')) {
  192. status = 'failed';
  193. } else if (this.get('hosts').someProperty('status', 'warning')) {
  194. if (this.isStepFailed()) {
  195. status = 'failed';
  196. } else {
  197. status = 'warning';
  198. }
  199. } else if (this.get('progress') == '100' && this.get('content.cluster.status') !== 'INSTALL FAILED') {
  200. status = 'success';
  201. }
  202. this.set('status', status);
  203. }.observes('progress'),
  204. /**
  205. * This function is called when a click event happens on Next button of "Install, Start and Test" page
  206. * @method submit
  207. */
  208. submit: function () {
  209. App.router.send('next');
  210. },
  211. /**
  212. * This function is called when a click event happens on back button of "Install, Start and Test" page
  213. * @method back
  214. */
  215. back: function () {
  216. if (!this.get('isSubmitDisabled')) {
  217. App.router.send('back');
  218. }
  219. },
  220. /**
  221. * navigateStep is called by App.WizardStep9View's didInsertElement and "retry" from router.
  222. * content.cluster.status can be:
  223. * PENDING: set upon successful transition from step 1 to step 2
  224. * INSTALLED: set upon successful completion of install phase as well as successful invocation of start services API
  225. * STARTED: set up on successful completion of start phase
  226. * INSTALL FAILED: set up upon encountering a failure in install phase
  227. * START FAILED: set upon unsuccessful invocation of start services API and also upon encountering a failure
  228. * during start phase
  229. * content.cluster.isCompleted
  230. * set to false upon successful transition from step 1 to step 2
  231. * set to true upon successful start of services in this step
  232. * note: looks like this is the same thing as checking content.cluster.status == 'STARTED'
  233. * @method navigateStep
  234. */
  235. navigateStep: function () {
  236. if (App.get('testMode')) {
  237. // this is for repeatedly testing out installs in test mode
  238. this.set('content.cluster.status', 'PENDING');
  239. this.set('content.cluster.isCompleted', false);
  240. this.set('content.cluster.requestId', 1);
  241. }
  242. var needPolling = false;
  243. var clusterStatus = this.get('content.cluster.status');
  244. if (this.get('content.cluster.isCompleted') === false) {
  245. if (clusterStatus !== 'INSTALL FAILED' && clusterStatus !== 'START FAILED') {
  246. needPolling = true;
  247. }
  248. } else {
  249. // handle STARTED
  250. // the cluster has successfully installed and started
  251. this.set('progress', '100');
  252. }
  253. this.loadStep();
  254. this.loadLogData(needPolling);
  255. },
  256. /**
  257. * This is called on initial page load, refreshes and retry event.
  258. * clears all in memory stale data for retry event.
  259. * @method clearStep
  260. */
  261. clearStep: function () {
  262. this.get('hosts').clear();
  263. this.set('hostsWithHeartbeatLost', []);
  264. this.set('startCallFailed', false);
  265. this.set('status', 'info');
  266. this.set('progress', '0');
  267. this.set('numPolls', 1);
  268. },
  269. /**
  270. * This is called on initial page load, refreshes and retry event.
  271. * @method loadStep
  272. */
  273. loadStep: function () {
  274. this.clearStep();
  275. this.loadHosts();
  276. },
  277. /**
  278. * Reset status and message of all hosts when retry install
  279. * @method resetHostsForRetry
  280. */
  281. resetHostsForRetry: function () {
  282. var hosts = this.get('content.hosts');
  283. for (var name in hosts) {
  284. if (hosts.hasOwnProperty(name)) {
  285. hosts[name].status = "pending";
  286. hosts[name].message = 'Waiting';
  287. hosts[name].isNoTasksForInstall = false;
  288. }
  289. }
  290. this.set('content.hosts', hosts);
  291. },
  292. /**
  293. * Sets the <code>hosts</code> array for the controller
  294. * @method loadHosts
  295. */
  296. loadHosts: function () {
  297. var hosts = this.get('content.hosts');
  298. //flag identify whether get all hosts or only NewHosts(newly added) hosts
  299. var getOnlyNewHosts = (this.get('content.controllerName') !== 'addServiceController');
  300. for (var index in hosts) {
  301. if (hosts[index].bootStatus === 'REGISTERED' && (!getOnlyNewHosts || !hosts[index].isInstalled)) {
  302. var hostInfo = App.HostInfo.create({
  303. name: hosts[index].name,
  304. status: (hosts[index].status) ? hosts[index].status : 'info',
  305. logTasks: [],
  306. message: (hosts[index].message) ? hosts[index].message : 'Waiting',
  307. progress: 0,
  308. isNoTasksForInstall: false
  309. });
  310. this.get('hosts').pushObject(hostInfo);
  311. }
  312. }
  313. },
  314. /**
  315. * Set new polled data
  316. * @param polledData sets the <code>polledData</code> object of the controller
  317. * @method replacePolledData
  318. */
  319. replacePolledData: function (polledData) {
  320. this.get('polledData').clear();
  321. this.set('polledData', polledData);
  322. },
  323. /**
  324. * Get the appropriate message for the host as per the running task
  325. * @param {object} task
  326. * @returns {String}
  327. * @method displayMessage
  328. */
  329. displayMessage: function (task) {
  330. var role = App.format.role(task.role);
  331. /* istanbul ignore next */
  332. switch (task.command) {
  333. case 'INSTALL':
  334. switch (task.status) {
  335. case 'PENDING':
  336. return Em.I18n.t('installer.step9.serviceStatus.install.pending') + role;
  337. case 'QUEUED' :
  338. return Em.I18n.t('installer.step9.serviceStatus.install.queued') + role;
  339. case 'IN_PROGRESS':
  340. return Em.I18n.t('installer.step9.serviceStatus.install.inProgress') + role;
  341. case 'COMPLETED' :
  342. return Em.I18n.t('installer.step9.serviceStatus.install.completed') + role;
  343. case 'FAILED':
  344. return Em.I18n.t('installer.step9.serviceStatus.install.failed') + role;
  345. }
  346. break;
  347. case 'UNINSTALL':
  348. switch (task.status) {
  349. case 'PENDING':
  350. return Em.I18n.t('installer.step9.serviceStatus.uninstall.pending') + role;
  351. case 'QUEUED' :
  352. return Em.I18n.t('installer.step9.serviceStatus.uninstall.queued') + role;
  353. case 'IN_PROGRESS':
  354. return Em.I18n.t('installer.step9.serviceStatus.uninstall.inProgress') + role;
  355. case 'COMPLETED' :
  356. return Em.I18n.t('installer.step9.serviceStatus.uninstall.completed') + role;
  357. case 'FAILED':
  358. return Em.I18n.t('installer.step9.serviceStatus.uninstall.failed') + role;
  359. }
  360. break;
  361. case 'START' :
  362. switch (task.status) {
  363. case 'PENDING':
  364. return Em.I18n.t('installer.step9.serviceStatus.start.pending') + role;
  365. case 'QUEUED' :
  366. return Em.I18n.t('installer.step9.serviceStatus.start.queued') + role;
  367. case 'IN_PROGRESS':
  368. return Em.I18n.t('installer.step9.serviceStatus.start.inProgress') + role;
  369. case 'COMPLETED' :
  370. return role + Em.I18n.t('installer.step9.serviceStatus.start.completed');
  371. case 'FAILED':
  372. return role + Em.I18n.t('installer.step9.serviceStatus.start.failed');
  373. }
  374. break;
  375. case 'STOP' :
  376. switch (task.status) {
  377. case 'PENDING':
  378. return Em.I18n.t('installer.step9.serviceStatus.stop.pending') + role;
  379. case 'QUEUED' :
  380. return Em.I18n.t('installer.step9.serviceStatus.stop.queued') + role;
  381. case 'IN_PROGRESS':
  382. return Em.I18n.t('installer.step9.serviceStatus.stop.inProgress') + role;
  383. case 'COMPLETED' :
  384. return role + Em.I18n.t('installer.step9.serviceStatus.stop.completed');
  385. case 'FAILED':
  386. return role + Em.I18n.t('installer.step9.serviceStatus.stop.failed');
  387. }
  388. break;
  389. case 'EXECUTE' :
  390. case 'SERVICE_CHECK' :
  391. switch (task.status) {
  392. case 'PENDING':
  393. return Em.I18n.t('installer.step9.serviceStatus.execute.pending') + role;
  394. case 'QUEUED' :
  395. return Em.I18n.t('installer.step9.serviceStatus.execute.queued') + role;
  396. case 'IN_PROGRESS':
  397. return Em.I18n.t('installer.step9.serviceStatus.execute.inProgress') + role;
  398. case 'COMPLETED' :
  399. return role + Em.I18n.t('installer.step9.serviceStatus.execute.completed');
  400. case 'FAILED':
  401. return role + Em.I18n.t('installer.step9.serviceStatus.execute.failed');
  402. }
  403. break;
  404. case 'ABORT' :
  405. switch (task.status) {
  406. case 'PENDING':
  407. return Em.I18n.t('installer.step9.serviceStatus.abort.pending') + role;
  408. case 'QUEUED' :
  409. return Em.I18n.t('installer.step9.serviceStatus.abort.queued') + role;
  410. case 'IN_PROGRESS':
  411. return Em.I18n.t('installer.step9.serviceStatus.abort.inProgress') + role;
  412. case 'COMPLETED' :
  413. return role + Em.I18n.t('installer.step9.serviceStatus.abort.completed');
  414. case 'FAILED':
  415. return role + Em.I18n.t('installer.step9.serviceStatus.abort.failed');
  416. }
  417. }
  418. return '';
  419. },
  420. /**
  421. * Run start/check services after installation phase.
  422. * Does Ajax call to start all services
  423. * @return {$.ajax|null}
  424. * @method launchStartServices
  425. */
  426. launchStartServices: function (callback) {
  427. var data = {};
  428. var name = '';
  429. callback = callback || Em.K;
  430. switch(this.get('content.controllerName')) {
  431. case 'addHostController':
  432. name = 'common.host_components.update';
  433. var hostnames = [];
  434. var hosts = this.get('wizardController').getDBProperty('hosts');
  435. for (var hostname in hosts) {
  436. if(this.get('hosts').findProperty('name', hostname)){
  437. hostnames.push(hostname);
  438. }
  439. }
  440. data = {
  441. "context": Em.I18n.t("requestInfo.startHostComponents"),
  442. "query": "HostRoles/component_name.in(" + App.get('components.slaves').join(',') + ")&HostRoles/state=INSTALLED&HostRoles/host_name.in(" + hostnames.join(',') + ")",
  443. "HostRoles": { "state": "STARTED"}
  444. };
  445. break;
  446. case 'addServiceController':
  447. var servicesList = this.get('content.services').filterProperty('isSelected').filterProperty('isInstalled', false).mapProperty('serviceName');
  448. if (servicesList.contains('OOZIE')) {
  449. servicesList = servicesList.concat(['HDFS', 'YARN', 'MAPREDUCE2']);
  450. }
  451. name = 'common.services.update';
  452. data = {
  453. "context": Em.I18n.t("requestInfo.startAddedServices"),
  454. "ServiceInfo": { "state": "STARTED" },
  455. "urlParams": "ServiceInfo/state=INSTALLED&ServiceInfo/service_name.in(" + servicesList.join(",") + ")&params/run_smoke_test=true&params/reconfigure_client=false"
  456. };
  457. break;
  458. default:
  459. name = 'common.services.update';
  460. data = {
  461. "context": Em.I18n.t("requestInfo.startServices"),
  462. "ServiceInfo": { "state": "STARTED" },
  463. "urlParams": "ServiceInfo/state=INSTALLED&params/run_smoke_test=" + !this.get('skipServiceChecks') + "&params/reconfigure_client=false"
  464. };
  465. }
  466. if (App.get('testMode')) {
  467. this.set('numPolls', 6);
  468. }
  469. return App.ajax.send({
  470. name: name,
  471. sender: this,
  472. data: data,
  473. success: 'launchStartServicesSuccessCallback',
  474. error: 'launchStartServicesErrorCallback'
  475. }).then(callback, callback);
  476. },
  477. /**
  478. * Success callback function for start services task.
  479. * @param {object} jsonData Contains Request id to poll.
  480. * @method launchStartServicesSuccessCallback
  481. */
  482. launchStartServicesSuccessCallback: function (jsonData) {
  483. var clusterStatus = {};
  484. if (jsonData) {
  485. var requestId = jsonData.Requests.id;
  486. clusterStatus = {
  487. status: 'INSTALLED',
  488. requestId: requestId,
  489. isStartError: false,
  490. isCompleted: false
  491. };
  492. this.hostHasClientsOnly(false);
  493. this.saveClusterStatus(clusterStatus);
  494. }
  495. else {
  496. this.hostHasClientsOnly(true);
  497. clusterStatus = {
  498. status: 'STARTED',
  499. isStartError: false,
  500. isCompleted: true
  501. };
  502. this.saveClusterStatus(clusterStatus);
  503. this.set('status', 'success');
  504. this.set('progress', '100');
  505. }
  506. // We need to do recovery if there is a browser crash
  507. App.clusterStatus.setClusterStatus({
  508. clusterState: 'SERVICE_STARTING_3',
  509. wizardControllerName: this.get('content.controllerName'),
  510. localdb: App.db.data
  511. });
  512. if (jsonData) {
  513. this.startPolling();
  514. }
  515. },
  516. /**
  517. * This function will be called for Add host wizard only.
  518. * @param {bool} jsonError Boolean is true when API to start services returns 200 ok and no json data
  519. * @method hostHasClientsOnly
  520. */
  521. hostHasClientsOnly: function (jsonError) {
  522. this.get('hosts').forEach(function (host) {
  523. var OnlyClients = true;
  524. var tasks = host.get('logTasks');
  525. tasks.forEach(function (task) {
  526. var component = App.StackServiceComponent.find().findProperty('componentName', task.Tasks.role);
  527. if (!(component && component.get('isClient'))) {
  528. OnlyClients = false;
  529. }
  530. });
  531. if (OnlyClients || jsonError) {
  532. host.set('status', 'success');
  533. host.set('progress', '100');
  534. }
  535. });
  536. },
  537. /**
  538. * Error callback function for start services task.
  539. * @param {object} jqXHR
  540. * @param {object} ajaxOptions
  541. * @param {string} error
  542. * @param {object} opt
  543. * @method launchStartServicesErrorCallback
  544. */
  545. launchStartServicesErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
  546. this.set('startCallFailed', true);
  547. var clusterStatus = {
  548. status: 'INSTALL FAILED',
  549. isStartError: false,
  550. isCompleted: false
  551. };
  552. this.saveClusterStatus(clusterStatus);
  553. this.get('hosts').forEach(function (host) {
  554. host.set('progress', '100');
  555. });
  556. this.set('progress', '100');
  557. console.log("Error starting installed services: ", jqXHR, ajaxOptions, error, opt);
  558. App.ModalPopup.show({
  559. encodeBody: false,
  560. primary: Em.I18n.t('ok'),
  561. header: Em.I18n.t('installer.step9.service.start.header'),
  562. secondaryClass: "hide",
  563. body: Em.I18n.t('installer.step9.service.start.failed'),
  564. primaryClass: 'btn-success',
  565. onPrimary: function() { this.hide(); },
  566. onClose: function() { this.hide(); }
  567. });
  568. },
  569. /**
  570. * Marks a host's status as "success" if all tasks are in COMPLETED state
  571. * @method onSuccessPerHost
  572. */
  573. onSuccessPerHost: function (actions, contentHost) {
  574. var status = this.get('content.cluster.status');
  575. if (actions.everyProperty('Tasks.status', 'COMPLETED') &&
  576. (status === 'INSTALLED' || status === 'STARTED') || App.get('supports.skipComponentStartAfterInstall')) {
  577. contentHost.set('status', 'success');
  578. }
  579. },
  580. /**
  581. * 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.
  582. * 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
  583. * to find which host FAILED occurred on, if any
  584. * @param actions {Array} of tasks retrieved from polled data
  585. * @param contentHost {Object} A host object
  586. * @method onErrorPerHost
  587. */
  588. onErrorPerHost: function (actions, contentHost) {
  589. if (!actions) return;
  590. if (actions.someProperty('Tasks.status', 'FAILED') || actions.someProperty('Tasks.status', 'ABORTED') || actions.someProperty('Tasks.status', 'TIMEDOUT')) {
  591. contentHost.set('status', 'warning');
  592. }
  593. if ((this.get('content.cluster.status') === 'PENDING' && actions.someProperty('Tasks.status', 'FAILED')) || (this.isMasterFailed(actions))) {
  594. contentHost.get('status') !== 'heartbeat_lost' ? contentHost.set('status', 'failed') : '';
  595. }
  596. },
  597. /**
  598. * Check if some master component is failed
  599. * @param {object} polledData data polled from API.
  600. * @returns {bool} true if there is at least one FAILED task of master component install
  601. * @method isMasterFailed
  602. */
  603. isMasterFailed: function (polledData) {
  604. var result = false;
  605. polledData.filterProperty('Tasks.command', 'INSTALL').filterProperty('Tasks.status', 'FAILED').mapProperty('Tasks.role').forEach(
  606. function (role) {
  607. if (!App.get('components.slaves').contains(role)) {
  608. result = true;
  609. }
  610. }
  611. );
  612. return result;
  613. },
  614. /**
  615. * Mark a host status as in_progress if the any task on the host if either in IN_PROGRESS, QUEUED or PENDONG state.
  616. * @param actions {Array} of tasks retrieved from polled data
  617. * @param contentHost {Object} A host object
  618. * @method onInProgressPerHost
  619. */
  620. onInProgressPerHost: function (actions, contentHost) {
  621. var runningAction = actions.findProperty('Tasks.status', 'IN_PROGRESS');
  622. if (runningAction === undefined || runningAction === null) {
  623. runningAction = actions.findProperty('Tasks.status', 'QUEUED');
  624. }
  625. if (runningAction === undefined || runningAction === null) {
  626. runningAction = actions.findProperty('Tasks.status', 'PENDING');
  627. }
  628. if (runningAction !== null && runningAction !== undefined) {
  629. contentHost.set('status', 'in_progress');
  630. contentHost.set('message', this.displayMessage(runningAction.Tasks));
  631. }
  632. },
  633. /**
  634. * Calculate progress of tasks per host
  635. * @param {object} actions
  636. * @param {object} contentHost
  637. * @return {Number}
  638. * @method progressPerHost
  639. */
  640. progressPerHost: function (actions, contentHost) {
  641. var progress = 0;
  642. var actionsPerHost = actions.length;
  643. var completedActions = 0;
  644. var queuedActions = 0;
  645. var inProgressActions = 0;
  646. var installProgressFactor = App.get('supports.skipComponentStartAfterInstall') ? 100 : 33;
  647. actions.forEach(function (action) {
  648. completedActions += +(['COMPLETED', 'FAILED', 'ABORTED', 'TIMEDOUT'].contains(action.Tasks.status));
  649. queuedActions += +(action.Tasks.status === 'QUEUED');
  650. inProgressActions += +(action.Tasks.status === 'IN_PROGRESS');
  651. }, this);
  652. /** for the install phase (PENDING), % completed per host goes up to 33%; floor(100 / 3)
  653. * for the start phase (INSTALLED), % completed starts from 34%
  654. * when task in queued state means it's completed on 9%
  655. * in progress - 35%
  656. * completed - 100%
  657. */
  658. switch (this.get('content.cluster.status')) {
  659. case 'PENDING':
  660. progress = actionsPerHost ? (Math.ceil(((queuedActions * 0.09) + (inProgressActions * 0.35) + completedActions ) / actionsPerHost * installProgressFactor)) : installProgressFactor;
  661. break;
  662. case 'INSTALLED':
  663. progress = actionsPerHost ? (33 + Math.floor(((queuedActions * 0.09) + (inProgressActions * 0.35) + completedActions ) / actionsPerHost * 67)) : 100;
  664. break;
  665. default:
  666. progress = 100;
  667. break;
  668. }
  669. contentHost.set('progress', progress.toString());
  670. return progress;
  671. },
  672. /**
  673. * Check if step completed successfully
  674. * @param {object} polledData data retrieved from API
  675. * @returns {bool}
  676. * @method isSuccess
  677. */
  678. isSuccess: function (polledData) {
  679. return polledData.everyProperty('Tasks.status', 'COMPLETED');
  680. },
  681. /**
  682. * Check if step is failed
  683. * Return true if:
  684. * 1. any of the master/client components failed to install
  685. * OR
  686. * 2. at least 50% of the slave host components for the particular service component fails to install
  687. * @method isStepFailed
  688. */
  689. isStepFailed: function () {
  690. var failed = false;
  691. var polledData = this.get('polledData');
  692. polledData.filterProperty('Tasks.command', 'INSTALL').mapProperty('Tasks.role').uniq().forEach(function (role) {
  693. if (failed) {
  694. return;
  695. }
  696. var actionsPerRole = polledData.filterProperty('Tasks.role', role);
  697. if (App.get('components.slaves').contains(role)) {
  698. // check slave components for success factor.
  699. // partial failure for slave components are allowed.
  700. var actionsFailed = actionsPerRole.filterProperty('Tasks.status', 'FAILED');
  701. var actionsAborted = actionsPerRole.filterProperty('Tasks.status', 'ABORTED');
  702. var actionsTimedOut = actionsPerRole.filterProperty('Tasks.status', 'TIMEDOUT');
  703. if ((((actionsFailed.length + actionsAborted.length + actionsTimedOut.length) / actionsPerRole.length) * 100) > 50) {
  704. failed = true;
  705. }
  706. } else if (actionsPerRole.someProperty('Tasks.status', 'FAILED') || actionsPerRole.someProperty('Tasks.status', 'ABORTED') ||
  707. actionsPerRole.someProperty('Tasks.status', 'TIMEDOUT')) {
  708. // check non-salve components (i.e., masters and clients). all of these must be successfully installed.
  709. failed = true;
  710. }
  711. }, this);
  712. return failed;
  713. },
  714. /**
  715. * polling from ui stops only when no action has 'PENDING', 'QUEUED' or 'IN_PROGRESS' status
  716. * Makes a state transition
  717. * PENDING -> INSTALLED
  718. * PENDING -> INSTALL FAILED
  719. * INSTALLED -> STARTED
  720. * INSTALLED -> START_FAILED
  721. * @param polledData json data retrieved from API
  722. * @method setFinishState
  723. */
  724. setFinishState: function (polledData) {
  725. if (this.get('content.cluster.status') === 'INSTALLED') {
  726. Em.run.next(this, function(){
  727. this.changeParseHostInfo(this.isServicesStarted(polledData));
  728. });
  729. return;
  730. } else if (this.get('content.cluster.status') === 'PENDING') {
  731. this.setIsServicesInstalled(polledData);
  732. return;
  733. } else if (this.get('content.cluster.status') === 'INSTALL FAILED' || this.get('content.cluster.status') === 'START FAILED'
  734. || this.get('content.cluster.status') === 'STARTED') {
  735. this.set('progress', '100');
  736. this.changeParseHostInfo(true);
  737. return;
  738. }
  739. this.changeParseHostInfo(true);
  740. },
  741. /**
  742. * @param polledData JSON data retrieved from API
  743. * @returns {bool} Has "Start All Services" request completed successfully
  744. * @method isServicesStarted
  745. */
  746. isServicesStarted: function (polledData) {
  747. var clusterStatus = {};
  748. if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
  749. this.set('progress', '100');
  750. clusterStatus = {
  751. status: 'INSTALLED',
  752. requestId: this.get('content.cluster.requestId'),
  753. isCompleted: true
  754. };
  755. if (this.isSuccess(polledData)) {
  756. clusterStatus.status = 'STARTED';
  757. var serviceStartTime = App.dateTime();
  758. clusterStatus.installTime = ((parseInt(serviceStartTime) - parseInt(this.get('content.cluster.installStartTime'))) / 60000).toFixed(2);
  759. }
  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 Json data retrieved from API
  771. * @method setIsServicesInstalled
  772. */
  773. setIsServicesInstalled: function (polledData) {
  774. var clusterStatus = {};
  775. var self = this;
  776. if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
  777. clusterStatus = {
  778. status: 'PENDING',
  779. requestId: this.get('content.cluster.requestId'),
  780. isCompleted: false
  781. };
  782. if (this.get('status') === 'failed') {
  783. clusterStatus.status = 'INSTALL FAILED';
  784. this.saveClusterStatus(clusterStatus);
  785. this.setProperties({
  786. progress: '100',
  787. isPolling: false
  788. });
  789. this.get('hosts').forEach(function (host) {
  790. host.set('progress', '100');
  791. });
  792. this.isAllComponentsInstalled().done(function () {
  793. self.changeParseHostInfo(false);
  794. });
  795. return;
  796. } else {
  797. if (App.get('supports.skipComponentStartAfterInstall')) {
  798. clusterStatus.status = 'START_SKIPPED';
  799. clusterStatus.isCompleted = true;
  800. this.saveClusterStatus(clusterStatus);
  801. this.get('hosts').forEach(function (host) {
  802. host.set('status', 'success');
  803. host.set('message', Em.I18n.t('installer.step9.host.status.success'));
  804. host.set('progress', '100');
  805. });
  806. this.set('progress', '100');
  807. self.saveInstalledHosts(self);
  808. this.changeParseHostInfo(true);
  809. } else {
  810. this.set('progress', '34');
  811. if (this.get('content.controllerName') === 'installerController') {
  812. this.isAllComponentsInstalled().done(function () {
  813. self.saveInstalledHosts(self);
  814. self.changeParseHostInfo(true);
  815. });
  816. return;
  817. } else {
  818. this.launchStartServices(function () {
  819. self.saveInstalledHosts(self);
  820. self.changeParseHostInfo(true);
  821. });
  822. return;
  823. }
  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. errorLogMessage: 'Install services all retries failed'
  996. },
  997. success: 'reloadSuccessCallback',
  998. error: 'reloadErrorCallback'
  999. });
  1000. },
  1001. /**
  1002. * Success callback for get log by request
  1003. * @param {object} data
  1004. * @param {object} opt
  1005. * @param {object} params
  1006. * @method reloadSuccessCallback
  1007. */
  1008. reloadSuccessCallback: function (data, opt, params) {
  1009. var parsedData = jQuery.parseJSON(data);
  1010. this._super();
  1011. this.set('isPolling', params.polling);
  1012. this.setParseHostInfo(parsedData);
  1013. },
  1014. /**
  1015. * Error-callback for get log by request
  1016. * @param {object} jqXHR
  1017. * @param {string} ajaxOptions
  1018. * @param {string} error
  1019. * @param {object} opt
  1020. * @param {object} params
  1021. * @method reloadErrorCallback
  1022. */
  1023. reloadErrorCallback: function (jqXHR, ajaxOptions, error, opt, params) {
  1024. this._super(jqXHR, ajaxOptions, error, opt, params);
  1025. if (jqXHR.status) {
  1026. this.loadLogData(true);
  1027. }
  1028. },
  1029. /**
  1030. * Delegates the function call to {getLogsByRequest} with appropriate params
  1031. * @method doPolling
  1032. */
  1033. doPolling: function () {
  1034. var requestId = this.get('content.cluster.requestId');
  1035. if (App.get('testMode')) {
  1036. this.incrementProperty('numPolls');
  1037. }
  1038. this.getLogsByRequest(true, requestId);
  1039. },
  1040. /**
  1041. * Check that all components are in INSTALLED state before issuing start command
  1042. * @method isAllComponentsInstalled
  1043. * @return {$.ajax|null}
  1044. */
  1045. isAllComponentsInstalled: function () {
  1046. var dfd = $.Deferred();
  1047. if (this.get('content.controllerName') !== 'installerController' && this.get('content.controllerName') !== 'addHostController') {
  1048. dfd.resolve();
  1049. } else {
  1050. App.ajax.send({
  1051. name: 'wizard.step9.installer.get_host_status',
  1052. sender: this,
  1053. data: {
  1054. cluster: this.get('content.cluster.name')
  1055. },
  1056. success: 'isAllComponentsInstalledSuccessCallback',
  1057. error: 'isAllComponentsInstalledErrorCallback'
  1058. }).complete(function(){
  1059. dfd.resolve();
  1060. });
  1061. }
  1062. return dfd.promise();
  1063. },
  1064. /**
  1065. * Success callback function for API checking host state and host_components state.
  1066. * @param {Object} jsonData
  1067. * @method isAllComponentsInstalledSuccessCallback
  1068. */
  1069. isAllComponentsInstalledSuccessCallback: function (jsonData) {
  1070. var clusterStatus = {
  1071. status: 'INSTALL FAILED',
  1072. isStartError: true,
  1073. isCompleted: false
  1074. };
  1075. var hostsWithHeartbeatLost = [];
  1076. jsonData.items.filterProperty('Hosts.host_state', 'HEARTBEAT_LOST').forEach(function (host) {
  1077. var hostComponentObj = {hostName: host.Hosts.host_name};
  1078. var componentArr = [];
  1079. host.host_components.forEach(function (_hostComponent) {
  1080. var componentName = App.format.role(_hostComponent.HostRoles.component_name);
  1081. componentArr.pushObject(componentName);
  1082. }, this);
  1083. hostComponentObj.componentNames = stringUtils.getFormattedStringFromArray(componentArr);
  1084. hostsWithHeartbeatLost.pushObject(hostComponentObj);
  1085. }, this);
  1086. this.set('hostsWithHeartbeatLost', hostsWithHeartbeatLost);
  1087. if (hostsWithHeartbeatLost.length) {
  1088. this.get('hosts').forEach(function (host) {
  1089. if (hostsWithHeartbeatLost.someProperty(('hostName'), host.get('name'))) {
  1090. host.set('status', 'heartbeat_lost');
  1091. } else if (host.get('status') !== 'failed' && host.get('status') !== 'warning') {
  1092. host.set('message', Em.I18n.t('installer.step9.host.status.startAborted'));
  1093. }
  1094. host.set('progress', '100');
  1095. });
  1096. this.set('progress', '100');
  1097. this.saveClusterStatus(clusterStatus);
  1098. } else if (this.get('content.cluster.status') === 'PENDING' && this.get('isPolling')) {
  1099. if (App.get('supports.skipComponentStartAfterInstall')) {
  1100. this.set('progress', '100');
  1101. this.changeParseHostInfo(true);
  1102. } else {
  1103. this.launchStartServices();
  1104. }
  1105. }
  1106. },
  1107. /**
  1108. * Error callback function for API checking host state and host_components state
  1109. * @method isAllComponentsInstalledErrorCallback
  1110. */
  1111. isAllComponentsInstalledErrorCallback: function () {
  1112. var clusterStatus = {
  1113. status: 'INSTALL FAILED',
  1114. isStartError: true,
  1115. isCompleted: false
  1116. };
  1117. this.set('progress', '100');
  1118. this.get('hosts').forEach(function (host) {
  1119. if (host.get('status') !== 'failed' && host.get('status') !== 'warning') {
  1120. host.set('message', Em.I18n.t('installer.step9.host.status.startAborted'));
  1121. host.set('progress', '100');
  1122. }
  1123. });
  1124. this.saveClusterStatus(clusterStatus);
  1125. },
  1126. /**
  1127. * save cluster status in the parentController and localdb
  1128. * @param {object} clusterStatus
  1129. * @method saveClusterStatus
  1130. */
  1131. saveClusterStatus: function (clusterStatus) {
  1132. if (!App.get('testMode')) {
  1133. App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
  1134. }
  1135. else {
  1136. this.set('content.cluster', clusterStatus);
  1137. }
  1138. },
  1139. /**
  1140. * save cluster status in the parentController and localdb
  1141. * @param {object} context
  1142. * @method saveInstalledHosts
  1143. */
  1144. saveInstalledHosts: function (context) {
  1145. if (!App.get('testMode')) {
  1146. App.router.get(this.get('content.controllerName')).saveInstalledHosts(context);
  1147. }
  1148. },
  1149. /**
  1150. * Load ambari property to determine if we should run service checks on deploy
  1151. */
  1152. loadDoServiceChecksFlag: function () {
  1153. var def = $.Deferred();
  1154. App.ajax.send({
  1155. name: 'ambari.service',
  1156. sender: this,
  1157. data: {
  1158. fields: '?fields=RootServiceComponents/properties/skip.service.checks'
  1159. },
  1160. success: 'loadDoServiceChecksFlagSuccessCallback'
  1161. }).complete(function(){
  1162. def.resolve();
  1163. });
  1164. return def.promise();
  1165. },
  1166. /**
  1167. * Callback function Load ambari property to determine if we should run service checks on deploy
  1168. * @param {Object} data
  1169. * @method loadDoServiceChecksFlagSuccessCallback
  1170. */
  1171. loadDoServiceChecksFlagSuccessCallback: function (data) {
  1172. var properties = Em.get(data, 'RootServiceComponents.properties');
  1173. if(properties && properties.hasOwnProperty('skip.service.checks')){
  1174. this.set('skipServiceChecks', properties['skip.service.checks'] === 'true');
  1175. }
  1176. }
  1177. });