Polling for a specific event ucsmsdk.
Optional poll mode is added to waitforevent API
The below code will wait for the usr_lbl
property of the service profile org-root/ls-demo-sp
to change to demo_label
. It will poll the server every poll_sec=10 here. It will timeout after 600 seconds.
wait_for_event
will keep the script alive until (i) either the condition is met or (ii) timeout is triggered
from ucsmsdk.ucshandle import UcsHandle
def usr_label_changed(mce):
print(mce.mo.usr_label)
handle.logout()
handle = UcsHandle("192.168.1.1", "username", "password")
handle.login()
sp_mo = handle.query_dn("org-root/ls-demo-sp")
handle.wait_for_event(
mo=sp_mo,
prop="usr_lbl",
value="demo_label",
cb=usr_label_changed,
timeout=600,
poll_sec=10
)