installer.js 24 KB

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