stack_config_property.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. * this property contains array of properties which value
  96. * is dependent from current property
  97. * @property {array}
  98. */
  99. propertyDependedBy: DS.attr('array', {defaultValue: []}),
  100. /**
  101. * this property contains list of file type and name of properties
  102. * which values depends on current property
  103. * @property {object[]}
  104. */
  105. propertyDependsOn: DS.attr('array', {defaultValue: []}),
  106. /**
  107. * info for displaying property
  108. * example:
  109. * {
  110. * "type": "value-list",
  111. * "entries": ["true", "false"],
  112. * "entry_labels": ["Active", "Inactive"],
  113. * "entries_editable": "false",
  114. * "selection_cardinality": "1"
  115. * },
  116. * OR
  117. * {
  118. * "type": "int",
  119. * "minimum": "512",
  120. * "maximum": "10240",
  121. * "unit": "MB"
  122. * },
  123. * OR
  124. * {
  125. * "type": "value-list",
  126. * "entries": ["New_MySQL_Database", "Existing_MySQL_Database", "Existing_PostgreSQL_Database", "Existing_Oracle_Database"],
  127. * "entry_labels": ["New MySQL Database", "Existing MySQL Database", "Existing PostgreSQL Database", "Existing Oracle Database"],
  128. * "entry_descriptions": ["d1", "d2", "d3", "d4"],
  129. * "entries_editable": "false",
  130. * "selection_cardinality": "1" // 0+, 1+, etc.
  131. * }
  132. * @property {object}
  133. */
  134. valueAttributes: DS.attr('object', {defaultValue: null}),
  135. /**
  136. * sub section to which belongs this property
  137. * @property {App.SubSection}
  138. */
  139. subSection: DS.belongsTo('App.SubSection'),
  140. /**
  141. * sub section tab to which belongs this property
  142. * @property {App.SubSectionTab}
  143. */
  144. subSectionTab: DS.belongsTo('App.SubSectionTab'),
  145. /******************************* UI properties ****************************************/
  146. /**
  147. * defines what kind of value this property contains
  148. * ex: string, digits, number, directories, custom
  149. * @property {string}
  150. */
  151. displayType: DS.attr('string', {defaultValue: 'string'}),
  152. /**
  153. * defines category name of property
  154. * used for advanced tab
  155. * @property {string}
  156. */
  157. category: DS.attr('string'),
  158. /**
  159. * config property value same as default
  160. * @property {string}
  161. */
  162. value: DS.attr('string'),
  163. /**
  164. * config property isFinal value same as recommendedIsFinal
  165. * @property {boolean}
  166. */
  167. isFinal: DS.attr('boolean', {defaultValue: false}),
  168. /**
  169. * @type {boolean}
  170. */
  171. index: DS.attr('number', {defaultValue: null}),
  172. /**
  173. * defines if the property can be overriden in the host config group
  174. * @type {boolean}
  175. */
  176. isOverridable: function() {
  177. var result = true;
  178. if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.overridable'))) {
  179. result = !!this.get('valueAttributes.overridable');
  180. }
  181. return result;
  182. }.property('valueAttributes.overridable'),
  183. /**
  184. * defines if the property is visible or hidden
  185. * @type {boolean}
  186. */
  187. isVisible: function() {
  188. var result = true;
  189. if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.visible'))) {
  190. result = !!this.get('valueAttributes.visible');
  191. }
  192. return result;
  193. }.property('valueAttributes.visible'),
  194. /**
  195. * defines if the value of property can be left empty or not
  196. * @type {boolean}
  197. */
  198. isRequired: function() {
  199. var result = true;
  200. if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.empty_value_valid'))) {
  201. result = !this.get('valueAttributes.empty_value_valid');
  202. }
  203. return result;
  204. }.property('valueAttributes.empty_value_valid'),
  205. /**
  206. * defines if the value of property can be reconfigured post-install
  207. * @type {boolean}
  208. */
  209. isReconfigurable: function() {
  210. var result = true;
  211. if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.editable_only_at_install'))) {
  212. result = !this.get('valueAttributes.editable_only_at_install');
  213. }
  214. return result;
  215. }.property('valueAttributes.editable_only_at_install'),
  216. /**
  217. * defines if the name of the property is visible or hidden
  218. * @type {boolean}
  219. */
  220. showLabel: function() {
  221. var result = true;
  222. if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.show_property_name'))) {
  223. result = !!this.get('valueAttributes.show_property_name');
  224. }
  225. return result;
  226. }.property('valueAttributes.show_property_name'),
  227. /**
  228. * defines if the property is editable or not
  229. * @type {boolean}
  230. */
  231. isEditable: function() {
  232. var result = true;
  233. if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.read_only'))) {
  234. result = !!this.get('valueAttributes.read_only');
  235. }
  236. return result;
  237. }.property('valueAttributes.read_only'),
  238. /**
  239. * defines if the property is editable or not
  240. * @type {boolean}
  241. */
  242. unit: function() {
  243. var result = '';
  244. if (this.get('valueAttributes') && !Em.empty(this.get('valueAttributes.unit'))) {
  245. result = this.get('valueAttributes.unit');
  246. }
  247. return result;
  248. }.property('valueAttributes.unit'),
  249. /**
  250. * Does config property has a valid value defined in the stack
  251. * @type {boolean}
  252. */
  253. isValueDefined: function() {
  254. return !Em.none(this.get('value'));
  255. }.property('id')
  256. });
  257. App.StackConfigProperty.FIXTURES = [];
  258. App.StackConfigValAttributesMap = {
  259. 'overridable': 'isOverridable' ,
  260. 'visible': 'isVisible' ,
  261. 'empty_value_valid':'isRequired' ,
  262. 'editable_only_at_install': 'isReconfigurable' ,
  263. 'show_property_name': 'showLabel',
  264. 'read_only': 'isEditable',
  265. 'ui_only_property': 'isRequiredByAgent'
  266. };