add_controller.js 24 KB

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