installer.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  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. var stringUtils = require('utils/string_utils');
  20. App.InstallerController = App.WizardController.extend({
  21. name: 'installerController',
  22. isCheckInProgress: false,
  23. totalSteps: 11,
  24. content: Em.Object.create({
  25. cluster: null,
  26. installOptions: null,
  27. hosts: null,
  28. services: null,
  29. slaveComponentHosts: null,
  30. masterComponentHosts: null,
  31. serviceConfigProperties: null,
  32. advancedServiceConfig: null,
  33. configGroups: [],
  34. slaveGroupProperties: null,
  35. stacks: null,
  36. clients: [],
  37. /**
  38. * recommendations for host groups loaded from server
  39. */
  40. recommendations: null,
  41. /**
  42. * recommendationsHostGroups - current component assignment after 5 and 6 steps
  43. * (uses for host groups validation and to load recommended configs)
  44. */
  45. recommendationsHostGroups: null,
  46. controllerName: 'installerController'
  47. }),
  48. /**
  49. * Wizard properties in local storage, which should be cleaned right after wizard has been finished
  50. */
  51. dbPropertiesToClean: [
  52. 'service',
  53. 'hosts',
  54. 'masterComponentHosts',
  55. 'slaveComponentHosts',
  56. 'cluster',
  57. 'allHostNames',
  58. 'installOptions',
  59. 'allHostNamesPattern',
  60. 'serviceComponents',
  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: true
  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. App.configsCollection.clearAll();
  218. App.Section.find().clear();
  219. App.SubSection.find().clear();
  220. App.SubSectionTab.find().clear();
  221. App.Tab.find().clear();
  222. this.set('stackConfigsLoaded', false);
  223. if (stacks && stacks.get('length')) {
  224. App.set('currentStackVersion', App.Stack.find().findProperty('isSelected').get('id'));
  225. dfd.resolve(true);
  226. } else {
  227. App.ajax.send({
  228. name: 'wizard.stacks',
  229. sender: this,
  230. success: 'loadStacksSuccessCallback',
  231. error: 'loadStacksErrorCallback'
  232. }).complete(function () {
  233. dfd.resolve(false);
  234. });
  235. }
  236. return dfd.promise();
  237. },
  238. /**
  239. * Send queries to load versions for each stack
  240. */
  241. loadStacksSuccessCallback: function (data) {
  242. this.get('stacks').clear();
  243. this.set('stackNames', data.items.mapProperty('Stacks.stack_name'));
  244. },
  245. /**
  246. * onError callback for loading stacks data
  247. */
  248. loadStacksErrorCallback: function () {
  249. },
  250. /**
  251. * query every stack names from server
  252. * @return {Array}
  253. */
  254. loadStacksVersions: function () {
  255. var requests = [];
  256. this.get('stackNames').forEach(function (stackName) {
  257. requests.push(App.ajax.send({
  258. name: 'wizard.stacks_versions',
  259. sender: this,
  260. data: {
  261. stackName: stackName
  262. },
  263. success: 'loadStacksVersionsSuccessCallback',
  264. error: 'loadStacksVersionsErrorCallback'
  265. }));
  266. }, this);
  267. this.set('loadStacksRequestsCounter', requests.length);
  268. return requests;
  269. },
  270. /**
  271. * Counter for counting number of successful requests to load stack versions
  272. */
  273. loadStacksRequestsCounter: 0,
  274. /**
  275. * Parse loaded data and create array of stacks objects
  276. */
  277. loadStacksVersionsSuccessCallback: function (data) {
  278. var stacks = App.db.getStacks();
  279. var isStacksExistInDb = stacks && stacks.length;
  280. if (isStacksExistInDb) {
  281. stacks.forEach(function (_stack) {
  282. var stack = data.items.filterProperty('Versions.stack_name', _stack.stack_name).findProperty('Versions.stack_version', _stack.stack_version);
  283. if (stack) {
  284. stack.Versions.is_selected = _stack.is_selected;
  285. }
  286. }, this);
  287. }
  288. App.stackMapper.map(data);
  289. if (!this.decrementProperty('loadStacksRequestsCounter')) {
  290. if (!isStacksExistInDb) {
  291. var defaultStackVersion = App.Stack.find().findProperty('id', App.defaultStackVersion);
  292. if (defaultStackVersion) {
  293. defaultStackVersion.set('isSelected', true)
  294. } else {
  295. App.Stack.find().objectAt(0).set('isSelected', true);
  296. }
  297. }
  298. this.set('content.stacks', App.Stack.find());
  299. App.set('currentStackVersion', App.Stack.find().findProperty('isSelected').get('id'));
  300. }
  301. },
  302. /**
  303. * onError callback for loading stacks data
  304. */
  305. loadStacksVersionsErrorCallback: function () {
  306. },
  307. /**
  308. * check server version and web client version
  309. */
  310. checkServerClientVersion: function () {
  311. var dfd = $.Deferred();
  312. var self = this;
  313. self.getServerVersion().done(function () {
  314. dfd.resolve();
  315. });
  316. return dfd.promise();
  317. },
  318. getServerVersion: function () {
  319. return App.ajax.send({
  320. name: 'ambari.service',
  321. sender: this,
  322. data: {
  323. fields: '?fields=RootServiceComponents/component_version,RootServiceComponents/properties/server.os_family&minimal_response=true'
  324. },
  325. success: 'getServerVersionSuccessCallback',
  326. error: 'getServerVersionErrorCallback'
  327. });
  328. },
  329. getServerVersionSuccessCallback: function (data) {
  330. var clientVersion = App.get('version');
  331. var serverVersion = (data.RootServiceComponents.component_version).toString();
  332. this.set('ambariServerVersion', serverVersion);
  333. if (clientVersion) {
  334. this.set('versionConflictAlertBody', Em.I18n.t('app.versionMismatchAlert.body').format(serverVersion, clientVersion));
  335. this.set('isServerClientVersionMismatch', clientVersion != serverVersion);
  336. } else {
  337. this.set('isServerClientVersionMismatch', false);
  338. }
  339. App.set('isManagedMySQLForHiveEnabled', App.config.isManagedMySQLForHiveAllowed(data.RootServiceComponents.properties['server.os_family']));
  340. },
  341. getServerVersionErrorCallback: function () {
  342. },
  343. /**
  344. * set stacks from server to content and local DB
  345. */
  346. setStacks: function () {
  347. var result = App.Stack.find() || [];
  348. Em.assert('Stack model is not populated', result.get('length'));
  349. App.db.setStacks(result.slice());
  350. this.set('content.stacks', result);
  351. },
  352. /**
  353. * Save data to model
  354. * @param stepController App.WizardStep4Controller
  355. */
  356. saveServices: function (stepController) {
  357. var selectedServiceNames = [];
  358. var installedServiceNames = [];
  359. stepController.filterProperty('isSelected').forEach(function (item) {
  360. selectedServiceNames.push(item.get('serviceName'));
  361. });
  362. stepController.filterProperty('isInstalled').forEach(function (item) {
  363. installedServiceNames.push(item.get('serviceName'));
  364. });
  365. this.set('content.services', App.StackService.find());
  366. this.set('content.selectedServiceNames', selectedServiceNames);
  367. this.set('content.installedServiceNames', installedServiceNames);
  368. this.setDBProperties({
  369. selectedServiceNames: selectedServiceNames,
  370. installedServiceNames: installedServiceNames
  371. });
  372. },
  373. /**
  374. * Save Master Component Hosts data to Main Controller
  375. * @param stepController App.WizardStep5Controller
  376. */
  377. saveMasterComponentHosts: function (stepController) {
  378. var obj = stepController.get('selectedServicesMasters'),
  379. hosts = this.getDBProperty('hosts');
  380. var masterComponentHosts = [];
  381. obj.forEach(function (_component) {
  382. masterComponentHosts.push({
  383. display_name: _component.get('display_name'),
  384. component: _component.get('component_name'),
  385. serviceId: _component.get('serviceId'),
  386. isInstalled: false,
  387. host_id: hosts[_component.get('selectedHost')].id
  388. });
  389. });
  390. this.setDBProperty('masterComponentHosts', masterComponentHosts);
  391. this.set('content.masterComponentHosts', masterComponentHosts);
  392. },
  393. /**
  394. * Load master component hosts data for using in required step controllers
  395. */
  396. loadMasterComponentHosts: function () {
  397. var props = this.getDBProperties(['masterComponentHosts', 'hosts']);
  398. var masterComponentHosts = props.masterComponentHosts,
  399. hosts = props.hosts || {},
  400. host_names = Em.keys(hosts);
  401. if (Em.isNone(masterComponentHosts)) {
  402. masterComponentHosts = [];
  403. }
  404. else {
  405. masterComponentHosts.forEach(function (component) {
  406. for (var i = 0; i < host_names.length; i++) {
  407. if (hosts[host_names[i]].id === component.host_id) {
  408. component.hostName = host_names[i];
  409. break;
  410. }
  411. }
  412. });
  413. }
  414. this.set("content.masterComponentHosts", masterComponentHosts);
  415. },
  416. loadCurrentHostGroups: function () {
  417. this.set("content.recommendationsHostGroups", this.getDBProperty('recommendationsHostGroups'));
  418. },
  419. loadRecommendationsConfigs: function () {
  420. App.router.set("wizardStep7Controller.recommendationsConfigs", this.getDBProperty('recommendationsConfigs'));
  421. },
  422. /**
  423. * Load master component hosts data for using in required step controllers
  424. */
  425. loadSlaveComponentHosts: function () {
  426. var props = this.getDBProperties(['slaveComponentHosts', 'hosts']);
  427. var slaveComponentHosts = props.slaveComponentHosts,
  428. hosts = props.hosts || {},
  429. host_names = Em.keys(hosts);
  430. if (!Em.isNone(slaveComponentHosts)) {
  431. slaveComponentHosts.forEach(function (component) {
  432. component.hosts.forEach(function (host) {
  433. for (var i = 0; i < host_names.length; i++) {
  434. if (hosts[host_names[i]].id === host.host_id) {
  435. host.hostName = host_names[i];
  436. break;
  437. }
  438. }
  439. });
  440. });
  441. }
  442. this.set("content.slaveComponentHosts", slaveComponentHosts);
  443. },
  444. /**
  445. * Load serviceConfigProperties to model
  446. */
  447. loadServiceConfigProperties: function () {
  448. var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
  449. this.set('content.serviceConfigProperties', serviceConfigProperties);
  450. },
  451. /**
  452. * Generate clients list for selected services and save it to model
  453. * @param stepController step4WizardController
  454. */
  455. saveClients: function (stepController) {
  456. var clients = [];
  457. stepController.get('content').filterProperty('isSelected', true).forEach(function (_service) {
  458. var client = _service.get('serviceComponents').filterProperty('isClient', true);
  459. client.forEach(function (clientComponent) {
  460. clients.pushObject({
  461. component_name: clientComponent.get('componentName'),
  462. display_name: clientComponent.get('displayName'),
  463. isInstalled: false
  464. });
  465. }, this);
  466. }, this);
  467. this.setDBProperty('clientInfo', clients);
  468. this.set('content.clients', clients);
  469. },
  470. /**
  471. * Check validation of the customized local urls
  472. */
  473. checkRepoURL: function (wizardStep1Controller) {
  474. var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
  475. selectedStack.set('reload', true);
  476. var nameVersionCombo = selectedStack.get('id');
  477. var stackName = nameVersionCombo.split('-')[0];
  478. var stackVersion = nameVersionCombo.split('-')[1];
  479. var dfd = $.Deferred();
  480. if (selectedStack && selectedStack.get('operatingSystems')) {
  481. this.set('validationCnt', selectedStack.get('repositories').filterProperty('isSelected').length);
  482. var verifyBaseUrl = !wizardStep1Controller.get('skipValidationChecked');
  483. selectedStack.get('operatingSystems').forEach(function (os) {
  484. if (os.get('isSelected')) {
  485. os.get('repositories').forEach(function (repo) {
  486. repo.setProperties({
  487. errorTitle: '',
  488. errorContent: '',
  489. validation: App.Repository.validation['INPROGRESS']
  490. });
  491. this.set('content.isCheckInProgress', true);
  492. App.ajax.send({
  493. name: 'wizard.advanced_repositories.valid_url',
  494. sender: this,
  495. data: {
  496. stackName: stackName,
  497. stackVersion: stackVersion,
  498. repoId: repo.get('repoId'),
  499. osType: os.get('osType'),
  500. osId: os.get('id'),
  501. dfd: dfd,
  502. data: {
  503. 'Repositories': {
  504. 'base_url': repo.get('baseUrl'),
  505. "verify_base_url": verifyBaseUrl
  506. }
  507. }
  508. },
  509. success: 'checkRepoURLSuccessCallback',
  510. error: 'checkRepoURLErrorCallback'
  511. });
  512. }, this);
  513. }
  514. }, this);
  515. }
  516. return dfd.promise();
  517. },
  518. /**
  519. * onSuccess callback for check Repo URL.
  520. */
  521. checkRepoURLSuccessCallback: function (response, request, data) {
  522. var selectedStack = this.get('content.stacks').findProperty('isSelected');
  523. if (selectedStack && selectedStack.get('operatingSystems')) {
  524. var os = selectedStack.get('operatingSystems').findProperty('id', data.osId);
  525. var repo = os.get('repositories').findProperty('repoId', data.repoId);
  526. if (repo) {
  527. repo.set('validation', App.Repository.validation['OK']);
  528. }
  529. }
  530. this.set('validationCnt', this.get('validationCnt') - 1);
  531. if (!this.get('validationCnt')) {
  532. this.set('content.isCheckInProgress', false);
  533. data.dfd.resolve();
  534. }
  535. },
  536. /**
  537. * onError callback for check Repo URL.
  538. */
  539. checkRepoURLErrorCallback: function (request, ajaxOptions, error, data, params) {
  540. var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
  541. if (selectedStack && selectedStack.get('operatingSystems')) {
  542. var os = selectedStack.get('operatingSystems').findProperty('id', params.osId);
  543. var repo = os.get('repositories').findProperty('repoId', params.repoId);
  544. if (repo) {
  545. repo.setProperties({
  546. validation: App.Repository.validation['INVALID'],
  547. errorTitle: request.status + ":" + request.statusText,
  548. errorContent: $.parseJSON(request.responseText) ? $.parseJSON(request.responseText).message : ""
  549. });
  550. }
  551. }
  552. this.set('content.isCheckInProgress', false);
  553. params.dfd.reject();
  554. },
  555. loadMap: {
  556. '0': [
  557. {
  558. type: 'sync',
  559. callback: function () {
  560. this.load('cluster');
  561. }
  562. }
  563. ],
  564. '1': [
  565. {
  566. type: 'async',
  567. callback: function () {
  568. var dfd = $.Deferred();
  569. this.loadStacks().always(function() {
  570. App.router.get('clusterController').loadAmbariProperties().always(function() {
  571. dfd.resolve();
  572. });
  573. });
  574. return dfd.promise();
  575. }
  576. },
  577. {
  578. type: 'async',
  579. callback: function (stacksLoaded) {
  580. var dfd = $.Deferred();
  581. if (!stacksLoaded) {
  582. $.when.apply(this, this.loadStacksVersions()).done(function () {
  583. dfd.resolve(stacksLoaded);
  584. });
  585. } else {
  586. dfd.resolve(stacksLoaded);
  587. }
  588. return dfd.promise();
  589. }
  590. }
  591. ],
  592. '2': [
  593. {
  594. type: 'sync',
  595. callback: function () {
  596. this.load('installOptions');
  597. }
  598. }
  599. ],
  600. '3': [
  601. {
  602. type: 'sync',
  603. callback: function () {
  604. this.loadConfirmedHosts();
  605. }
  606. }
  607. ],
  608. '4': [
  609. {
  610. type: 'async',
  611. callback: function () {
  612. return this.loadServices();
  613. }
  614. }
  615. ],
  616. '5': [
  617. {
  618. type: 'sync',
  619. callback: function () {
  620. this.setSkipSlavesStep(App.StackService.find().filterProperty('isSelected'), 6);
  621. this.loadMasterComponentHosts();
  622. this.loadConfirmedHosts();
  623. this.loadRecommendations();
  624. }
  625. }
  626. ],
  627. '6': [
  628. {
  629. type: 'sync',
  630. callback: function () {
  631. this.loadSlaveComponentHosts();
  632. this.loadClients();
  633. this.loadRecommendations();
  634. }
  635. }
  636. ],
  637. '7': [
  638. {
  639. type: 'async',
  640. callback: function () {
  641. this.loadServiceConfigGroups();
  642. this.loadServiceConfigProperties();
  643. this.loadCurrentHostGroups();
  644. this.loadRecommendationsConfigs();
  645. return this.loadConfigThemes();
  646. }
  647. }
  648. ]
  649. },
  650. /**
  651. * Clear all temporary data
  652. */
  653. finish: function () {
  654. this.setCurrentStep('0');
  655. this.clearStorageData();
  656. App.router.get('userSettingsController').postUserPref('show_bg', true);
  657. },
  658. /**
  659. * Save cluster provisioning state to the server
  660. * @param state cluster provisioning state
  661. */
  662. setClusterProvisioningState: function (state) {
  663. return App.ajax.send({
  664. name: 'cluster.save_provisioning_state',
  665. sender: this,
  666. data: {
  667. state: state
  668. }
  669. });
  670. },
  671. setStepsEnable: function () {
  672. for (var i = 0; i <= this.totalSteps; i++) {
  673. this.get('isStepDisabled').findProperty('step', i).set('value', i > this.get('currentStep'));
  674. }
  675. }.observes('currentStep'),
  676. setLowerStepsDisable: function (stepNo) {
  677. for (var i = 0; i < stepNo; i++) {
  678. var step = this.get('isStepDisabled').findProperty('step', i);
  679. step.set('value', true);
  680. }
  681. },
  682. /**
  683. * Compare jdk versions used for ambari and selected stack.
  684. * Validation check will fire only for non-custom jdk configuration.
  685. *
  686. * @param {Function} successCallback
  687. * @param {Function} failCallback
  688. */
  689. validateJDKVersion: function (successCallback, failCallback) {
  690. var selectedStack = App.Stack.find().findProperty('isSelected', true),
  691. currentJDKVersion = App.router.get('clusterController.ambariProperties')['java.version'],
  692. // use min as max, or max as min version, in case when some of them missed
  693. minJDKVersion = selectedStack.get('minJdkVersion') || selectedStack.get('maxJdkVersion'),
  694. maxJDKVersion = selectedStack.get('maxJdkVersion') || selectedStack.get('minJdkVersion'),
  695. t = Em.I18n.t,
  696. fCallback = failCallback || function() {},
  697. sCallback = successCallback || function() {};
  698. // Skip jdk check if min and max required version not set in stack definition.
  699. if (!minJDKVersion && !maxJDKVersion) {
  700. sCallback();
  701. return;
  702. }
  703. if (currentJDKVersion) {
  704. if (stringUtils.compareVersions(currentJDKVersion, minJDKVersion) < 0 ||
  705. stringUtils.compareVersions(maxJDKVersion, currentJDKVersion) < 0) {
  706. // checks and process only minor part for now
  707. var versionDistance = parseInt(maxJDKVersion.split('.')[1]) - parseInt(minJDKVersion.split('.')[1]);
  708. var versionsList = [minJDKVersion];
  709. for (var i = 1; i < (versionDistance + 1); i++) {
  710. versionsList.push("" + minJDKVersion.split('.')[0] + '.' + (+minJDKVersion.split('.')[1] + i));
  711. }
  712. var versionsString = stringUtils.getFormattedStringFromArray(versionsList, t('or'));
  713. var popupBody = t('popup.jdkValidation.body').format(selectedStack.get('stackName') + ' ' + selectedStack.get('stackVersion'), versionsString, currentJDKVersion);
  714. App.showConfirmationPopup(sCallback, popupBody, fCallback, t('popup.jdkValidation.header'), t('common.proceedAnyway'), true);
  715. return;
  716. }
  717. }
  718. sCallback();
  719. }
  720. });