Skip to content

Commit

Permalink
Merge "Closes-Bug:#1602364 Incorporated the alarm schema changes in U…
Browse files Browse the repository at this point in the history
…I config alarms and monitor alarms" into R3.1
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Aug 5, 2016
2 parents d187a50 + e6c34c3 commit 5a0946b
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 49 deletions.
18 changes: 16 additions & 2 deletions webroot/common/api/infra.common.api.js
Expand Up @@ -1061,13 +1061,27 @@ function sendServerRetrieveError (res)
commonUtils.handleJSONResponse(error, res, null);
}
function getUVEKeys (req, res, appData) {
var url = '/analytics/uves';
var url = '/analytics/uve-types';
var isProject = req.query['isProject'],
globalUVEKeys = [],
projectUVEKeys = [],
uveKeys = [];
opApiServer.apiGet(url, appData,
function(err, data) {
if (err || (null == data)) {
commonUtils.handleJSONResponse(err, res, null);
} else {
commonUtils.handleJSONResponse(null, res, data);
for(var key in data) {
if (data[key] != null) {
var uveObj = data[key];
globalUVEKeys.push(key);
if (uveObj['global_system_object'] == false) {
projectUVEKeys.push(key);
}
}
}
uveKeys = (isProject === 'true') ? projectUVEKeys : globalUVEKeys;
commonUtils.handleJSONResponse(null, res, uveKeys);
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions webroot/common/ui/js/controller.labels.js
Expand Up @@ -1001,9 +1001,9 @@ define([
this.TITLE_CREATE_ALARM_RULE = 'Create Alarm Rule';
this.TXT_CONFIG_ALARM_RULE = 'rule';
this.CONFIG_ALARM_TEXT_MAP = {
2: 'Critical',
3: 'Major',
4: 'Minor'
0: 'Critical',
1: 'Major',
2: 'Minor'
};

//Config DB Labels - Start
Expand Down
6 changes: 3 additions & 3 deletions webroot/config/alarm/common/ui/js/ConfigAlarmFormatters.js
Expand Up @@ -21,7 +21,7 @@
var template = contrail.getTemplate4Id(ctwc.CONFIG_ALARM_SEVERITY_TEMPLATE);
if (ctwl.CONFIG_ALARM_TEXT_MAP[getValueByJsonPath(dc, 'alarm_severity', null)] != null) {
var color = 'red';
if (dc['alarm_severity'] == '4') {
if (dc['alarm_severity'] == '2') {
color = 'orange';
}
return template({
Expand Down Expand Up @@ -71,8 +71,8 @@
var returnString = "";
returnString += alarmObj['operand1'] + " ";
returnString += '<span class="rule-format">'+ alarmObj['operation'] +'</span>';
returnString += " "+alarmObj['operand2'];
if (ifNull(alarmObj['vars'], []).length) {
returnString += " "+getValueByJsonPath(alarmObj,'operand2;uve_attribute',getValueByJsonPath(alarmObj,'operand2;json_value'));
if (ifNull(alarmObj['variables'], []).length) {
returnString += ", <span class='rule-format'>variables</span> " +alarmObj['variables'];
}
return returnString;
Expand Down
19 changes: 16 additions & 3 deletions webroot/config/alarm/common/ui/js/models/AlarmModel.js
Expand Up @@ -14,7 +14,7 @@ define([
defaultConfig: {
name: null,
display_name: null,
alarm_severity: 4, //Default minor severity
alarm_severity: 2, //Default minor severity
uve_keys: {
uve_key: []
},
Expand Down Expand Up @@ -81,10 +81,23 @@ define([
} else if (vars == "") {
vars = [];
}
var operation = andRuleObj.operation()();
operationArr = operation.split(cowc.DROPDOWN_VALUE_SEPARATOR),
operand2 = andRuleObj.operand2()(),
operand2Obj = {};
if (operationArr[1] == 'uve_attribute') {
operand2Obj = {
uve_attribute: operand2
}
} else if (operationArr[1] == 'json_value') {
operand2Obj = {
json_value: operand2
}
}
andRulePostObjArr.push({
operand1: andRuleObj.operand1()(),
operand2: andRuleObj.operand2()(),
operation: andRuleObj.operation()(),
operand2: operand2Obj,
operation: operationArr[0],
variables: vars
});
}
Expand Down
2 changes: 1 addition & 1 deletion webroot/config/alarm/common/ui/js/models/AlarmRuleModel.js
Expand Up @@ -11,7 +11,7 @@ define([
var AlarmRuleModel = ContrailModel.extend({

defaultConfig: {
operation: '==',
operation: '==' + cowc.DROPDOWN_VALUE_SEPARATOR + 'uve_attribute',
variables: [],
operand1: null,
operand2: null,
Expand Down
25 changes: 19 additions & 6 deletions webroot/config/alarm/common/ui/js/models/AlarmRuleOrModel.js
Expand Up @@ -45,10 +45,16 @@ define([
if (andRuleListLen > 0) {
for (var i = 0 ; i < andRuleListLen; i ++) {
var ruleObj = andRuleList[i];
var operand2Key = 'uve_attribute';
if (getValueByJsonPath(ruleObj, 'operand2;json_value') != null) {
operand2Key = 'json_value';
}
var operand2 = getValueByJsonPath(ruleObj, 'operand2;'+operand2Key);
var operation = ruleObj['operation'] + cowc.DROPDOWN_VALUE_SEPARATOR + operand2Key,
andRuleObj = {
operand1: ruleObj['operand1'],
operand2: ruleObj['operand2'],
operation: ruleObj['operation'],
operand2: operand2,
operation: operation,
variables: ruleObj['variables'],
};
andRuleModel = new AlarmRuleModel(self, andRuleObj);
Expand Down Expand Up @@ -98,18 +104,25 @@ define([
operand2 = andRuleObj.operand2(),
operation = andRuleObj.operation(),
vars = andRuleObj.variables(),
andRuleStr = '';
andRuleStr = '', operationStr = '';
operand1 = contrail.checkIfFunction(operand1) ? operand1() : operand1;
operand2 = contrail.checkIfFunction(operand2) ? operand2() : operand2;
operation = contrail.checkIfFunction(operation) ? operation() : operation;
vars = contrail.checkIfFunction(vars) ? vars() : vars;
operationArr = operation.split(cowc.DROPDOWN_VALUE_SEPARATOR);
if (operationArr[1] == 'uve_attribute') {
operationStr += 'UVE Key';
} else if (operationArr[1] == 'json_value') {
operationStr += 'Value';
}
operationStr += " "+operationArr[0];
if (operand1 != null && operand2 != null && operation != null ) {
andRuleStr += operand1 + ' ' + operation + ' ' + operand2;
andRuleStr += operand1 + ' ' + operationStr + ' ' + operand2;
if (vars != null){
if (typeof vars == 'string') {
andRuleStr += ', vars ' + vars;
andRuleStr += ', variables ' + vars;
} else if (typeof vars == 'object' && vars.length > 0){
andRuleStr += ', vars ' + vars.join(',');
andRuleStr += ', variables ' + vars.join(',');
}
}
andRuleArray.push(andRuleStr);
Expand Down

0 comments on commit 5a0946b

Please sign in to comment.