unable to get from attribute from alarm event
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 763
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I need to retrieve alarm event from host, but i can't access to the "from" attribute.
Alarm event example :
`(vim.event.AlarmStatusChangedEvent) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = xxxxxx,
chainId = xxxxx,
createdTime = 20xx-xx-xxTxx:xx:xx.864999Z,
userName = '',
datacenter = (vim.event.DatacenterEventArgument) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
name = 'xxxxxx',
datacenter = 'vim.Datacenter:datacenter-xxx'
},
computeResource = (vim.event.ComputeResourceEventArgument) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
name = 'Cluster P-SciMotors',
computeResource = 'vim.ClusterComputeResource:xxxxx'
},
host = (vim.event.HostEventArgument) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
name = 'xxxxxxxxxxxxx',
host = 'vim.HostSystem:xxxxx'
},
vm = <unset>,
ds = <unset>,
net = <unset>,
dvs = <unset>,
fullFormattedMessage = "Alarm 'Host memory usage' on xxxx from Green to Yellow",
changeTag = <unset>,
alarm = (vim.event.AlarmEventArgument) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
name = 'Host memory usage',
alarm = 'vim.alarm.Alarm:alarm-4'
},
source = (vim.event.ManagedEntityEventArgument) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
name = 'Datacenters',
entity = 'xxxxxxxx'
},
entity = (vim.event.ManagedEntityEventArgument) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
name = 'xxxxxxxxxxx',
entity = 'xxxxxx'
},
from = 'green',
to = 'yellow'
}`
my code to retrieve alarm's info :
for alarm in event_res:
if hasattr(alarm, "alarm"):
print(alarm.from)
result :
File "C:\xxxxx\xxxxx\xxxxxx\xxxx-xxx\test.py", line 125
print(alarm.from)
^
SyntaxError: invalid syntax
"from" is a reserved keyword in python
thx for reading
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the event_res loop in test.py around the reported line 125 and inspect how the alarm event exposes its fields. Verify the Python syntax and attribute access for the event's from value, then confirm the retrieved value matches the alarm event shown in the issue without raising a SyntaxError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100