add_controller.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  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: "DONE",
  188. isInstalled: true
  189. };
  190. });
  191. App.db.setHosts(hosts);
  192. }
  193. this.set('content.hostsInfo', hosts);
  194. console.log('AddServiceController.loadConfirmedHosts: loaded hosts', hosts);
  195. },
  196. /**
  197. * Save data after installation to main controller
  198. * @param stepController App.WizardStep9Controller
  199. */
  200. saveInstalledHosts: function (stepController) {
  201. var hosts = stepController.get('hosts');
  202. var hostInfo = App.db.getHosts();
  203. for (var index in hostInfo) {
  204. hostInfo[index].status = "pending";
  205. var host = hosts.findProperty('name', hostInfo[index].name);
  206. if (host) {
  207. hostInfo[index].status = host.status;
  208. hostInfo[index].message = host.message;
  209. hostInfo[index].progress = host.progress;
  210. }
  211. }
  212. App.db.setHosts(hostInfo);
  213. this.set('content.hostsInfo', hostInfo);
  214. console.log('AddServiceController:saveInstalledHosts: save hosts ', hostInfo);
  215. },
  216. /**
  217. * Remove all data for hosts
  218. */
  219. clearHosts: function () {
  220. var hosts = this.get('content').get('hosts');
  221. if (hosts) {
  222. hosts.hostNames = '';
  223. hosts.manualInstall = false;
  224. hosts.localRepo = '';
  225. hosts.localRepopath = '';
  226. hosts.sshKey = '';
  227. hosts.passphrase = '';
  228. hosts.confirmPassphrase = '';
  229. }
  230. App.db.setHosts(null);
  231. App.db.setAllHostNames(null);
  232. },
  233. /**
  234. * Load services data. Will be used at <code>Select services(step4)</code> step
  235. */
  236. loadServices: function () {
  237. var servicesInfo = App.db.getService();
  238. if(!servicesInfo || !servicesInfo.length){
  239. servicesInfo = require('data/mock/services').slice(0);
  240. servicesInfo.forEach(function(item, index){
  241. servicesInfo[index].isSelected = App.Service.find().someProperty('id', item.serviceName);
  242. servicesInfo[index].isDisabled = servicesInfo[index].isSelected;
  243. servicesInfo[index].isInstalled = servicesInfo[index].isSelected;
  244. });
  245. }
  246. servicesInfo.forEach(function (item, index) {
  247. servicesInfo[index] = Em.Object.create(item);
  248. });
  249. this.set('content.services', servicesInfo);
  250. console.log('AddServiceController.loadServices: loaded data ', servicesInfo);
  251. var serviceNames = servicesInfo.filterProperty('isSelected', true).filterProperty('isDisabled', false).mapProperty('serviceName');
  252. console.log('selected services ', serviceNames);
  253. this.set('content.missSlavesStep', !serviceNames.contains('MAPREDUCE') && !serviceNames.contains('HBASE'));
  254. },
  255. /**
  256. * Save data to model
  257. * @param stepController App.WizardStep4Controller
  258. */
  259. saveServices: function (stepController) {
  260. var serviceNames = [];
  261. App.db.setService(stepController.get('content'));
  262. console.log('AddServiceController.saveServices: saved data', stepController.get('content'));
  263. stepController.filterProperty('isSelected', true).filterProperty('isInstalled', false).forEach(function (item) {
  264. serviceNames.push(item.serviceName);
  265. });
  266. this.set('content.selectedServiceNames', serviceNames);
  267. App.db.setSelectedServiceNames(serviceNames);
  268. console.log('AddServiceController.selectedServiceNames:', serviceNames);
  269. this.set('content.missSlavesStep', !serviceNames.contains('MAPREDUCE') && !serviceNames.contains('HBASE'));
  270. },
  271. /**
  272. * Save Master Component Hosts data to Main Controller
  273. * @param stepController App.WizardStep5Controller
  274. */
  275. saveMasterComponentHosts: function (stepController) {
  276. var obj = stepController.get('selectedServicesMasters');
  277. var masterComponentHosts = [];
  278. var installedComponents = App.Component.find();
  279. obj.forEach(function (_component) {
  280. masterComponentHosts.push({
  281. display_name: _component.display_name,
  282. component: _component.component_name,
  283. hostName: _component.selectedHost,
  284. serviceId: _component.serviceId,
  285. isInstalled: installedComponents.someProperty('componentName', _component.component_name)
  286. });
  287. });
  288. console.log("AddServiceController.saveMasterComponentHosts: saved hosts ", masterComponentHosts);
  289. App.db.setMasterComponentHosts(masterComponentHosts);
  290. this.set('content.masterComponentHosts', masterComponentHosts);
  291. this.set('content.missMasterStep', this.get('content.masterComponentHosts').everyProperty('isInstalled', true));
  292. },
  293. /**
  294. * Load master component hosts data for using in required step controllers
  295. */
  296. loadMasterComponentHosts: function () {
  297. var masterComponentHosts = App.db.getMasterComponentHosts();
  298. if(!masterComponentHosts){
  299. masterComponentHosts = [];
  300. App.Component.find().filterProperty('isMaster', true).forEach(function(item){
  301. masterComponentHosts.push({
  302. component: item.get('componentName'),
  303. hostName: item.get('host.hostName'),
  304. isInstalled: true
  305. })
  306. });
  307. }
  308. this.set("content.masterComponentHosts", masterComponentHosts);
  309. console.log("AddServiceController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts);
  310. this.set('content.missMasterStep', this.get('content.masterComponentHosts').everyProperty('isInstalled', true));
  311. },
  312. /**
  313. * Save slaveHostComponents to main controller
  314. * @param stepController
  315. */
  316. saveSlaveComponentHosts: function (stepController) {
  317. var hosts = stepController.get('hosts');
  318. var isMrSelected = stepController.get('isMrSelected');
  319. var isHbSelected = stepController.get('isHbSelected');
  320. var dataNodeHosts = [];
  321. var taskTrackerHosts = [];
  322. var regionServerHosts = [];
  323. var clientHosts = [];
  324. hosts.forEach(function (host) {
  325. if (host.get('isDataNode')) {
  326. dataNodeHosts.push({
  327. hostName: host.hostName,
  328. group: 'Default',
  329. isInstalled: host.get('isDataNodeInstalled')
  330. });
  331. }
  332. if (isMrSelected && host.get('isTaskTracker')) {
  333. taskTrackerHosts.push({
  334. hostName: host.hostName,
  335. group: 'Default',
  336. isInstalled: host.get('isTaskTrackerInstalled')
  337. });
  338. }
  339. if (isHbSelected && host.get('isRegionServer')) {
  340. regionServerHosts.push({
  341. hostName: host.hostName,
  342. group: 'Default',
  343. isInstalled: host.get('isRegionServerInstalled')
  344. });
  345. }
  346. if (host.get('isClient')) {
  347. clientHosts.pushObject({
  348. hostName: host.hostName,
  349. group: 'Default',
  350. isInstalled: host.get('isClientInstalled')
  351. });
  352. }
  353. }, this);
  354. var slaveComponentHosts = [];
  355. slaveComponentHosts.push({
  356. componentName: 'DATANODE',
  357. displayName: 'DataNode',
  358. hosts: dataNodeHosts
  359. });
  360. if (isMrSelected) {
  361. slaveComponentHosts.push({
  362. componentName: 'TASKTRACKER',
  363. displayName: 'TaskTracker',
  364. hosts: taskTrackerHosts
  365. });
  366. }
  367. if (isHbSelected) {
  368. slaveComponentHosts.push({
  369. componentName: 'HBASE_REGIONSERVER',
  370. displayName: 'RegionServer',
  371. hosts: regionServerHosts
  372. });
  373. }
  374. slaveComponentHosts.pushObject({
  375. componentName: 'CLIENT',
  376. displayName: 'client',
  377. hosts: clientHosts
  378. });
  379. App.db.setSlaveComponentHosts(slaveComponentHosts);
  380. console.log('addServiceController.slaveComponentHosts: saved hosts', slaveComponentHosts);
  381. this.set('content.slaveComponentHosts', slaveComponentHosts);
  382. },
  383. /**
  384. * return slaveComponents bound to hosts
  385. * @return {Array}
  386. */
  387. getSlaveComponentHosts: function () {
  388. var components = [{
  389. name : 'DATANODE',
  390. service : 'HDFS'
  391. },
  392. {
  393. name: 'TASKTRACKER',
  394. service: 'MAPREDUCE'
  395. },{
  396. name: 'HBASE_REGIONSERVER',
  397. service: 'HBASE'
  398. }];
  399. var result = [];
  400. var services = App.Service.find();
  401. var selectedServices = this.get('content.services').filterProperty('isSelected', true).mapProperty('serviceName');
  402. for(var index=0; index < components.length; index++){
  403. var comp = components[index];
  404. if(!selectedServices.contains(comp.service)){
  405. continue;
  406. }
  407. var service = services.findProperty('id', comp.service);
  408. var hosts = [];
  409. if(!service){
  410. service = services.findProperty('id', 'HDFS');
  411. service.get('hostComponents').filterProperty('componentName', 'DATANODE').forEach(function (host_component) {
  412. hosts.push({
  413. group: "Default",
  414. hostName: host_component.get('host.id'),
  415. isInstalled: false
  416. });
  417. }, this);
  418. } else {
  419. service.get('hostComponents').filterProperty('componentName', comp.name).forEach(function (host_component) {
  420. hosts.push({
  421. group: "Default",
  422. hostName: host_component.get('host.id'),
  423. isInstalled: true
  424. });
  425. }, this);
  426. }
  427. result.push({
  428. componentName: comp.name,
  429. displayName: App.format.role(comp.name),
  430. hosts: hosts
  431. })
  432. }
  433. var clientsHosts = App.HostComponent.find().filterProperty('componentName', 'HDFS_CLIENT');
  434. var hosts = [];
  435. clientsHosts.forEach(function (host_component) {
  436. hosts.push({
  437. group: "Default",
  438. hostName: host_component.get('host.id'),
  439. isInstalled: true
  440. });
  441. }, this);
  442. result.push({
  443. componentName: 'CLIENT',
  444. displayName: 'client',
  445. hosts: hosts
  446. })
  447. return result;
  448. },
  449. /**
  450. * Load master component hosts data for using in required step controllers
  451. */
  452. loadSlaveComponentHosts: function () {
  453. var slaveComponentHosts = App.db.getSlaveComponentHosts();
  454. if(!slaveComponentHosts){
  455. slaveComponentHosts = this.getSlaveComponentHosts();
  456. }
  457. this.set("content.slaveComponentHosts", slaveComponentHosts);
  458. console.log("AddServiceController.loadSlaveComponentHosts: loaded hosts ", slaveComponentHosts);
  459. },
  460. /**
  461. * Save config properties
  462. * @param stepController Step7WizardController
  463. */
  464. saveServiceConfigProperties: function (stepController) {
  465. var serviceConfigProperties = [];
  466. stepController.get('stepConfigs').forEach(function (_content) {
  467. _content.get('configs').forEach(function (_configProperties) {
  468. var configProperty = {
  469. name: _configProperties.get('name'),
  470. value: _configProperties.get('value'),
  471. service: _configProperties.get('serviceName')
  472. };
  473. serviceConfigProperties.push(configProperty);
  474. }, this);
  475. }, this);
  476. App.db.setServiceConfigProperties(serviceConfigProperties);
  477. this.set('content.serviceConfigProperties', serviceConfigProperties);
  478. },
  479. /**
  480. * Load serviceConfigProperties to model
  481. */
  482. loadServiceConfigProperties: function () {
  483. var serviceConfigProperties = App.db.getServiceConfigProperties();
  484. this.set('content.serviceConfigProperties', serviceConfigProperties);
  485. console.log("AddServiceController.loadServiceConfigProperties: loaded config ", serviceConfigProperties);
  486. },
  487. /**
  488. * Load information about hosts with clients components
  489. */
  490. loadClients: function(){
  491. var clients = App.db.getClientsForSelectedServices();
  492. this.set('content.clients', clients);
  493. console.log("AddServiceController.loadClients: loaded list ", clients);
  494. },
  495. dataLoading: function(){
  496. var dfd = $.Deferred();
  497. this.connectOutlet('loading');
  498. if (App.router.get('clusterController.isLoaded')){
  499. dfd.resolve();
  500. } else{
  501. var interval = setInterval(function(){
  502. if (App.router.get('clusterController.isLoaded')){
  503. dfd.resolve();
  504. clearInterval(interval);
  505. }
  506. },50);
  507. }
  508. return dfd.promise();
  509. },
  510. /**
  511. * Generate clients list for selected services and save it to model
  512. * @param stepController step4WizardController
  513. */
  514. saveClients: function(stepController){
  515. var clients = [];
  516. var serviceComponents = require('data/service_components');
  517. var hostComponents = App.HostComponent.find();
  518. stepController.get('content').filterProperty('isSelected',true).forEach(function (_service) {
  519. var client = serviceComponents.filterProperty('service_name', _service.serviceName).findProperty('isClient', true);
  520. if (client) {
  521. clients.pushObject({
  522. component_name: client.component_name,
  523. display_name: client.display_name,
  524. isInstalled: hostComponents.filterProperty('componentName', client.component_name).length > 0
  525. });
  526. }
  527. }, this);
  528. App.db.setClientsForSelectedServices(clients);
  529. this.set('content.clients', clients);
  530. console.log("AddServiceController.saveClients: saved list ", clients);
  531. },
  532. /**
  533. * Load data for all steps until <code>current step</code>
  534. */
  535. loadAllPriorSteps: function () {
  536. var step = this.get('currentStep');
  537. switch (step) {
  538. case '7':
  539. case '6':
  540. case '5':
  541. this.loadClusterInfo();
  542. case '4':
  543. this.loadServiceConfigProperties();
  544. case '3':
  545. this.loadServices();
  546. this.loadClients();
  547. this.loadSlaveComponentHosts();//depends on loadServices
  548. case '2':
  549. this.loadMasterComponentHosts();
  550. this.loadConfirmedHosts();
  551. case '1':
  552. this.loadServices();
  553. }
  554. },
  555. loadAdvancedConfigs: function () {
  556. App.db.getSelectedServiceNames().forEach(function (_serviceName) {
  557. this.loadAdvancedConfig(_serviceName);
  558. }, this);
  559. },
  560. /**
  561. * Generate serviceProperties save it to localdata
  562. * called form stepController step6WizardController
  563. */
  564. loadAdvancedConfig: function (serviceName) {
  565. var self = this;
  566. 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
  567. var method = 'GET';
  568. $.ajax({
  569. type: method,
  570. url: url,
  571. async: false,
  572. dataType: 'text',
  573. timeout: App.timeout,
  574. success: function (data) {
  575. var jsonData = jQuery.parseJSON(data);
  576. console.log("TRACE: Step6 submit -> In success function for the loadAdvancedConfig call");
  577. console.log("TRACE: Step6 submit -> value of the url is: " + url);
  578. var serviceComponents = jsonData.properties;
  579. serviceComponents.setEach('serviceName', serviceName);
  580. var configs;
  581. if (App.db.getAdvancedServiceConfig()) {
  582. configs = App.db.getAdvancedServiceConfig();
  583. } else {
  584. configs = [];
  585. }
  586. configs = configs.concat(serviceComponents);
  587. self.set('content.advancedServiceConfig', configs);
  588. App.db.setAdvancedServiceConfig(configs);
  589. console.log('TRACE: servicename: ' + serviceName);
  590. },
  591. error: function (request, ajaxOptions, error) {
  592. console.log("TRACE: STep6 submit -> In error function for the loadAdvancedConfig call");
  593. console.log("TRACE: STep6 submit-> value of the url is: " + url);
  594. console.log("TRACE: STep6 submit-> error code status is: " + request.status);
  595. console.log('Step6 submit: Error message is: ' + request.responseText);
  596. },
  597. statusCode: require('data/statusCodes')
  598. });
  599. },
  600. /**
  601. * Generate clients list for selected services and save it to model
  602. * @param stepController step8WizardController or step9WizardController
  603. */
  604. installServices: function (isRetry) {
  605. if(!isRetry && this.get('content.cluster.requestId')){
  606. return;
  607. }
  608. var self = this;
  609. var clusterName = this.get('content.cluster.name');
  610. var url = (App.testMode) ? '/data/wizard/deploy/poll_1.json' : App.apiPrefix + '/clusters/' + clusterName + '/services?ServiceInfo/state=INIT';
  611. var method = (App.testMode) ? 'GET' : 'PUT';
  612. var data = '{"ServiceInfo": {"state": "INSTALLED"}}';
  613. $.ajax({
  614. type: method,
  615. url: url,
  616. data: data,
  617. async: false,
  618. dataType: 'text',
  619. timeout: App.timeout,
  620. success: function (data) {
  621. var jsonData = jQuery.parseJSON(data);
  622. var installSartTime = new Date().getTime();
  623. console.log("TRACE: STep8 -> In success function for the installService call");
  624. console.log("TRACE: STep8 -> value of the url is: " + url);
  625. if (jsonData) {
  626. var requestId = jsonData.href.match(/.*\/(.*)$/)[1];
  627. console.log('requestId is: ' + requestId);
  628. var clusterStatus = {
  629. status: 'PENDING',
  630. requestId: requestId,
  631. isInstallError: false,
  632. isCompleted: false,
  633. installStartTime: installSartTime
  634. };
  635. self.saveClusterStatus(clusterStatus);
  636. } else {
  637. console.log('ERROR: Error occurred in parsing JSON data');
  638. }
  639. },
  640. error: function (request, ajaxOptions, error) {
  641. console.log("TRACE: STep8 -> In error function for the installService call");
  642. console.log("TRACE: STep8 -> value of the url is: " + url);
  643. console.log("TRACE: STep8 -> error code status is: " + request.status);
  644. console.log('Step8: Error message is: ' + request.responseText);
  645. var clusterStatus = {
  646. status: 'PENDING',
  647. isInstallError: true,
  648. isCompleted: false
  649. };
  650. self.saveClusterStatus(clusterStatus);
  651. },
  652. statusCode: require('data/statusCodes')
  653. });
  654. },
  655. /**
  656. * Remove all loaded data.
  657. * Created as copy for App.router.clearAllSteps
  658. */
  659. clearAllSteps: function () {
  660. this.clearHosts();
  661. //todo it)
  662. },
  663. /**
  664. * Clear all temporary data
  665. */
  666. finish: function(){
  667. this.setCurrentStep('1', false);
  668. App.db.setService(undefined); //not to use this data at AddService page
  669. App.db.setHosts(undefined);
  670. App.db.setMasterComponentHosts(undefined);
  671. App.db.setSlaveComponentHosts(undefined);
  672. App.db.setClusterStatus(undefined);
  673. App.db.setAllHostNames(undefined);
  674. }
  675. });