Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vCenter Alarm support #3516

Merged
merged 5 commits into from
Aug 9, 2024
Merged

Add vCenter Alarm support #3516

merged 5 commits into from
Aug 9, 2024

Conversation

dougm
Copy link
Member

@dougm dougm commented Aug 8, 2024

vcsim: add AlarmManager
govc: add alarm commands
api: add alarm package with helpers for AlarmManager and Alarms
govc: add event.post command
fix: govc: output Message field for 'EventEx' types

@dougm dougm force-pushed the alarms branch 3 times, most recently from fa9fd45 to e97164b Compare August 8, 2024 16:16
dougm added 3 commits August 8, 2024 12:30
EventEx will have an empty FullFormattedMessage field, as the event is not predefined in vCenter.
This command can be used to trigger alarms and test use of EventEx in general.
dilyar85
dilyar85 previously approved these changes Aug 9, 2024
Copy link
Member

@dilyar85 dilyar85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I built a govc locally from your change, but when I ran the alarm commands with $vm passed, I always get the following error:

$ govc alarms vm-lcm-izrm
govc: 2 objects at path "vm-lcm-izrm": [VirtualMachine:vm-159 VirtualMachine:vm-159]

I don't think this is specific to your change as the error message seems to be coming from the datacenter.go file here: https://github.com/vmware/govmomi/blob/main/govc/flags/datacenter.go#L177.

Other than that, the change LGTM. Thanks again for adding this support in all components!

govc/USAGE.md Show resolved Hide resolved
@dougm
Copy link
Member Author

dougm commented Aug 9, 2024

Thanks for reviewing and trying it out @dilyar85 !
I pushed an update so the alarms doc mentions to use an inventory path. Also changed the error message a bit:

% govc alarms vm-lcm-oyr0
govc: 2 objects match "vm-lcm-oyr0": [VirtualMachine:vm-174 VirtualMachine:vm-174] (unique inventory path required)

You can see with govc tree -l -p /, each vm shows up under the vm folder and under its host, those are the 2 matches found.

Since you're trying it out, you can see the alarms in action w/ the doc from create:

% export GOVC_SHOW_UNRELEASED=true
% govc alarm.create -n "My Alarm" -green my.alarm.success -yellow my.alarm.failure
% govc event.post -i my.alarm.failure vm/folder/vm-name
% govc alarms vm/folder/vm-name

@dilyar85
Copy link
Member

dilyar85 commented Aug 9, 2024

Thanks for reviewing and trying it out @dilyar85 ! I pushed an update so the alarms doc mentions to use an inventory path. Also changed the error message a bit:

% govc alarms vm-lcm-oyr0
govc: 2 objects match "vm-lcm-oyr0": [VirtualMachine:vm-174 VirtualMachine:vm-174] (unique inventory path required)

You can see with govc tree -l -p /, each vm shows up under the vm folder and under its host, those are the 2 matches found.

Since you're trying it out, you can see the alarms in action w/ the doc from create:

% export GOVC_SHOW_UNRELEASED=true
% govc alarm.create -n "My Alarm" -green my.alarm.success -yellow my.alarm.failure
% govc event.post -i my.alarm.failure vm/folder/vm-name
% govc alarms vm/folder/vm-name

Yep, it worked perfectly after specifying the VM inventory path:

$ govc alarm.create -n "My Alarm" -green my.alarm.success -yellow my.alarm.failure
$  govc event.post -i my.alarm.failure vm/Namespaces/vm-lcm-6hgu25/vm-lcm-oyr0
$ govc alarms vm/Namespaces/vm-lcm-6hgu25/vm-lcm-oyr0
Alarm Name  Object                 Severity  Triggered Time   Acknowledged Time  Acknowledged By
My Alarm    VirtualMachine:vm-174  Warning   Aug  9 16:35:49

Thanks for improving the error message as well!

Copy link
Member

@dilyar85 dilyar85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dougm dougm merged commit a22290f into vmware:main Aug 9, 2024
10 checks passed
@dougm dougm deleted the alarms branch August 9, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants