Skip to content

I created an alarm for vim.event.VmRemovedEvent, but not triggered #465

Open
@pengqiaojun

Description

@pengqiaojun

I created an alarm monitor the virtual machine is removed.Alarm is created successfully, but can not be triggered. And in the same way to create an alert to monitor the virtual machine is created,it will be triggered.How can I through the alarm to monitor the virtual machine to be deleted?
my code like this:
` service_instance = get_service_instance()
content = service_instance.content
folder = content.rootFolder
expression = vim.alarm.EventAlarmExpression(eventType=eventType, eventTypeId='vim.event.{0}'.format(str(eventType._wsdlName)), objectType=vim.VirtualMachine, status='yellow')

action = vim.alarm.AlarmTriggeringAction(
            action=vim.action.RunScriptAction(script='/bin/sh /opt/alarm.sh'),
            transitionSpecs=[vim.alarm.AlarmTriggeringAction.TransitionSpec(startState='green',finalState='yellow',repeats=False)],
            green2yellow=True, yellow2red=False, red2yellow=False, yellow2green=False)

setting = vim.alarm.AlarmSetting(toleranceRange=0, reportingFrequency=0)

spec = vim.alarm.AlarmSpec(name='alarm_to_smc_{0}'.format(name),
                            description='create alarms by python api: {0}'.format(name),
                            enabled = True, actionFrequency = 0,
                            expression = expression,
                            action = action,
                            setting = setting)

this_alarm = service_instance.content.alarmManager.CreateAlarm(entity=folder, spec=spec)

`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions