step9_controller.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  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. App.WizardStep9Controller = Em.Controller.extend({
  20. name: 'wizardStep9Controller',
  21. hosts: [],
  22. progress: '0',
  23. isStepCompleted: false,
  24. isSubmitDisabled: function () {
  25. return !this.get('isStepCompleted');
  26. }.property('isStepCompleted'),
  27. mockHostData: require('data/mock/step9_hosts'),
  28. mockDataPrefix: '/data/wizard/deploy/slave_warning',
  29. pollDataCounter: 0,
  30. polledData: [],
  31. status: function () {
  32. if (this.hosts.length && this.hosts.everyProperty('status', 'success')) {
  33. return 'success';
  34. } else if (this.hosts.someProperty('status', 'failed')) {
  35. return 'failed';
  36. } else if (this.hosts.someProperty('status', 'warning')) {
  37. return 'warning';
  38. } else {
  39. return 'info';
  40. }
  41. }.property('hosts.@each.status'),
  42. showRetry: function(){
  43. return this.get('status') == 'failed';
  44. }.property('status'),
  45. // called by App.WizardStep9View's didInsertElement and "retry" from router.
  46. navigateStep: function () {
  47. if (App.testMode) {
  48. // this is for repeatedly testing out installs in test mode
  49. this.set('content.cluster.status', 'PENDING');
  50. this.set('content.cluster.isCompleted', false);
  51. }
  52. if (this.get('content.cluster.isCompleted') === false) {
  53. if (this.get('content.cluster.status') === 'INSTALL FAILED') {
  54. this.loadStep();
  55. this.loadLogData(this.get('content.cluster.requestId'));
  56. this.hosts.setEach('status', 'failed');
  57. this.set('progress', '100');
  58. this.set('isStepCompleted', true);
  59. //this.set('status', 'failed');
  60. } else if (this.get('content.cluster.status') === 'START FAILED') {
  61. this.loadStep();
  62. this.loadLogData(this.get('content.cluster.requestId'));
  63. this.hosts.setEach('status', 'info');
  64. this.set('isStepCompleted', false);
  65. this.launchStartServices();
  66. } else {
  67. this.loadStep();
  68. this.loadLogData(this.get('content.cluster.requestId'));
  69. this.startPolling();
  70. }
  71. } else {
  72. this.loadStep();
  73. this.loadLogData(this.get('content.cluster.requestId'));
  74. this.set('isStepCompleted', true);
  75. this.set('progress', '100');
  76. }
  77. },
  78. clearStep: function () {
  79. this.hosts.clear();
  80. this.set('status', 'info');
  81. this.set('progress', '0');
  82. this.set('isStepCompleted', false);
  83. this.numPolls = 0;
  84. },
  85. loadStep: function () {
  86. console.log("TRACE: Loading step9: Install, Start and Test");
  87. this.clearStep();
  88. this.renderHosts(this.loadHosts());
  89. },
  90. loadHosts: function () {
  91. var hostInfo = this.get('content.hostsInfo');
  92. var hosts = new Ember.Set();
  93. for (var index in hostInfo) {
  94. var obj = Em.Object.create(hostInfo[index]);
  95. obj.tasks = [];
  96. obj.logTasks = [];
  97. hosts.add(obj);
  98. console.log("TRACE: host name is: " + hostInfo[index].name);
  99. }
  100. // return hosts;
  101. return hosts.filterProperty('bootStatus', 'REGISTERED');
  102. },
  103. renderHosts: function (hostsInfo) {
  104. hostsInfo.forEach(function (_hostInfo) {
  105. var hostInfo = App.HostInfo.create({
  106. name: _hostInfo.name,
  107. status: _hostInfo.status,
  108. tasks: _hostInfo.tasks,
  109. logTasks: _hostInfo.logTasks,
  110. message: _hostInfo.message,
  111. progress: _hostInfo.progress
  112. });
  113. console.log('pushing ' + hostInfo.name);
  114. this.hosts.pushObject(hostInfo);
  115. }, this);
  116. },
  117. replacePolledData: function (polledData) {
  118. this.polledData.clear();
  119. this.set('polledData', polledData);
  120. },
  121. displayMessage: function (task) {
  122. var role = App.format.role(task.role);
  123. console.log("In display message with task command value: " + task.command);
  124. switch (task.command) {
  125. case 'INSTALL':
  126. switch (task.status) {
  127. case 'PENDING':
  128. return 'Preparing to install ' + role;
  129. case 'QUEUED' :
  130. return 'Waiting to install ' + role;
  131. case 'IN_PROGRESS':
  132. return 'Installing ' + role;
  133. case 'COMPLETED' :
  134. return 'Successfully installed ' + role;
  135. case 'FAILED':
  136. return 'Failed to install ' + role;
  137. }
  138. case 'UNINSTALL':
  139. switch (task.status) {
  140. case 'PENDING':
  141. return 'Preparing to uninstall ' + role;
  142. case 'QUEUED' :
  143. return 'Waiting to uninstall ' + role;
  144. case 'IN_PROGRESS':
  145. return 'Uninstalling ' + role;
  146. case 'COMPLETED' :
  147. return 'Successfully uninstalled ' + role;
  148. case 'FAILED':
  149. return 'Failed to uninstall ' + role;
  150. }
  151. case 'START' :
  152. switch (task.status) {
  153. case 'PENDING':
  154. return 'Preparing to start ' + role;
  155. case 'QUEUED' :
  156. return 'Waiting to start ' + role;
  157. case 'IN_PROGRESS':
  158. return 'Starting ' + role;
  159. case 'COMPLETED' :
  160. return role + ' started successfully';
  161. case 'FAILED':
  162. return role + ' failed to start';
  163. }
  164. case 'STOP' :
  165. switch (task.status) {
  166. case 'PENDING':
  167. return 'Preparing to stop ' + role;
  168. case 'QUEUED' :
  169. return 'Waiting to stop ' + role;
  170. case 'IN_PROGRESS':
  171. return 'Stopping ' + role;
  172. case 'COMPLETED' :
  173. return role + ' stopped successfully';
  174. case 'FAILED':
  175. return role + ' failed to stop';
  176. }
  177. case 'EXECUTE' :
  178. switch (task.status) {
  179. case 'PENDING':
  180. return 'Preparing to execute ' + role;
  181. case 'QUEUED' :
  182. return 'Waiting to execute ' + role;
  183. case 'IN_PROGRESS':
  184. return 'Executing ' + role;
  185. case 'COMPLETED' :
  186. return role + ' executed successfully';
  187. case 'FAILED':
  188. return role + ' failed to execute';
  189. }
  190. case 'ABORT' :
  191. switch (task.status) {
  192. case 'PENDING':
  193. return 'Preparing to abort ' + role;
  194. case 'QUEUED' :
  195. return 'Waiting to abort ' + role;
  196. case 'IN_PROGRESS':
  197. return 'Aborting ' + role;
  198. case 'COMPLETED' :
  199. return role + ' aborted successfully';
  200. case 'FAILED':
  201. return role + ' failed to abort';
  202. }
  203. }
  204. },
  205. launchStartServices: function () {
  206. var self = this;
  207. var clusterName = this.get('content.cluster.name');
  208. var url = App.apiPrefix + '/clusters/' + clusterName + '/services?ServiceInfo/state=INSTALLED';
  209. var data = '{"ServiceInfo": {"state": "STARTED"}}';
  210. var method = 'PUT';
  211. if (App.testMode) {
  212. url = this.get('mockDataPrefix') + '/poll_6.json';
  213. method = 'GET';
  214. this.numPolls = 6;
  215. }
  216. $.ajax({
  217. type: method,
  218. url: url,
  219. async: false,
  220. data: data,
  221. dataType: 'text',
  222. timeout: App.timeout,
  223. success: function (data) {
  224. var jsonData = jQuery.parseJSON(data);
  225. console.log("TRACE: Step9 -> In success function for the startService call");
  226. console.log("TRACE: Step9 -> value of the url is: " + url);
  227. console.log("TRACE: Step9 -> value of the received data is: " + jsonData);
  228. var requestId = jsonData.Requests.id;
  229. console.log('requestId is: ' + requestId);
  230. var clusterStatus = {
  231. status: 'INSTALLED',
  232. requestId: requestId,
  233. isStartError: false,
  234. isCompleted: false
  235. };
  236. App.router.get(self.get('content.controllerName')).saveClusterStatus(clusterStatus);
  237. self.startPolling();
  238. },
  239. error: function () {
  240. console.log("ERROR");
  241. var clusterStatus = {
  242. status: 'START FAILED',
  243. isStartError: true,
  244. isCompleted: false
  245. };
  246. App.router.get(self.get('content.controllerName')).saveClusterStatus(clusterStatus);
  247. },
  248. statusCode: require('data/statusCodes')
  249. });
  250. },
  251. onSuccessPerHost: function (actions, contentHost) {
  252. if (actions.everyProperty('Tasks.status', 'COMPLETED') && this.get('content.cluster.status') === 'INSTALLED') {
  253. contentHost.set('status', 'success');
  254. }
  255. },
  256. onWarningPerHost: function (actions, contentHost) {
  257. if (actions.someProperty('Tasks.status', 'FAILED') || actions.someProperty('Tasks.status', 'ABORTED') || actions.someProperty('Tasks.status', 'TIMEDOUT')) {
  258. console.log('step9: In warning');
  259. contentHost.set('status', 'warning');
  260. this.set('status', 'warning');
  261. }
  262. },
  263. onInProgressPerHost: function (tasks, contentHost) {
  264. var runningAction = tasks.findProperty('Tasks.status', 'IN_PROGRESS');
  265. if (runningAction === undefined || runningAction === null) {
  266. runningAction = tasks.findProperty('Tasks.status', 'QUEUED');
  267. }
  268. if (runningAction === undefined || runningAction === null) {
  269. runningAction = tasks.findProperty('Tasks.status', 'PENDING');
  270. }
  271. if (runningAction !== null && runningAction !== undefined) {
  272. contentHost.set('message', this.displayMessage(runningAction.Tasks));
  273. }
  274. },
  275. progressPerHost: function (actions, contentHost) {
  276. var progress = 0;
  277. var actionsPerHost = actions.length;
  278. var completedActions = actions.filterProperty('Tasks.status', 'COMPLETED').length
  279. + actions.filterProperty('Tasks.status', 'FAILED').length
  280. + actions.filterProperty('Tasks.status', 'ABORTED').length
  281. + actions.filterProperty('Tasks.status', 'TIMEDOUT').length;
  282. if (this.get('content.cluster.status') === 'PENDING') {
  283. progress = Math.floor(((completedActions / actionsPerHost) * 100) / 3);
  284. } else if (this.get('content.cluster.status') === 'INSTALLED') {
  285. progress = 34 + Math.floor(((completedActions / actionsPerHost) * 100 * 2) / 3);
  286. }
  287. console.log('INFO: progressPerHost is: ' + progress);
  288. contentHost.set('progress', progress.toString());
  289. return progress;
  290. },
  291. isSuccess: function (polledData) {
  292. return polledData.everyProperty('Tasks.status', 'COMPLETED');
  293. },
  294. // for DATANODE, JOBTRACKER, HBASE_REGIONSERVER, and GANGLIA_MONITOR, if more than 50% fail, then it's a fatal error;
  295. // otherwise, it's only a warning and installation/start can continue
  296. getSuccessFactor: function (role) {
  297. return ['DATANODE','JOBTRACKER','HBASE_REGIONSERVER','GANGLIA_MONITOR'].contains(role) ? 50 : 100;
  298. },
  299. isStepFailed: function (polledData) {
  300. var self = this;
  301. var result = false;
  302. polledData.forEach(function (_polledData) {
  303. var successFactor = this.getSuccessFactor(_polledData.Tasks.role);
  304. console.log("Step9: isStepFailed sf value: " + successFactor);
  305. var actionsPerRole = polledData.filterProperty('Tasks.role', _polledData.Tasks.role);
  306. var actionsFailed = actionsPerRole.filterProperty('Tasks.status', 'FAILED');
  307. var actionsAborted = actionsPerRole.filterProperty('Tasks.status', 'ABORTED');
  308. var actionsTimedOut = actionsPerRole.filterProperty('Tasks.status', 'TIMEDOUT');
  309. if ((((actionsFailed.length + actionsAborted.length + actionsTimedOut.length) / actionsPerRole.length) * 100) > (100 - successFactor)) {
  310. console.log('TRACE: Entering success factor and result is failed');
  311. result = true;
  312. }
  313. }, this);
  314. return result;
  315. },
  316. getFailedHostsForFailedRoles: function (polledData) {
  317. var hostArr = new Ember.Set();
  318. polledData.forEach(function (_polledData) {
  319. var successFactor = this.getSuccessFactor(_polledData.Tasks.role);
  320. var actionsPerRole = polledData.filterProperty('Tasks.role', _polledData.Tasks.role);
  321. var actionsFailed = actionsPerRole.filterProperty('Tasks.status', 'FAILED');
  322. var actionsAborted = actionsPerRole.filterProperty('Tasks.status', 'ABORTED');
  323. var actionsTimedOut = actionsPerRole.filterProperty('Tasks.status', 'TIMEDOUT');
  324. if ((((actionsFailed.length + actionsAborted.length + actionsTimedOut.length) / actionsPerRole.length) * 100) > (100 - successFactor)) {
  325. actionsFailed.forEach(function (_actionFailed) {
  326. hostArr.add(_actionFailed.Tasks.host_name);
  327. });
  328. actionsAborted.forEach(function (_actionFailed) {
  329. hostArr.add(_actionFailed.Tasks.host_name);
  330. });
  331. actionsTimedOut.forEach(function (_actionFailed) {
  332. hostArr.add(_actionFailed.Tasks.host_name);
  333. });
  334. }
  335. }, this);
  336. return hostArr;
  337. },
  338. setHostsStatus: function (hostNames, status) {
  339. hostNames.forEach(function (_hostName) {
  340. var host = this.hosts.findProperty('name', _hostName);
  341. if (host) {
  342. host.set('status', status)
  343. .set('progress', '100');
  344. }
  345. }, this);
  346. },
  347. // polling from ui stops only when no action has 'PENDING', 'QUEUED' or 'IN_PROGRESS' status
  348. finishState: function (polledData) {
  349. var clusterStatus = {};
  350. var requestId = this.get('content.cluster.requestId');
  351. if (this.get('content.cluster.status') === 'INSTALLED') {
  352. if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
  353. this.set('progress', '100');
  354. clusterStatus = {
  355. status: 'INSTALLED',
  356. requestId: requestId,
  357. isCompleted: true
  358. }
  359. if (this.isSuccess(polledData)) {
  360. clusterStatus.status = 'STARTED';
  361. var serviceStartTime = new Date().getTime();
  362. var timeToStart = ((parseInt(serviceStartTime) - parseInt(this.get('content.cluster.installStartTime'))) / 60000).toFixed(2);
  363. clusterStatus.installTime = timeToStart;
  364. this.set('status', 'success');
  365. } else {
  366. if (this.isStepFailed(polledData)) {
  367. clusterStatus.status = 'START FAILED'; // 'START FAILED' implies to step10 that installation was successful but start failed
  368. this.set('status', 'failed');
  369. this.setHostsStatus(this.getFailedHostsForFailedRoles(polledData), 'failed');
  370. }
  371. }
  372. App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
  373. this.set('isStepCompleted', true);
  374. this.setTasksPerHost();
  375. App.router.get(this.get('content.controllerName')).saveInstalledHosts(this);
  376. return true;
  377. }
  378. } else if (this.get('content.cluster.status') === 'PENDING') {
  379. if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
  380. clusterStatus = {
  381. status: 'PENDING',
  382. requestId: requestId,
  383. isCompleted: false
  384. }
  385. if (this.isStepFailed(polledData)) {
  386. console.log("In installation failure");
  387. clusterStatus.status = 'INSTALL FAILED';
  388. this.set('progress', '100');
  389. this.set('status', 'failed');
  390. this.setHostsStatus(this.getFailedHostsForFailedRoles(polledData), 'failed');
  391. App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
  392. this.set('isStepCompleted', true);
  393. } else {
  394. clusterStatus.status = 'INSTALLED';
  395. this.set('progress', '34');
  396. this.launchStartServices();
  397. }
  398. this.setTasksPerHost();
  399. App.router.get(this.get('content.controllerName')).saveInstalledHosts(this);
  400. return true;
  401. }
  402. }
  403. return false;
  404. },
  405. setTasksPerHost: function () {
  406. var tasksData = this.get('polledData');
  407. this.get('hosts').forEach(function (_host) {
  408. var tasksPerHost = tasksData.filterProperty('Tasks.host_name', _host.name); // retrieved from polled Data
  409. if (tasksPerHost.length === 0) {
  410. //alert('For testing with mockData follow the sequence: hit referesh,"mockData btn", "pollData btn", again "pollData btn"');
  411. //exit();
  412. }
  413. if (tasksPerHost !== null && tasksPerHost !== undefined && tasksPerHost.length !== 0) {
  414. tasksPerHost.forEach(function (_taskPerHost) {
  415. console.log('In step9 _taskPerHost function.');
  416. //if (_taskPerHost.Tasks.status !== 'PENDING' && _taskPerHost.Tasks.status !== 'QUEUED' && _taskPerHost.Tasks.status !== 'IN_PROGRESS') {
  417. _host.tasks.pushObject(_taskPerHost);
  418. //}
  419. }, this);
  420. }
  421. }, this);
  422. },
  423. // This is done at HostRole level.
  424. setLogTasksStatePerHost: function (tasksPerHost, host) {
  425. console.log('In step9 setTasksStatePerHost function.');
  426. tasksPerHost.forEach(function (_task) {
  427. console.log('In step9 _taskPerHost function.');
  428. if (_task.Tasks.status !== 'PENDING' && _task.Tasks.status !== 'QUEUED') {
  429. var task = host.logTasks.findProperty('Tasks.id', _task.Tasks.id);
  430. if (task) {
  431. host.logTasks.removeObject(task);
  432. }
  433. host.logTasks.pushObject(_task);
  434. }
  435. }, this);
  436. },
  437. parseHostInfo: function (polledData) {
  438. console.log('TRACE: Entering host info function');
  439. var self = this;
  440. var totalProgress = 0;
  441. /* if (this.get('content.cluster.status') === 'INSTALLED') {
  442. totalProgress = 34;
  443. } else {
  444. totalProgress = 0;
  445. } */
  446. var tasksData = polledData.tasks;
  447. console.log("The value of tasksData is: ", tasksData);
  448. if (!tasksData) {
  449. console.log("Step9: ERROR: NO tasks available to process");
  450. }
  451. this.replacePolledData(tasksData);
  452. this.hosts.forEach(function (_host) {
  453. var actionsPerHost = tasksData.filterProperty('Tasks.host_name', _host.name); // retrieved from polled Data
  454. if (actionsPerHost.length === 0) {
  455. console.log("Error: No task is hosted on the host");
  456. }
  457. if (actionsPerHost !== null && actionsPerHost !== undefined && actionsPerHost.length !== 0) {
  458. this.setLogTasksStatePerHost(actionsPerHost, _host);
  459. this.onSuccessPerHost(actionsPerHost, _host); // every action should be a success
  460. this.onWarningPerHost(actionsPerHost, _host); // any action should be a failure
  461. this.onInProgressPerHost(actionsPerHost, _host); // current running action for a host
  462. totalProgress += self.progressPerHost(actionsPerHost, _host);
  463. }
  464. }, this);
  465. totalProgress = Math.floor(totalProgress / this.hosts.length);
  466. this.set('progress', totalProgress.toString());
  467. console.log("INFO: right now the progress is: " + this.get('progress'));
  468. return this.finishState(tasksData);
  469. },
  470. startPolling: function () {
  471. this.set('isSubmitDisabled', true);
  472. this.doPolling();
  473. },
  474. numPolls: 0,
  475. getUrl: function (requestId) {
  476. var clusterName = this.get('content.cluster.name');
  477. var requestId = requestId || this.get('content.cluster.requestId');
  478. var url = App.apiPrefix + '/clusters/' + clusterName + '/requests/' + requestId + '?fields=tasks/*';
  479. console.log("URL for step9 is: " + url);
  480. return url;
  481. },
  482. POLL_INTERVAL: 4000,
  483. loadLogData:function(requestId){
  484. var url = this.getUrl(requestId);
  485. var requestsId = App.db.getCluster().oldRequestsId;
  486. if (App.testMode) {
  487. this.POLL_INTERVAL = 1;
  488. this.numPolls++;
  489. }
  490. requestsId.forEach(function(requestId) {
  491. url = this.getUrl(requestId);
  492. if (App.testMode) {
  493. this.POLL_INTERVAL = 1;
  494. if (requestId == 1) {
  495. url = this.get('mockDataPrefix') + '/poll_' + this.numPolls + '.json';
  496. // url = this.get('mockDataPrefix') + '/poll_5_failed.json';
  497. } else {
  498. url = this.get('mockDataPrefix') + '/poll_9.json';
  499. }
  500. }
  501. this.getLogsByRequest(url, false);
  502. }, this);
  503. },
  504. getLogsByRequest: function(url, polling){
  505. var self = this;
  506. $.ajax({
  507. type: 'GET',
  508. url: url,
  509. async: true,
  510. timeout: App.timeout,
  511. dataType: 'text',
  512. success: function (data) {
  513. console.log("TRACE: In success function for the GET logs data");
  514. console.log("TRACE: STep9 -> The value is: ", jQuery.parseJSON(data));
  515. var result = self.parseHostInfo(jQuery.parseJSON(data));
  516. if(!polling){
  517. return;
  518. }
  519. if (result !== true) {
  520. window.setTimeout(function () {
  521. self.doPolling();
  522. }, self.POLL_INTERVAL);
  523. } else {
  524. self.stopPolling();
  525. }
  526. },
  527. error: function (request, ajaxOptions, error) {
  528. console.log("TRACE: STep9 -> In error function for the GET logs data");
  529. console.log("TRACE: STep9 -> value of the url is: " + url);
  530. console.log("TRACE: STep9 -> error code status is: " + request.status);
  531. self.stopPolling();
  532. },
  533. statusCode: require('data/statusCodes')
  534. });
  535. },
  536. doPolling: function () {
  537. var url = this.getUrl();
  538. if (App.testMode) {
  539. this.numPolls++;
  540. url = this.get('mockDataPrefix') + '/poll_' + this.get('numPolls') + '.json';
  541. }
  542. this.getLogsByRequest(url, true);
  543. },
  544. stopPolling: function () {
  545. //TODO: uncomment following line after the hook up with the API call
  546. // this.set('isStepCompleted',true);
  547. },
  548. submit: function () {
  549. if (!this.get('isSubmitDisabled')) {
  550. App.router.send('next');
  551. }
  552. },
  553. back: function () {
  554. if (!this.get('isSubmitDisabled')) {
  555. App.router.send('back');
  556. }
  557. },
  558. mockBtn: function () {
  559. this.set('isSubmitDisabled', false);
  560. this.hosts.clear();
  561. var hostInfo = this.mockHostData;
  562. this.renderHosts(hostInfo);
  563. },
  564. pollBtn: function () {
  565. this.set('isSubmitDisabled', false);
  566. var data1 = require('data/mock/step9PolledData/pollData_1');
  567. var data2 = require('data/mock/step9PolledData/pollData_2');
  568. var data3 = require('data/mock/step9PolledData/pollData_3');
  569. var data4 = require('data/mock/step9PolledData/pollData_4');
  570. var data5 = require('data/mock/step9PolledData/pollData_5');
  571. var data6 = require('data/mock/step9PolledData/pollData_6');
  572. var data7 = require('data/mock/step9PolledData/pollData_7');
  573. var data8 = require('data/mock/step9PolledData/pollData_8');
  574. var data9 = require('data/mock/step9PolledData/pollData_9');
  575. console.log("TRACE: In pollBtn function data1");
  576. var counter = parseInt(this.get('pollDataCounter')) + 1;
  577. this.set('pollDataCounter', counter.toString());
  578. switch (this.get('pollDataCounter')) {
  579. case '1':
  580. this.parseHostInfo(data1);
  581. break;
  582. case '2':
  583. this.parseHostInfo(data2);
  584. break;
  585. case '3':
  586. this.parseHostInfo(data3);
  587. break;
  588. case '4':
  589. this.parseHostInfo(data4);
  590. break;
  591. case '5':
  592. this.parseHostInfo(data5);
  593. break;
  594. case '6':
  595. this.set('content.cluster.status', 'INSTALLED');
  596. this.parseHostInfo(data6);
  597. break;
  598. case '7':
  599. this.parseHostInfo(data7);
  600. break;
  601. case '8':
  602. this.parseHostInfo(data8);
  603. break;
  604. case '9':
  605. this.parseHostInfo(data9);
  606. break;
  607. default:
  608. break;
  609. }
  610. }
  611. });