wizard.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  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. };
  675. }
  676. });
  677. this.setDBProperty('hosts', hosts);
  678. this.set('content.hosts', hosts);
  679. },
  680. /**
  681. * Save data after installation to main controller
  682. * @param stepController App.WizardStep9Controller
  683. */
  684. saveInstalledHosts: function (stepController) {
  685. var hosts = stepController.get('hosts');
  686. var hostInfo = this.getDBProperty('hosts');
  687. for (var index in hostInfo) {
  688. hostInfo[index].status = "pending";
  689. var host = hosts.findProperty('name', hostInfo[index].name);
  690. if (host) {
  691. hostInfo[index].status = host.status;
  692. hostInfo[index].message = host.message;
  693. hostInfo[index].progress = host.progress;
  694. }
  695. }
  696. this.set('content.hosts', hostInfo);
  697. this.setDBProperty('hosts', hostInfo);
  698. },
  699. /**
  700. * Save slaveHostComponents to main controller
  701. * @param stepController
  702. */
  703. saveSlaveComponentHosts: function (stepController) {
  704. var hosts = stepController.get('hosts'),
  705. dbHosts = this.getDBProperty('hosts'),
  706. headers = stepController.get('headers');
  707. var formattedHosts = Ember.Object.create();
  708. headers.forEach(function (header) {
  709. formattedHosts.set(header.get('name'), []);
  710. });
  711. hosts.forEach(function (host) {
  712. var checkboxes = host.checkboxes;
  713. headers.forEach(function (header) {
  714. var cb = checkboxes.findProperty('title', header.get('label'));
  715. if (cb.checked) {
  716. formattedHosts.get(header.get('name')).push({
  717. group: 'Default',
  718. isInstalled: cb.isInstalled,
  719. host_id: dbHosts[host.hostName].id
  720. });
  721. }
  722. });
  723. });
  724. var slaveComponentHosts = [];
  725. headers.forEach(function (header) {
  726. slaveComponentHosts.push({
  727. componentName: header.get('name'),
  728. displayName: header.get('label').replace(/\s/g, ''),
  729. hosts: formattedHosts.get(header.get('name'))
  730. });
  731. });
  732. this.setDBProperty('slaveComponentHosts', slaveComponentHosts);
  733. this.set('content.slaveComponentHosts', slaveComponentHosts);
  734. },
  735. /**
  736. * Return true if cluster data is loaded and false otherwise.
  737. * This is used for all wizard controllers except for installer wizard.
  738. */
  739. dataLoading: function () {
  740. var dfd = $.Deferred();
  741. this.connectOutlet('loading');
  742. if (App.router.get('clusterController.isLoaded')) {
  743. dfd.resolve();
  744. } else {
  745. var interval = setInterval(function () {
  746. if (App.router.get('clusterController.isLoaded')) {
  747. dfd.resolve();
  748. clearInterval(interval);
  749. }
  750. }, 50);
  751. }
  752. return dfd.promise();
  753. },
  754. /**
  755. * Return true if user data is loaded via App.MainServiceInfoConfigsController
  756. * This function is used in reassign master wizard right now.
  757. */
  758. usersLoading: function () {
  759. var self = this;
  760. var dfd = $.Deferred();
  761. var miscController = App.MainAdminServiceAccountsController.create({content: self.get('content')});
  762. miscController.loadUsers();
  763. var interval = setInterval(function () {
  764. if (miscController.get('dataIsLoaded')) {
  765. if (self.get("content.hdfsUser")) {
  766. self.set('content.hdfsUser', miscController.get('content.hdfsUser'));
  767. }
  768. dfd.resolve();
  769. clearInterval(interval);
  770. }
  771. }, 10);
  772. return dfd.promise();
  773. },
  774. /**
  775. * Save cluster status before going to deploy step
  776. * @param name cluster state. Unique for every wizard
  777. */
  778. saveClusterState: function (name) {
  779. App.clusterStatus.setClusterStatus({
  780. clusterName: this.get('content.cluster.name'),
  781. clusterState: name,
  782. wizardControllerName: this.get('content.controllerName'),
  783. localdb: App.db.data
  784. });
  785. },
  786. /**
  787. * Load serviceConfigProperties to model
  788. */
  789. loadServiceConfigProperties: function () {
  790. var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
  791. this.set('content.serviceConfigProperties', serviceConfigProperties);
  792. },
  793. /**
  794. * Save config properties
  795. * @param stepController Step7WizardController
  796. */
  797. saveServiceConfigProperties: function (stepController) {
  798. var serviceConfigProperties = [];
  799. var fileNamesToUpdate = this.getDBProperty('fileNamesToUpdate') || [];
  800. var installedServiceNames = stepController.get('installedServiceNames') || [];
  801. var installedServiceNamesMap = installedServiceNames.toWickMap();
  802. stepController.get('stepConfigs').forEach(function (_content) {
  803. if (_content.serviceName === 'YARN') {
  804. _content.set('configs', App.config.textareaIntoFileConfigs(_content.get('configs'), 'capacity-scheduler.xml'));
  805. }
  806. _content.get('configs').forEach(function (_configProperties) {
  807. if (!Em.isNone(_configProperties.get('group'))) {
  808. return false;
  809. }
  810. var configProperty = App.config.createDefaultConfig(
  811. _configProperties.get('name'),
  812. _configProperties.get('filename'),
  813. _configProperties.get('isUserProperty'),
  814. {value: _configProperties.get('value')}
  815. );
  816. configProperty = App.config.mergeStaticProperties(configProperty, _configProperties, ['name', 'filename']);
  817. if (this.isExcludedConfig(configProperty)) {
  818. configProperty.value = '';
  819. }
  820. serviceConfigProperties.push(configProperty);
  821. }, this);
  822. // check for configs that need to update for installed services
  823. if (installedServiceNamesMap[_content.get('serviceName')]) {
  824. // get only modified configs
  825. var configs = _content.get('configs').filter(function (config) {
  826. if (config.get('isNotDefaultValue') || (config.get('savedValue') === null)) {
  827. return config.isRequiredByAgent!== false;
  828. }
  829. return false;
  830. });
  831. // if modified configs detected push all service's configs for update
  832. if (configs.length) {
  833. fileNamesToUpdate = fileNamesToUpdate.concat(configs.mapProperty('filename').uniq());
  834. }
  835. }
  836. }, this);
  837. this.setDBProperties({
  838. fileNamesToUpdate: fileNamesToUpdate,
  839. serviceConfigProperties: serviceConfigProperties
  840. });
  841. this.set('content.serviceConfigProperties', serviceConfigProperties);
  842. },
  843. isExcludedConfig: function (configProperty) {
  844. return this.get('sensibleConfigs').mapProperty('name').indexOf(configProperty.name) > -1
  845. && this.get('sensibleConfigs').mapProperty('filename').indexOf(configProperty.filename) > -1;
  846. },
  847. /**
  848. * save Config groups
  849. * @param stepController
  850. * @param isAddService
  851. */
  852. saveServiceConfigGroups: function (stepController, isAddService) {
  853. var serviceConfigGroups = [],
  854. hosts = isAddService ? App.router.get('addServiceController').getDBProperty('hosts') : this.getDBProperty('hosts');
  855. stepController.get('stepConfigs').forEach(function (service) {
  856. // mark group of installed service
  857. var isForInstalledService = service.get('selected') === false;
  858. service.get('configGroups').forEach(function (configGroup) {
  859. var properties = [];
  860. configGroup.get('properties').forEach(function (property) {
  861. properties.push({
  862. name: property.get('name'),
  863. value: property.get('value'),
  864. isFinal: property.get('isFinal'),
  865. filename: property.get('filename')
  866. })
  867. });
  868. //configGroup copied into plain JS object to avoid Converting circular structure to JSON
  869. var hostNames = configGroup.get('hosts').map(function(host_name) {return hosts[host_name].id;});
  870. serviceConfigGroups.push({
  871. id: configGroup.get('id'),
  872. name: configGroup.get('name'),
  873. description: configGroup.get('description'),
  874. hosts: hostNames.slice(),
  875. properties: properties.slice(),
  876. is_default: configGroup.get('isDefault'),
  877. is_for_installed_service: isForInstalledService,
  878. is_for_update: configGroup.isForUpdate || configGroup.get('hash') != this.getConfigGroupHash(configGroup, hostNames),
  879. service_name: configGroup.get('serviceName'),
  880. service_id: configGroup.get('serviceName'),
  881. desired_configs: configGroup.get('desiredConfigs'),
  882. child_config_groups: configGroup.get('childConfigGroups') ? configGroup.get('childConfigGroups').mapProperty('id') : [],
  883. parent_config_group_id: configGroup.get('parentConfigGroup.id'),
  884. is_temporary: configGroup.get('isTemporary')
  885. });
  886. }, this)
  887. }, this);
  888. this.setDBProperty('serviceConfigGroups', serviceConfigGroups);
  889. this.set('content.configGroups', serviceConfigGroups);
  890. },
  891. /**
  892. * generate string hash for config group
  893. * @param {Object} configGroup
  894. * @param {Array|undefined} hosts
  895. * @returns {String|null}
  896. * @method getConfigGroupHash
  897. */
  898. getConfigGroupHash: function(configGroup, hosts) {
  899. if (!Em.get(configGroup, 'properties.length') && !Em.get(configGroup, 'hosts.length') && !hosts) {
  900. return null;
  901. }
  902. var hash = {};
  903. Em.get(configGroup, 'properties').forEach(function (config) {
  904. hash[Em.get(config, 'name')] = {value: Em.get(config, 'value'), isFinal: Em.get(config, 'isFinal')};
  905. });
  906. hash['hosts'] = hosts || Em.get(configGroup, 'hosts');
  907. return JSON.stringify(hash);
  908. },
  909. /**
  910. * return slaveComponents bound to hosts
  911. * @return {Array}
  912. */
  913. getSlaveComponentHosts: function () {
  914. var components = this.get('slaveComponents');
  915. var result = [];
  916. var installedServices = App.Service.find().mapProperty('serviceName');
  917. var selectedServices = App.StackService.find().filterProperty('isSelected', true).mapProperty('serviceName');
  918. var installedComponentsMap = {};
  919. var uninstalledComponents = [];
  920. components.forEach(function (component) {
  921. if (installedServices.contains(component.get('serviceName'))) {
  922. installedComponentsMap[component.get('componentName')] = [];
  923. } else if (selectedServices.contains(component.get('serviceName'))) {
  924. uninstalledComponents.push(component);
  925. }
  926. }, this);
  927. installedComponentsMap['HDFS_CLIENT'] = [];
  928. App.HostComponent.find().forEach(function (hostComponent) {
  929. if (installedComponentsMap[hostComponent.get('componentName')]) {
  930. installedComponentsMap[hostComponent.get('componentName')].push(hostComponent.get('hostName'));
  931. }
  932. }, this);
  933. for (var componentName in installedComponentsMap) {
  934. var name = (componentName === 'HDFS_CLIENT') ? 'CLIENT' : componentName;
  935. var component = {
  936. componentName: name,
  937. displayName: App.format.role(name, false),
  938. hosts: [],
  939. isInstalled: true
  940. };
  941. installedComponentsMap[componentName].forEach(function (hostName) {
  942. component.hosts.push({
  943. group: "Default",
  944. hostName: hostName,
  945. isInstalled: true
  946. });
  947. }, this);
  948. result.push(component);
  949. }
  950. uninstalledComponents.forEach(function (component) {
  951. var hosts = jQuery.extend(true, [], result.findProperty('componentName', 'DATANODE').hosts);
  952. hosts.setEach('isInstalled', false);
  953. result.push({
  954. componentName: component.get('componentName'),
  955. displayName: App.format.role(component.get('componentName'), false),
  956. hosts: hosts,
  957. isInstalled: false
  958. })
  959. });
  960. return result;
  961. },
  962. /**
  963. * Load master component hosts data for using in required step controllers
  964. */
  965. loadMasterComponentHosts: function () {
  966. var masterComponentHosts = this.getDBProperty('masterComponentHosts');
  967. var stackMasterComponents = App.get('components.masters').uniq();
  968. if (!masterComponentHosts) {
  969. masterComponentHosts = [];
  970. App.HostComponent.find().filter(function(component) {
  971. return stackMasterComponents.contains(component.get('componentName'));
  972. }).forEach(function (item) {
  973. masterComponentHosts.push({
  974. component: item.get('componentName'),
  975. hostName: item.get('hostName'),
  976. isInstalled: true,
  977. serviceId: item.get('service.id'),
  978. display_name: item.get('displayName')
  979. })
  980. });
  981. this.setDBProperty('masterComponentHosts', masterComponentHosts);
  982. }
  983. this.set("content.masterComponentHosts", masterComponentHosts);
  984. },
  985. /**
  986. * Save Master Component Hosts data to Main Controller
  987. * @param stepController App.WizardStep5Controller
  988. */
  989. saveMasterComponentHosts: function (stepController) {
  990. var obj = stepController.get('selectedServicesMasters');
  991. var masterComponentHosts = [];
  992. obj.forEach(function (_component) {
  993. masterComponentHosts.push({
  994. display_name: _component.get('display_name'),
  995. component: _component.get('component_name'),
  996. hostName: _component.get('selectedHost'),
  997. serviceId: _component.get('serviceId'),
  998. isInstalled: _component.get('isInstalled')
  999. });
  1000. });
  1001. this.setDBProperty('masterComponentHosts', masterComponentHosts);
  1002. this.set('content.masterComponentHosts', masterComponentHosts);
  1003. },
  1004. clearMasterComponentHosts: function() {
  1005. this.set('content.masterComponentHosts', null);
  1006. this.setDBProperty('masterComponentHosts', null);
  1007. },
  1008. /**
  1009. * Load information about hosts with clients components
  1010. */
  1011. loadClients: function () {
  1012. var clients = this.getDBProperty('clientInfo');
  1013. this.set('content.clients', clients);
  1014. },
  1015. /**
  1016. * load methods assigned to each step
  1017. * methods executed in exact order as they described in map
  1018. * @return {object}
  1019. */
  1020. loadAllPriorSteps: function () {
  1021. var currentStep = this.get('currentStep');
  1022. var loadMap = this.get('loadMap');
  1023. var operationStack = [];
  1024. var dfd = $.Deferred();
  1025. for (var s in loadMap) {
  1026. if (parseInt(s) <= parseInt(currentStep)) {
  1027. operationStack.pushObjects(loadMap[s]);
  1028. }
  1029. }
  1030. var sequence = App.actionSequence.create({context: this});
  1031. sequence.setSequence(operationStack).onFinish(function () {
  1032. dfd.resolve();
  1033. }).start();
  1034. return dfd.promise();
  1035. },
  1036. /**
  1037. * return new object extended from clusterStatusTemplate
  1038. * @return Object
  1039. */
  1040. getCluster: function () {
  1041. return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
  1042. },
  1043. /**
  1044. * Load services data from server.
  1045. */
  1046. loadServicesFromServer: function () {
  1047. var services = this.getDBProperty('services');
  1048. if (!services) {
  1049. services = {
  1050. selectedServices: [],
  1051. installedServices: []
  1052. };
  1053. App.StackService.find().forEach(function(item){
  1054. var isInstalled = App.Service.find().someProperty('id', item.get('serviceName'));
  1055. item.set('isSelected', isInstalled);
  1056. item.set('isInstalled', isInstalled);
  1057. if (isInstalled) {
  1058. services.selectedServices.push(item.get('serviceName'));
  1059. services.installedServices.push(item.get('serviceName'));
  1060. }
  1061. },this);
  1062. this.setDBProperty('services',services);
  1063. } else {
  1064. App.StackService.find().forEach(function(item) {
  1065. var isSelected = services.selectedServices.contains(item.get('serviceName'));
  1066. var isInstalled = services.installedServices.contains(item.get('serviceName'));
  1067. item.set('isSelected', isSelected);
  1068. item.set('isInstalled', isInstalled);
  1069. },this);
  1070. }
  1071. this.set('content.services', App.StackService.find());
  1072. },
  1073. /**
  1074. * Load confirmed hosts.
  1075. * Will be used at <code>Assign Masters(step5)</code> step
  1076. */
  1077. loadConfirmedHosts: function () {
  1078. var hosts = App.db.getHosts();
  1079. if (hosts) {
  1080. this.set('content.hosts', hosts);
  1081. }
  1082. },
  1083. loadHosts: function () {
  1084. var dfd;
  1085. var hostsInDb = this.getDBProperty('hosts');
  1086. if (hostsInDb) {
  1087. this.set('content.hosts', hostsInDb);
  1088. dfd = $.Deferred();
  1089. dfd.resolve();
  1090. } else {
  1091. dfd = App.ajax.send({
  1092. name: 'hosts.confirmed',
  1093. sender: this,
  1094. data: {},
  1095. success: 'loadHostsSuccessCallback',
  1096. error: 'loadHostsErrorCallback'
  1097. });
  1098. }
  1099. return dfd.promise();
  1100. },
  1101. loadHostsSuccessCallback: function (response) {
  1102. var installedHosts = {};
  1103. response.items.forEach(function (item, indx) {
  1104. installedHosts[item.Hosts.host_name] = {
  1105. name: item.Hosts.host_name,
  1106. cpu: item.Hosts.cpu_count,
  1107. memory: item.Hosts.total_mem,
  1108. disk_info: item.Hosts.disk_info,
  1109. osType: item.Hosts.os_type,
  1110. osArch: item.Hosts.os_arch,
  1111. ip: item.Hosts.ip,
  1112. maintenance_state: item.Hosts.maintenance_state,
  1113. bootStatus: "REGISTERED",
  1114. isInstalled: true,
  1115. hostComponents: item.host_components,
  1116. id: indx++
  1117. };
  1118. });
  1119. this.setDBProperty('hosts', installedHosts);
  1120. this.set('content.hosts', installedHosts);
  1121. },
  1122. loadHostsErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
  1123. App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.type, jqXHR.status);
  1124. },
  1125. /**
  1126. * Determine if <code>Assign Slaves and Clients</code> step should be skipped
  1127. * @method setSkipSlavesStep
  1128. * @param services
  1129. * @param step
  1130. */
  1131. setSkipSlavesStep: function (services, step) {
  1132. var hasServicesWithSlave = services.someProperty('hasSlave');
  1133. var hasServicesWithClient = services.someProperty('hasClient');
  1134. var hasServicesWithCustomAssignedNonMasters = services.someProperty('hasNonMastersWithCustomAssignment');
  1135. this.set('content.skipSlavesStep', !hasServicesWithSlave && !hasServicesWithClient || !hasServicesWithCustomAssignedNonMasters);
  1136. if (this.get('content.skipSlavesStep')) {
  1137. this.get('isStepDisabled').findProperty('step', step).set('value', this.get('content.skipSlavesStep'));
  1138. }
  1139. },
  1140. /**
  1141. * Load config themes for enhanced config layout.
  1142. *
  1143. * @method loadConfigThemes
  1144. * @return {$.Deferred}
  1145. */
  1146. loadConfigThemes: function () {
  1147. var self = this;
  1148. var dfd = $.Deferred();
  1149. if (!this.get('stackConfigsLoaded')) {
  1150. var serviceNames = App.StackService.find().filter(function (s) {
  1151. return s.get('isSelected') || s.get('isInstalled');
  1152. }).mapProperty('serviceName');
  1153. // Load stack configs before loading themes
  1154. App.config.loadClusterConfigsFromStack().always(function() {
  1155. App.config.loadConfigsFromStack(serviceNames).done(function () {
  1156. self.loadConfigThemeForServices(serviceNames).always(function () {
  1157. self.set('stackConfigsLoaded', true);
  1158. dfd.resolve();
  1159. });
  1160. });
  1161. });
  1162. }
  1163. else {
  1164. dfd.resolve();
  1165. this.set('stackConfigsLoaded', true);
  1166. }
  1167. return dfd.promise();
  1168. },
  1169. /**
  1170. * Cache "stepConfigs" to local storage in name value pairs
  1171. * @param stepController
  1172. */
  1173. cacheStepConfigValues: function(stepController) {
  1174. var self = this;
  1175. var stepConfigs = [];
  1176. stepController.get("stepConfigs").forEach(function (category) {
  1177. var configs = category.configs.map(function(config) {
  1178. if (self.isExcludedConfig(config)) {
  1179. config.set('value', '');
  1180. }
  1181. return {
  1182. name: config.name,
  1183. filename: config.filename,
  1184. value: config.value
  1185. };
  1186. });
  1187. stepConfigs = stepConfigs.concat(configs);
  1188. });
  1189. if (stepConfigs.length > 0 ) {
  1190. this.setDBProperty(stepController.name + "-sc", stepConfigs);
  1191. }
  1192. },
  1193. loadCachedStepConfigValues: function(stepController) {
  1194. return this.getDBProperty(stepController.name + "-sc");
  1195. },
  1196. clearCachedStepConfigValues: function(stepController) {
  1197. this.setDBProperty(stepController.name + "-sc", null);
  1198. },
  1199. saveTasksStatuses: function (tasksStatuses) {
  1200. this.set('content.tasksStatuses', tasksStatuses);
  1201. this.setDBProperty('tasksStatuses', tasksStatuses);
  1202. },
  1203. loadTasksStatuses: function() {
  1204. var tasksStatuses = this.getDBProperty('tasksStatuses');
  1205. this.set('content.tasksStatuses', tasksStatuses);
  1206. },
  1207. saveTasksRequestIds: function (tasksRequestIds) {
  1208. this.set('content.tasksRequestIds', tasksRequestIds);
  1209. this.setDBProperty('tasksRequestIds', tasksRequestIds);
  1210. },
  1211. loadTasksRequestIds: function() {
  1212. var tasksRequestIds = this.getDBProperty('tasksRequestIds');
  1213. this.set('content.tasksRequestIds', tasksRequestIds);
  1214. },
  1215. saveRequestIds: function (requestIds) {
  1216. this.set('content.requestIds', requestIds);
  1217. this.setDBProperty('requestIds', requestIds);
  1218. },
  1219. loadRequestIds: function() {
  1220. var requestIds = this.getDBProperty('requestIds');
  1221. this.set('content.requestIds', requestIds);
  1222. },
  1223. loadRecommendations: function () {
  1224. this.set("content.recommendations", this.getDBProperty('recommendations'));
  1225. },
  1226. /**
  1227. * reset stored wizard data and reload App
  1228. * @param {App.WizardController} controller - wizard controller
  1229. * @param {string} route - preferable path to go after wizard finished
  1230. */
  1231. resetOnClose: function(controller, route) {
  1232. App.router.get('wizardWatcherController').resetUser();
  1233. controller.finish();
  1234. App.router.get('updateController').set('isWorking', true);
  1235. App.clusterStatus.setClusterStatus({
  1236. clusterName: App.get('clusterName'),
  1237. clusterState: 'DEFAULT',
  1238. localdb: App.db.data
  1239. },
  1240. {
  1241. alwaysCallback: function () {
  1242. controller.get('popup').hide();
  1243. App.router.transitionTo(route);
  1244. Em.run.next(function() {
  1245. location.reload();
  1246. });
  1247. }
  1248. });
  1249. }
  1250. });