step5_controller.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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 numberUtils = require('utils/number_utils');
  20. App.WizardStep5Controller = Em.Controller.extend({
  21. name:"wizardStep5Controller",
  22. title: function () {
  23. if (this.get('content.controllerName') == 'reassignMasterController') {
  24. return Em.I18n.t('installer.step5.reassign.header');
  25. }
  26. return Em.I18n.t('installer.step5.header');
  27. }.property('content.controllerName'),
  28. isReassignWizard: function () {
  29. return this.get('content.controllerName') == 'reassignMasterController';
  30. }.property('content.controllerName'),
  31. isReassignHive: function () {
  32. return this.get('servicesMasters').objectAt(0) && this.get('servicesMasters').objectAt(0).component_name == 'HIVE_SERVER' && this.get('isReassignWizard');
  33. }.property('isReassignWizard', 'servicesMasters'),
  34. isSubmitDisabled: function () {
  35. if (!this.get('isReassignWizard')) {
  36. return false;
  37. }
  38. var reassigned = false;
  39. var arr1 = App.HostComponent.find().filterProperty('componentName', this.get('content.reassign.component_name')).mapProperty('host.hostName');
  40. var arr2 = this.get('servicesMasters').mapProperty('selectedHost');
  41. arr1.forEach(function (host) {
  42. if (!arr2.contains(host)) {
  43. reassigned = true;
  44. }
  45. }, this);
  46. return !reassigned;
  47. }.property('servicesMasters.@each.selectedHost'),
  48. hosts:[],
  49. servicesMasters:[],
  50. selectedServicesMasters:[],
  51. components:require('data/service_components'),
  52. clearStep:function () {
  53. this.set('hosts', []);
  54. this.set('selectedServicesMasters', []);
  55. this.set('servicesMasters', []);
  56. },
  57. loadStep:function () {
  58. console.log("WizardStep5Controller: Loading step5: Assign Masters");
  59. this.clearStep();
  60. this.renderHostInfo();
  61. this.renderComponents(this.loadComponents());
  62. this.updateComponent('ZOOKEEPER_SERVER');
  63. if(App.supports.multipleHBaseMasters){
  64. this.updateComponent('HBASE_MASTER');
  65. }
  66. if (!this.get("selectedServicesMasters").filterProperty('isInstalled', false).length) {
  67. console.log('no master components to add');
  68. App.router.send('next');
  69. }
  70. },
  71. /**
  72. * Used to set showAddControl flag for ZOOKEEPER_SERVER and HBASE_SERVER
  73. */
  74. updateComponent: function(componentName){
  75. var component = this.last(componentName);
  76. var services = this.get('content.services').filterProperty('isInstalled', true).mapProperty('serviceName');
  77. var currentService = componentName.split('_')[0];
  78. var showControl = !services.contains(currentService);
  79. if (component) {
  80. if(showControl){
  81. if (this.get("selectedServicesMasters").filterProperty("component_name", componentName).length < this.get("hosts.length") && !this.get('isReassignWizard')) {
  82. component.set('showAddControl', true);
  83. } else {
  84. component.set('showRemoveControl', false);
  85. }
  86. }
  87. this.rebalanceComponentHosts(componentName);
  88. }
  89. },
  90. /**
  91. * Load active host list to <code>hosts</code> variable
  92. */
  93. renderHostInfo:function () {
  94. var hostInfo = this.get('content.hosts');
  95. var result = [];
  96. for (var index in hostInfo) {
  97. var _host = hostInfo[index];
  98. if (_host.bootStatus === 'REGISTERED') {
  99. result.push(Ember.Object.create({
  100. host_name:_host.name,
  101. cpu:_host.cpu,
  102. memory:_host.memory,
  103. disk_info:_host.disk_info,
  104. host_info: Em.I18n.t('installer.step5.hostInfo').fmt(_host.name, numberUtils.bytesToSize(_host.memory, 1, 'parseFloat', 1024), _host.cpu)
  105. }));
  106. }
  107. }
  108. this.set("hosts", result);
  109. this.sortHosts(this.get('hosts'));
  110. },
  111. sortHosts: function (hosts) {
  112. hosts.sort(function (a, b) {
  113. if (a.get('memory') == b.get('memory')) {
  114. if (a.get('cpu') == b.get('cpu')) {
  115. return a.get('host_name').localeCompare(b.get('host_name')); // hostname asc
  116. }
  117. return b.get('cpu') - a.get('cpu'); // cores desc
  118. }
  119. return b.get('memory') - a.get('memory'); // ram desc
  120. });
  121. },
  122. /**
  123. * Load services info to appropriate variable and return masterComponentHosts
  124. * @return Array
  125. */
  126. loadComponents:function () {
  127. var services = this.get('content.services')
  128. .filterProperty('isSelected', true).mapProperty('serviceName'); //list of shown services
  129. var masterComponents = this.get('components').filterProperty('isMaster', true); //get full list from mock data
  130. var masterHosts = this.get('content.masterComponentHosts'); //saved to local storage info
  131. var resultComponents = [];
  132. var servicesLength = services.length;
  133. for (var index = 0; index < servicesLength; index++) {
  134. var componentInfo = masterComponents.filterProperty('service_name', services[index]);
  135. componentInfo.forEach(function (_componentInfo) {
  136. if (_componentInfo.component_name == 'ZOOKEEPER_SERVER' || _componentInfo.component_name == 'HBASE_MASTER') {
  137. var savedComponents = masterHosts.filterProperty('component', _componentInfo.component_name);
  138. if (savedComponents.length) {
  139. savedComponents.forEach(function (item) {
  140. var zooKeeperHost = {};
  141. zooKeeperHost.display_name = _componentInfo.display_name;
  142. zooKeeperHost.component_name = _componentInfo.component_name;
  143. zooKeeperHost.selectedHost = item.hostName;
  144. zooKeeperHost.availableHosts = [];
  145. zooKeeperHost.serviceId = services[index];
  146. zooKeeperHost.isInstalled = item.isInstalled;
  147. zooKeeperHost.isHiveCoHost = false;
  148. resultComponents.push(zooKeeperHost);
  149. })
  150. } else {
  151. var zooHosts = this.selectHost(_componentInfo.component_name);
  152. zooHosts.forEach(function (_host) {
  153. var zooKeeperHost = {};
  154. zooKeeperHost.display_name = _componentInfo.display_name;
  155. zooKeeperHost.component_name = _componentInfo.component_name;
  156. zooKeeperHost.selectedHost = _host;
  157. zooKeeperHost.availableHosts = [];
  158. zooKeeperHost.serviceId = services[index];
  159. zooKeeperHost.isInstalled = false;
  160. zooKeeperHost.isHiveCoHost = false;
  161. resultComponents.push(zooKeeperHost);
  162. });
  163. }
  164. } else {
  165. var savedComponent = masterHosts.findProperty('component', _componentInfo.component_name);
  166. var componentObj = {};
  167. componentObj.component_name = _componentInfo.component_name;
  168. componentObj.display_name = _componentInfo.display_name;
  169. componentObj.selectedHost = savedComponent ? savedComponent.hostName : this.selectHost(_componentInfo.component_name); // call the method that plays selectNode algorithm or fetches from server
  170. componentObj.isInstalled = savedComponent ? savedComponent.isInstalled : App.HostComponent.find().someProperty('componentName', _componentInfo.component_name);
  171. componentObj.serviceId = services[index];
  172. componentObj.availableHosts = [];
  173. componentObj.isHiveCoHost = ['HIVE_METASTORE', 'WEBHCAT_SERVER'].contains(_componentInfo.component_name) && !this.get('isReassignWizard');
  174. resultComponents.push(componentObj);
  175. }
  176. }, this);
  177. }
  178. return resultComponents;
  179. },
  180. /**
  181. * Put master components to <code>selectedServicesMasters</code>, which will be automatically rendered in template
  182. * @param masterComponents
  183. */
  184. renderComponents:function (masterComponents) {
  185. var services = this.get('content.services')
  186. .filterProperty('isInstalled', true).mapProperty('serviceName'); //list of shown services
  187. var showRemoveControlZk = !services.contains('ZOOKEEPER') && masterComponents.filterProperty('display_name', 'ZooKeeper').length > 1;
  188. var showRemoveControlHb = !services.contains('HBASE') && masterComponents.filterProperty('component_name', 'HBASE_MASTER').length > 1;
  189. var zid = 1;
  190. var hid = 1;
  191. var result = [];
  192. masterComponents.forEach(function (item) {
  193. var componentObj = Ember.Object.create(item);
  194. console.log("TRACE: render master component name is: " + item.component_name);
  195. if (item.display_name === "ZooKeeper") {
  196. componentObj.set('zId', zid++);
  197. componentObj.set("showRemoveControl", showRemoveControlZk);
  198. } else if (App.supports.multipleHBaseMasters && item.component_name === "HBASE_MASTER") {
  199. componentObj.set('zId', hid++);
  200. componentObj.set("showRemoveControl", showRemoveControlHb);
  201. }
  202. componentObj.set("availableHosts", this.get("hosts"));
  203. result.push(componentObj);
  204. }, this);
  205. this.set("selectedServicesMasters", result);
  206. if (this.get('isReassignWizard')) {
  207. var components = result.filterProperty('component_name', this.get('content.reassign.component_name'));
  208. components.setEach('isInstalled', false);
  209. this.set('servicesMasters', components);
  210. } else {
  211. this.set('servicesMasters', result);
  212. }
  213. },
  214. hasHiveServer: function () {
  215. return !!this.get('selectedServicesMasters').findProperty('component_name', 'HIVE_SERVER') && !this.get('isReassignWizard');
  216. }.property('selectedServicesMasters'),
  217. updateHiveCoHosts: function () {
  218. var hiveServer = this.get('selectedServicesMasters').findProperty('component_name', 'HIVE_SERVER');
  219. var hiveMetastore = this.get('selectedServicesMasters').findProperty('component_name', 'HIVE_METASTORE');
  220. var webHCatServer = this.get('selectedServicesMasters').findProperty('component_name', 'WEBHCAT_SERVER');
  221. if (hiveServer && hiveMetastore && webHCatServer) {
  222. if (!this.get('isReassignHive') && this.get('servicesMasters').objectAt(0) && !(this.get('servicesMasters').objectAt(0).component_name == 'HIVE_METASTORE')) {
  223. this.get('selectedServicesMasters').findProperty('component_name', 'HIVE_METASTORE').set('selectedHost', hiveServer.get('selectedHost'))
  224. }
  225. this.get('selectedServicesMasters').findProperty('component_name', 'WEBHCAT_SERVER').set('selectedHost', hiveServer.get('selectedHost'));
  226. }
  227. }.observes('selectedServicesMasters.@each.selectedHost'),
  228. /**
  229. * select and return host for component by scheme
  230. * Scheme is an object that has keys which compared to number of hosts,
  231. * if key more that number of hosts, then return value of that key.
  232. * Value is index of host in hosts array.
  233. *
  234. * @param noOfHosts
  235. * @param selectionScheme
  236. * @return {*}
  237. */
  238. getHostForComponent: function(noOfHosts, selectionScheme){
  239. var hosts = this.get('hosts');
  240. if(hosts.length === 1 || $.isEmptyObject(selectionScheme)){
  241. return hosts[0];
  242. } else {
  243. for(var i in selectionScheme){
  244. if(window.isFinite(i)){
  245. if(noOfHosts < window.parseInt(i)){
  246. return hosts[selectionScheme[i]];
  247. }
  248. }
  249. }
  250. return hosts[selectionScheme['else']]
  251. }
  252. },
  253. getZooKeeperServer:function (noOfHosts) {
  254. var hosts = this.get('hosts');
  255. if (noOfHosts < 3) {
  256. return [hosts[0].host_name];
  257. } else {
  258. return [hosts[0].host_name, hosts[1].host_name, hosts[2].host_name];
  259. }
  260. },
  261. getGangliaServer:function (noOfHosts) {
  262. var hostNames = this.get('hosts').mapProperty('host_name');
  263. var hostExcAmbari = hostNames.without(location.hostname);
  264. if (noOfHosts > 1) {
  265. return hostExcAmbari[0];
  266. } else {
  267. return hostNames[0];
  268. }
  269. },
  270. getNagiosServer:function (noOfHosts) {
  271. return this.getGangliaServer(noOfHosts);
  272. },
  273. getHueServer:function (noOfHosts) {
  274. return this.getGangliaServer(noOfHosts);
  275. },
  276. /**
  277. * Return hostName of masterNode for specified service
  278. * @param componentName
  279. * @return {*}
  280. */
  281. selectHost:function (componentName) {
  282. var noOfHosts = this.get('hosts').length;
  283. switch (componentName) {
  284. case 'KERBEROS_SERVER':
  285. return this.getHostForComponent(noOfHosts, {
  286. "3" : 1,
  287. "6" : 1,
  288. "31" : 3,
  289. "else" : 5
  290. }).host_name;
  291. case 'NAMENODE':
  292. return this.getHostForComponent(noOfHosts, {
  293. "else" : 0
  294. }).host_name;
  295. case 'SECONDARY_NAMENODE':
  296. return this.getHostForComponent(noOfHosts, {
  297. "else" : 1
  298. }).host_name;
  299. case 'JOBTRACKER':
  300. return this.getHostForComponent(noOfHosts, {
  301. "3" : 1,
  302. "6" : 1,
  303. "31" : 1,
  304. "else" : 2
  305. }).host_name;
  306. case 'HISTORYSERVER':
  307. return this.getHostForComponent(noOfHosts, {
  308. "3" : 1,
  309. "6" : 1,
  310. "31" : 1,
  311. "else" : 2
  312. }).host_name;
  313. case 'RESOURCEMANAGER':
  314. return this.getHostForComponent(noOfHosts, {
  315. "3" : 1,
  316. "6" : 1,
  317. "31" : 1,
  318. "else" : 2
  319. }).host_name;
  320. case 'HBASE_MASTER':
  321. return [this.getHostForComponent(noOfHosts, {
  322. "3" : 0,
  323. "6" : 0,
  324. "31" : 2,
  325. "else" : 3
  326. }).host_name];
  327. case 'OOZIE_SERVER':
  328. return this.getHostForComponent(noOfHosts, {
  329. "3" : 1,
  330. "6" : 1,
  331. "31" : 2,
  332. "else" : 3
  333. }).host_name;
  334. case 'HIVE_SERVER':
  335. return this.getHostForComponent(noOfHosts, {
  336. "3" : 1,
  337. "6" : 1,
  338. "31" : 2,
  339. "else" : 4
  340. }).host_name;
  341. case 'HIVE_METASTORE':
  342. return this.getHostForComponent(noOfHosts, {
  343. "3" : 1,
  344. "6" : 1,
  345. "31" : 2,
  346. "else" : 4
  347. }).host_name;
  348. case 'WEBHCAT_SERVER':
  349. return this.getHostForComponent(noOfHosts, {
  350. "3" : 1,
  351. "6" : 1,
  352. "31" : 2,
  353. "else" : 4
  354. }).host_name;
  355. case 'ZOOKEEPER_SERVER':
  356. return this.getZooKeeperServer(noOfHosts);
  357. case 'GANGLIA_SERVER':
  358. return this.getGangliaServer(noOfHosts);
  359. case 'NAGIOS_SERVER':
  360. return this.getNagiosServer(noOfHosts);
  361. case 'HUE_SERVER':
  362. return this.getHueServer(noOfHosts);
  363. }
  364. },
  365. masterHostMapping:function () {
  366. var mapping = [], mappingObject, self = this, mappedHosts, hostObj, hostInfo;
  367. //get the unique assigned hosts and find the master services assigned to them
  368. mappedHosts = this.get("selectedServicesMasters").mapProperty("selectedHost").uniq();
  369. mappedHosts.forEach(function (item) {
  370. hostObj = self.get("hosts").findProperty("host_name", item);
  371. console.log("Name of the host is: " + hostObj.host_name);
  372. mappingObject = Ember.Object.create({
  373. host_name:item,
  374. hostInfo:hostObj.host_info,
  375. masterServices:self.get("selectedServicesMasters").filterProperty("selectedHost", item)
  376. });
  377. mapping.pushObject(mappingObject);
  378. }, this);
  379. mapping.sort(this.sortHostsByName);
  380. return mapping;
  381. }.property("selectedServicesMasters.@each.selectedHost"),
  382. remainingHosts:function () {
  383. return (this.get("hosts.length") - this.get("masterHostMapping.length"));
  384. }.property("selectedServicesMasters.@each.selectedHost"),
  385. //methods
  386. getAvailableHosts:function (componentName) {
  387. var selectedHosts = this.get("selectedServicesMasters").filterProperty("component_name", componentName).mapProperty("selectedHost").uniq();
  388. return this.get('hosts').filter(function(item){
  389. return !selectedHosts.contains(item.get("host_name"));
  390. });
  391. },
  392. /**
  393. * On change callback for selects
  394. * @param componentName
  395. * @param selectedHost
  396. * @param zId
  397. */
  398. assignHostToMaster:function (componentName, selectedHost, zId) {
  399. if (selectedHost && componentName) {
  400. if (zId) {
  401. this.get('selectedServicesMasters').filterProperty('component_name', componentName).findProperty("zId", zId).set("selectedHost", selectedHost);
  402. this.rebalanceComponentHosts(componentName);
  403. } else {
  404. this.get('selectedServicesMasters').findProperty("component_name", componentName).set("selectedHost", selectedHost);
  405. }
  406. }
  407. },
  408. /**
  409. * Returns last component of selected type
  410. * @param componentName
  411. * @return {*}
  412. */
  413. last: function(componentName){
  414. return this.get("selectedServicesMasters").filterProperty("component_name", componentName).get("lastObject");
  415. },
  416. /**
  417. * Add new component to ZooKeeper Server and Hbase master
  418. * @param componentName
  419. * @return {Boolean}
  420. */
  421. addComponent:function (componentName) {
  422. /*
  423. *Logic: If ZooKeeper service is selected then there can be
  424. * minimum 1 ZooKeeper master in total, and
  425. * maximum 1 ZooKeeper on every host
  426. */
  427. var maxNumZooKeepers = this.get("hosts.length"),
  428. currentZooKeepers = this.get("selectedServicesMasters").filterProperty("component_name", componentName),
  429. newZookeeper = null,
  430. zookeeperHosts = null,
  431. suggestedHost = null,
  432. i = 0,
  433. lastZoo = null;
  434. if (!currentZooKeepers.length) {
  435. console.log('ALERT: Zookeeper service was not selected');
  436. return false;
  437. }
  438. if (currentZooKeepers.get("length") < maxNumZooKeepers) {
  439. currentZooKeepers.set("lastObject.showAddControl", false);
  440. currentZooKeepers.set("lastObject.showRemoveControl", true);
  441. //create a new zookeeper based on an existing one
  442. newZookeeper = Ember.Object.create({});
  443. lastZoo = currentZooKeepers.get("lastObject");
  444. newZookeeper.set("display_name", lastZoo.get("display_name"));
  445. newZookeeper.set("component_name", lastZoo.get("component_name"));
  446. newZookeeper.set("selectedHost", lastZoo.get("selectedHost"));
  447. newZookeeper.set("availableHosts", this.getAvailableHosts(componentName));
  448. if (currentZooKeepers.get("length") === (maxNumZooKeepers - 1)) {
  449. newZookeeper.set("showAddControl", false);
  450. } else {
  451. newZookeeper.set("showAddControl", true);
  452. }
  453. newZookeeper.set("showRemoveControl", true);
  454. //get recommended host for the new Zookeeper server
  455. zookeeperHosts = currentZooKeepers.mapProperty("selectedHost").uniq();
  456. for (i = 0; i < this.get("hosts.length"); i++) {
  457. if (!(zookeeperHosts.contains(this.get("hosts")[i].get("host_name")))) {
  458. suggestedHost = this.get("hosts")[i].get("host_name");
  459. break;
  460. }
  461. }
  462. newZookeeper.set("selectedHost", suggestedHost);
  463. newZookeeper.set("zId", (currentZooKeepers.get("lastObject.zId") + 1));
  464. this.get("selectedServicesMasters").insertAt(this.get("selectedServicesMasters").indexOf(lastZoo) + 1, newZookeeper);
  465. if(componentName == 'ZOOKEEPER_SERVER' || componentName == 'HBASE_MASTER'){
  466. this.rebalanceComponentHosts(componentName);
  467. }
  468. return true;
  469. }
  470. return false;//if no more zookeepers can be added
  471. },
  472. /**
  473. * Remove component from ZooKeeper server or Hbase Master
  474. * @param componentName
  475. * @param zId
  476. * @return {Boolean}
  477. */
  478. removeComponent:function (componentName, zId) {
  479. var currentZooKeepers = this.get("selectedServicesMasters").filterProperty("component_name", componentName)
  480. //work only if the Zookeeper service is selected in previous step
  481. if (!currentZooKeepers.length) {
  482. return false;
  483. }
  484. if (currentZooKeepers.get("length") > 1) {
  485. this.get("selectedServicesMasters").removeAt(this.get("selectedServicesMasters").indexOf(currentZooKeepers.findProperty("zId", zId)));
  486. currentZooKeepers = this.get("selectedServicesMasters").filterProperty("component_name", componentName);
  487. if (currentZooKeepers.get("length") < this.get("hosts.length")) {
  488. currentZooKeepers.set("lastObject.showAddControl", true);
  489. }
  490. if (currentZooKeepers.get("length") === 1) {
  491. currentZooKeepers.set("lastObject.showRemoveControl", false);
  492. }
  493. if(componentName == 'ZOOKEEPER_SERVER' || componentName == 'HBASE_MASTER'){
  494. this.rebalanceComponentHosts(componentName);
  495. }
  496. return true;
  497. }
  498. return false;
  499. },
  500. rebalanceComponentHosts:function (componentName) {
  501. //for a zookeeper and hbase update the available hosts for the other zookeepers and hbases
  502. var currentComponents = this.get("selectedServicesMasters").filterProperty("component_name", componentName),
  503. componentHosts = currentComponents.mapProperty("selectedHost"),
  504. availableComponentHosts = [],
  505. preparedAvailableHosts = null;
  506. //get all hosts available for zookeepers
  507. this.get("hosts").forEach(function (item) {
  508. if (!componentHosts.contains(item.get("host_name"))) {
  509. availableComponentHosts.pushObject(item);
  510. }
  511. }, this);
  512. currentComponents.forEach(function (item) {
  513. preparedAvailableHosts = availableComponentHosts.slice(0);
  514. preparedAvailableHosts.pushObject(this.get("hosts").findProperty("host_name", item.get("selectedHost")))
  515. preparedAvailableHosts.sort(this.sortHostsByConfig, this);
  516. item.set("availableHosts", preparedAvailableHosts);
  517. }, this);
  518. },
  519. sortHostsByConfig:function (a, b) {
  520. //currently handling only total memory on the host
  521. if (a.memory < b.memory) {
  522. return 1;
  523. }
  524. else {
  525. return -1;
  526. }
  527. },
  528. sortHostsByName:function (a, b) {
  529. if (a.host_name > b.host_name) {
  530. return 1;
  531. }
  532. else {
  533. return -1;
  534. }
  535. },
  536. submit: function () {
  537. if (!this.get('isSubmitDisabled')){
  538. App.router.send('next');
  539. }
  540. }
  541. });