step9_controller.js 44 KB

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