installer.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  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. App.InstallerController = App.WizardController.extend({
  20. name: 'installerController',
  21. isCheckInProgress: false,
  22. totalSteps: 11,
  23. content: Em.Object.create({
  24. cluster: null,
  25. installOptions: null,
  26. hosts: null,
  27. services: null,
  28. slaveComponentHosts: null,
  29. masterComponentHosts: null,
  30. serviceConfigProperties: null,
  31. advancedServiceConfig: null,
  32. configGroups: [],
  33. slaveGroupProperties: null,
  34. stacks: null,
  35. clients: [],
  36. /**
  37. * recommendations for host groups loaded from server
  38. */
  39. recommendations: null,
  40. /**
  41. * recommendationsHostGroups - current component assignment after 5 and 6 steps
  42. * (uses for host groups validation and to load recommended configs)
  43. */
  44. recommendationsHostGroups: null,
  45. controllerName: 'installerController'
  46. }),
  47. /**
  48. * Wizard properties in local storage, which should be cleaned right after wizard has been finished
  49. */
  50. dbPropertiesToClean: [
  51. 'service',
  52. 'hosts',
  53. 'masterComponentHosts',
  54. 'slaveComponentHosts',
  55. 'cluster',
  56. 'allHostNames',
  57. 'installOptions',
  58. 'allHostNamesPattern',
  59. 'serviceComponents',
  60. 'advancedServiceConfig',
  61. 'clientInfo',
  62. 'selectedServiceNames',
  63. 'serviceConfigGroups',
  64. 'serviceConfigProperties',
  65. 'fileNamesToUpdate',
  66. 'bootStatus',
  67. 'stacksVersions',
  68. 'currentStep',
  69. 'serviceInfo',
  70. 'hostInfo',
  71. 'recommendations',
  72. 'recommendationsHostGroups',
  73. 'recommendationsConfigs'
  74. ],
  75. init: function () {
  76. this._super();
  77. this.get('isStepDisabled').setEach('value', true);
  78. this.get('isStepDisabled').pushObject(Ember.Object.create({
  79. step: 0,
  80. value: false
  81. }));
  82. },
  83. /**
  84. * redefined connectOutlet method to avoid view loading by unauthorized user
  85. * @param view
  86. * @param content
  87. */
  88. connectOutlet: function (view, content) {
  89. if (App.db.getAuthenticated()) {
  90. this._super(view, content);
  91. }
  92. },
  93. getCluster: function () {
  94. return jQuery.extend({}, this.get('clusterStatusTemplate'));
  95. },
  96. getHosts: function () {
  97. return [];
  98. },
  99. /**
  100. * Remove host from model. Used at <code>Confirm hosts(step2)</code> step
  101. * @param hosts Array of hosts, which we want to delete
  102. */
  103. removeHosts: function (hosts) {
  104. var dbHosts = this.getDBProperty('hosts');
  105. hosts.forEach(function (_hostInfo) {
  106. var host = _hostInfo.name;
  107. delete dbHosts[host];
  108. });
  109. this.setDBProperty('hosts', dbHosts);
  110. },
  111. /**
  112. * Load confirmed hosts.
  113. * Will be used at <code>Assign Masters(step5)</code> step
  114. */
  115. loadConfirmedHosts: function () {
  116. this.set('content.hosts', this.getDBProperty('hosts') || {});
  117. },
  118. /**
  119. * Load services data. Will be used at <code>Select services(step4)</code> step
  120. */
  121. loadServices: function () {
  122. var dfd = $.Deferred();
  123. var self = this;
  124. var stackServices = App.StackService.find().mapProperty('serviceName');
  125. if (!(stackServices && !!stackServices.length && App.StackService.find().objectAt(0).get('stackVersion') == App.get('currentStackVersionNumber'))) {
  126. this.loadServiceComponents().complete(function () {
  127. self.set('content.services', App.StackService.find());
  128. dfd.resolve();
  129. });
  130. } else {
  131. dfd.resolve();
  132. }
  133. return dfd.promise();
  134. },
  135. /**
  136. * total set of hosts registered to cluster, analog of App.Host model,
  137. * used in Installer wizard until hosts are installed
  138. */
  139. allHosts: function () {
  140. var rawHosts = this.get('content.hosts');
  141. var masterComponents = this.get('content.masterComponentHosts');
  142. var slaveComponents = this.get('content.slaveComponentHosts');
  143. var hosts = [];
  144. masterComponents.forEach(function (component) {
  145. var host = rawHosts[component.hostName];
  146. if (host.hostComponents) {
  147. host.hostComponents.push(Em.Object.create({
  148. componentName: component.component,
  149. displayName: component.display_name
  150. }));
  151. } else {
  152. rawHosts[component.hostName].hostComponents = [
  153. Em.Object.create({
  154. componentName: component.component,
  155. displayName: component.display_name
  156. })
  157. ]
  158. }
  159. });
  160. slaveComponents.forEach(function (component) {
  161. component.hosts.forEach(function (rawHost) {
  162. var host = rawHosts[rawHost.hostName];
  163. if (host.hostComponents) {
  164. host.hostComponents.push(Em.Object.create({
  165. componentName: component.componentName,
  166. displayName: component.displayName
  167. }));
  168. } else {
  169. rawHosts[rawHost.hostName].hostComponents = [
  170. Em.Object.create({
  171. componentName: component.componentName,
  172. displayName: component.displayName
  173. })
  174. ]
  175. }
  176. });
  177. });
  178. for (var hostName in rawHosts) {
  179. var host = rawHosts[hostName];
  180. var disksOverallCapacity = 0;
  181. var diskFree = 0;
  182. host.disk_info.forEach(function (disk) {
  183. disksOverallCapacity += parseFloat(disk.size);
  184. diskFree += parseFloat(disk.available);
  185. });
  186. hosts.pushObject(Em.Object.create({
  187. id: host.name,
  188. ip: host.ip,
  189. osType: host.os_type,
  190. osArch: host.os_arch,
  191. hostName: host.name,
  192. publicHostName: host.name,
  193. cpu: host.cpu,
  194. memory: host.memory,
  195. diskInfo: host.disk_info,
  196. diskTotal: disksOverallCapacity / (1024 * 1024),
  197. diskFree: diskFree / (1024 * 1024),
  198. hostComponents: host.hostComponents
  199. }
  200. ))
  201. }
  202. return hosts;
  203. }.property('content.hosts'),
  204. stacks: [],
  205. /**
  206. * stack names used as auxiliary data to query stacks by name
  207. */
  208. stackNames: [],
  209. /**
  210. * Load stacks data from server or take exist data from in memory variable {{content.stacks}}
  211. * The series of API calls will be called When landing first time on Select Stacks page
  212. * or on hitting refresh post select stacks page in installer wizard
  213. */
  214. loadStacks: function () {
  215. var stacks = this.get('content.stacks');
  216. var dfd = $.Deferred();
  217. if (stacks && stacks.get('length')) {
  218. App.set('currentStackVersion', App.Stack.find().findProperty('isSelected').get('id'));
  219. dfd.resolve(true);
  220. } else {
  221. App.ajax.send({
  222. name: 'wizard.stacks',
  223. sender: this,
  224. success: 'loadStacksSuccessCallback',
  225. error: 'loadStacksErrorCallback'
  226. }).complete(function () {
  227. dfd.resolve(false);
  228. });
  229. }
  230. return dfd.promise();
  231. },
  232. /**
  233. * Send queries to load versions for each stack
  234. */
  235. loadStacksSuccessCallback: function (data) {
  236. this.get('stacks').clear();
  237. this.set('stackNames', data.items.mapProperty('Stacks.stack_name'));
  238. },
  239. /**
  240. * onError callback for loading stacks data
  241. */
  242. loadStacksErrorCallback: function () {
  243. console.log('Error in loading stacks');
  244. },
  245. /**
  246. * query every stack names from server
  247. * @return {Array}
  248. */
  249. loadStacksVersions: function () {
  250. var requests = [];
  251. this.get('stackNames').forEach(function (stackName) {
  252. requests.push(App.ajax.send({
  253. name: 'wizard.stacks_versions',
  254. sender: this,
  255. data: {
  256. stackName: stackName
  257. },
  258. success: 'loadStacksVersionsSuccessCallback',
  259. error: 'loadStacksVersionsErrorCallback'
  260. }));
  261. }, this);
  262. return requests;
  263. },
  264. /**
  265. * Parse loaded data and create array of stacks objects
  266. */
  267. loadStacksVersionsSuccessCallback: function (data) {
  268. var stacks = App.db.getStacks();
  269. var isStacksExistInDb = stacks && stacks.length;
  270. if (isStacksExistInDb) {
  271. stacks.forEach(function (_stack) {
  272. var stack = data.items.filterProperty('Versions.stack_name', _stack.stack_name).findProperty('Versions.stack_version', _stack.stack_version);
  273. if (stack) {
  274. stack.Versions.is_selected = _stack.is_selected;
  275. }
  276. }, this);
  277. }
  278. App.stackMapper.map(data);
  279. if (!isStacksExistInDb) {
  280. var defaultStackVersion = App.Stack.find().findProperty('id', App.defaultStackVersion);
  281. if (defaultStackVersion) {
  282. defaultStackVersion.set('isSelected', true)
  283. } else {
  284. App.Stack.find().objectAt(0).set('isSelected', true);
  285. }
  286. }
  287. this.set('content.stacks', App.Stack.find());
  288. App.set('currentStackVersion', App.Stack.find().findProperty('isSelected').get('id'));
  289. },
  290. /**
  291. * onError callback for loading stacks data
  292. */
  293. loadStacksVersionsErrorCallback: function () {
  294. console.log('Error in loading stacks');
  295. },
  296. /**
  297. * check server version and web client version
  298. */
  299. checkServerClientVersion: function () {
  300. var dfd = $.Deferred();
  301. var self = this;
  302. self.getServerVersion().done(function () {
  303. dfd.resolve();
  304. });
  305. return dfd.promise();
  306. },
  307. getServerVersion: function () {
  308. return App.ajax.send({
  309. name: 'ambari.service',
  310. sender: this,
  311. data: {
  312. fields: '?fields=RootServiceComponents/component_version,RootServiceComponents/properties/server.os_family&minimal_response=true'
  313. },
  314. success: 'getServerVersionSuccessCallback',
  315. error: 'getServerVersionErrorCallback'
  316. });
  317. },
  318. getServerVersionSuccessCallback: function (data) {
  319. var clientVersion = App.get('version');
  320. var serverVersion = (data.RootServiceComponents.component_version).toString();
  321. this.set('ambariServerVersion', serverVersion);
  322. if (clientVersion) {
  323. this.set('versionConflictAlertBody', Em.I18n.t('app.versionMismatchAlert.body').format(serverVersion, clientVersion));
  324. this.set('isServerClientVersionMismatch', clientVersion != serverVersion);
  325. } else {
  326. this.set('isServerClientVersionMismatch', false);
  327. }
  328. App.set('isManagedMySQLForHiveEnabled', App.config.isManagedMySQLForHiveAllowed(data.RootServiceComponents.properties['server.os_family']));
  329. },
  330. getServerVersionErrorCallback: function () {
  331. console.log('ERROR: Cannot load Ambari server version');
  332. },
  333. /**
  334. * set stacks from server to content and local DB
  335. */
  336. setStacks: function () {
  337. var result = App.Stack.find() || [];
  338. Em.assert('Stack model is not populated', result.get('length'));
  339. App.db.setStacks(result.slice());
  340. this.set('content.stacks', result);
  341. },
  342. /**
  343. * Save data to model
  344. * @param stepController App.WizardStep4Controller
  345. */
  346. saveServices: function (stepController) {
  347. var selectedServiceNames = [];
  348. var installedServiceNames = [];
  349. stepController.filterProperty('isSelected').forEach(function (item) {
  350. selectedServiceNames.push(item.get('serviceName'));
  351. });
  352. stepController.filterProperty('isInstalled').forEach(function (item) {
  353. installedServiceNames.push(item.get('serviceName'));
  354. });
  355. this.set('content.services', App.StackService.find());
  356. this.set('content.selectedServiceNames', selectedServiceNames);
  357. this.setDBProperty('selectedServiceNames', selectedServiceNames);
  358. this.set('content.installedServiceNames', installedServiceNames);
  359. this.setDBProperty('installedServiceNames', installedServiceNames);
  360. },
  361. /**
  362. * Save Master Component Hosts data to Main Controller
  363. * @param stepController App.WizardStep5Controller
  364. */
  365. saveMasterComponentHosts: function (stepController) {
  366. var obj = stepController.get('selectedServicesMasters'),
  367. hosts = this.getDBProperty('hosts');
  368. var masterComponentHosts = [];
  369. obj.forEach(function (_component) {
  370. masterComponentHosts.push({
  371. display_name: _component.get('display_name'),
  372. component: _component.get('component_name'),
  373. serviceId: _component.get('serviceId'),
  374. isInstalled: false,
  375. host_id: hosts[_component.get('selectedHost')].id
  376. });
  377. });
  378. console.log("installerController.saveMasterComponentHosts: saved hosts ", masterComponentHosts);
  379. this.setDBProperty('masterComponentHosts', masterComponentHosts);
  380. this.set('content.masterComponentHosts', masterComponentHosts);
  381. },
  382. /**
  383. * Load master component hosts data for using in required step controllers
  384. */
  385. loadMasterComponentHosts: function () {
  386. var masterComponentHosts = this.getDBProperty('masterComponentHosts'),
  387. hosts = this.getDBProperty('hosts'),
  388. host_names = Em.keys(hosts);
  389. if (Em.isNone(masterComponentHosts)) {
  390. masterComponentHosts = [];
  391. }
  392. else {
  393. masterComponentHosts.forEach(function (component) {
  394. for (var i = 0; i < host_names.length; i++) {
  395. if (hosts[host_names[i]].id === component.host_id) {
  396. component.hostName = host_names[i];
  397. break;
  398. }
  399. }
  400. });
  401. }
  402. this.set("content.masterComponentHosts", masterComponentHosts);
  403. },
  404. loadRecommendations: function () {
  405. this.set("content.recommendations", this.getDBProperty('recommendations'));
  406. },
  407. loadCurrentHostGroups: function () {
  408. this.set("content.recommendationsHostGroups", this.getDBProperty('recommendationsHostGroups'));
  409. },
  410. loadRecommendationsConfigs: function () {
  411. App.router.set("wizardStep7Controller.recommendationsConfigs", this.getDBProperty('recommendationsConfigs'));
  412. },
  413. /**
  414. * Load master component hosts data for using in required step controllers
  415. */
  416. loadSlaveComponentHosts: function () {
  417. var slaveComponentHosts = this.getDBProperty('slaveComponentHosts'),
  418. hosts = this.getDBProperty('hosts'),
  419. host_names = Em.keys(hosts);
  420. if (!Em.isNone(slaveComponentHosts)) {
  421. slaveComponentHosts.forEach(function (component) {
  422. component.hosts.forEach(function (host) {
  423. for (var i = 0; i < host_names.length; i++) {
  424. if (hosts[host_names[i]].id === host.host_id) {
  425. host.hostName = host_names[i];
  426. break;
  427. }
  428. }
  429. });
  430. });
  431. }
  432. this.set("content.slaveComponentHosts", slaveComponentHosts);
  433. console.log("InstallerController.loadSlaveComponentHosts: loaded hosts ", slaveComponentHosts);
  434. },
  435. /**
  436. * Load serviceConfigProperties to model
  437. */
  438. loadServiceConfigProperties: function () {
  439. var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
  440. this.set('content.serviceConfigProperties', serviceConfigProperties);
  441. console.log("InstallerController.loadServiceConfigProperties: loaded config ", serviceConfigProperties);
  442. this.set('content.advancedServiceConfig', this.getDBProperty('advancedServiceConfig'));
  443. },
  444. /**
  445. * Generate clients list for selected services and save it to model
  446. * @param stepController step4WizardController
  447. */
  448. saveClients: function (stepController) {
  449. var clients = [];
  450. stepController.get('content').filterProperty('isSelected', true).forEach(function (_service) {
  451. var client = _service.get('serviceComponents').filterProperty('isClient', true);
  452. client.forEach(function (clientComponent) {
  453. clients.pushObject({
  454. component_name: clientComponent.get('componentName'),
  455. display_name: clientComponent.get('displayName'),
  456. isInstalled: false
  457. });
  458. }, this);
  459. }, this);
  460. this.setDBProperty('clientInfo', clients);
  461. this.set('content.clients', clients);
  462. },
  463. /**
  464. * Check validation of the customized local urls
  465. */
  466. checkRepoURL: function (wizardStep1Controller) {
  467. var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
  468. selectedStack.set('reload', true);
  469. var nameVersionCombo = selectedStack.get('id');
  470. var stackName = nameVersionCombo.split('-')[0];
  471. var stackVersion = nameVersionCombo.split('-')[1];
  472. var dfd = $.Deferred();
  473. if (selectedStack && selectedStack.get('operatingSystems')) {
  474. this.set('validationCnt', selectedStack.get('repositories').filterProperty('isSelected').length);
  475. var verifyBaseUrl = !wizardStep1Controller.get('skipValidationChecked');
  476. selectedStack.get('operatingSystems').forEach(function (os) {
  477. if (os.get('isSelected')) {
  478. os.get('repositories').forEach(function (repo) {
  479. repo.setProperties({
  480. errorTitle: '',
  481. errorContent: '',
  482. validation: App.Repository.validation['INPROGRESS']
  483. });
  484. this.set('content.isCheckInProgress', true);
  485. App.ajax.send({
  486. name: 'wizard.advanced_repositories.valid_url',
  487. sender: this,
  488. data: {
  489. stackName: stackName,
  490. stackVersion: stackVersion,
  491. repoId: repo.get('repoId'),
  492. osType: os.get('osType'),
  493. osId: os.get('id'),
  494. dfd: dfd,
  495. data: {
  496. 'Repositories': {
  497. 'base_url': repo.get('baseUrl'),
  498. "verify_base_url": verifyBaseUrl
  499. }
  500. }
  501. },
  502. success: 'checkRepoURLSuccessCallback',
  503. error: 'checkRepoURLErrorCallback'
  504. });
  505. }, this);
  506. }
  507. }, this);
  508. }
  509. return dfd.promise();
  510. },
  511. /**
  512. * onSuccess callback for check Repo URL.
  513. */
  514. checkRepoURLSuccessCallback: function (response, request, data) {
  515. console.log('Success in check Repo URL. data osType: ' + data.osType);
  516. var selectedStack = this.get('content.stacks').findProperty('isSelected');
  517. if (selectedStack && selectedStack.get('operatingSystems')) {
  518. var os = selectedStack.get('operatingSystems').findProperty('id', data.osId);
  519. var repo = os.get('repositories').findProperty('repoId', data.repoId);
  520. if (repo) {
  521. repo.set('validation', App.Repository.validation['OK']);
  522. }
  523. }
  524. this.set('validationCnt', this.get('validationCnt') - 1);
  525. if (!this.get('validationCnt')) {
  526. this.set('content.isCheckInProgress', false);
  527. data.dfd.resolve();
  528. }
  529. },
  530. /**
  531. * onError callback for check Repo URL.
  532. */
  533. checkRepoURLErrorCallback: function (request, ajaxOptions, error, data, params) {
  534. console.log('Error in check Repo URL. The baseURL sent is: ' + data.data);
  535. var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
  536. if (selectedStack && selectedStack.get('operatingSystems')) {
  537. var os = selectedStack.get('operatingSystems').findProperty('id', params.osId);
  538. var repo = os.get('repositories').findProperty('repoId', params.repoId);
  539. if (repo) {
  540. repo.setProperties({
  541. validation: App.Repository.validation['INVALID'],
  542. errorTitle: request.status + ":" + request.statusText,
  543. errorContent: $.parseJSON(request.responseText) ? $.parseJSON(request.responseText).message : ""
  544. });
  545. }
  546. }
  547. this.set('content.isCheckInProgress', false);
  548. params.dfd.reject();
  549. },
  550. loadMap: {
  551. '0': [
  552. {
  553. type: 'sync',
  554. callback: function () {
  555. this.load('cluster');
  556. }
  557. }
  558. ],
  559. '1': [
  560. {
  561. type: 'async',
  562. callback: function () {
  563. return this.loadStacks();
  564. }
  565. },
  566. {
  567. type: 'async',
  568. callback: function (stacksLoaded) {
  569. var dfd = $.Deferred();
  570. if (!stacksLoaded) {
  571. $.when.apply(this, this.loadStacksVersions()).done(function () {
  572. dfd.resolve(stacksLoaded);
  573. });
  574. } else {
  575. dfd.resolve(stacksLoaded);
  576. }
  577. return dfd.promise();
  578. }
  579. }
  580. ],
  581. '2': [
  582. {
  583. type: 'sync',
  584. callback: function () {
  585. this.load('installOptions');
  586. }
  587. }
  588. ],
  589. '3': [
  590. {
  591. type: 'sync',
  592. callback: function () {
  593. this.loadConfirmedHosts();
  594. }
  595. }
  596. ],
  597. '4': [
  598. {
  599. type: 'async',
  600. callback: function () {
  601. return this.loadServices();
  602. }
  603. }
  604. ],
  605. '5': [
  606. {
  607. type: 'sync',
  608. callback: function () {
  609. this.setSkipSlavesStep(App.StackService.find().filterProperty('isSelected'), 6);
  610. this.loadMasterComponentHosts();
  611. this.loadConfirmedHosts();
  612. this.loadRecommendations();
  613. }
  614. }
  615. ],
  616. '6': [
  617. {
  618. type: 'sync',
  619. callback: function () {
  620. this.loadSlaveComponentHosts();
  621. this.loadClients();
  622. this.loadRecommendations();
  623. }
  624. }
  625. ],
  626. '7': [
  627. {
  628. type: 'async',
  629. callback: function () {
  630. this.loadServiceConfigGroups();
  631. this.loadServiceConfigProperties();
  632. this.loadCurrentHostGroups();
  633. this.loadRecommendationsConfigs();
  634. return this.loadConfigThemes();
  635. }
  636. }
  637. ]
  638. },
  639. /**
  640. * Clear all temporary data
  641. */
  642. finish: function () {
  643. this.setCurrentStep('0');
  644. this.clearStorageData();
  645. var persists = App.router.get('applicationController').persistKey();
  646. App.router.get('applicationController').postUserPref(persists, true);
  647. },
  648. /**
  649. * Save cluster provisioning state to the server
  650. * @param state cluster provisioning state
  651. */
  652. setClusterProvisioningState: function (state) {
  653. return App.ajax.send({
  654. name: 'cluster.save_provisioning_state',
  655. sender: this,
  656. data: {
  657. state: state
  658. }
  659. });
  660. },
  661. setStepsEnable: function () {
  662. for (var i = 0; i <= this.totalSteps; i++) {
  663. var step = this.get('isStepDisabled').findProperty('step', i);
  664. if (i <= this.get('currentStep')) {
  665. step.set('value', false);
  666. } else {
  667. step.set('value', true);
  668. }
  669. }
  670. }.observes('currentStep'),
  671. setLowerStepsDisable: function (stepNo) {
  672. for (var i = 0; i < stepNo; i++) {
  673. var step = this.get('isStepDisabled').findProperty('step', i);
  674. step.set('value', true);
  675. }
  676. }
  677. });