wizard.js 44 KB

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