stack_config_property.js 8.2 KB

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