step9_controller.js 43 KB

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