| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301 |
1
1
1
2
2
2
2
2
2
2
2
19
19
9
19
1
1
| 'use strict';
;require.register("models/configs/stack_config_property", function (exports, require, module) {
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var App = require('app');
//TODO delete this file soon
App.StackConfigProperty = DS.Model.extend({
/**
* id is consist of property <code>name<code>+<code>fileName<code>
*/
id: DS.attr('string'),
/**
* name of property that is taken from stack
* @property {string}
*/
name: DS.attr('string'),
/**
* display name of property that is taken from ui or
* if UI has no info about property this can be formatted or plain name of property
* @property {string}
*/
displayName: DS.attr('string'),
/**
* filename of property that is taken from stack
* ex: "hdfs-site.xml"
* @property {string}
*/
fileName: DS.attr('string'),
/**
* same as fileName
* @property {string}
*/
filename: Em.computed.alias('fileName'),
/**
* description of config property meaning
* @property {string}
*/
description: DS.attr('string'),
/**
* defaultValue value of property is taken from stack before cluster is created
* after cluster created is taken from cluster properties value
* @property {string}
*/
recommendedValue: DS.attr('string'),
/**
* defines if property support usage <code>isFinal<code> flag
* @property {boolean}
*/
supportsFinal: DS.attr('boolean', { defaultValue: true }),
/**
* defines the recommended value of <code>isFinal<code> value
* @property {boolean}
*/
recommendedIsFinal: DS.attr('boolean', { defaultValue: false }),
/**
* type of property
* @property {string[]}
*/
type: DS.attr('array', { defaultValue: [] }),
/**
* service name
* @property {string}
*/
serviceName: DS.attr('string', { defaultValue: 'MISC' }),
/**
* stack name
* @property {string}
*/
stackName: DS.attr('string'),
/**
* stack version
* @property {string}
*/
stackVersion: DS.attr('string'),
/**
* describe widget details
* @property {object}
*/
widget: DS.attr('object', { defaultValue: null }),
/**
* widget type
* @property {string}
*/
widgetType: DS.attr('string', { defaultValue: null }),
/**
* this property contains array of properties which value
* is dependent from current property
* @property {array}
*/
propertyDependedBy: DS.attr('array', { defaultValue: [] }),
/**
* this property contains list of file type and name of properties
* which values depends on current property
* @property {object[]}
*/
propertyDependsOn: DS.attr('array', { defaultValue: [] }),
/**
* info for displaying property
* example:
* {
* "type": "value-list",
* "entries": ["true", "false"],
* "entry_labels": ["Active", "Inactive"],
* "entries_editable": "false",
* "selection_cardinality": "1"
* },
* OR
* {
* "type": "int",
* "minimum": "512",
* "maximum": "10240",
* "unit": "MB"
* },
* OR
* {
* "type": "value-list",
* "entries": ["New_MySQL_Database", "Existing_MySQL_Database", "Existing_PostgreSQL_Database", "Existing_Oracle_Database"],
* "entry_labels": ["New MySQL Database", "Existing MySQL Database", "Existing PostgreSQL Database", "Existing Oracle Database"],
* "entry_descriptions": ["d1", "d2", "d3", "d4"],
* "entries_editable": "false",
* "selection_cardinality": "1" // 0+, 1+, etc.
* }
* @property {object}
*/
valueAttributes: DS.attr('object', { defaultValue: null }),
/**
* sub section to which belongs this property
* @property {App.SubSection}
*/
subSection: DS.belongsTo('App.SubSection'),
/**
* sub section tab to which belongs this property
* @property {App.SubSectionTab}
*/
subSectionTab: DS.belongsTo('App.SubSectionTab'),
/******************************* UI properties ****************************************/
/**
* if property should be saved to server
* @property {boolean}
*/
isRequiredByAgent: DS.attr('boolean', { defaultValue: true }),
/**
* defines category name of property
* used for advanced tab
* @property {string}
*/
category: DS.attr('string'),
/**
* config property value same as default
* @property {string}
*/
value: DS.attr('string'),
/**
* config property isFinal value same as recommendedIsFinal
* @property {boolean}
*/
isFinal: DS.attr('boolean', { defaultValue: false }),
/**
* @type {boolean}
*/
index: DS.attr('number', { defaultValue: null }),
/**
* defines if property is listed on some default config theme
* @type {boolean}
*/
isInDefaultTheme: DS.attr('boolean', { defaultValue: false }),
/**
* defines what kind of value this property contains
* ex: string, digits, number, directories, custom
* @property {string}
*/
displayType: function () {
return this.getAttribute('type', 'string');
}.property('valueAttributes.type'),
/**
* defines if the property can be overriden in the host config group
* @type {boolean}
*/
isOverridable: function () {
return this.getAttribute('overridable', true);
}.property('valueAttributes.overridable'),
/**
* defines if the property is visible or hidden
* @type {boolean}
*/
isVisible: function () {
return this.getAttribute('visible', true);
}.property('valueAttributes.visible'),
/**
* defines if the value of property can be left empty or not
* @type {boolean}
*/
isRequired: function () {
return !this.getAttribute('empty_value_valid', false);
}.property('valueAttributes.empty_value_valid'),
/**
* defines if the value of property can be reconfigured post-install
* @type {boolean}
*/
isReconfigurable: function () {
return !this.getAttribute('editable_only_at_install', false);
}.property('valueAttributes.editable_only_at_install'),
/**
* defines if the name of the property is visible or hidden
* @type {boolean}
*/
showLabel: function () {
return this.getAttribute('show_property_name', true);
}.property('valueAttributes.show_property_name'),
/**
* defines if the property is editable or not
* @type {boolean}
*/
isEditable: function () {
return this.getAttribute('read_only', true);
}.property('valueAttributes.read_only'),
/**
* defines if the property is editable or not
* @type {boolean}
*/
unit: function () {
return this.getAttribute('unit', '');
}.property('valueAttributes.unit'),
/**
*
* @param propertyName
* @param defaultValue
* @returns {string}
*/
getAttribute: function getAttribute(propertyName, defaultValue) {
var result = defaultValue;
if (!Em.empty(this.get('valueAttributes.' + propertyName))) {
result = this.get('valueAttributes.' + propertyName);
}
return result;
}
});
App.StackConfigProperty.FIXTURES = [];
App.StackConfigValAttributesMap = {
'overridable': 'isOverridable',
'visible': 'isVisible',
'empty_value_valid': 'isRequired',
'editable_only_at_install': 'isReconfigurable',
'show_property_name': 'showLabel',
'read_only': 'isEditable',
'ui_only_property': 'isRequiredByAgent'
};
}); |