I am using vCO 5 with the vCenter plugin 5. I was able to successfully create a custom event alarm on a VM. However, when the event is fired, the status of the VM does not change. Any suggestions would be much apreciated.
The code for creating the alarm is:
var exp = new VcEventAlarmExpression();
exp.eventType = "com.vmware.vim.GeneralUserEvent";
exp.eventTypeId = "com.vmware.vim.GeneralUserEvent";
exp.objectType = "VcVirtualMachine";
exp.status = VcManagedEntityStatus.red;
var spec = new VcAlarmSpec();
spec.name = "Alarm Name";
spec.description = "Alarm Message";
spec.enabled = true;
spec.expression = exp;
var mgdEntity = sdk.searchIndex.findByIp(null, vmIpAddress, true);
var alarm = alarmMgr.createAlarm(mgdEntity, spec);
The event is fired using the following code:
var sdk = vcVM.sdkConnection;
var eventMgr = sdk.eventManager;
var mgdEntity = sdk.searchIndex.findByIp(null, vmIpAddress, true);
eventMgr.logUserEvent(mgdEntity, "My Error Message");