Search in sources :

Example 1 with SymptomDefinitions

use of com.vmware.ops.api.model.symptomdefinition.SymptomDefinition.SymptomDefinitions 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);
}
Also used : SymptomState(com.vmware.ops.api.model.symptomdefinition.SymptomState) SymptomDefinitionQuery(com.vmware.ops.api.model.symptomdefinition.SymptomDefinitionQuery) SymptomDefinition(com.vmware.ops.api.model.symptomdefinition.SymptomDefinition) HTCondition(com.vmware.ops.api.model.symptomdefinition.HTCondition) SymptomDefinitionsClient(com.vmware.ops.api.client.controllers.SymptomDefinitionsClient) SymptomDefinitions(com.vmware.ops.api.model.symptomdefinition.SymptomDefinition.SymptomDefinitions)

Aggregations

SymptomDefinitionsClient (com.vmware.ops.api.client.controllers.SymptomDefinitionsClient)1 HTCondition (com.vmware.ops.api.model.symptomdefinition.HTCondition)1 SymptomDefinition (com.vmware.ops.api.model.symptomdefinition.SymptomDefinition)1 SymptomDefinitions (com.vmware.ops.api.model.symptomdefinition.SymptomDefinition.SymptomDefinitions)1 SymptomDefinitionQuery (com.vmware.ops.api.model.symptomdefinition.SymptomDefinitionQuery)1 SymptomState (com.vmware.ops.api.model.symptomdefinition.SymptomState)1