stack_config_property.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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. //TODO delete this file soon
  20. App.StackConfigProperty = DS.Model.extend({
  21. /**
  22. * id is consist of property <code>name<code>+<code>fileName<code>
  23. */
  24. id: DS.attr('string'),
  25. /**
  26. * name of property that is taken from stack
  27. * @property {string}
  28. */
  29. name: DS.attr('string'),
  30. /**
  31. * display name of property that is taken from ui or
  32. * if UI has no info about property this can be formatted or plain name of property
  33. * @property {string}
  34. */
  35. displayName: DS.attr('string'),
  36. /**
  37. * filename of property that is taken from stack
  38. * ex: "hdfs-site.xml"
  39. * @property {string}
  40. */
  41. fileName: DS.attr('string'),
  42. /**
  43. * same as fileName
  44. * @property {string}
  45. */
  46. filename: Em.computed.alias('fileName'),
  47. /**
  48. * description of config property meaning
  49. * @property {string}
  50. */
  51. description: DS.attr('string'),
  52. /**
  53. * defaultValue value of property is taken from stack before cluster is created
  54. * after cluster created is taken from cluster properties value
  55. * @property {string}
  56. */
  57. recommendedValue: DS.attr('string'),
  58. /**
  59. * defines if property support usage <code>isFinal<code> flag
  60. * @property {boolean}
  61. */
  62. supportsFinal: DS.attr('boolean', {defaultValue: true}),
  63. /**
  64. * defines the recommended value of <code>isFinal<code> value
  65. * @property {boolean}
  66. */
  67. recommendedIsFinal: DS.attr('boolean', {defaultValue: false}),
  68. /**
  69. * type of property
  70. * @property {string[]}
  71. */
  72. type: DS.attr('array', {defaultValue: []}),
  73. /**
  74. * service name
  75. * @property {string}
  76. */
  77. serviceName: DS.attr('string', {defaultValue: 'MISC'}),
  78. /**
  79. * stack name
  80. * @property {string}
  81. */
  82. stackName: DS.attr('string'),
  83. /**
  84. * stack version
  85. * @property {string}
  86. */
  87. stackVersion: DS.attr('string'),
  88. /**
  89. * describe widget details
  90. * @property {object}
  91. */
  92. widget: DS.attr('object', {defaultValue: null}),
  93. /**
  94. * widget type
  95. * @property {string}
  96. */
  97. widgetType: DS.attr('string', {defaultValue: null}),
  98. /**
  99. * this property contains array of properties which value
  100. * is dependent from current property
  101. * @property {array}
  102. */
  103. propertyDependedBy: DS.attr('array', {defaultValue: []}),
  104. /**
  105. * this property contains list of file type and name of properties
  106. * which values depends on current property
  107. * @property {object[]}
  108. */
  109. propertyDependsOn: DS.attr('array', {defaultValue: []}),
  110. /**
  111. * info for displaying property
  112. * example:
  113. * {
  114. * "type": "value-list",
  115. * "entries": ["true", "false"],
  116. * "entry_labels": ["Active", "Inactive"],
  117. * "entries_editable": "false",
  118. * "selection_cardinality": "1"
  119. * },
  120. * OR
  121. * {
  122. * "type": "int",
  123. * "minimum": "512",
  124. * "maximum": "10240",
  125. * "unit": "MB"
  126. * },
  127. * OR
  128. * {
  129. * "type": "value-list",
  130. * "entries": ["New_MySQL_Database", "Existing_MySQL_Database", "Existing_PostgreSQL_Database", "Existing_Oracle_Database"],
  131. * "entry_labels": ["New MySQL Database", "Existing MySQL Database", "Existing PostgreSQL Database", "Existing Oracle Database"],
  132. * "entry_descriptions": ["d1", "d2", "d3", "d4"],
  133. * "entries_editable": "false",
  134. * "selection_cardinality": "1" // 0+, 1+, etc.
  135. * }
  136. * @property {object}
  137. */
  138. valueAttributes: DS.attr('object', {defaultValue: null}),
  139. /**
  140. * sub section to which belongs this property
  141. * @property {App.SubSection}
  142. */
  143. subSection: DS.belongsTo('App.SubSection'),
  144. /**
  145. * sub section tab to which belongs this property
  146. * @property {App.SubSectionTab}
  147. */
  148. subSectionTab: DS.belongsTo('App.SubSectionTab'),
  149. /******************************* UI properties ****************************************/
  150. /**
  151. * if property should be saved to server
  152. * @property {boolean}
  153. */
  154. isRequiredByAgent: DS.attr('boolean', {defaultValue: true}),
  155. /**
  156. * defines category name of property
  157. * used for advanced tab
  158. * @property {string}
  159. */
  160. category: DS.attr('string'),
  161. /**
  162. * config property value same as default
  163. * @property {string}
  164. */
  165. value: DS.attr('string'),
  166. /**
  167. * config property isFinal value same as recommendedIsFinal
  168. * @property {boolean}
  169. */
  170. isFinal: DS.attr('boolean', {defaultValue: false}),
  171. /**
  172. * @type {boolean}
  173. */
  174. index: DS.attr('number', {defaultValue: null}),
  175. /**
  176. * defines what kind of value this property contains
  177. * ex: string, digits, number, directories, custom
  178. * @property {string}
  179. */
  180. displayType: function() {
  181. return this.getAttribute('type', 'string');
  182. }.property('valueAttributes.type'),
  183. /**
  184. * defines if the property can be overriden in the host config group
  185. * @type {boolean}
  186. */
  187. isOverridable: function() {
  188. return this.getAttribute('overridable', true);
  189. }.property('valueAttributes.overridable'),
  190. /**
  191. * defines if the property is visible or hidden
  192. * @type {boolean}
  193. */
  194. isVisible: function() {
  195. return this.getAttribute('visible', true);
  196. }.property('valueAttributes.visible'),
  197. /**
  198. * defines if the value of property can be left empty or not
  199. * @type {boolean}
  200. */
  201. isRequired: function() {
  202. return !this.getAttribute('empty_value_valid', false);
  203. }.property('valueAttributes.empty_value_valid'),
  204. /**
  205. * defines if the value of property can be reconfigured post-install
  206. * @type {boolean}
  207. */
  208. isReconfigurable: function() {
  209. return !this.getAttribute('editable_only_at_install', false);
  210. }.property('valueAttributes.editable_only_at_install'),
  211. /**
  212. * defines if the name of the property is visible or hidden
  213. * @type {boolean}
  214. */
  215. showLabel: function() {
  216. return this.getAttribute('show_property_name', true);
  217. }.property('valueAttributes.show_property_name'),
  218. /**
  219. * defines if the property is editable or not
  220. * @type {boolean}
  221. */
  222. isEditable: function() {
  223. return this.getAttribute('read_only' ,true);
  224. }.property('valueAttributes.read_only'),
  225. /**
  226. * defines if the property is editable or not
  227. * @type {boolean}
  228. */
  229. unit: function() {
  230. return this.getAttribute('unit', '');
  231. }.property('valueAttributes.unit'),
  232. /**
  233. *
  234. * @param propertyName
  235. * @param defaultValue
  236. * @returns {string}
  237. */
  238. getAttribute: function(propertyName, defaultValue) {
  239. var result = defaultValue;
  240. if (!Em.empty(this.get('valueAttributes.' + propertyName))) {
  241. result = this.get('valueAttributes.' + propertyName);
  242. }
  243. return result;
  244. }
  245. });
  246. App.StackConfigProperty.FIXTURES = [];
  247. App.StackConfigValAttributesMap = {
  248. 'overridable': 'isOverridable' ,
  249. 'visible': 'isVisible' ,
  250. 'empty_value_valid':'isRequired' ,
  251. 'editable_only_at_install': 'isReconfigurable' ,
  252. 'show_property_name': 'showLabel',
  253. 'read_only': 'isEditable',
  254. 'ui_only_property': 'isRequiredByAgent'
  255. };