installer.js 26 KB

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