installer.js 24 KB

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