installer.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  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.InstallerController = Em.Controller.extend({
  20. name: 'installerController',
  21. isStepDisabled: [],
  22. totalSteps: 10,
  23. init: function () {
  24. this.clusters = App.Cluster.find();
  25. this.isStepDisabled.pushObject(Ember.Object.create({
  26. step: 1,
  27. value: false
  28. }));
  29. for (var i = 2; i <= this.totalSteps; i++) {
  30. this.isStepDisabled.pushObject(Ember.Object.create({
  31. step: i,
  32. value: true
  33. }));
  34. }
  35. // window.onbeforeunload = function () {
  36. // return "You have not saved your document yet. If you continue, your work will not be saved."
  37. //}
  38. },
  39. setStepsEnable: function () {
  40. for (var i = 2; i <= this.totalSteps; i++) {
  41. var step = this.get('isStepDisabled').findProperty('step', i);
  42. if (i <= this.get('currentStep')) {
  43. step.set('value', false);
  44. } else {
  45. step.set('value', true);
  46. }
  47. }
  48. }.observes('currentStep'),
  49. prevInstallStatus: function () {
  50. console.log('Inside the prevInstallStep function: The name is ' + App.router.get('loginController.loginName'));
  51. var result = App.db.isCompleted()
  52. if (result == '1') {
  53. return true;
  54. }
  55. }.property('App.router.loginController.loginName'),
  56. /**
  57. * Set current step to new value.
  58. * Method moved from App.router.setInstallerCurrentStep
  59. * @param currentStep
  60. * @param completed
  61. */
  62. currentStep: function () {
  63. return App.get('router').getInstallerCurrentStep();
  64. }.property(),
  65. clusters: null,
  66. isStep1: function () {
  67. return this.get('currentStep') == 1;
  68. }.property('currentStep'),
  69. isStep2: function () {
  70. return this.get('currentStep') == 2;
  71. }.property('currentStep'),
  72. isStep3: function () {
  73. return this.get('currentStep') == 3;
  74. }.property('currentStep'),
  75. isStep4: function () {
  76. return this.get('currentStep') == 4;
  77. }.property('currentStep'),
  78. isStep5: function () {
  79. return this.get('currentStep') == 5;
  80. }.property('currentStep'),
  81. isStep6: function () {
  82. return this.get('currentStep') == 6;
  83. }.property('currentStep'),
  84. isStep7: function () {
  85. return this.get('currentStep') == 7;
  86. }.property('currentStep'),
  87. isStep8: function () {
  88. return this.get('currentStep') == 8;
  89. }.property('currentStep'),
  90. isStep9: function () {
  91. return this.get('currentStep') == 9;
  92. }.property('currentStep'),
  93. isStep10: function () {
  94. return this.get('currentStep') == 10;
  95. }.property('currentStep'),
  96. gotoStep1: function () {
  97. if (this.get('isStepDisabled').findProperty('step', 1).get('value') === true) {
  98. return;
  99. } else {
  100. App.router.send('gotoStep1');
  101. }
  102. },
  103. gotoStep2: function () {
  104. if (this.get('isStepDisabled').findProperty('step', 2).get('value') === true) {
  105. return;
  106. } else {
  107. App.router.send('gotoStep2');
  108. }
  109. },
  110. gotoStep3: function () {
  111. if (this.get('isStepDisabled').findProperty('step', 3).get('value') === true) {
  112. return;
  113. } else {
  114. App.router.send('gotoStep3');
  115. }
  116. },
  117. gotoStep4: function () {
  118. if (this.get('isStepDisabled').findProperty('step', 4).get('value') === true) {
  119. return;
  120. } else {
  121. App.router.send('gotoStep4');
  122. }
  123. },
  124. gotoStep5: function () {
  125. if (this.get('isStepDisabled').findProperty('step', 5).get('value') === true) {
  126. return;
  127. } else {
  128. App.router.send('gotoStep5');
  129. }
  130. },
  131. gotoStep6: function () {
  132. if (this.get('isStepDisabled').findProperty('step', 6).get('value') === true) {
  133. return;
  134. } else {
  135. App.router.send('gotoStep6');
  136. }
  137. },
  138. gotoStep7: function () {
  139. if (this.get('isStepDisabled').findProperty('step', 7).get('value') === true) {
  140. return;
  141. } else {
  142. App.router.send('gotoStep7');
  143. }
  144. },
  145. gotoStep8: function () {
  146. if (this.get('isStepDisabled').findProperty('step', 8).get('value') === true) {
  147. return;
  148. } else {
  149. App.router.send('gotoStep8');
  150. }
  151. },
  152. gotoStep9: function () {
  153. if (this.get('isStepDisabled').findProperty('step', 9).get('value') === true) {
  154. return;
  155. } else {
  156. App.router.send('gotoStep9');
  157. }
  158. },
  159. gotoStep10: function () {
  160. if (this.get('isStepDisabled').findProperty('step', 10).get('value') === true) {
  161. return;
  162. } else {
  163. App.router.send('gotoStep10');
  164. }
  165. },
  166. content: Em.Object.create({
  167. cluster: null,
  168. hosts: null,
  169. services: null,
  170. hostsInfo: null,
  171. slaveComponentHosts: null,
  172. hostSlaveComponents: null,
  173. masterComponentHosts: null,
  174. hostToMasterComponent: null,
  175. serviceConfigProperties: null
  176. }),
  177. /**
  178. * Load clusterInfo(step1) to model
  179. */
  180. loadClusterInfo: function () {
  181. var cStatus = App.db.getClusterStatus() || {status: "", isCompleted: false};
  182. var cluster = {
  183. name: App.db.getClusterName() || "",
  184. status: cStatus.status,
  185. isCompleted: cStatus.isCompleted
  186. };
  187. this.set('content.cluster', cluster);
  188. console.log("InstallerController:loadClusterInfo: loaded data ", cluster);
  189. },
  190. /**
  191. * Save all info about cluster to model
  192. * @param stepController Step1WizardController
  193. */
  194. saveClusterInfo: function (stepController) {
  195. var cluster = stepController.get('content.cluster');
  196. var clusterStatus = {
  197. status: cluster.status,
  198. isCompleted: cluster.isCompleted
  199. };
  200. App.db.setClusterName(cluster.name);
  201. App.db.setClusterStatus(clusterStatus);
  202. console.log("InstallerController:saveClusterInfo: saved data ", cluster);
  203. //probably next line is extra work - need to check it
  204. //this.set('content.cluster', cluster);
  205. },
  206. /**
  207. * save status of the cluster. This is called from step8 and step9 to persist install and start requestId
  208. * @param clusterStatus object with status, isCompleted, requestId, isInstallError and isStartError field.
  209. */
  210. saveClusterStatus: function (clusterStatus) {
  211. clusterStatus.name = this.get('content.cluster.name');
  212. this.set('content.cluster', clusterStatus);
  213. console.log('called saveClusterStatus ' + JSON.stringify(clusterStatus));
  214. App.db.setClusterStatus(clusterStatus);
  215. },
  216. /**
  217. * Temporary function for wizardStep9, before back-end integration
  218. */
  219. setInfoForStep9: function () {
  220. var hostInfo = App.db.getHosts();
  221. for (var index in hostInfo) {
  222. hostInfo[index].status = "pending";
  223. hostInfo[index].message = 'Waiting';
  224. hostInfo[index].tasks = [];
  225. hostInfo[index].progress = '0';
  226. }
  227. App.db.setHosts(hostInfo);
  228. },
  229. /**
  230. * Load all data for <code>Specify Host(install step2)</code> step
  231. * Data Example:
  232. * {
  233. * hostNames: '',
  234. * manualInstall: false,
  235. * sshKey: '',
  236. * passphrase: '',
  237. * confirmPassphrase: '',
  238. * localRepo: false,
  239. * localRepoPath: ''
  240. * }
  241. */
  242. loadInstallOptions: function () {
  243. if (!this.content.hosts) {
  244. this.content.hosts = Em.Object.create();
  245. }
  246. //TODO : rewire it as model. or not :)
  247. var hostsInfo = Em.Object.create();
  248. hostsInfo.hostNames = App.db.getAllHostNames() || ''; //empty string if undefined
  249. //TODO : should we check installType for add host wizard????
  250. var installType = App.db.getInstallType();
  251. //false if installType not equals 'manual'
  252. hostsInfo.manualInstall = installType && installType.installType === 'manual' || false;
  253. var softRepo = App.db.getSoftRepo();
  254. if (softRepo && softRepo.repoType === 'local') {
  255. hostsInfo.localRepo = true;
  256. hostsInfo.localRepopath = softRepo.repoPath;
  257. } else {
  258. hostsInfo.localRepo = false;
  259. hostsInfo.localRepoPath = '';
  260. }
  261. hostsInfo.sshKey = '';
  262. hostsInfo.passphrase = '';
  263. hostsInfo.confirmPassphrase = '';
  264. this.set('content.hosts', hostsInfo);
  265. console.log("InstallerController:loadHosts: loaded data ", hostsInfo);
  266. },
  267. /**
  268. * Save data, which user filled, to main controller
  269. * @param stepController App.WizardStep2Controller
  270. */
  271. saveHosts: function (stepController) {
  272. //TODO: put data to content.hosts and only then save it)
  273. //App.db.setBootStatus(false);
  274. App.db.setAllHostNames(stepController.get('hostNames'));
  275. App.db.setHosts(stepController.getHostInfo());
  276. if (stepController.get('manualInstall') === false) {
  277. App.db.setInstallType({installType: 'ambari' });
  278. } else {
  279. App.db.setInstallType({installType: 'manual' });
  280. }
  281. if (stepController.get('localRepo') === false) {
  282. App.db.setSoftRepo({ 'repoType': 'remote', 'repoPath': null});
  283. } else {
  284. App.db.setSoftRepo({ 'repoType': 'local', 'repoPath': stepController.get('localRepoPath') });
  285. }
  286. },
  287. /**
  288. * Return hosts, which were add at <code>Specify Host(step2)</code> step
  289. * @paramm isNew whether return all hosts or only new ones
  290. */
  291. getHostList: function (isNew) {
  292. var hosts = [];
  293. var hostArray = App.db.getHosts()
  294. console.log('in instsllerController.getHostList: host names is ', hostArray);
  295. for (var i in hostArray) {
  296. var hostInfo = App.HostInfo.create({
  297. name: hostArray[i].name,
  298. bootStatus: hostArray[i].bootStatus
  299. });
  300. hosts.pushObject(hostInfo);
  301. }
  302. console.log('TRACE: pushing ' + hosts);
  303. return hosts;
  304. },
  305. /**
  306. * Remove host from model. Used at <code>Confirm hosts(step2)</code> step
  307. * @param hosts Array of hosts, which we want to delete
  308. */
  309. removeHosts: function (hosts) {
  310. //todo Replace this code with real logic
  311. App.db.removeHosts(hosts);
  312. },
  313. /**
  314. * Save data, which user filled, to main controller
  315. * @param stepController App.WizardStep3Controller
  316. */
  317. saveConfirmedHosts: function (stepController) {
  318. var hostInfo = {};
  319. stepController.get('content.hostsInfo').forEach(function (_host) {
  320. hostInfo[_host.name] = {
  321. name: _host.name,
  322. cpu: _host.cpu,
  323. memory: _host.memory,
  324. bootStatus: _host.bootStatus
  325. };
  326. });
  327. console.log('installerController:saveConfirmedHosts: save hosts ', hostInfo);
  328. App.db.setHosts(hostInfo);
  329. this.set('content.hostsInfo', hostInfo);
  330. },
  331. /**
  332. * Load confirmed hosts.
  333. * Will be used at <code>Assign Masters(step5)</code> step
  334. */
  335. loadConfirmedHosts: function () {
  336. this.set('content.hostsInfo', App.db.getHosts());
  337. },
  338. /**
  339. * Save data after installation to main controller
  340. * @param stepController App.WizardStep9Controller
  341. */
  342. saveInstalledHosts: function (stepController) {
  343. var hosts = stepController.get('hosts');
  344. var hostInfo = App.db.getHosts();
  345. for (var index in hostInfo) {
  346. var host = hosts.findProperty('name', hostInfo[index].name);
  347. if (host) {
  348. hostInfo[index].status = host.status;
  349. hostInfo[index].tasks = host.tasks;
  350. hostInfo[index].message = host.message;
  351. hostInfo[index].progress = host.progress;
  352. }
  353. }
  354. App.db.setHosts(hostInfo);
  355. console.log('installerController:saveInstalledHosts: save hosts ', hostInfo);
  356. },
  357. /**
  358. * Remove all data for hosts
  359. */
  360. clearHosts: function () {
  361. var hosts = this.get('content').get('hosts');
  362. if (hosts) {
  363. hosts.hostNames = '';
  364. hosts.manualInstall = false;
  365. hosts.localRepo = '';
  366. hosts.localRepopath = '';
  367. hosts.sshKey = '';
  368. hosts.passphrase = '';
  369. hosts.confirmPassphrase = '';
  370. }
  371. },
  372. /**
  373. * Load services data. Will be used at <code>Select services(step4)</code> step
  374. */
  375. loadServices: function () {
  376. var servicesInfo = App.db.getService();
  377. servicesInfo.forEach(function (item, index) {
  378. servicesInfo[index] = Em.Object.create(item);
  379. });
  380. this.set('content.services', servicesInfo);
  381. console.log('installerController.loadServices: loaded data ', servicesInfo);
  382. console.log('selected services ', servicesInfo.filterProperty('isSelected', true).mapProperty('serviceName'));
  383. },
  384. /**
  385. * Save data to model
  386. * @param stepController App.WizardStep4Controller
  387. */
  388. saveServices: function (stepController) {
  389. var serviceNames = [];
  390. // we can also do it without stepController since all data,
  391. // changed at page, automatically changes in model(this.content.services)
  392. App.db.setService(stepController.get('content'));
  393. stepController.filterProperty('isSelected', true).forEach(function (item) {
  394. serviceNames.push(item.serviceName);
  395. });
  396. App.db.setSelectedServiceNames(serviceNames);
  397. console.log('installerController.saveServices: saved data ', serviceNames);
  398. },
  399. /**
  400. * Save Master Component Hosts data to Main Controller
  401. * @param stepController App.WizardStep5Controller
  402. */
  403. saveMasterComponentHosts: function (stepController) {
  404. var obj = stepController.get('selectedServicesMasters');
  405. console.log("installerController.selectedServicesMasters: saved hosts ", stepController.get('selectedServicesMasters'));
  406. var masterComponentHosts = [];
  407. obj.forEach(function (_component) {
  408. masterComponentHosts.push({
  409. display_name: _component.get('display_name'),
  410. component: _component.get('component_name'),
  411. hostName: _component.get('selectedHost')
  412. });
  413. });
  414. console.log("installerController.saveComponentHosts: saved hosts ", masterComponentHosts);
  415. App.db.setMasterComponentHosts(masterComponentHosts);
  416. this.set('content.masterComponentHosts', masterComponentHosts);
  417. var hosts = masterComponentHosts.mapProperty('hostName').uniq();
  418. var hostsMasterServicesMapping = [];
  419. hosts.forEach(function (_host) {
  420. var componentsOnHost = masterComponentHosts.filterProperty('hostName', _host).mapProperty('component');
  421. hostsMasterServicesMapping.push({
  422. hostname: _host,
  423. components: componentsOnHost
  424. });
  425. }, this);
  426. console.log("installerController.setHostToMasterComponent: saved hosts ", hostsMasterServicesMapping);
  427. App.db.setHostToMasterComponent(hostsMasterServicesMapping);
  428. this.set('content.hostToMasterComponent', hostsMasterServicesMapping);
  429. },
  430. /**
  431. * Load master component hosts data for using in required step controllers
  432. */
  433. loadMasterComponentHosts: function () {
  434. var masterComponentHosts = App.db.getMasterComponentHosts();
  435. this.set("content.masterComponentHosts", masterComponentHosts);
  436. console.log("InstallerController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts);
  437. var hostsMasterServicesMapping = App.db.getHostToMasterComponent();
  438. this.set("content.hostToMasterComponent", hostsMasterServicesMapping);
  439. console.log("InstallerController.loadHostToMasterComponent: loaded hosts ", hostsMasterServicesMapping);
  440. },
  441. /**
  442. * Save slaveHostComponents to main controller
  443. * @param stepController
  444. */
  445. saveSlaveComponentHosts: function (stepController) {
  446. var hosts = stepController.get('hosts');
  447. var isMrSelected = stepController.get('isMrSelected');
  448. var isHbSelected = stepController.get('isHbSelected');
  449. App.db.setHostSlaveComponents(hosts);
  450. this.set('content.hostSlaveComponents', hosts);
  451. var dataNodeHosts = [];
  452. var taskTrackerHosts = [];
  453. var regionServerHosts = [];
  454. var clientHosts = [];
  455. hosts.forEach(function (host) {
  456. if (host.get('isDataNode')) {
  457. dataNodeHosts.push({
  458. hostname: host.hostname,
  459. group: 'Default'
  460. });
  461. }
  462. if (isMrSelected && host.get('isTaskTracker')) {
  463. taskTrackerHosts.push({
  464. hostname: host.hostname,
  465. group: 'Default'
  466. });
  467. }
  468. if (isHbSelected && host.get('isRegionServer')) {
  469. regionServerHosts.push({
  470. hostname: host.hostname,
  471. group: 'Default'
  472. });
  473. }
  474. if (host.get('isClient')) {
  475. clientHosts.pushObject({
  476. hostname: host.hostname,
  477. group: 'Default'
  478. });
  479. }
  480. }, this);
  481. var slaveComponentHosts = [];
  482. slaveComponentHosts.push({
  483. componentName: 'DATANODE',
  484. displayName: 'DataNode',
  485. hosts: dataNodeHosts
  486. });
  487. if (isMrSelected) {
  488. slaveComponentHosts.push({
  489. componentName: 'TASKTRACKER',
  490. displayName: 'TaskTracker',
  491. hosts: taskTrackerHosts
  492. });
  493. }
  494. if (isHbSelected) {
  495. slaveComponentHosts.push({
  496. componentName: 'HBASE_REGIONSERVER',
  497. displayName: 'RegionServer',
  498. hosts: regionServerHosts
  499. });
  500. }
  501. slaveComponentHosts.pushObject({
  502. componentName: 'CLIENT',
  503. displayName: 'client',
  504. hosts: clientHosts
  505. });
  506. App.db.setSlaveComponentHosts(slaveComponentHosts);
  507. this.set('content.slaveComponentHosts', slaveComponentHosts);
  508. },
  509. /**
  510. * Load master component hosts data for using in required step controllers
  511. */
  512. loadSlaveComponentHosts: function () {
  513. var slaveComponentHosts = App.db.getSlaveComponentHosts();
  514. this.set("content.slaveComponentHosts", slaveComponentHosts);
  515. console.log("InstallerController.loadSlaveComponentHosts: loaded hosts ", slaveComponentHosts);
  516. var hostSlaveComponents = App.db.getHostSlaveComponents();
  517. this.set('content.hostSlaveComponents', hostSlaveComponents);
  518. console.log("InstallerController.loadSlaveComponentHosts: loaded hosts ", hostSlaveComponents);
  519. },
  520. /**
  521. * Save config properties
  522. * @param stepController Step7WizardController
  523. */
  524. saveServiceConfigProperties: function (stepController) {
  525. var serviceConfigProperties = [];
  526. stepController.get('stepConfigs').forEach(function (_content) {
  527. _content.get('configs').forEach(function (_configProperties) {
  528. var configProperty = {
  529. name: _configProperties.get('name'),
  530. value: _configProperties.get('value'),
  531. service: _configProperties.get('serviceName')
  532. };
  533. serviceConfigProperties.push(configProperty);
  534. }, this);
  535. }, this);
  536. App.db.setServiceConfigProperties(serviceConfigProperties);
  537. this.set('content.serviceConfigProperties', serviceConfigProperties);
  538. },
  539. /**
  540. * Load serviceConfigProperties to model
  541. */
  542. loadServiceConfigProperties: function () {
  543. var serviceConfigProperties = App.db.getServiceConfigProperties();
  544. this.set('content.serviceConfigProperties', serviceConfigProperties);
  545. console.log("InstallerController.loadServiceConfigProperties: loaded config ", serviceConfigProperties);
  546. },
  547. /**
  548. * Load information about hosts with clients components
  549. */
  550. loadClients: function () {
  551. var clients = App.db.getClientsForSelectedServices();
  552. this.set('content.clients', clients);
  553. console.log("InstallerController.loadClients: loaded list ", clients);
  554. },
  555. /**
  556. * Generate clients list for selected services and save it to model
  557. * @param stepController step4WizardController
  558. */
  559. saveClients: function (stepController) {
  560. var clients = [];
  561. var serviceComponents = require('data/service_components');
  562. stepController.get('content').filterProperty('isSelected', true).forEach(function (_service) {
  563. var client = serviceComponents.filterProperty('service_name', _service.serviceName).findProperty('isClient', true);
  564. if (client) {
  565. clients.pushObject({
  566. component_name: client.component_name,
  567. display_name: client.display_name
  568. });
  569. }
  570. }, this);
  571. App.db.setClientsForSelectedServices(clients);
  572. this.set('content.clients', clients);
  573. console.log("InstallerController.saveClients: saved list ", clients);
  574. },
  575. /**
  576. * Load HostToMasterComponent array
  577. */
  578. loadHostToMasterComponent: function () {
  579. var list = App.db.getHostToMasterComponent();
  580. this.set('content.hostToMasterComponent', list);
  581. console.log("AddHostController.loadHostToMasterComponent: loaded list ", list);
  582. },
  583. /**
  584. * Load data for all steps until <code>current step</code>
  585. */
  586. loadAllPriorSteps: function () {
  587. var step = this.get('currentStep');
  588. switch (step) {
  589. case '9':
  590. case '8':
  591. case '7':
  592. this.loadServiceConfigProperties();
  593. case '6':
  594. this.loadClients();
  595. case '5':
  596. this.loadMasterComponentHosts();
  597. this.loadSlaveComponentHosts();
  598. this.loadHostToMasterComponent();
  599. this.loadConfirmedHosts();
  600. case '4':
  601. this.loadServices();
  602. this.loadClients();
  603. case '3':
  604. this.loadConfirmedHosts();
  605. case '2':
  606. this.loadInstallOptions();
  607. case '1':
  608. this.loadClusterInfo();
  609. }
  610. },
  611. /**
  612. * Generate clients list for selected services and save it to model
  613. * @param stepController step8WizardController or step9WizardController
  614. */
  615. installServices: function () {
  616. var self = this;
  617. var clusterName = this.get('content.cluster.name');
  618. var url = (App.testMode) ? '/data/wizard/deploy/poll_1.json' : '/api/clusters/' + clusterName + '/services?state=INIT';
  619. var method = (App.testMode) ? 'GET' : 'PUT';
  620. var data = '{"ServiceInfo": {"state": "INSTALLED"}}';
  621. $.ajax({
  622. type: method,
  623. url: url,
  624. data: data,
  625. async: false,
  626. dataType: 'text',
  627. timeout: 5000,
  628. success: function (data) {
  629. var jsonData = jQuery.parseJSON(data);
  630. console.log("TRACE: STep8 -> In success function for the installService call");
  631. console.log("TRACE: STep8 -> value of the url is: " + url);
  632. if (jsonData) {
  633. var requestId = jsonData.href.match(/.*\/(.*)$/)[1];
  634. console.log('requestId is: ' + requestId);
  635. var clusterStatus = {
  636. status: 'PENDING',
  637. requestId: requestId,
  638. isInstallError: false,
  639. isCompleted: false
  640. };
  641. self.saveClusterStatus(clusterStatus);
  642. } else {
  643. console.log('ERROR: Error occurred in parsing JSON data');
  644. }
  645. },
  646. error: function (request, ajaxOptions, error) {
  647. console.log("TRACE: STep8 -> In error function for the installService call");
  648. console.log("TRACE: STep8 -> value of the url is: " + url);
  649. console.log("TRACE: STep8 -> error code status is: " + request.status);
  650. console.log('Step8: Error message is: ' + request.responseText);
  651. var clusterStatus = {
  652. status: 'PENDING',
  653. isInstallError: true,
  654. isCompleted: false
  655. };
  656. self.saveClusterStatus(clusterStatus);
  657. },
  658. statusCode: require('data/statusCodes')
  659. });
  660. }
  661. });