step5_controller.js 21 KB

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