stack.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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}-${repositoryVersion}.
  21. stackName: DS.attr('string'),
  22. stackVersion: DS.attr('string'),
  23. stackDefault: DS.attr('boolean'),
  24. repositoryVersion: DS.attr('string'),
  25. showAvailable: DS.attr('boolean'), // All of the instances should have this value to true. We should map only those stacks that has this flag set to true
  26. type: DS.attr('string'), // ["PATCH", "STANDARD"]
  27. useRedhatSatellite: DS.attr('boolean'),
  28. stackServices: DS.hasMany('App.ServiceSimple'),
  29. operatingSystems: DS.hasMany('App.OperatingSystem'),
  30. isSelected: DS.attr('boolean', {defaultValue: false}),
  31. stackNameVersion: Em.computed.concat('-', 'stackName', 'stackVersion'),
  32. isPatch: Em.computed.equal('type', 'PATCH'),
  33. displayName: Em.computed.concat('-', 'stackName', 'repositoryVersion'),
  34. /**
  35. * @type {boolean}
  36. */
  37. usePublicRepo: true,
  38. /**
  39. * @type {boolean}
  40. */
  41. useLocalRepo: false,
  42. /**
  43. * @return: {Array} returns supported repositories for all OperatingSystem's supported by a stack instance
  44. */
  45. repositories: function () {
  46. var operatingSystems = this.get('operatingSystems');
  47. var repositories = [];
  48. operatingSystems.filterProperty('isSelected', true).forEach(function (os) {
  49. os.get('repositories').forEach(function (repository) {
  50. repositories.pushObject(repository);
  51. }, this);
  52. }, this);
  53. return repositories;
  54. }.property('operatingSystems.@each.isSelected'),
  55. cleanReposBaseUrls: function () {
  56. this.get('operatingSystems').forEach(function (os) {
  57. os.get('repositories').setEach('baseUrl', '');
  58. });
  59. },
  60. restoreReposBaseUrls: function () {
  61. this.get('operatingSystems').forEach(function (os) {
  62. os.get('repositories').forEach(function (repo) {
  63. repo.set('baseUrl', repo.get('latestBaseUrl'));
  64. });
  65. });
  66. }
  67. });
  68. App.Stack.FIXTURES = [];