wizard.js 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373
  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. require('models/host');
  20. App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingMixin, {
  21. isStepDisabled: null,
  22. previousStep: 0,
  23. /**
  24. * map of actions which load data required by which step
  25. * used by <code>loadAllPriorSteps</code>
  26. */
  27. loadMap: {},
  28. /**
  29. * Wizard properties in local storage, which should be cleaned right after wizard has been finished
  30. */
  31. dbPropertiesToClean: [
  32. 'service',
  33. 'hosts',
  34. 'masterComponentHosts',
  35. 'slaveComponentHosts',
  36. 'cluster',
  37. 'allHostNames',
  38. 'installOptions',
  39. 'allHostNamesPattern',
  40. 'serviceComponents',
  41. 'fileNamesToUpdate'
  42. ],
  43. sensibleConfigs: [
  44. { name: 'admin_principal', filename: 'krb5-conf.xml'},
  45. { name: 'admin_password', filename: 'krb5-conf.xml' }
  46. ],
  47. init: function () {
  48. this.clusters = App.Cluster.find();
  49. this.setIsStepDisabled();
  50. },
  51. connectOutlet:function(name, context) {
  52. if (name !== 'loading') this.set('isStepDisabled.isLocked', false);
  53. return this._super.apply(this,arguments);
  54. },
  55. /**
  56. * Set <code>isStepDisabled</code> with list of available steps (basing on <code>totalSteps</code>)
  57. * @method setIsStepDisabled
  58. */
  59. setIsStepDisabled: function () {
  60. this.set('isStepDisabled', Ember.ArrayProxy.create({
  61. content:[],
  62. isLocked:true,
  63. objectAtContent: function(idx) {
  64. var obj = this.get('content').objectAt(idx);
  65. if (obj && !obj.hasOwnProperty('isLocked')) {
  66. obj.reopen({
  67. isLocked:true,
  68. get:function (key) {
  69. return (key === 'value' && this.get('isLocked')) || this._super.apply(this,arguments);
  70. },
  71. notifyValues:function () {
  72. this.notifyPropertyChange('value');
  73. }.observes('isLocked')
  74. });
  75. }
  76. return obj;
  77. },
  78. toggleLock:function () {
  79. this.setEach('isLocked',this.get('isLocked'));
  80. }.observes('isLocked')
  81. }));
  82. this.get('isStepDisabled').pushObject(Em.Object.create({
  83. step: 1,
  84. value: false
  85. }));
  86. for (var i = 2; i <= this.get('totalSteps'); i++) {
  87. this.get('isStepDisabled').pushObject(Em.Object.create({
  88. step: i,
  89. value: true
  90. }));
  91. }
  92. },
  93. slaveComponents: function () {
  94. return App.StackServiceComponent.find().filterProperty('isSlave', true);
  95. }.property('App.router.clusterController.isLoaded'),
  96. allHosts: function () {
  97. var dbHosts = this.get('content.hosts');
  98. var hosts = [];
  99. var hostComponents = [];
  100. for (var hostName in dbHosts) {
  101. hostComponents = [];
  102. var disksOverallCapacity = 0;
  103. var diskFree = 0;
  104. dbHosts[hostName].hostComponents.forEach(function (componentName) {
  105. hostComponents.push(Em.Object.create({
  106. componentName: componentName,
  107. displayName: App.format.role(componentName)
  108. }));
  109. });
  110. dbHosts[hostName].disk_info.forEach(function (disk) {
  111. disksOverallCapacity += parseFloat(disk.size);
  112. diskFree += parseFloat(disk.available);
  113. });
  114. hosts.push(Em.Object.create({
  115. id: hostName,
  116. hostName: hostName,
  117. publicHostName: hostName,
  118. diskInfo: dbHosts[hostName].disk_info,
  119. diskTotal: disksOverallCapacity / (1024 * 1024),
  120. diskFree: diskFree / (1024 * 1024),
  121. disksMounted: dbHosts[hostName].disk_info.length,
  122. cpu: dbHosts[hostName].cpu,
  123. memory: dbHosts[hostName].memory,
  124. osType: dbHosts[hostName].osType ? dbHosts[hostName].osType: 0,
  125. osArch: dbHosts[hostName].osArch ? dbHosts[hostName].osArch : 0,
  126. ip: dbHosts[hostName].ip ? dbHosts[hostName].ip: 0,
  127. hostComponents: hostComponents
  128. }))
  129. }
  130. return hosts;
  131. }.property('content.hosts'),
  132. setStepsEnable: function () {
  133. for (var i = 1; i <= this.totalSteps; i++) {
  134. var step = this.get('isStepDisabled').findProperty('step', i);
  135. if (i <= this.get('currentStep')) {
  136. step.set('value', false);
  137. } else {
  138. step.set('value', true);
  139. }
  140. }
  141. }.observes('currentStep'),
  142. /**
  143. * Enable step link in left nav menu
  144. * @param step - step number
  145. */
  146. enableStep: function (step) {
  147. this.get('isStepDisabled').findProperty('step', step).set('value', false);
  148. },
  149. setLowerStepsDisable: function (stepNo) {
  150. for (var i = 1; i < stepNo; i++) {
  151. var step = this.get('isStepDisabled').findProperty('step', i);
  152. step.set('value', true);
  153. }
  154. },
  155. /**
  156. * Set current step to new value.
  157. * Method moved from App.router.setInstallerCurrentStep
  158. * @param currentStep
  159. * @param completed
  160. */
  161. currentStep: function () {
  162. return App.get('router').getWizardCurrentStep(this.get('name').substr(0, this.get('name').length - 10));
  163. }.property(),
  164. /**
  165. * Set current step to new value.
  166. * Method moved from App.router.setInstallerCurrentStep
  167. * @param currentStep
  168. * @param completed
  169. */
  170. setCurrentStep: function (currentStep, completed) {
  171. this.set('previousStep', this.get('currentStep'));
  172. App.db.setWizardCurrentStep(this.get('name').substr(0, this.get('name').length - 10), currentStep, completed);
  173. this.set('currentStep', currentStep);
  174. },
  175. clusters: null,
  176. isStep0: function () {
  177. return this.get('currentStep') == 0;
  178. }.property('currentStep'),
  179. isStep1: function () {
  180. return this.get('currentStep') == 1;
  181. }.property('currentStep'),
  182. isStep2: function () {
  183. return this.get('currentStep') == 2;
  184. }.property('currentStep'),
  185. isStep3: function () {
  186. return this.get('currentStep') == 3;
  187. }.property('currentStep'),
  188. isStep4: function () {
  189. return this.get('currentStep') == 4;
  190. }.property('currentStep'),
  191. isStep5: function () {
  192. return this.get('currentStep') == 5;
  193. }.property('currentStep'),
  194. isStep6: function () {
  195. return this.get('currentStep') == 6;
  196. }.property('currentStep'),
  197. isStep7: function () {
  198. return this.get('currentStep') == 7;
  199. }.property('currentStep'),
  200. isStep8: function () {
  201. return this.get('currentStep') == 8;
  202. }.property('currentStep'),
  203. isStep9: function () {
  204. return this.get('currentStep') == 9;
  205. }.property('currentStep'),
  206. isStep10: function () {
  207. return this.get('currentStep') == 10;
  208. }.property('currentStep'),
  209. gotoStep: function (step, disableNaviWarning) {
  210. if (this.get('isStepDisabled').findProperty('step', step).get('value') !== false) {
  211. return false;
  212. }
  213. // if going back from Step 9 in Install Wizard, delete the checkpoint so that the user is not redirected
  214. // to Step 9
  215. if (this.get('content.controllerName') == 'installerController' && this.get('currentStep') === '9' && step < 9) {
  216. App.clusterStatus.setClusterStatus({
  217. clusterName: this.get('clusterName'),
  218. clusterState: 'CLUSTER_NOT_CREATED_1',
  219. wizardControllerName: 'installerController',
  220. localdb: {}
  221. });
  222. }
  223. if ((this.get('currentStep') - step) > 1 && !disableNaviWarning) {
  224. App.ModalPopup.show({
  225. header: Em.I18n.t('installer.navigation.warning.header'),
  226. onPrimary: function () {
  227. App.router.send('gotoStep' + step);
  228. this.hide();
  229. },
  230. body: "If you proceed to go back to Step " + step + ", you will lose any changes you have made beyond this step"
  231. });
  232. } else {
  233. App.router.send('gotoStep' + step);
  234. }
  235. return true;
  236. },
  237. gotoStep0: function () {
  238. this.gotoStep(0);
  239. },
  240. gotoStep1: function () {
  241. this.gotoStep(1);
  242. },
  243. gotoStep2: function () {
  244. this.gotoStep(2);
  245. },
  246. gotoStep3: function () {
  247. this.gotoStep(3);
  248. },
  249. gotoStep4: function () {
  250. this.gotoStep(4);
  251. },
  252. gotoStep5: function () {
  253. this.gotoStep(5);
  254. },
  255. gotoStep6: function () {
  256. this.gotoStep(6);
  257. },
  258. gotoStep7: function () {
  259. this.gotoStep(7);
  260. },
  261. gotoStep8: function () {
  262. this.gotoStep(8);
  263. },
  264. gotoStep9: function () {
  265. this.gotoStep(9);
  266. },
  267. gotoStep10: function () {
  268. this.gotoStep(10);
  269. },
  270. /**
  271. * Initialize host status info for step9
  272. */
  273. setInfoForStep9: function () {
  274. var hostInfo = this.getDBProperty('hosts');
  275. for (var index in hostInfo) {
  276. hostInfo[index].status = "pending";
  277. hostInfo[index].message = 'Waiting';
  278. hostInfo[index].logTasks = [];
  279. hostInfo[index].tasks = [];
  280. hostInfo[index].progress = '0';
  281. }
  282. this.setDBProperty('hosts', hostInfo);
  283. },
  284. /**
  285. * Remove all data for installOptions step
  286. */
  287. clearInstallOptions: function () {
  288. var installOptions = this.getInstallOptions();
  289. this.set('content.installOptions', installOptions);
  290. this.set('content.hosts', {});
  291. this.setDBProperties({
  292. installOptions: installOptions,
  293. hosts: {}
  294. });
  295. },
  296. toObject: function (object) {
  297. var result = {};
  298. for (var i in object) {
  299. if (object.hasOwnProperty(i)) {
  300. result[i] = object[i];
  301. }
  302. }
  303. return result;
  304. },
  305. /**
  306. * Convert any object or array to pure JS instance without inherit properties
  307. * It is used to convert Ember.Object to pure JS Object and Ember.Array to pure JS Array
  308. * @param originalInstance
  309. * @returns {*}
  310. */
  311. toJSInstance: function (originalInstance) {
  312. var convertedInstance = originalInstance;
  313. if (Em.isArray(originalInstance)) {
  314. convertedInstance = [];
  315. originalInstance.forEach(function (element) {
  316. convertedInstance.push(this.toJSInstance(element));
  317. }, this)
  318. } else if (originalInstance && typeof originalInstance === 'object') {
  319. convertedInstance = {};
  320. for (var property in originalInstance) {
  321. if (originalInstance.hasOwnProperty(property)) {
  322. convertedInstance[property] = this.toJSInstance(originalInstance[property]);
  323. }
  324. }
  325. }
  326. return convertedInstance
  327. },
  328. /**
  329. * save status of the cluster. This is called from step8 and step9 to persist install and start requestId
  330. * @param clusterStatus object with status, isCompleted, requestId, isInstallError and isStartError field.
  331. */
  332. saveClusterStatus: function (clusterStatus) {
  333. var oldStatus = this.toObject(this.get('content.cluster'));
  334. clusterStatus = jQuery.extend(oldStatus, clusterStatus);
  335. if (clusterStatus.requestId &&
  336. clusterStatus.oldRequestsId.indexOf(clusterStatus.requestId) === -1) {
  337. clusterStatus.oldRequestsId.push(clusterStatus.requestId);
  338. }
  339. this.set('content.cluster', clusterStatus);
  340. this.setDBProperty('cluster', clusterStatus);
  341. },
  342. /**
  343. * Invoke installation of selected services to the server and saves the request id returned by the server.
  344. * @param isRetry
  345. */
  346. installServices: function (isRetry, callback) {
  347. // clear requests since we are installing services
  348. // and we don't want to get tasks for previous install attempts
  349. this.set('content.cluster.oldRequestsId', []);
  350. var data;
  351. callback = callback || Em.K;
  352. if (isRetry) {
  353. data = {
  354. context: Em.I18n.t('requestInfo.installComponents'),
  355. HostRoles: {"state": "INSTALLED"},
  356. urlParams: "HostRoles/desired_state=INSTALLED"
  357. };
  358. } else {
  359. data = {
  360. context: Em.I18n.t('requestInfo.installServices'),
  361. ServiceInfo: {"state": "INSTALLED"},
  362. urlParams: "ServiceInfo/state=INIT"
  363. };
  364. }
  365. var clusterStatus = {
  366. status: 'PENDING'
  367. };
  368. this.saveClusterStatus(clusterStatus);
  369. App.ajax.send({
  370. name: isRetry ? 'common.host_components.update' : 'common.services.update',
  371. sender: this,
  372. data: data,
  373. success: 'installServicesSuccessCallback',
  374. error: 'installServicesErrorCallback'
  375. }).then(callback, callback);
  376. },
  377. installServicesSuccessCallback: function (jsonData) {
  378. var installStartTime = App.dateTime();
  379. console.log("TRACE: In success function for the installService call");
  380. if (jsonData) {
  381. var requestId = jsonData.Requests.id;
  382. console.log('requestId is: ' + requestId);
  383. var clusterStatus = {
  384. status: 'PENDING',
  385. requestId: requestId,
  386. isInstallError: false,
  387. isCompleted: false,
  388. installStartTime: installStartTime
  389. };
  390. this.saveClusterStatus(clusterStatus);
  391. } else {
  392. console.log('ERROR: Error occurred in parsing JSON data');
  393. }
  394. },
  395. installServicesErrorCallback: function (request, ajaxOptions, error) {
  396. console.log("TRACE: In error function for the installService call");
  397. console.log("TRACE: error code status is: " + request.status);
  398. console.log('Error message is: ' + request.responseText);
  399. var clusterStatus = {
  400. status: 'PENDING',
  401. requestId: this.get('content.cluster.requestId'),
  402. isInstallError: true,
  403. isCompleted: false
  404. };
  405. this.saveClusterStatus(clusterStatus);
  406. App.showAlertPopup(Em.I18n.t('common.errorPopup.header'), request.responseText);
  407. },
  408. /**
  409. * show popup, that display status of bootstrap launching
  410. * @param callback
  411. * @return {Object}
  412. */
  413. showLaunchBootstrapPopup: function (callback) {
  414. return App.ModalPopup.show({
  415. header: Em.I18n.t('installer.step2.bootStrap.header'),
  416. isError: false,
  417. serverError: null,
  418. bodyClass: Em.View.extend({
  419. templateName: require('templates/wizard/bootstrap_call_popup')
  420. }),
  421. showFooter: false,
  422. showCloseButton: false,
  423. secondary: null,
  424. /**
  425. * handle requestId when call is completed,
  426. * if it's correct call callback and hide popup
  427. * otherwise notify error and enable buttons to close popup
  428. * @param requestId
  429. * @param serverError
  430. * @param status
  431. * @param log
  432. */
  433. finishLoading: function (requestId, serverError, status, log) {
  434. if (Em.isNone(requestId) || status == 'ERROR') {
  435. var stepController = App.get('router.wizardStep3Controller');
  436. this.setProperties({
  437. isError: true,
  438. showFooter: true,
  439. showCloseButton: true,
  440. serverError: status == 'ERROR' ? log : serverError
  441. });
  442. stepController.setProperties({
  443. isRegistrationInProgress: false,
  444. isBootstrapFailed: true
  445. });
  446. stepController.get('hosts').setEach('bootStatus', 'FAILED');
  447. } else {
  448. callback(requestId);
  449. this.hide();
  450. }
  451. }
  452. });
  453. },
  454. /**
  455. * Bootstrap selected hosts.
  456. * @param bootStrapData
  457. * @param callback
  458. * @return {Object}
  459. */
  460. launchBootstrap: function (bootStrapData, callback) {
  461. var popup = this.showLaunchBootstrapPopup(callback);
  462. App.ajax.send({
  463. name: 'wizard.launch_bootstrap',
  464. sender: this,
  465. data: {
  466. bootStrapData: bootStrapData,
  467. popup: popup
  468. },
  469. success: 'launchBootstrapSuccessCallback',
  470. error: 'launchBootstrapErrorCallback'
  471. });
  472. return popup;
  473. },
  474. launchBootstrapSuccessCallback: function (data, opt, params) {
  475. console.log("TRACE: POST bootstrap succeeded");
  476. params.popup.finishLoading(data.requestId, null, data.status, data.log);
  477. },
  478. launchBootstrapErrorCallback: function (request, ajaxOptions, error, opt, params) {
  479. console.log("ERROR: POST bootstrap failed");
  480. params.popup.finishLoading(null, error);
  481. },
  482. /**
  483. * Load <code>content.<name></code> variable from localStorage, if wasn't loaded before.
  484. * If you specify <code>reload</code> to true - it will reload it.
  485. * @param name
  486. * @param reload
  487. * @return {Boolean}
  488. */
  489. load: function (name, reload) {
  490. if (this.get('content.' + name) && !reload) {
  491. return false;
  492. }
  493. var result = this.getDBProperty(name);
  494. if (!result) {
  495. if (this['get' + name.capitalize()]) {
  496. result = this['get' + name.capitalize()]();
  497. this.setDBProperty(name, result);
  498. console.log(this.get('name') + ": created " + name, result);
  499. }
  500. else {
  501. console.debug('get' + name.capitalize(), ' not defined in the ' + this.get('name'));
  502. }
  503. }
  504. this.set('content.' + name, result);
  505. console.log(this.get('name') + ": loaded " + name, result);
  506. },
  507. save: function (name) {
  508. var convertedValue = this.toJSInstance(this.get('content.' + name));
  509. this.setDBProperty(name, convertedValue);
  510. console.log(this.get('name') + ": saved " + name, convertedValue);
  511. },
  512. clear: function () {
  513. this.set('content', Ember.Object.create({
  514. 'controllerName': this.get('content.controllerName')
  515. }));
  516. this.set('currentStep', 0);
  517. this.clearStorageData();
  518. },
  519. clusterStatusTemplate: {
  520. name: "",
  521. status: "PENDING",
  522. isCompleted: false,
  523. requestId: null,
  524. installStartTime: null,
  525. installTime: null,
  526. isInstallError: false,
  527. isStartError: false,
  528. oldRequestsId: []
  529. },
  530. clearStorageData: function () {
  531. var hash = {};
  532. this.get('dbPropertiesToClean').forEach(function (key) {
  533. hash[key] = undefined;
  534. }, this);
  535. this.setDBProperties(hash);
  536. },
  537. getInstallOptions: function() {
  538. return jQuery.extend({}, App.get('isHadoopWindowsStack') ? this.get('installWindowsOptionsTemplate') : this.get('installOptionsTemplate'));
  539. },
  540. installOptionsTemplate: {
  541. hostNames: "", //string
  542. manualInstall: false, //true, false
  543. useSsh: true, //bool
  544. javaHome: App.defaultJavaHome, //string
  545. localRepo: false, //true, false
  546. sshKey: "", //string
  547. bootRequestId: null, //string
  548. sshUser: "root", //string
  549. agentUser: "root" //string
  550. },
  551. installWindowsOptionsTemplate: {
  552. hostNames: "", //string
  553. manualInstall: false, //true, false
  554. useSsh: true, //bool
  555. javaHome: App.defaultJavaHome, //string
  556. localRepo: false, //true, false
  557. sshKey: "", //string
  558. bootRequestId: null, //string
  559. sshUser: "", //string
  560. agentUser: "" //string
  561. },
  562. loadedServiceComponents: null,
  563. /**
  564. * Generate serviceComponents as pr the stack definition and save it to localdata
  565. * called form stepController step4WizardController
  566. */
  567. loadServiceComponents: function () {
  568. return App.ajax.send({
  569. name: 'wizard.service_components',
  570. sender: this,
  571. data: {
  572. stackUrl: App.get('stackVersionURL'),
  573. stackVersion: App.get('currentStackVersionNumber')
  574. },
  575. success: 'loadServiceComponentsSuccessCallback',
  576. error: 'loadServiceComponentsErrorCallback'
  577. });
  578. },
  579. loadServiceComponentsSuccessCallback: function (jsonData) {
  580. var props = this.getDBProperties(['selectedServiceNames', 'installedServiceNames']);
  581. var savedSelectedServices = props.selectedServiceNames;
  582. var savedInstalledServices = props.installedServiceNames;
  583. this.set('content.selectedServiceNames', savedSelectedServices);
  584. this.set('content.installedServiceNames', savedInstalledServices);
  585. if (!savedSelectedServices) {
  586. jsonData.items.forEach(function (service) {
  587. service.StackServices.is_selected = true;
  588. }, this);
  589. } else {
  590. jsonData.items.forEach(function (service) {
  591. if (savedSelectedServices.contains(service.StackServices.service_name))
  592. service.StackServices.is_selected = true;
  593. else
  594. service.StackServices.is_selected = false;
  595. }, this);
  596. }
  597. if (!savedInstalledServices) {
  598. jsonData.items.forEach(function (service) {
  599. service.StackServices.is_installed = false;
  600. }, this);
  601. } else {
  602. jsonData.items.forEach(function (service) {
  603. if (savedInstalledServices.contains(service.StackServices.service_name))
  604. service.StackServices.is_installed = true;
  605. else
  606. service.StackServices.is_installed = false;
  607. }, this);
  608. }
  609. App.stackServiceMapper.mapStackServices(jsonData);
  610. },
  611. loadServiceComponentsErrorCallback: function (request, ajaxOptions, error) {
  612. console.log("TRACE: STep5 -> In error function for the getServiceComponents call");
  613. console.log("TRACE: STep5 -> error code status is: " + request.status);
  614. console.log('Step8: Error message is: ' + request.responseText);
  615. },
  616. /**
  617. * Load config groups from local DB
  618. */
  619. loadServiceConfigGroups: function () {
  620. var props = this.getDBProperties(['serviceConfigGroups', 'hosts']);
  621. var serviceConfigGroups = props.serviceConfigGroups,
  622. hosts = props.hosts || {},
  623. host_names = Em.keys(hosts);
  624. if (Em.isNone(serviceConfigGroups)) {
  625. serviceConfigGroups = [];
  626. }
  627. else {
  628. serviceConfigGroups.forEach(function(group) {
  629. var hostNames = group.hosts.map(function(host_id) {
  630. for (var i = 0; i < host_names.length; i++) {
  631. if (hosts[host_names[i]].id === host_id) {
  632. return host_names[i];
  633. }
  634. }
  635. Em.assert('host is missing!!!!', false);
  636. });
  637. Em.set(group, 'hosts', hostNames);
  638. });
  639. }
  640. this.set('content.configGroups', serviceConfigGroups);
  641. console.log("InstallerController.configGroups: loaded config ", serviceConfigGroups);
  642. },
  643. registerErrPopup: function (header, message) {
  644. App.ModalPopup.show({
  645. header: header,
  646. secondary: false,
  647. bodyClass: Ember.View.extend({
  648. template: Ember.Handlebars.compile('<p>{{view.message}}</p>'),
  649. message: message
  650. })
  651. });
  652. },
  653. /**
  654. * Save hosts that the user confirmed to proceed with from step 3
  655. * @param stepController App.WizardStep3Controller
  656. */
  657. saveConfirmedHosts: function (stepController) {
  658. var hosts = this.get('content.hosts'),
  659. indx = 1;
  660. //add previously installed hosts
  661. for (var hostName in hosts) {
  662. if (!hosts[hostName].isInstalled) {
  663. delete hosts[hostName];
  664. }
  665. }
  666. stepController.get('confirmedHosts').forEach(function (_host) {
  667. if (_host.bootStatus == 'REGISTERED') {
  668. hosts[_host.name] = {
  669. name: _host.name,
  670. cpu: _host.cpu,
  671. memory: _host.memory,
  672. disk_info: _host.disk_info,
  673. os_type: _host.os_type,
  674. os_arch: _host.os_arch,
  675. ip: _host.ip,
  676. bootStatus: _host.bootStatus,
  677. isInstalled: false,
  678. id: indx++
  679. };
  680. }
  681. });
  682. console.log('wizardController:saveConfirmedHosts: save hosts ', hosts);
  683. this.setDBProperty('hosts', hosts);
  684. this.set('content.hosts', hosts);
  685. },
  686. /**
  687. * Save data after installation to main controller
  688. * @param stepController App.WizardStep9Controller
  689. */
  690. saveInstalledHosts: function (stepController) {
  691. var hosts = stepController.get('hosts');
  692. var hostInfo = this.getDBProperty('hosts');
  693. for (var index in hostInfo) {
  694. hostInfo[index].status = "pending";
  695. var host = hosts.findProperty('name', hostInfo[index].name);
  696. if (host) {
  697. hostInfo[index].status = host.status;
  698. hostInfo[index].message = host.message;
  699. hostInfo[index].progress = host.progress;
  700. }
  701. }
  702. this.set('content.hosts', hostInfo);
  703. this.setDBProperty('hosts', hostInfo);
  704. console.log('wizardController:saveInstalledHosts: save hosts ', hostInfo);
  705. },
  706. /**
  707. * Save slaveHostComponents to main controller
  708. * @param stepController
  709. */
  710. saveSlaveComponentHosts: function (stepController) {
  711. var hosts = stepController.get('hosts'),
  712. dbHosts = this.getDBProperty('hosts'),
  713. headers = stepController.get('headers');
  714. var formattedHosts = Ember.Object.create();
  715. headers.forEach(function (header) {
  716. formattedHosts.set(header.get('name'), []);
  717. });
  718. hosts.forEach(function (host) {
  719. var checkboxes = host.checkboxes;
  720. headers.forEach(function (header) {
  721. var cb = checkboxes.findProperty('title', header.get('label'));
  722. if (cb.checked) {
  723. formattedHosts.get(header.get('name')).push({
  724. group: 'Default',
  725. isInstalled: cb.isInstalled,
  726. host_id: dbHosts[host.hostName].id
  727. });
  728. }
  729. });
  730. });
  731. var slaveComponentHosts = [];
  732. headers.forEach(function (header) {
  733. slaveComponentHosts.push({
  734. componentName: header.get('name'),
  735. displayName: header.get('label').replace(/\s/g, ''),
  736. hosts: formattedHosts.get(header.get('name'))
  737. });
  738. });
  739. this.setDBProperty('slaveComponentHosts', slaveComponentHosts);
  740. console.log('wizardController.slaveComponentHosts: saved hosts', slaveComponentHosts);
  741. this.set('content.slaveComponentHosts', slaveComponentHosts);
  742. },
  743. /**
  744. * Return true if cluster data is loaded and false otherwise.
  745. * This is used for all wizard controllers except for installer wizard.
  746. */
  747. dataLoading: function () {
  748. var dfd = $.Deferred();
  749. this.connectOutlet('loading');
  750. if (App.router.get('clusterController.isLoaded')) {
  751. dfd.resolve();
  752. } else {
  753. var interval = setInterval(function () {
  754. if (App.router.get('clusterController.isLoaded')) {
  755. dfd.resolve();
  756. clearInterval(interval);
  757. }
  758. }, 50);
  759. }
  760. return dfd.promise();
  761. },
  762. /**
  763. * Return true if user data is loaded via App.MainServiceInfoConfigsController
  764. * This function is used in reassign master wizard right now.
  765. */
  766. usersLoading: function () {
  767. var self = this;
  768. var dfd = $.Deferred();
  769. var miscController = App.MainAdminServiceAccountsController.create({content: self.get('content')});
  770. miscController.loadUsers();
  771. var interval = setInterval(function () {
  772. if (miscController.get('dataIsLoaded')) {
  773. if (self.get("content.hdfsUser")) {
  774. self.set('content.hdfsUser', miscController.get('content.hdfsUser'));
  775. }
  776. dfd.resolve();
  777. clearInterval(interval);
  778. }
  779. }, 10);
  780. return dfd.promise();
  781. },
  782. /**
  783. * Save cluster status before going to deploy step
  784. * @param name cluster state. Unique for every wizard
  785. */
  786. saveClusterState: function (name) {
  787. App.clusterStatus.setClusterStatus({
  788. clusterName: this.get('content.cluster.name'),
  789. clusterState: name,
  790. wizardControllerName: this.get('content.controllerName'),
  791. localdb: App.db.data
  792. });
  793. },
  794. /**
  795. * Load serviceConfigProperties to model
  796. */
  797. loadServiceConfigProperties: function () {
  798. var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
  799. this.set('content.serviceConfigProperties', serviceConfigProperties);
  800. console.log("AddHostController.loadServiceConfigProperties: loaded config ", serviceConfigProperties);
  801. },
  802. /**
  803. * Save config properties
  804. * @param stepController Step7WizardController
  805. */
  806. saveServiceConfigProperties: function (stepController) {
  807. var serviceConfigProperties = [];
  808. var fileNamesToUpdate = this.getDBProperty('fileNamesToUpdate') || [];
  809. var installedServiceNames = stepController.get('installedServiceNames') || [];
  810. var installedServiceNamesMap = {};
  811. var notAllowed = ['masterHost', 'masterHosts', 'slaveHosts', 'slaveHost'];
  812. installedServiceNames.forEach(function(name) {
  813. installedServiceNamesMap[name] = true;
  814. });
  815. stepController.get('stepConfigs').forEach(function (_content) {
  816. if (_content.serviceName === 'YARN') {
  817. _content.set('configs', App.config.textareaIntoFileConfigs(_content.get('configs'), 'capacity-scheduler.xml'));
  818. }
  819. _content.get('configs').forEach(function (_configProperties) {
  820. var configProperty = App.config.createDefaultConfig(
  821. _configProperties.get('name'),
  822. _configProperties.get('serviceName'),
  823. _configProperties.get('filename'),
  824. _configProperties.get('isUserProperty'),
  825. {value: _configProperties.get('value')}
  826. );
  827. configProperty = App.config.mergeStaticProperties(configProperty, _configProperties, ['name', 'filename']);
  828. if (this.isExcludedConfig(configProperty)) {
  829. configProperty.value = '';
  830. }
  831. serviceConfigProperties.push(configProperty);
  832. }, this);
  833. // check for configs that need to update for installed services
  834. if (installedServiceNamesMap[_content.get('serviceName')]) {
  835. // get only modified configs
  836. var configs = _content.get('configs').filter(function (config) {
  837. if (config.get('isNotDefaultValue') || (config.get('savedValue') === null)) {
  838. return !notAllowed.contains(config.get('displayType')) && !!config.filename && config.isRequiredByAgent!== false;
  839. }
  840. return false;
  841. });
  842. // if modified configs detected push all service's configs for update
  843. if (configs.length) {
  844. fileNamesToUpdate = fileNamesToUpdate.concat(configs.mapProperty('filename').uniq());
  845. }
  846. }
  847. }, this);
  848. this.setDBProperties({
  849. fileNamesToUpdate: fileNamesToUpdate,
  850. serviceConfigProperties: serviceConfigProperties
  851. });
  852. this.set('content.serviceConfigProperties', serviceConfigProperties);
  853. },
  854. isExcludedConfig: function (configProperty) {
  855. return this.get('sensibleConfigs').mapProperty('name').indexOf(configProperty.name) > -1
  856. && this.get('sensibleConfigs').mapProperty('filename').indexOf(configProperty.filename) > -1;
  857. },
  858. /**
  859. * save Config groups
  860. * @param stepController
  861. * @param isAddService
  862. */
  863. saveServiceConfigGroups: function (stepController, isAddService) {
  864. var serviceConfigGroups = [],
  865. isForInstalledService = false,
  866. hosts = isAddService ? App.router.get('addServiceController').getDBProperty('hosts') : this.getDBProperty('hosts');
  867. stepController.get('stepConfigs').forEach(function (service) {
  868. // mark group of installed service
  869. if (service.get('selected') === false) isForInstalledService = true;
  870. service.get('configGroups').forEach(function (configGroup) {
  871. var properties = [];
  872. configGroup.get('properties').forEach(function (property) {
  873. properties.push({
  874. isRequiredByAgent: property.get('isRequiredByAgent'),
  875. name: property.get('name'),
  876. value: property.get('value'),
  877. isFinal: property.get('isFinal'),
  878. filename: property.get('filename')
  879. })
  880. });
  881. //configGroup copied into plain JS object to avoid Converting circular structure to JSON
  882. var hostNames = configGroup.get('hosts').map(function(host_name) {return hosts[host_name].id;});
  883. serviceConfigGroups.push({
  884. id: configGroup.get('id'),
  885. name: configGroup.get('name'),
  886. description: configGroup.get('description'),
  887. hosts: hostNames.slice(),
  888. properties: properties.slice(),
  889. is_default: configGroup.get('isDefault'),
  890. is_for_installed_service: isForInstalledService,
  891. is_for_update: configGroup.isForUpdate || configGroup.get('hash') != this.getConfigGroupHash(configGroup, hostNames),
  892. service_name: configGroup.get('serviceName'),
  893. service_id: configGroup.get('serviceName'),
  894. desired_configs: configGroup.get('desiredConfigs'),
  895. config_group_id: configGroup.get('configGroupId'),
  896. child_config_groups: configGroup.get('childConfigGroups') ? configGroup.get('childConfigGroups').mapProperty('id') : [],
  897. parent_config_group_id: configGroup.get('parentConfigGroup.id')
  898. });
  899. }, this)
  900. }, this);
  901. this.setDBProperty('serviceConfigGroups', serviceConfigGroups);
  902. this.set('content.configGroups', serviceConfigGroups);
  903. },
  904. /**
  905. * generate string hash for config group
  906. * @param {Object} configGroup
  907. * @param {Array|undefined} hosts
  908. * @returns {String|null}
  909. * @method getConfigGroupHash
  910. */
  911. getConfigGroupHash: function(configGroup, hosts) {
  912. if (!Em.get(configGroup, 'properties.length') && !Em.get(configGroup, 'hosts.length') && !hosts) {
  913. return null;
  914. }
  915. var hash = {};
  916. Em.get(configGroup, 'properties').forEach(function (config) {
  917. hash[Em.get(config, 'name')] = {value: Em.get(config, 'value'), isFinal: Em.get(config, 'isFinal')};
  918. });
  919. hash['hosts'] = hosts || Em.get(configGroup, 'hosts');
  920. return JSON.stringify(hash);
  921. },
  922. /**
  923. * return slaveComponents bound to hosts
  924. * @return {Array}
  925. */
  926. getSlaveComponentHosts: function () {
  927. var components = this.get('slaveComponents');
  928. var result = [];
  929. var installedServices = App.Service.find().mapProperty('serviceName');
  930. var selectedServices = App.StackService.find().filterProperty('isSelected', true).mapProperty('serviceName');
  931. var installedComponentsMap = {};
  932. var uninstalledComponents = [];
  933. components.forEach(function (component) {
  934. if (installedServices.contains(component.get('serviceName'))) {
  935. installedComponentsMap[component.get('componentName')] = [];
  936. } else if (selectedServices.contains(component.get('serviceName'))) {
  937. uninstalledComponents.push(component);
  938. }
  939. }, this);
  940. installedComponentsMap['HDFS_CLIENT'] = [];
  941. App.HostComponent.find().forEach(function (hostComponent) {
  942. if (installedComponentsMap[hostComponent.get('componentName')]) {
  943. installedComponentsMap[hostComponent.get('componentName')].push(hostComponent.get('hostName'));
  944. }
  945. }, this);
  946. for (var componentName in installedComponentsMap) {
  947. var name = (componentName === 'HDFS_CLIENT') ? 'CLIENT' : componentName;
  948. var component = {
  949. componentName: name,
  950. displayName: App.format.role(name),
  951. hosts: [],
  952. isInstalled: true
  953. };
  954. installedComponentsMap[componentName].forEach(function (hostName) {
  955. component.hosts.push({
  956. group: "Default",
  957. hostName: hostName,
  958. isInstalled: true
  959. });
  960. }, this);
  961. result.push(component);
  962. }
  963. uninstalledComponents.forEach(function (component) {
  964. var hosts = jQuery.extend(true, [], result.findProperty('componentName', 'DATANODE').hosts);
  965. hosts.setEach('isInstalled', false);
  966. result.push({
  967. componentName: component.get('componentName'),
  968. displayName: App.format.role(component.get('componentName')),
  969. hosts: hosts,
  970. isInstalled: false
  971. })
  972. });
  973. return result;
  974. },
  975. /**
  976. * Load master component hosts data for using in required step controllers
  977. */
  978. loadMasterComponentHosts: function () {
  979. var masterComponentHosts = this.getDBProperty('masterComponentHosts');
  980. var stackMasterComponents = App.get('components.masters').uniq();
  981. if (!masterComponentHosts) {
  982. masterComponentHosts = [];
  983. App.HostComponent.find().filter(function(component) {
  984. return stackMasterComponents.contains(component.get('componentName'));
  985. }).forEach(function (item) {
  986. masterComponentHosts.push({
  987. component: item.get('componentName'),
  988. hostName: item.get('hostName'),
  989. isInstalled: true,
  990. serviceId: item.get('service.id'),
  991. display_name: item.get('displayName')
  992. })
  993. });
  994. this.setDBProperty('masterComponentHosts', masterComponentHosts);
  995. }
  996. this.set("content.masterComponentHosts", masterComponentHosts);
  997. },
  998. /**
  999. * Save Master Component Hosts data to Main Controller
  1000. * @param stepController App.WizardStep5Controller
  1001. */
  1002. saveMasterComponentHosts: function (stepController) {
  1003. var obj = stepController.get('selectedServicesMasters');
  1004. var masterComponentHosts = [];
  1005. obj.forEach(function (_component) {
  1006. masterComponentHosts.push({
  1007. display_name: _component.get('display_name'),
  1008. component: _component.get('component_name'),
  1009. hostName: _component.get('selectedHost'),
  1010. serviceId: _component.get('serviceId'),
  1011. isInstalled: _component.get('isInstalled')
  1012. });
  1013. });
  1014. this.setDBProperty('masterComponentHosts', masterComponentHosts);
  1015. this.set('content.masterComponentHosts', masterComponentHosts);
  1016. },
  1017. clearMasterComponentHosts: function() {
  1018. this.set('content.masterComponentHosts', null);
  1019. this.setDBProperty('masterComponentHosts', null);
  1020. },
  1021. /**
  1022. * Load information about hosts with clients components
  1023. */
  1024. loadClients: function () {
  1025. var clients = this.getDBProperty('clientInfo');
  1026. this.set('content.clients', clients);
  1027. console.log(this.get('content.controllerName') + ".loadClients: loaded list ", clients);
  1028. },
  1029. /**
  1030. * load methods assigned to each step
  1031. * methods executed in exact order as they described in map
  1032. * @return {object}
  1033. */
  1034. loadAllPriorSteps: function () {
  1035. var currentStep = this.get('currentStep');
  1036. var loadMap = this.get('loadMap');
  1037. var operationStack = [];
  1038. var dfd = $.Deferred();
  1039. for (var s in loadMap) {
  1040. if (parseInt(s) <= parseInt(currentStep)) {
  1041. operationStack.pushObjects(loadMap[s]);
  1042. }
  1043. }
  1044. var sequence = App.actionSequence.create({context: this});
  1045. sequence.setSequence(operationStack).onFinish(function () {
  1046. dfd.resolve();
  1047. }).start();
  1048. return dfd.promise();
  1049. },
  1050. /**
  1051. * return new object extended from clusterStatusTemplate
  1052. * @return Object
  1053. */
  1054. getCluster: function () {
  1055. return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
  1056. },
  1057. /**
  1058. * Load services data from server.
  1059. */
  1060. loadServicesFromServer: function () {
  1061. var services = this.getDBProperty('services');
  1062. if (!services) {
  1063. services = {
  1064. selectedServices: [],
  1065. installedServices: []
  1066. };
  1067. App.StackService.find().forEach(function(item){
  1068. var isInstalled = App.Service.find().someProperty('id', item.get('serviceName'));
  1069. item.set('isSelected', isInstalled);
  1070. item.set('isInstalled', isInstalled);
  1071. if (isInstalled) {
  1072. services.selectedServices.push(item.get('serviceName'));
  1073. services.installedServices.push(item.get('serviceName'));
  1074. }
  1075. },this);
  1076. this.setDBProperty('services',services);
  1077. } else {
  1078. App.StackService.find().forEach(function(item) {
  1079. var isSelected = services.selectedServices.contains(item.get('serviceName'));
  1080. var isInstalled = services.installedServices.contains(item.get('serviceName'));
  1081. item.set('isSelected', isSelected);
  1082. item.set('isInstalled', isInstalled);
  1083. },this);
  1084. }
  1085. this.set('content.services', App.StackService.find());
  1086. },
  1087. /**
  1088. * Load confirmed hosts.
  1089. * Will be used at <code>Assign Masters(step5)</code> step
  1090. */
  1091. loadConfirmedHosts: function () {
  1092. var hosts = App.db.getHosts();
  1093. if (hosts) {
  1094. this.set('content.hosts', hosts);
  1095. }
  1096. },
  1097. loadHosts: function () {
  1098. var dfd;
  1099. var hostsInDb = this.getDBProperty('hosts');
  1100. if (hostsInDb) {
  1101. this.set('content.hosts', hostsInDb);
  1102. dfd = $.Deferred();
  1103. dfd.resolve();
  1104. } else {
  1105. dfd = App.ajax.send({
  1106. name: 'hosts.confirmed',
  1107. sender: this,
  1108. data: {},
  1109. success: 'loadHostsSuccessCallback',
  1110. error: 'loadHostsErrorCallback'
  1111. });
  1112. }
  1113. return dfd.promise();
  1114. },
  1115. loadHostsSuccessCallback: function (response) {
  1116. var installedHosts = {};
  1117. response.items.forEach(function (item, indx) {
  1118. installedHosts[item.Hosts.host_name] = {
  1119. name: item.Hosts.host_name,
  1120. cpu: item.Hosts.cpu_count,
  1121. memory: item.Hosts.total_mem,
  1122. disk_info: item.Hosts.disk_info,
  1123. osType: item.Hosts.os_type,
  1124. osArch: item.Hosts.os_arch,
  1125. ip: item.Hosts.ip,
  1126. bootStatus: "REGISTERED",
  1127. isInstalled: true,
  1128. hostComponents: item.host_components,
  1129. id: indx++
  1130. };
  1131. });
  1132. this.setDBProperty('hosts', installedHosts);
  1133. this.set('content.hosts', installedHosts);
  1134. },
  1135. loadHostsErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
  1136. App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
  1137. console.log('Loading hosts failed');
  1138. },
  1139. /**
  1140. * Determine if <code>Assign Slaves and Clients</code> step should be skipped
  1141. * @method setSkipSlavesStep
  1142. * @param services
  1143. * @param step
  1144. */
  1145. setSkipSlavesStep: function (services, step) {
  1146. var hasServicesWithSlave = services.someProperty('hasSlave');
  1147. var hasServicesWithClient = services.someProperty('hasClient');
  1148. var hasServicesWithCustomAssignedNonMasters = services.someProperty('hasNonMastersWithCustomAssignment');
  1149. this.set('content.skipSlavesStep', !hasServicesWithSlave && !hasServicesWithClient || !hasServicesWithCustomAssignedNonMasters);
  1150. if (this.get('content.skipSlavesStep')) {
  1151. this.get('isStepDisabled').findProperty('step', step).set('value', this.get('content.skipSlavesStep'));
  1152. }
  1153. },
  1154. /**
  1155. * Load config themes for enhanced config layout.
  1156. *
  1157. * @method loadConfigThemes
  1158. * @return {$.Deferred}
  1159. */
  1160. loadConfigThemes: function () {
  1161. var self = this;
  1162. var dfd = $.Deferred();
  1163. if (!this.get('stackConfigsLoaded')) {
  1164. var serviceNames = App.StackService.find().filter(function (s) {
  1165. return s.get('isSelected') || s.get('isInstalled');
  1166. }).mapProperty('serviceName');
  1167. // Load stack configs before loading themes
  1168. App.config.loadClusterConfigsFromStack().always(function() {
  1169. App.config.loadConfigsFromStack(serviceNames).done(function () {
  1170. if (App.get('isClusterSupportsEnhancedConfigs')) {
  1171. self.loadConfigThemeForServices(serviceNames).always(function () {
  1172. self.set('stackConfigsLoaded', true);
  1173. App.themesMapper.generateAdvancedTabs(serviceNames);
  1174. dfd.resolve();
  1175. });
  1176. } else {
  1177. self.set('stackConfigsLoaded', true);
  1178. dfd.resolve();
  1179. }
  1180. });
  1181. });
  1182. }
  1183. else {
  1184. dfd.resolve();
  1185. this.set('stackConfigsLoaded', true);
  1186. }
  1187. return dfd.promise();
  1188. },
  1189. /**
  1190. * Cache "stepConfigs" to local storage in name value pairs
  1191. * @param stepController
  1192. */
  1193. cacheStepConfigValues: function(stepController) {
  1194. var self = this;
  1195. var stepConfigs = [];
  1196. stepController.get("stepConfigs").forEach(function (category) {
  1197. var configs = category.configs.map(function(config) {
  1198. if (self.isExcludedConfig(config)) {
  1199. config.set('value', '');
  1200. }
  1201. return {
  1202. name: config.name,
  1203. filename: config.filename,
  1204. value: config.value
  1205. };
  1206. });
  1207. stepConfigs = stepConfigs.concat(configs);
  1208. });
  1209. if (stepConfigs.length > 0 ) {
  1210. this.setDBProperty(stepController.name + "-sc", stepConfigs);
  1211. }
  1212. },
  1213. loadCachedStepConfigValues: function(stepController) {
  1214. return this.getDBProperty(stepController.name + "-sc");
  1215. },
  1216. clearCachedStepConfigValues: function(stepController) {
  1217. this.setDBProperty(stepController.name + "-sc", null);
  1218. },
  1219. saveTasksStatuses: function (tasksStatuses) {
  1220. this.set('content.tasksStatuses', tasksStatuses);
  1221. this.setDBProperty('tasksStatuses', tasksStatuses);
  1222. },
  1223. loadTasksStatuses: function() {
  1224. var tasksStatuses = this.getDBProperty('tasksStatuses');
  1225. this.set('content.tasksStatuses', tasksStatuses);
  1226. },
  1227. saveTasksRequestIds: function (tasksRequestIds) {
  1228. this.set('content.tasksRequestIds', tasksRequestIds);
  1229. this.setDBProperty('tasksRequestIds', tasksRequestIds);
  1230. },
  1231. loadTasksRequestIds: function() {
  1232. var tasksRequestIds = this.getDBProperty('tasksRequestIds');
  1233. this.set('content.tasksRequestIds', tasksRequestIds);
  1234. },
  1235. saveRequestIds: function (requestIds) {
  1236. this.set('content.requestIds', requestIds);
  1237. this.setDBProperty('requestIds', requestIds);
  1238. },
  1239. loadRequestIds: function() {
  1240. var requestIds = this.getDBProperty('requestIds');
  1241. this.set('content.requestIds', requestIds);
  1242. },
  1243. loadRecommendations: function () {
  1244. this.set("content.recommendations", this.getDBProperty('recommendations'));
  1245. }
  1246. });