wizard.js 45 KB

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