wizard.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372
  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. installedServiceNames.forEach(function(name) {
  812. installedServiceNamesMap[name] = true;
  813. });
  814. stepController.get('stepConfigs').forEach(function (_content) {
  815. if (_content.serviceName === 'YARN') {
  816. _content.set('configs', App.config.textareaIntoFileConfigs(_content.get('configs'), 'capacity-scheduler.xml'));
  817. }
  818. _content.get('configs').forEach(function (_configProperties) {
  819. var configProperty = App.config.createDefaultConfig(
  820. _configProperties.get('name'),
  821. _configProperties.get('serviceName'),
  822. _configProperties.get('filename'),
  823. _configProperties.get('isUserProperty'),
  824. {value: _configProperties.get('value')}
  825. );
  826. configProperty = App.config.mergeStaticProperties(configProperty, _configProperties, ['name', 'filename']);
  827. if (this.isExcludedConfig(configProperty)) {
  828. configProperty.value = '';
  829. }
  830. serviceConfigProperties.push(configProperty);
  831. }, this);
  832. // check for configs that need to update for installed services
  833. if (installedServiceNamesMap[_content.get('serviceName')]) {
  834. // get only modified configs
  835. var configs = _content.get('configs').filter(function (config) {
  836. if (config.get('isNotDefaultValue') || (config.get('savedValue') === null)) {
  837. return config.isRequiredByAgent!== false;
  838. }
  839. return false;
  840. });
  841. // if modified configs detected push all service's configs for update
  842. if (configs.length) {
  843. fileNamesToUpdate = fileNamesToUpdate.concat(configs.mapProperty('filename').uniq());
  844. }
  845. }
  846. }, this);
  847. this.setDBProperties({
  848. fileNamesToUpdate: fileNamesToUpdate,
  849. serviceConfigProperties: serviceConfigProperties
  850. });
  851. this.set('content.serviceConfigProperties', serviceConfigProperties);
  852. },
  853. isExcludedConfig: function (configProperty) {
  854. return this.get('sensibleConfigs').mapProperty('name').indexOf(configProperty.name) > -1
  855. && this.get('sensibleConfigs').mapProperty('filename').indexOf(configProperty.filename) > -1;
  856. },
  857. /**
  858. * save Config groups
  859. * @param stepController
  860. * @param isAddService
  861. */
  862. saveServiceConfigGroups: function (stepController, isAddService) {
  863. var serviceConfigGroups = [],
  864. isForInstalledService = false,
  865. hosts = isAddService ? App.router.get('addServiceController').getDBProperty('hosts') : this.getDBProperty('hosts');
  866. stepController.get('stepConfigs').forEach(function (service) {
  867. // mark group of installed service
  868. if (service.get('selected') === false) isForInstalledService = true;
  869. service.get('configGroups').forEach(function (configGroup) {
  870. var properties = [];
  871. configGroup.get('properties').forEach(function (property) {
  872. properties.push({
  873. isRequiredByAgent: property.get('isRequiredByAgent'),
  874. name: property.get('name'),
  875. value: property.get('value'),
  876. isFinal: property.get('isFinal'),
  877. filename: property.get('filename')
  878. })
  879. });
  880. //configGroup copied into plain JS object to avoid Converting circular structure to JSON
  881. var hostNames = configGroup.get('hosts').map(function(host_name) {return hosts[host_name].id;});
  882. serviceConfigGroups.push({
  883. id: configGroup.get('id'),
  884. name: configGroup.get('name'),
  885. description: configGroup.get('description'),
  886. hosts: hostNames.slice(),
  887. properties: properties.slice(),
  888. is_default: configGroup.get('isDefault'),
  889. is_for_installed_service: isForInstalledService,
  890. is_for_update: configGroup.isForUpdate || configGroup.get('hash') != this.getConfigGroupHash(configGroup, hostNames),
  891. service_name: configGroup.get('serviceName'),
  892. service_id: configGroup.get('serviceName'),
  893. desired_configs: configGroup.get('desiredConfigs'),
  894. config_group_id: configGroup.get('configGroupId'),
  895. child_config_groups: configGroup.get('childConfigGroups') ? configGroup.get('childConfigGroups').mapProperty('id') : [],
  896. parent_config_group_id: configGroup.get('parentConfigGroup.id')
  897. });
  898. }, this)
  899. }, this);
  900. this.setDBProperty('serviceConfigGroups', serviceConfigGroups);
  901. this.set('content.configGroups', serviceConfigGroups);
  902. },
  903. /**
  904. * generate string hash for config group
  905. * @param {Object} configGroup
  906. * @param {Array|undefined} hosts
  907. * @returns {String|null}
  908. * @method getConfigGroupHash
  909. */
  910. getConfigGroupHash: function(configGroup, hosts) {
  911. if (!Em.get(configGroup, 'properties.length') && !Em.get(configGroup, 'hosts.length') && !hosts) {
  912. return null;
  913. }
  914. var hash = {};
  915. Em.get(configGroup, 'properties').forEach(function (config) {
  916. hash[Em.get(config, 'name')] = {value: Em.get(config, 'value'), isFinal: Em.get(config, 'isFinal')};
  917. });
  918. hash['hosts'] = hosts || Em.get(configGroup, 'hosts');
  919. return JSON.stringify(hash);
  920. },
  921. /**
  922. * return slaveComponents bound to hosts
  923. * @return {Array}
  924. */
  925. getSlaveComponentHosts: function () {
  926. var components = this.get('slaveComponents');
  927. var result = [];
  928. var installedServices = App.Service.find().mapProperty('serviceName');
  929. var selectedServices = App.StackService.find().filterProperty('isSelected', true).mapProperty('serviceName');
  930. var installedComponentsMap = {};
  931. var uninstalledComponents = [];
  932. components.forEach(function (component) {
  933. if (installedServices.contains(component.get('serviceName'))) {
  934. installedComponentsMap[component.get('componentName')] = [];
  935. } else if (selectedServices.contains(component.get('serviceName'))) {
  936. uninstalledComponents.push(component);
  937. }
  938. }, this);
  939. installedComponentsMap['HDFS_CLIENT'] = [];
  940. App.HostComponent.find().forEach(function (hostComponent) {
  941. if (installedComponentsMap[hostComponent.get('componentName')]) {
  942. installedComponentsMap[hostComponent.get('componentName')].push(hostComponent.get('hostName'));
  943. }
  944. }, this);
  945. for (var componentName in installedComponentsMap) {
  946. var name = (componentName === 'HDFS_CLIENT') ? 'CLIENT' : componentName;
  947. var component = {
  948. componentName: name,
  949. displayName: App.format.role(name),
  950. hosts: [],
  951. isInstalled: true
  952. };
  953. installedComponentsMap[componentName].forEach(function (hostName) {
  954. component.hosts.push({
  955. group: "Default",
  956. hostName: hostName,
  957. isInstalled: true
  958. });
  959. }, this);
  960. result.push(component);
  961. }
  962. uninstalledComponents.forEach(function (component) {
  963. var hosts = jQuery.extend(true, [], result.findProperty('componentName', 'DATANODE').hosts);
  964. hosts.setEach('isInstalled', false);
  965. result.push({
  966. componentName: component.get('componentName'),
  967. displayName: App.format.role(component.get('componentName')),
  968. hosts: hosts,
  969. isInstalled: false
  970. })
  971. });
  972. return result;
  973. },
  974. /**
  975. * Load master component hosts data for using in required step controllers
  976. */
  977. loadMasterComponentHosts: function () {
  978. var masterComponentHosts = this.getDBProperty('masterComponentHosts');
  979. var stackMasterComponents = App.get('components.masters').uniq();
  980. if (!masterComponentHosts) {
  981. masterComponentHosts = [];
  982. App.HostComponent.find().filter(function(component) {
  983. return stackMasterComponents.contains(component.get('componentName'));
  984. }).forEach(function (item) {
  985. masterComponentHosts.push({
  986. component: item.get('componentName'),
  987. hostName: item.get('hostName'),
  988. isInstalled: true,
  989. serviceId: item.get('service.id'),
  990. display_name: item.get('displayName')
  991. })
  992. });
  993. this.setDBProperty('masterComponentHosts', masterComponentHosts);
  994. }
  995. this.set("content.masterComponentHosts", masterComponentHosts);
  996. },
  997. /**
  998. * Save Master Component Hosts data to Main Controller
  999. * @param stepController App.WizardStep5Controller
  1000. */
  1001. saveMasterComponentHosts: function (stepController) {
  1002. var obj = stepController.get('selectedServicesMasters');
  1003. var masterComponentHosts = [];
  1004. obj.forEach(function (_component) {
  1005. masterComponentHosts.push({
  1006. display_name: _component.get('display_name'),
  1007. component: _component.get('component_name'),
  1008. hostName: _component.get('selectedHost'),
  1009. serviceId: _component.get('serviceId'),
  1010. isInstalled: _component.get('isInstalled')
  1011. });
  1012. });
  1013. this.setDBProperty('masterComponentHosts', masterComponentHosts);
  1014. this.set('content.masterComponentHosts', masterComponentHosts);
  1015. },
  1016. clearMasterComponentHosts: function() {
  1017. this.set('content.masterComponentHosts', null);
  1018. this.setDBProperty('masterComponentHosts', null);
  1019. },
  1020. /**
  1021. * Load information about hosts with clients components
  1022. */
  1023. loadClients: function () {
  1024. var clients = this.getDBProperty('clientInfo');
  1025. this.set('content.clients', clients);
  1026. console.log(this.get('content.controllerName') + ".loadClients: loaded list ", clients);
  1027. },
  1028. /**
  1029. * load methods assigned to each step
  1030. * methods executed in exact order as they described in map
  1031. * @return {object}
  1032. */
  1033. loadAllPriorSteps: function () {
  1034. var currentStep = this.get('currentStep');
  1035. var loadMap = this.get('loadMap');
  1036. var operationStack = [];
  1037. var dfd = $.Deferred();
  1038. for (var s in loadMap) {
  1039. if (parseInt(s) <= parseInt(currentStep)) {
  1040. operationStack.pushObjects(loadMap[s]);
  1041. }
  1042. }
  1043. var sequence = App.actionSequence.create({context: this});
  1044. sequence.setSequence(operationStack).onFinish(function () {
  1045. dfd.resolve();
  1046. }).start();
  1047. return dfd.promise();
  1048. },
  1049. /**
  1050. * return new object extended from clusterStatusTemplate
  1051. * @return Object
  1052. */
  1053. getCluster: function () {
  1054. return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
  1055. },
  1056. /**
  1057. * Load services data from server.
  1058. */
  1059. loadServicesFromServer: function () {
  1060. var services = this.getDBProperty('services');
  1061. if (!services) {
  1062. services = {
  1063. selectedServices: [],
  1064. installedServices: []
  1065. };
  1066. App.StackService.find().forEach(function(item){
  1067. var isInstalled = App.Service.find().someProperty('id', item.get('serviceName'));
  1068. item.set('isSelected', isInstalled);
  1069. item.set('isInstalled', isInstalled);
  1070. if (isInstalled) {
  1071. services.selectedServices.push(item.get('serviceName'));
  1072. services.installedServices.push(item.get('serviceName'));
  1073. }
  1074. },this);
  1075. this.setDBProperty('services',services);
  1076. } else {
  1077. App.StackService.find().forEach(function(item) {
  1078. var isSelected = services.selectedServices.contains(item.get('serviceName'));
  1079. var isInstalled = services.installedServices.contains(item.get('serviceName'));
  1080. item.set('isSelected', isSelected);
  1081. item.set('isInstalled', isInstalled);
  1082. },this);
  1083. }
  1084. this.set('content.services', App.StackService.find());
  1085. },
  1086. /**
  1087. * Load confirmed hosts.
  1088. * Will be used at <code>Assign Masters(step5)</code> step
  1089. */
  1090. loadConfirmedHosts: function () {
  1091. var hosts = App.db.getHosts();
  1092. if (hosts) {
  1093. this.set('content.hosts', hosts);
  1094. }
  1095. },
  1096. loadHosts: function () {
  1097. var dfd;
  1098. var hostsInDb = this.getDBProperty('hosts');
  1099. if (hostsInDb) {
  1100. this.set('content.hosts', hostsInDb);
  1101. dfd = $.Deferred();
  1102. dfd.resolve();
  1103. } else {
  1104. dfd = App.ajax.send({
  1105. name: 'hosts.confirmed',
  1106. sender: this,
  1107. data: {},
  1108. success: 'loadHostsSuccessCallback',
  1109. error: 'loadHostsErrorCallback'
  1110. });
  1111. }
  1112. return dfd.promise();
  1113. },
  1114. loadHostsSuccessCallback: function (response) {
  1115. var installedHosts = {};
  1116. response.items.forEach(function (item, indx) {
  1117. installedHosts[item.Hosts.host_name] = {
  1118. name: item.Hosts.host_name,
  1119. cpu: item.Hosts.cpu_count,
  1120. memory: item.Hosts.total_mem,
  1121. disk_info: item.Hosts.disk_info,
  1122. osType: item.Hosts.os_type,
  1123. osArch: item.Hosts.os_arch,
  1124. ip: item.Hosts.ip,
  1125. bootStatus: "REGISTERED",
  1126. isInstalled: true,
  1127. hostComponents: item.host_components,
  1128. id: indx++
  1129. };
  1130. });
  1131. this.setDBProperty('hosts', installedHosts);
  1132. this.set('content.hosts', installedHosts);
  1133. },
  1134. loadHostsErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
  1135. App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
  1136. console.log('Loading hosts failed');
  1137. },
  1138. /**
  1139. * Determine if <code>Assign Slaves and Clients</code> step should be skipped
  1140. * @method setSkipSlavesStep
  1141. * @param services
  1142. * @param step
  1143. */
  1144. setSkipSlavesStep: function (services, step) {
  1145. var hasServicesWithSlave = services.someProperty('hasSlave');
  1146. var hasServicesWithClient = services.someProperty('hasClient');
  1147. var hasServicesWithCustomAssignedNonMasters = services.someProperty('hasNonMastersWithCustomAssignment');
  1148. this.set('content.skipSlavesStep', !hasServicesWithSlave && !hasServicesWithClient || !hasServicesWithCustomAssignedNonMasters);
  1149. if (this.get('content.skipSlavesStep')) {
  1150. this.get('isStepDisabled').findProperty('step', step).set('value', this.get('content.skipSlavesStep'));
  1151. }
  1152. },
  1153. /**
  1154. * Load config themes for enhanced config layout.
  1155. *
  1156. * @method loadConfigThemes
  1157. * @return {$.Deferred}
  1158. */
  1159. loadConfigThemes: function () {
  1160. var self = this;
  1161. var dfd = $.Deferred();
  1162. if (!this.get('stackConfigsLoaded')) {
  1163. var serviceNames = App.StackService.find().filter(function (s) {
  1164. return s.get('isSelected') || s.get('isInstalled');
  1165. }).mapProperty('serviceName');
  1166. // Load stack configs before loading themes
  1167. App.config.loadClusterConfigsFromStack().always(function() {
  1168. App.config.loadConfigsFromStack(serviceNames).done(function () {
  1169. if (App.get('isClusterSupportsEnhancedConfigs')) {
  1170. self.loadConfigThemeForServices(serviceNames).always(function () {
  1171. self.set('stackConfigsLoaded', true);
  1172. App.themesMapper.generateAdvancedTabs(serviceNames);
  1173. dfd.resolve();
  1174. });
  1175. } else {
  1176. self.set('stackConfigsLoaded', true);
  1177. dfd.resolve();
  1178. }
  1179. });
  1180. });
  1181. }
  1182. else {
  1183. dfd.resolve();
  1184. this.set('stackConfigsLoaded', true);
  1185. }
  1186. return dfd.promise();
  1187. },
  1188. /**
  1189. * Cache "stepConfigs" to local storage in name value pairs
  1190. * @param stepController
  1191. */
  1192. cacheStepConfigValues: function(stepController) {
  1193. var self = this;
  1194. var stepConfigs = [];
  1195. stepController.get("stepConfigs").forEach(function (category) {
  1196. var configs = category.configs.map(function(config) {
  1197. if (self.isExcludedConfig(config)) {
  1198. config.set('value', '');
  1199. }
  1200. return {
  1201. name: config.name,
  1202. filename: config.filename,
  1203. value: config.value
  1204. };
  1205. });
  1206. stepConfigs = stepConfigs.concat(configs);
  1207. });
  1208. if (stepConfigs.length > 0 ) {
  1209. this.setDBProperty(stepController.name + "-sc", stepConfigs);
  1210. }
  1211. },
  1212. loadCachedStepConfigValues: function(stepController) {
  1213. return this.getDBProperty(stepController.name + "-sc");
  1214. },
  1215. clearCachedStepConfigValues: function(stepController) {
  1216. this.setDBProperty(stepController.name + "-sc", null);
  1217. },
  1218. saveTasksStatuses: function (tasksStatuses) {
  1219. this.set('content.tasksStatuses', tasksStatuses);
  1220. this.setDBProperty('tasksStatuses', tasksStatuses);
  1221. },
  1222. loadTasksStatuses: function() {
  1223. var tasksStatuses = this.getDBProperty('tasksStatuses');
  1224. this.set('content.tasksStatuses', tasksStatuses);
  1225. },
  1226. saveTasksRequestIds: function (tasksRequestIds) {
  1227. this.set('content.tasksRequestIds', tasksRequestIds);
  1228. this.setDBProperty('tasksRequestIds', tasksRequestIds);
  1229. },
  1230. loadTasksRequestIds: function() {
  1231. var tasksRequestIds = this.getDBProperty('tasksRequestIds');
  1232. this.set('content.tasksRequestIds', tasksRequestIds);
  1233. },
  1234. saveRequestIds: function (requestIds) {
  1235. this.set('content.requestIds', requestIds);
  1236. this.setDBProperty('requestIds', requestIds);
  1237. },
  1238. loadRequestIds: function() {
  1239. var requestIds = this.getDBProperty('requestIds');
  1240. this.set('content.requestIds', requestIds);
  1241. },
  1242. loadRecommendations: function () {
  1243. this.set("content.recommendations", this.getDBProperty('recommendations'));
  1244. }
  1245. });