step9_controller.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233
  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. var status = this.get('content.cluster.status');
  571. if (actions.everyProperty('Tasks.status', 'COMPLETED') &&
  572. (status === 'INSTALLED' || status === 'STARTED') ) {
  573. contentHost.set('status', 'success');
  574. }
  575. },
  576. /**
  577. * 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.
  578. * 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
  579. * to find which host FAILED occurred on, if any
  580. * @param actions {Array} of tasks retrieved from polled data
  581. * @param contentHost {Object} A host object
  582. * @method onErrorPerHost
  583. */
  584. onErrorPerHost: function (actions, contentHost) {
  585. if (!actions) return;
  586. if (actions.someProperty('Tasks.status', 'FAILED') || actions.someProperty('Tasks.status', 'ABORTED') || actions.someProperty('Tasks.status', 'TIMEDOUT')) {
  587. contentHost.set('status', 'warning');
  588. }
  589. if ((this.get('content.cluster.status') === 'PENDING' && actions.someProperty('Tasks.status', 'FAILED')) || (this.isMasterFailed(actions))) {
  590. contentHost.get('status') !== 'heartbeat_lost' ? contentHost.set('status', 'failed') : '';
  591. }
  592. },
  593. /**
  594. * Check if some master component is failed
  595. * @param {object} polledData data polled from API.
  596. * @returns {bool} true if there is at least one FAILED task of master component install
  597. * @method isMasterFailed
  598. */
  599. isMasterFailed: function (polledData) {
  600. var result = false;
  601. polledData.filterProperty('Tasks.command', 'INSTALL').filterProperty('Tasks.status', 'FAILED').mapProperty('Tasks.role').forEach(
  602. function (role) {
  603. if (!App.get('components.slaves').contains(role)) {
  604. result = true;
  605. }
  606. }
  607. );
  608. return result;
  609. },
  610. /**
  611. * Mark a host status as in_progress if the any task on the host if either in IN_PROGRESS, QUEUED or PENDONG state.
  612. * @param actions {Array} of tasks retrieved from polled data
  613. * @param contentHost {Object} A host object
  614. * @method onInProgressPerHost
  615. */
  616. onInProgressPerHost: function (actions, contentHost) {
  617. var runningAction = actions.findProperty('Tasks.status', 'IN_PROGRESS');
  618. if (runningAction === undefined || runningAction === null) {
  619. runningAction = actions.findProperty('Tasks.status', 'QUEUED');
  620. }
  621. if (runningAction === undefined || runningAction === null) {
  622. runningAction = actions.findProperty('Tasks.status', 'PENDING');
  623. }
  624. if (runningAction !== null && runningAction !== undefined) {
  625. contentHost.set('status', 'in_progress');
  626. contentHost.set('message', this.displayMessage(runningAction.Tasks));
  627. }
  628. },
  629. /**
  630. * Calculate progress of tasks per host
  631. * @param {object} actions
  632. * @param {object} contentHost
  633. * @return {Number}
  634. * @method progressPerHost
  635. */
  636. progressPerHost: function (actions, contentHost) {
  637. var progress = 0;
  638. var actionsPerHost = actions.length;
  639. var completedActions = 0;
  640. var queuedActions = 0;
  641. var inProgressActions = 0;
  642. actions.forEach(function (action) {
  643. completedActions += +(['COMPLETED', 'FAILED', 'ABORTED', 'TIMEDOUT'].contains(action.Tasks.status));
  644. queuedActions += +(action.Tasks.status === 'QUEUED');
  645. inProgressActions += +(action.Tasks.status === 'IN_PROGRESS');
  646. }, this);
  647. /** for the install phase (PENDING), % completed per host goes up to 33%; floor(100 / 3)
  648. * for the start phase (INSTALLED), % completed starts from 34%
  649. * when task in queued state means it's completed on 9%
  650. * in progress - 35%
  651. * completed - 100%
  652. */
  653. switch (this.get('content.cluster.status')) {
  654. case 'PENDING':
  655. progress = actionsPerHost ? (Math.ceil(((queuedActions * 0.09) + (inProgressActions * 0.35) + completedActions ) / actionsPerHost * 33)) : 33;
  656. break;
  657. case 'INSTALLED':
  658. progress = actionsPerHost ? (34 + Math.ceil(((queuedActions * 0.09) + (inProgressActions * 0.35) + completedActions ) / actionsPerHost * 66)) : 100;
  659. break;
  660. default:
  661. progress = 100;
  662. break;
  663. }
  664. contentHost.set('progress', progress.toString());
  665. return progress;
  666. },
  667. /**
  668. * Check if step completed successfully
  669. * @param {object} polledData data retrieved from API
  670. * @returns {bool}
  671. * @method isSuccess
  672. */
  673. isSuccess: function (polledData) {
  674. return polledData.everyProperty('Tasks.status', 'COMPLETED');
  675. },
  676. /**
  677. * Check if step is failed
  678. * Return true if:
  679. * 1. any of the master/client components failed to install
  680. * OR
  681. * 2. at least 50% of the slave host components for the particular service component fails to install
  682. * @method isStepFailed
  683. */
  684. isStepFailed: function () {
  685. var failed = false;
  686. var polledData = this.get('polledData');
  687. polledData.filterProperty('Tasks.command', 'INSTALL').mapProperty('Tasks.role').uniq().forEach(function (role) {
  688. if (failed) {
  689. return;
  690. }
  691. var actionsPerRole = polledData.filterProperty('Tasks.role', role);
  692. if (App.get('components.slaves').contains(role)) {
  693. // check slave components for success factor.
  694. // partial failure for slave components are allowed.
  695. var actionsFailed = actionsPerRole.filterProperty('Tasks.status', 'FAILED');
  696. var actionsAborted = actionsPerRole.filterProperty('Tasks.status', 'ABORTED');
  697. var actionsTimedOut = actionsPerRole.filterProperty('Tasks.status', 'TIMEDOUT');
  698. if ((((actionsFailed.length + actionsAborted.length + actionsTimedOut.length) / actionsPerRole.length) * 100) > 50) {
  699. failed = true;
  700. }
  701. } else if (actionsPerRole.someProperty('Tasks.status', 'FAILED') || actionsPerRole.someProperty('Tasks.status', 'ABORTED') ||
  702. actionsPerRole.someProperty('Tasks.status', 'TIMEDOUT')) {
  703. // check non-salve components (i.e., masters and clients). all of these must be successfully installed.
  704. failed = true;
  705. }
  706. }, this);
  707. return failed;
  708. },
  709. /**
  710. * polling from ui stops only when no action has 'PENDING', 'QUEUED' or 'IN_PROGRESS' status
  711. * Makes a state transition
  712. * PENDING -> INSTALLED
  713. * PENDING -> INSTALL FAILED
  714. * INSTALLED -> STARTED
  715. * INSTALLED -> START_FAILED
  716. * @param polledData json data retrieved from API
  717. * @method setFinishState
  718. */
  719. setFinishState: function (polledData) {
  720. if (this.get('content.cluster.status') === 'INSTALLED') {
  721. Em.run.next(this, function(){
  722. this.changeParseHostInfo(this.isServicesStarted(polledData));
  723. });
  724. return;
  725. } else if (this.get('content.cluster.status') === 'PENDING') {
  726. this.setIsServicesInstalled(polledData);
  727. return;
  728. } else if (this.get('content.cluster.status') === 'INSTALL FAILED' || this.get('content.cluster.status') === 'START FAILED'
  729. || this.get('content.cluster.status') === 'STARTED') {
  730. this.set('progress', '100');
  731. this.changeParseHostInfo(true);
  732. return;
  733. }
  734. this.changeParseHostInfo(true);
  735. },
  736. /**
  737. * @param polledData JSON data retrieved from API
  738. * @returns {bool} Has "Start All Services" request completed successfully
  739. * @method isServicesStarted
  740. */
  741. isServicesStarted: function (polledData) {
  742. var clusterStatus = {};
  743. if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
  744. this.set('progress', '100');
  745. clusterStatus = {
  746. status: 'INSTALLED',
  747. requestId: this.get('content.cluster.requestId'),
  748. isCompleted: true
  749. };
  750. if (this.isSuccess(polledData)) {
  751. clusterStatus.status = 'STARTED';
  752. var serviceStartTime = App.dateTime();
  753. clusterStatus.installTime = ((parseInt(serviceStartTime) - parseInt(this.get('content.cluster.installStartTime'))) / 60000).toFixed(2);
  754. }
  755. else {
  756. clusterStatus.status = 'START FAILED'; // 'START FAILED' implies to step10 that installation was successful but start failed
  757. }
  758. this.saveClusterStatus(clusterStatus);
  759. this.saveInstalledHosts(this);
  760. return true;
  761. }
  762. return false;
  763. },
  764. /**
  765. * @param polledData Json data retrieved from API
  766. * @method setIsServicesInstalled
  767. */
  768. setIsServicesInstalled: function (polledData) {
  769. var clusterStatus = {};
  770. var self = this;
  771. if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
  772. clusterStatus = {
  773. status: 'PENDING',
  774. requestId: this.get('content.cluster.requestId'),
  775. isCompleted: false
  776. };
  777. if (this.get('status') === 'failed') {
  778. clusterStatus.status = 'INSTALL FAILED';
  779. this.saveClusterStatus(clusterStatus);
  780. this.setProperties({
  781. progress: '100',
  782. isPolling: false
  783. });
  784. this.get('hosts').forEach(function (host) {
  785. host.set('progress', '100');
  786. });
  787. this.isAllComponentsInstalled().done(function(){
  788. self.changeParseHostInfo(false);
  789. });
  790. return;
  791. } else {
  792. this.set('progress', '34');
  793. if (this.get('content.controllerName') === 'installerController') {
  794. this.isAllComponentsInstalled().done(function(){
  795. self.saveInstalledHosts(self);
  796. self.changeParseHostInfo(true);
  797. });
  798. return;
  799. } else {
  800. this.launchStartServices(function () {
  801. self.saveInstalledHosts(self);
  802. self.changeParseHostInfo(true);
  803. });
  804. return;
  805. }
  806. }
  807. }
  808. this.changeParseHostInfo(false);
  809. },
  810. /**
  811. * This is done at HostRole level.
  812. * @param {Ember.Enumerable} tasksPerHost
  813. * @param {Object} host
  814. * @method setLogTasksStatePerHost
  815. */
  816. setLogTasksStatePerHost: function (tasksPerHost, host) {
  817. tasksPerHost.forEach(function (_task) {
  818. var task = host.logTasks.findProperty('Tasks.id', _task.Tasks.id);
  819. if (task) {
  820. task.Tasks.status = _task.Tasks.status;
  821. task.Tasks.start_time = _task.Tasks.start_time;
  822. task.Tasks.end_time = _task.Tasks.end_time;
  823. task.Tasks.exit_code = _task.Tasks.exit_code;
  824. } else {
  825. host.logTasks.pushObject(_task);
  826. }
  827. }, this);
  828. },
  829. /**
  830. * Parses the Json data retrieved from API and sets the task on the host of {hosts} array binded to template
  831. * @param polledData Json data retrieved from API
  832. * @method setParseHostInfo
  833. */
  834. setParseHostInfo: function (polledData) {
  835. console.log('TRACE: Entering host info function');
  836. var self = this;
  837. var totalProgress = 0;
  838. var tasksData = polledData.tasks || [];
  839. console.log("The value of tasksData is: ", tasksData);
  840. var requestId = this.get('content.cluster.requestId');
  841. tasksData.setEach('Tasks.request_id', requestId);
  842. if (polledData.Requests && polledData.Requests.id && polledData.Requests.id != requestId) {
  843. // We don't want to use non-current requestId's tasks data to
  844. // determine the current install status.
  845. // Also, we don't want to keep polling if it is not the
  846. // current requestId.
  847. this.changeParseHostInfo(false);
  848. return;
  849. }
  850. this.replacePolledData(tasksData);
  851. var tasksHostMap = {};
  852. tasksData.forEach(function (task) {
  853. if (tasksHostMap[task.Tasks.host_name]) {
  854. tasksHostMap[task.Tasks.host_name].push(task);
  855. } else {
  856. tasksHostMap[task.Tasks.host_name] = [task];
  857. }
  858. });
  859. this.get('hosts').forEach(function (_host) {
  860. var actionsPerHost = tasksHostMap[_host.name] || []; // retrieved from polled Data
  861. if (actionsPerHost.length === 0) {
  862. if (this.get('content.cluster.status') === 'PENDING' || this.get('content.cluster.status') === 'INSTALL FAILED') {
  863. _host.set('progress', '33');
  864. _host.set('isNoTasksForInstall', true);
  865. _host.set('status', 'pending');
  866. }
  867. if (this.get('content.cluster.status') === 'INSTALLED' || this.get('content.cluster.status') === 'FAILED') {
  868. _host.set('progress', '100');
  869. _host.set('status', 'success');
  870. }
  871. console.log("INFO: No task is hosted on the host");
  872. } else {
  873. _host.set('isNoTasksForInstall', false);
  874. }
  875. this.setLogTasksStatePerHost(actionsPerHost, _host);
  876. this.onSuccessPerHost(actionsPerHost, _host); // every action should be a success
  877. this.onErrorPerHost(actionsPerHost, _host); // any action should be a failure
  878. this.onInProgressPerHost(actionsPerHost, _host); // current running action for a host
  879. totalProgress += self.progressPerHost(actionsPerHost, _host);
  880. if (_host.get('progress') == '33' && _host.get('status') != 'failed' && _host.get('status') != 'warning') {
  881. _host.set('message', this.t('installer.step9.host.status.nothingToInstall'));
  882. _host.set('status', 'pending');
  883. }
  884. }, this);
  885. this.set('logTasksChangesCounter', this.get('logTasksChangesCounter') + 1);
  886. totalProgress = Math.floor(totalProgress / this.get('hosts.length'));
  887. this.set('progress', totalProgress.toString());
  888. console.log("INFO: right now the progress is: " + this.get('progress'));
  889. this.setFinishState(tasksData);
  890. },
  891. /**
  892. * Starts polling to the API
  893. * @method startPolling
  894. */
  895. startPolling: function () {
  896. this.set('isSubmitDisabled', true);
  897. this.doPolling();
  898. },
  899. /**
  900. * This function calls API just once to fetch log data of all tasks.
  901. * @method loadLogData
  902. */
  903. loadLogData: function (startPolling) {
  904. var requestsId = this.get('wizardController').getDBProperty('cluster').oldRequestsId;
  905. if (App.get('testMode')) {
  906. this.set('POLL_INTERVAL', 1);
  907. }
  908. this.getLogsByRequest(!!startPolling, requestsId[requestsId.length-1]);
  909. },
  910. /**
  911. * Load form server <code>stderr, stdout</code> of current open task
  912. * @method loadCurrentTaskLog
  913. */
  914. loadCurrentTaskLog: function () {
  915. var taskId = this.get('currentOpenTaskId');
  916. var requestId = this.get('currentOpenTaskRequestId');
  917. var clusterName = this.get('content.cluster.name');
  918. if (!taskId) {
  919. console.log('taskId is null.');
  920. return;
  921. }
  922. App.ajax.send({
  923. name: 'background_operations.get_by_task',
  924. sender: this,
  925. data: {
  926. 'taskId': taskId,
  927. 'requestId': requestId,
  928. 'clusterName': clusterName
  929. },
  930. success: 'loadCurrentTaskLogSuccessCallback',
  931. error: 'loadCurrentTaskLogErrorCallback'
  932. });
  933. },
  934. /**
  935. * success callback function for getting log data of the opened task
  936. * @param {object} data
  937. * @method loadCurrentTaskLogSuccessCallback
  938. */
  939. loadCurrentTaskLogSuccessCallback: function (data) {
  940. var taskId = this.get('currentOpenTaskId');
  941. if (taskId) {
  942. var host = this.get('hosts').findProperty('name', data.Tasks.host_name);
  943. if (host) {
  944. var currentTask = host.get('logTasks').findProperty('Tasks.id', data.Tasks.id);
  945. if (currentTask) {
  946. currentTask.Tasks.stderr = data.Tasks.stderr;
  947. currentTask.Tasks.stdout = data.Tasks.stdout;
  948. currentTask.Tasks.output_log = data.Tasks.output_log;
  949. currentTask.Tasks.error_log = data.Tasks.error_log;
  950. }
  951. }
  952. }
  953. this.set('logTasksChangesCounter', this.get('logTasksChangesCounter') + 1);
  954. },
  955. /**
  956. * Error callback function for getting log data of the opened task
  957. * @method loadCurrentTaskLogErrorCallback
  958. */
  959. loadCurrentTaskLogErrorCallback: function () {
  960. this.set('currentOpenTaskId', 0);
  961. },
  962. /**
  963. * Function polls the API to retrieve data for the request.
  964. * @param {bool} polling whether to continue polling for status or not
  965. * @param {number} requestId
  966. * @method getLogsByRequest
  967. * @return {$.ajax|null}
  968. */
  969. getLogsByRequest: function (polling, requestId) {
  970. var self = this;
  971. return App.ajax.send({
  972. name: 'wizard.step9.load_log',
  973. sender: this,
  974. data: {
  975. polling: polling,
  976. cluster: this.get('content.cluster.name'),
  977. requestId: requestId,
  978. numPolls: this.get('numPolls')
  979. },
  980. success: 'getLogsByRequestSuccessCallback',
  981. error: 'getLogsByRequestErrorCallback'
  982. }).retry({times: App.maxRetries, timeout: 3000}).then(
  983. function () {
  984. self.closeReloadPopup();
  985. },
  986. function () {
  987. self.showReloadPopup();
  988. console.log('Install services all retries failed');
  989. }
  990. );
  991. },
  992. /**
  993. * Success callback for get log by request
  994. * @param {object} data
  995. * @param {object} opt
  996. * @param {object} params
  997. * @method getLogsByRequestSuccessCallback
  998. */
  999. getLogsByRequestSuccessCallback: function (data, opt, params) {
  1000. var parsedData = jQuery.parseJSON(data);
  1001. console.log("TRACE: In success function for the GET logs data");
  1002. console.log("TRACE: Step9 -> The value is: ", parsedData);
  1003. this.set('isPolling', params.polling);
  1004. this.setParseHostInfo(parsedData);
  1005. },
  1006. /**
  1007. * Error-callback for get log by request
  1008. * @method getLogsByRequestErrorCallback
  1009. */
  1010. getLogsByRequestErrorCallback: function () {
  1011. this.loadLogData(true);
  1012. },
  1013. /**
  1014. * Delegates the function call to {getLogsByRequest} with appropriate params
  1015. * @method doPolling
  1016. */
  1017. doPolling: function () {
  1018. var requestId = this.get('content.cluster.requestId');
  1019. if (App.get('testMode')) {
  1020. this.incrementProperty('numPolls');
  1021. }
  1022. this.getLogsByRequest(true, requestId);
  1023. },
  1024. /**
  1025. * Check that all components are in INSTALLED state before issuing start command
  1026. * @method isAllComponentsInstalled
  1027. * @return {$.ajax|null}
  1028. */
  1029. isAllComponentsInstalled: function () {
  1030. var dfd = $.Deferred();
  1031. if (this.get('content.controllerName') !== 'installerController' && this.get('content.controllerName') !== 'addHostController') {
  1032. dfd.resolve();
  1033. } else {
  1034. App.ajax.send({
  1035. name: 'wizard.step9.installer.get_host_status',
  1036. sender: this,
  1037. data: {
  1038. cluster: this.get('content.cluster.name')
  1039. },
  1040. success: 'isAllComponentsInstalledSuccessCallback',
  1041. error: 'isAllComponentsInstalledErrorCallback'
  1042. }).complete(function(){
  1043. dfd.resolve();
  1044. });
  1045. }
  1046. return dfd.promise();
  1047. },
  1048. /**
  1049. * Success callback function for API checking host state and host_components state.
  1050. * @param {Object} jsonData
  1051. * @method isAllComponentsInstalledSuccessCallback
  1052. */
  1053. isAllComponentsInstalledSuccessCallback: function (jsonData) {
  1054. var clusterStatus = {
  1055. status: 'INSTALL FAILED',
  1056. isStartError: true,
  1057. isCompleted: false
  1058. };
  1059. var hostsWithHeartbeatLost = [];
  1060. jsonData.items.filterProperty('Hosts.host_state', 'HEARTBEAT_LOST').forEach(function (host) {
  1061. var hostComponentObj = {hostName: host.Hosts.host_name};
  1062. var componentArr = [];
  1063. host.host_components.forEach(function (_hostComponent) {
  1064. var componentName = App.format.role(_hostComponent.HostRoles.component_name);
  1065. componentArr.pushObject(componentName);
  1066. }, this);
  1067. hostComponentObj.componentNames = stringUtils.getFormattedStringFromArray(componentArr);
  1068. hostsWithHeartbeatLost.pushObject(hostComponentObj);
  1069. }, this);
  1070. this.set('hostsWithHeartbeatLost', hostsWithHeartbeatLost);
  1071. if (hostsWithHeartbeatLost.length) {
  1072. this.get('hosts').forEach(function (host) {
  1073. if (hostsWithHeartbeatLost.someProperty(('hostName'), host.get('name'))) {
  1074. host.set('status', 'heartbeat_lost');
  1075. } else if (host.get('status') !== 'failed' && host.get('status') !== 'warning') {
  1076. host.set('message', Em.I18n.t('installer.step9.host.status.startAborted'));
  1077. }
  1078. host.set('progress', '100');
  1079. });
  1080. this.set('progress', '100');
  1081. this.saveClusterStatus(clusterStatus);
  1082. } else if (this.get('content.cluster.status') === 'PENDING' && this.get('isPolling')) {
  1083. this.launchStartServices();
  1084. }
  1085. },
  1086. /**
  1087. * Error callback function for API checking host state and host_components state
  1088. * @method isAllComponentsInstalledErrorCallback
  1089. */
  1090. isAllComponentsInstalledErrorCallback: function () {
  1091. var clusterStatus = {
  1092. status: 'INSTALL FAILED',
  1093. isStartError: true,
  1094. isCompleted: false
  1095. };
  1096. this.set('progress', '100');
  1097. this.get('hosts').forEach(function (host) {
  1098. if (host.get('status') !== 'failed' && host.get('status') !== 'warning') {
  1099. host.set('message', Em.I18n.t('installer.step9.host.status.startAborted'));
  1100. host.set('progress', '100');
  1101. }
  1102. });
  1103. this.saveClusterStatus(clusterStatus);
  1104. },
  1105. /**
  1106. * save cluster status in the parentController and localdb
  1107. * @param {object} clusterStatus
  1108. * @method saveClusterStatus
  1109. */
  1110. saveClusterStatus: function (clusterStatus) {
  1111. if (!App.get('testMode')) {
  1112. App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
  1113. }
  1114. else {
  1115. this.set('content.cluster', clusterStatus);
  1116. }
  1117. },
  1118. /**
  1119. * save cluster status in the parentController and localdb
  1120. * @param {object} context
  1121. * @method saveInstalledHosts
  1122. */
  1123. saveInstalledHosts: function (context) {
  1124. if (!App.get('testMode')) {
  1125. App.router.get(this.get('content.controllerName')).saveInstalledHosts(context);
  1126. }
  1127. },
  1128. /**
  1129. * Load ambari property to determine if we should run service checks on deploy
  1130. */
  1131. loadDoServiceChecksFlag: function () {
  1132. var def = $.Deferred();
  1133. App.ajax.send({
  1134. name: 'ambari.service',
  1135. sender: this,
  1136. data: {
  1137. fields: '?fields=RootServiceComponents/properties/skip.service.checks'
  1138. },
  1139. success: 'loadDoServiceChecksFlagSuccessCallback'
  1140. }).complete(function(){
  1141. def.resolve();
  1142. });
  1143. return def.promise();
  1144. },
  1145. /**
  1146. * Callback function Load ambari property to determine if we should run service checks on deploy
  1147. * @param {Object} data
  1148. * @method loadDoServiceChecksFlagSuccessCallback
  1149. */
  1150. loadDoServiceChecksFlagSuccessCallback: function (data) {
  1151. var properties = Em.get(data, 'RootServiceComponents.properties');
  1152. if(properties && properties.hasOwnProperty('skip.service.checks')){
  1153. this.set('skipServiceChecks', properties['skip.service.checks'] === 'true');
  1154. }
  1155. }
  1156. });