add_controller.js 23 KB

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