wizard.js 43 KB

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