use of com.vmware.ops.api.model.symptomdefinition.SymptomState in project flowgate by vmware.
the class AlertClient method createEnvrionmentSymptom.
protected SymptomDefinition createEnvrionmentSymptom(String name, int waitCycles, int cancleCycles, Criticality serverity, String conditionKey, CompareOperator conditionOperator, String value) {
SymptomDefinitionsClient sd = getClient().symptomDefinitionsClient();
SymptomDefinition aSymptomDefinition = new SymptomDefinition();
aSymptomDefinition.setName(name);
aSymptomDefinition.setAdapterKindKey(VROConsts.ADPTERKIND_VMARE_KEY);
aSymptomDefinition.setResourceKindKey(VROConsts.RESOURCEKIND_HOSTSYSTEM_KEY);
aSymptomDefinition.setWaitCycles(waitCycles);
aSymptomDefinition.setCancelCycles(cancleCycles);
SymptomState symptomState = new SymptomState();
symptomState.setSeverity(serverity);
HTCondition condition = new HTCondition();
condition.setKey(conditionKey);
condition.setOperator(conditionOperator);
// must set threshold type to STATKEY and set the TargetKey
condition.setThresholdType(ThresholdType.STATIC);
// condition.setTargetKey("cpu|availablemhz");
condition.setValue(value);
// condition.setValueType(Condition.ValueTypeEnum.NUMERIC); // necessary only when value is a string
condition.setInstanced(false);
symptomState.setCondition(condition);
aSymptomDefinition.setState(symptomState);
aSymptomDefinition = sd.createSymptomDefinition(aSymptomDefinition);
SymptomDefinitionQuery sdq = new SymptomDefinitionQuery();
sdq.setAdapterKind(VROConsts.ADPTERKIND_VMARE_KEY);
sdq.setResourceKind(VROConsts.RESOURCEKIND_HOSTSYSTEM_KEY);
sdq.setId(new String[] { aSymptomDefinition.getId() });
SymptomDefinitions allSymptoms = sd.querySymptomDefinitions(sdq, null);
return allSymptoms.getSymptomDefinitions().get(0);
}
Aggregations