add_controller.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  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.AddServiceController = Em.Controller.extend({
  20. name: 'addServiceController',
  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. hostSlaveComponents: null,
  39. masterComponentHosts: null,
  40. hostToMasterComponent : null,
  41. serviceConfigProperties: null
  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('addService');
  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('addService', 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. gotoStep: function (step) {
  110. if (this.get('isStepDisabled').findProperty('step', step).get('value') === false) {
  111. App.router.send('gotoStep' + step);
  112. }
  113. },
  114. gotoStep1: function () {
  115. this.gotoStep(1);
  116. },
  117. gotoStep2: function () {
  118. this.gotoStep(2);
  119. },
  120. gotoStep3: function () {
  121. this.gotoStep(3);
  122. },
  123. gotoStep4: function () {
  124. this.gotoStep(4);
  125. },
  126. gotoStep5: function () {
  127. this.gotoStep(5);
  128. },
  129. gotoStep6: function () {
  130. this.gotoStep(6);
  131. },
  132. gotoStep7: function () {
  133. this.gotoStep(7);
  134. },
  135. /**
  136. * Load clusterInfo(step1) to model
  137. */
  138. loadClusterInfo: function(){
  139. var cStatus = App.db.getClusterStatus() || {status: "", isCompleted: false};
  140. var cluster = {
  141. name: App.db.getClusterName() || "",
  142. status: cStatus.status,
  143. isCompleted: cStatus.isCompleted
  144. };
  145. this.set('content.cluster', cluster);
  146. console.log("AddServiceController:loadClusterInfo: loaded data ", cluster);
  147. },
  148. /**
  149. * Save all info about claster to model
  150. * @param stepController Step1WizardController
  151. */
  152. saveClusterInfo: function (stepController) {
  153. var cluster = stepController.get('content.cluster');
  154. var clusterStatus = {
  155. status: cluster.status,
  156. isCompleted: cluster.isCompleted
  157. }
  158. App.db.setClusterName(cluster.name);
  159. App.db.setClusterStatus(clusterStatus);
  160. console.log("AddServiceController:saveClusterInfo: saved data ", cluster);
  161. //probably next line is extra work - need to check it
  162. this.set('content.cluster', cluster);
  163. },
  164. /**
  165. * save status of the cluster. This is called from step8 and step9 to persist install and start requestId
  166. * @param clusterStatus object with status, isCompleted, requestId, isInstallError and isStartError field.
  167. */
  168. saveClusterStatus: function (clusterStatus) {
  169. this.set('content.cluster', clusterStatus);
  170. App.db.setClusterStatus(clusterStatus);
  171. },
  172. /**
  173. * Temporary function for wizardStep9, before back-end integration
  174. */
  175. setInfoForStep9: function () {
  176. var hostInfo = App.db.getHosts();
  177. for (var index in hostInfo) {
  178. hostInfo[index].status = "pending";
  179. hostInfo[index].message = 'Information';
  180. hostInfo[index].progress = '0';
  181. }
  182. App.db.setHosts(hostInfo);
  183. },
  184. /**
  185. * Load all data for <code>Specify Host(install step2)</code> step
  186. * Data Example:
  187. * {
  188. * hostNames: '',
  189. * manualInstall: false,
  190. * sshKey: '',
  191. * passphrase: '',
  192. * confirmPassphrase: '',
  193. * localRepo: false,
  194. * localRepoPath: ''
  195. * }
  196. */
  197. loadInstallOptions: function () {
  198. if (!this.content.hosts) {
  199. this.content.hosts = Em.Object.create();
  200. }
  201. //TODO : rewire it as model. or not :)
  202. var hostsInfo = Em.Object.create();
  203. hostsInfo.hostNames = App.db.getAllHostNames() || ''; //empty string if undefined
  204. //TODO : should we check installType for add host wizard????
  205. var installType = App.db.getInstallType();
  206. //false if installType not equals 'manual'
  207. hostsInfo.manualInstall = installType && installType.installType === 'manual' || false;
  208. var softRepo = App.db.getSoftRepo();
  209. if (softRepo && softRepo.repoType === 'local') {
  210. hostsInfo.localRepo = true;
  211. hostsInfo.localRepopath = softRepo.repoPath;
  212. } else {
  213. hostsInfo.localRepo = false;
  214. hostsInfo.localRepoPath = '';
  215. }
  216. hostsInfo.sshKey = 'random';
  217. hostsInfo.passphrase = '';
  218. hostsInfo.confirmPassphrase = '';
  219. this.set('content.hosts', hostsInfo);
  220. console.log("AddServiceController:loadHosts: loaded data ", hostsInfo);
  221. },
  222. /**
  223. * Save data, which user filled, to main controller
  224. * @param stepController App.WizardStep2Controller
  225. */
  226. saveHosts: function (stepController) {
  227. //TODO: put data to content.hosts and only then save it)
  228. //App.db.setBootStatus(false);
  229. App.db.setAllHostNames(stepController.get('hostNames'));
  230. App.db.setHosts(stepController.getHostInfo());
  231. if (stepController.get('manualInstall') === false) {
  232. App.db.setInstallType({installType: 'ambari' });
  233. } else {
  234. App.db.setInstallType({installType: 'manual' });
  235. }
  236. if (stepController.get('localRepo') === false) {
  237. App.db.setSoftRepo({ 'repoType': 'remote', 'repoPath': null});
  238. } else {
  239. App.db.setSoftRepo({ 'repoType': 'local', 'repoPath': stepController.get('localRepoPath') });
  240. }
  241. },
  242. /**
  243. * Return hosts, which were add at <code>Specify Host(step2)</code> step
  244. * @paramm isNew whether return all hosts or only new ones
  245. */
  246. getHostList: function (isNew) {
  247. var hosts = [];
  248. var hostArray = App.db.getHosts()
  249. console.log('in AddServiceController.getHostList: host names is ', hostArray);
  250. for (var i in hostArray) {
  251. var hostInfo = App.HostInfo.create({
  252. name: hostArray[i].name,
  253. bootStatus: hostArray[i].bootStatus
  254. });
  255. hosts.pushObject(hostInfo);
  256. }
  257. console.log('TRACE: pushing ' + hosts);
  258. return hosts;
  259. },
  260. /**
  261. * Remove host from model. Used at <code>Confirm hosts(step2)</code> step
  262. * @param hosts Array of hosts, which we want to delete
  263. */
  264. removeHosts: function (hosts) {
  265. //todo Replace this code with real logic
  266. App.db.removeHosts(hosts);
  267. },
  268. /**
  269. * Save data, which user filled, to main controller
  270. * @param stepController App.WizardStep3Controller
  271. */
  272. saveConfirmedHosts: function (stepController) {
  273. var hostInfo = {};
  274. stepController.get('content').forEach(function (_host) {
  275. hostInfo[_host.name] = {
  276. name: _host.name,
  277. cpu: _host.cpu,
  278. memory: _host.memory,
  279. bootStatus: _host.bootStatus
  280. };
  281. });
  282. console.log('AddServiceController:saveConfirmedHosts: save hosts ', hostInfo);
  283. App.db.setHosts(hostInfo);
  284. this.set('content.hostsInfo', hostInfo);
  285. },
  286. /**
  287. * Load confirmed hosts.
  288. * Will be used at <code>Assign Masters(step5)</code> step
  289. */
  290. loadConfirmedHosts: function(){
  291. var hosts=App.db.getHosts();
  292. hosts = {
  293. "192.168.1.1":{"name":"192.168.1.1","cpu":"2","memory":"2","bootStatus":"pending"},
  294. "192.168.1.2":{"name":"192.168.1.2","cpu":"2","memory":"2","bootStatus":"success"},
  295. "192.168.1.3":{"name":"192.168.1.3","cpu":"2","memory":"2","bootStatus":"pending"},
  296. "192.168.1.4":{"name":"192.168.1.4","cpu":"2","memory":"2","bootStatus":"pending"},
  297. "192.168.1.5":{"name":"192.168.1.5","cpu":"2","memory":"2","bootStatus":"success"},
  298. "192.168.1.6":{"name":"192.168.1.6","cpu":"2","memory":"2","bootStatus":"pending"},
  299. "192.168.1.7":{"name":"192.168.1.7","cpu":"2","memory":"2","bootStatus":"success"},
  300. "192.168.1.8":{"name":"192.168.1.8","cpu":"2","memory":"2","bootStatus":"success"},
  301. "192.168.1.9":{"name":"192.168.1.9","cpu":"2","memory":"2","bootStatus":"success"},
  302. "192.168.1.10":{"name":"192.168.1.10","cpu":"2","memory":"2","bootStatus":"pending"},
  303. "192.168.1.11":{"name":"192.168.1.11","cpu":"2","memory":"2","bootStatus":"success"},
  304. "192.168.1.12":{"name":"192.168.1.12","cpu":"2","memory":"2","bootStatus":"pending"},
  305. "192.168.1.13":{"name":"192.168.1.13","cpu":"2","memory":"2","bootStatus":"success"}
  306. };
  307. this.set('content.hostsInfo', hosts);
  308. },
  309. /**
  310. * Save data after installation to main controller
  311. * @param stepController App.WizardStep9Controller
  312. */
  313. saveInstalledHosts: function (stepController) {
  314. var hosts = stepController.get('hosts');
  315. var hostInfo = App.db.getHosts();
  316. for (var index in hostInfo) {
  317. hostInfo[index].status = "pending";
  318. var host = hosts.findProperty('name', hostInfo[index].name);
  319. if (host) {
  320. hostInfo[index].status = host.status;
  321. hostInfo[index].message = host.message;
  322. hostInfo[index].progress = host.progress;
  323. }
  324. }
  325. App.db.setHosts(hostInfo);
  326. console.log('AddServiceController:saveInstalledHosts: save hosts ', hostInfo);
  327. },
  328. /**
  329. * Remove all data for hosts
  330. */
  331. clearHosts: function () {
  332. var hosts = this.get('content').get('hosts');
  333. if (hosts) {
  334. hosts.hostNames = '';
  335. hosts.manualInstall = false;
  336. hosts.localRepo = '';
  337. hosts.localRepopath = '';
  338. hosts.sshKey = '';
  339. hosts.passphrase = '';
  340. hosts.confirmPassphrase = '';
  341. }
  342. },
  343. /**
  344. * Load services data. Will be used at <code>Select services(step4)</code> step
  345. */
  346. loadServices: function () {
  347. var servicesInfo = App.db.getService();
  348. servicesInfo.forEach(function (item, index) {
  349. servicesInfo[index] = Em.Object.create(item);
  350. });
  351. this.set('content.services', servicesInfo);
  352. console.log('AddServiceController.loadServices: loaded data ', servicesInfo);
  353. console.log('selected services ', servicesInfo.filterProperty('isSelected', true).mapProperty('serviceName'));
  354. },
  355. /**
  356. * Save data to model
  357. * @param stepController App.WizardStep4Controller
  358. */
  359. saveServices: function (stepController) {
  360. var serviceNames = [];
  361. // we can also do it without stepController since all data,
  362. // changed at page, automatically changes in model(this.content.services)
  363. App.db.setService(stepController.get('content'));
  364. stepController.filterProperty('isSelected', true).forEach(function (item) {
  365. serviceNames.push(item.serviceName);
  366. });
  367. App.db.setSelectedServiceNames(serviceNames);
  368. console.log('AddServiceController.saveServices: saved data ', serviceNames);
  369. },
  370. /**
  371. * Save Master Component Hosts data to Main Controller
  372. * @param stepController App.WizardStep5Controller
  373. */
  374. saveMasterComponentHosts: function (stepController) {
  375. var obj = stepController.get('selectedServicesMasters');
  376. var masterComponentHosts = [];
  377. obj.forEach(function (_component) {
  378. masterComponentHosts.push({
  379. display_name: _component.display_name,
  380. component: _component.component_name,
  381. hostName: _component.selectedHost
  382. });
  383. });
  384. console.log("AddServiceController.saveComponentHosts: saved hosts ", masterComponentHosts);
  385. App.db.setMasterComponentHosts(masterComponentHosts);
  386. this.set('content.masterComponentHosts', masterComponentHosts);
  387. var hosts = masterComponentHosts.mapProperty('hostName').uniq();
  388. var hostsMasterServicesMapping = [];
  389. hosts.forEach(function (_host) {
  390. var componentsOnHost = masterComponentHosts.filterProperty('hostName', _host).mapProperty('component');
  391. hostsMasterServicesMapping.push({
  392. hostname: _host,
  393. components: componentsOnHost
  394. });
  395. }, this);
  396. console.log("AddServiceController.setHostToMasterComponent: saved hosts ", hostsMasterServicesMapping);
  397. App.db.setHostToMasterComponent(hostsMasterServicesMapping);
  398. this.set('content.hostToMasterComponent', hostsMasterServicesMapping);
  399. },
  400. /**
  401. * Load master component hosts data for using in required step controllers
  402. */
  403. loadMasterComponentHosts: function () {
  404. var masterComponentHosts = App.db.getMasterComponentHosts();
  405. this.set("content.masterComponentHosts", masterComponentHosts);
  406. console.log("AddServiceController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts);
  407. var hostsMasterServicesMapping = App.db.getHostToMasterComponent();
  408. this.set("content.hostToMasterComponent", hostsMasterServicesMapping);
  409. console.log("AddServiceController.loadHostToMasterComponent: loaded hosts ", hostsMasterServicesMapping);
  410. },
  411. /**
  412. * Save slaveHostComponents to main controller
  413. * @param stepController
  414. */
  415. saveSlaveComponentHosts: function (stepController) {
  416. var hosts = stepController.get('hosts');
  417. var isMrSelected = stepController.get('isMrSelected');
  418. var isHbSelected = stepController.get('isHbSelected');
  419. App.db.setHostSlaveComponents(hosts);
  420. this.set('content.hostSlaveComponents', hosts);
  421. var dataNodeHosts = [];
  422. var taskTrackerHosts = [];
  423. var regionServerHosts = [];
  424. var clientHosts = [];
  425. hosts.forEach(function (host) {
  426. if (host.get('isDataNode')) {
  427. dataNodeHosts.push({
  428. hostname: host.hostname,
  429. group: 'Default'
  430. });
  431. }
  432. if (isMrSelected && host.get('isTaskTracker')) {
  433. taskTrackerHosts.push({
  434. hostname: host.hostname,
  435. group: 'Default'
  436. });
  437. }
  438. if (isHbSelected && host.get('isRegionServer')) {
  439. regionServerHosts.push({
  440. hostname: host.hostname,
  441. group: 'Default'
  442. });
  443. }
  444. if (host.get('isClient')) {
  445. clientHosts.pushObject({
  446. hostname: host.hostname,
  447. group: 'Default'
  448. });
  449. }
  450. }, this);
  451. var slaveComponentHosts = [];
  452. slaveComponentHosts.push({
  453. componentName: 'DATANODE',
  454. displayName: 'DataNode',
  455. hosts: dataNodeHosts
  456. });
  457. if (isMrSelected) {
  458. slaveComponentHosts.push({
  459. componentName: 'TASKTRACKER',
  460. displayName: 'TaskTracker',
  461. hosts: taskTrackerHosts
  462. });
  463. }
  464. if (isHbSelected) {
  465. slaveComponentHosts.push({
  466. componentName: 'HBASE_REGIONSERVER',
  467. displayName: 'RegionServer',
  468. hosts: regionServerHosts
  469. });
  470. }
  471. slaveComponentHosts.pushObject({
  472. componentName: 'CLIENT',
  473. displayName: 'client',
  474. hosts: clientHosts
  475. });
  476. App.db.setSlaveComponentHosts(slaveComponentHosts);
  477. this.set('content.slaveComponentHosts', slaveComponentHosts);
  478. },
  479. /**
  480. * Load master component hosts data for using in required step controllers
  481. */
  482. loadSlaveComponentHosts: function () {
  483. var slaveComponentHosts = App.db.getSlaveComponentHosts();
  484. this.set("content.slaveComponentHosts", slaveComponentHosts);
  485. console.log("AddServiceController.loadSlaveComponentHosts: loaded hosts ", slaveComponentHosts);
  486. var hostSlaveComponents = App.db.getHostSlaveComponents();
  487. this.set('content.hostSlaveComponents', hostSlaveComponents);
  488. console.log("AddServiceController.loadSlaveComponentHosts: loaded hosts ", hostSlaveComponents);
  489. },
  490. /**
  491. * Save config properties
  492. * @param stepController Step7WizardController
  493. */
  494. saveServiceConfigProperties: function (stepController) {
  495. var serviceConfigProperties = [];
  496. stepController.get('stepConfigs').forEach(function (_content) {
  497. _content.get('configs').forEach(function (_configProperties) {
  498. var configProperty = {
  499. name: _configProperties.get('name'),
  500. value: _configProperties.get('value')
  501. };
  502. serviceConfigProperties.push(configProperty);
  503. }, this);
  504. }, this);
  505. App.db.setServiceConfigProperties(serviceConfigProperties);
  506. this.set('content.serviceConfigProperties', serviceConfigProperties);
  507. },
  508. /**
  509. * Load serviceConfigProperties to model
  510. */
  511. loadServiceConfigProperties: function () {
  512. var serviceConfigProperties = App.db.getServiceConfigProperties();
  513. this.set('content.serviceConfigProperties', serviceConfigProperties);
  514. console.log("AddServiceController.loadServiceConfigProperties: loaded config ", serviceConfigProperties);
  515. },
  516. /**
  517. * Load information about hosts with clients components
  518. */
  519. loadClients: function(){
  520. var clients = App.db.getClientsForSelectedServices();
  521. this.set('content.clients', clients);
  522. console.log("AddServiceController.loadClients: loaded list ", clients);
  523. },
  524. /**
  525. * Generate clients list for selected services and save it to model
  526. * @param stepController step4WizardController
  527. */
  528. saveClients: function(stepController){
  529. var clients = [];
  530. var serviceComponents = require('data/service_components');
  531. stepController.get('content').filterProperty('isSelected',true).forEach(function (_service) {
  532. var client = serviceComponents.filterProperty('service_name', _service.serviceName).findProperty('isClient', true);
  533. if (client) {
  534. clients.pushObject({
  535. component_name: client.component_name,
  536. display_name: client.display_name
  537. });
  538. }
  539. }, this);
  540. App.db.setClientsForSelectedServices(clients);
  541. this.set('content.clients', clients);
  542. console.log("AddServiceController.saveClients: saved list ", clients);
  543. },
  544. /**
  545. * Load HostToMasterComponent array
  546. */
  547. loadHostToMasterComponent: function(){
  548. var list = App.db.getHostToMasterComponent();
  549. this.set('content.hostToMasterComponent', list);
  550. console.log("AddServiceController.loadHostToMasterComponent: loaded list ", list);
  551. },
  552. /**
  553. * Load data for all steps until <code>current step</code>
  554. */
  555. loadAllPriorSteps: function () {
  556. var step = this.get('currentStep');
  557. switch (step) {
  558. case '6':
  559. case '5':
  560. this.loadClusterInfo();
  561. case '4':
  562. this.loadServiceConfigProperties();
  563. case '3':
  564. this.loadClients();
  565. case '2':
  566. this.loadMasterComponentHosts();
  567. this.loadSlaveComponentHosts();
  568. this.loadHostToMasterComponent();
  569. this.loadConfirmedHosts();
  570. case '1':
  571. this.loadServices();
  572. }
  573. },
  574. /**
  575. * Generate clients list for selected services and save it to model
  576. * @param stepController step8WizardController or step9WizardController
  577. */
  578. installServices: function () {
  579. var self = this;
  580. var clusterName = this.get('content.cluster.name');
  581. var url = '/api/clusters/' + clusterName + '/services?state=INIT';
  582. var data = '{"ServiceInfo": {"state": "INSTALLED"}}';
  583. $.ajax({
  584. type: 'PUT',
  585. url: url,
  586. data: data,
  587. async: false,
  588. dataType: 'text',
  589. timeout: 5000,
  590. success: function (data) {
  591. var jsonData = jQuery.parseJSON(data);
  592. console.log("TRACE: STep8 -> In success function for the installService call");
  593. console.log("TRACE: STep8 -> value of the url is: " + url);
  594. if (jsonData) {
  595. var requestId = jsonData.href.match(/.*\/(.*)$/)[1];
  596. console.log('requestId is: ' + requestId);
  597. var clusterStatus = {
  598. status: 'PENDING',
  599. requestId: requestId,
  600. isInstallError: false,
  601. isCompleted: false
  602. };
  603. self.saveClusterStatus(clusterStatus);
  604. } else {
  605. console.log('ERROR: Error occurred in parsing JSON data');
  606. }
  607. },
  608. error: function (request, ajaxOptions, error) {
  609. console.log("TRACE: STep8 -> In error function for the installService call");
  610. console.log("TRACE: STep8 -> value of the url is: " + url);
  611. console.log("TRACE: STep8 -> error code status is: " + request.status);
  612. console.log('Step8: Error message is: ' + request.responseText);
  613. var clusterStatus = {
  614. status: 'PENDING',
  615. isInstallError: true,
  616. isCompleted: false
  617. };
  618. self.saveClusterStatus(clusterStatus);
  619. },
  620. statusCode: require('data/statusCodes')
  621. });
  622. },
  623. /**
  624. * Remove all loaded data.
  625. * Created as copy for App.router.clearAllSteps
  626. */
  627. clearAllSteps: function () {
  628. this.clearHosts();
  629. //todo it)
  630. }
  631. });