installer.js 25 KB

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