add_controller.js 23 KB

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