stack.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.Stack = DS.Model.extend({
  20. id: DS.attr('string'), // ${stackName}-${stackVersion}.
  21. stackName: DS.attr('string'),
  22. stackVersion: DS.attr('string'),
  23. active: DS.attr('boolean'), // All of the instances should have this value to true. We should map only those stacks that has active flag set to true
  24. parentStackVersion: DS.attr('string'),
  25. minUpgradeVersion: DS.attr('string'),
  26. configTypes: DS.attr('object'),
  27. operatingSystems: DS.hasMany('App.OperatingSystem'),
  28. isSelected: DS.attr('boolean', {defaultValue: false}),
  29. /**
  30. * @return: {Array} returns supported repositories for all OperatingSystem's supported by a stack instance
  31. */
  32. repositories: function () {
  33. var operatingSystems = this.get('operatingSystems');
  34. var repositories = [];
  35. operatingSystems.forEach(function (os) {
  36. os.get('repositories').forEach(function (repository) {
  37. repositories.pushObject(repository);
  38. }, this);
  39. }, this);
  40. return repositories;
  41. }.property('id'),
  42. /**
  43. * @return: {Array} App.StackService instances for selected stack instance. For non-selected stack instance returns empty array
  44. */
  45. services: function () {
  46. var result = [];
  47. var isStackSelected = this.get('isSelected');
  48. var stackServices = App.StackService.find().get('length');
  49. if (isStackSelected && stackServices) {
  50. result = App.StackService.find();
  51. }
  52. return result;
  53. }.property('isSelected'),
  54. /**
  55. * Right now there ambari-web is not fetching this information from the server as it does not need as of present.
  56. * @TODO: This should return stack level configurations for selected stack instance i.e properties of cluster-env file
  57. */
  58. configurations: function() {
  59. return [];
  60. }.property('isSelected')
  61. });
  62. App.Stack.FIXTURES = [];