installer.js 26 KB

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