add_controller.js 24 KB

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