installer.js 25 KB

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