step9_controller.js 24 KB

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