09-27-2022 09:50 PM
I have reviewed UCS programmability guide from DEVNET but no luck. Can you please help on the exact Python SDK / API to ' acknowledge & reboot a service profile ' after SP configuration change? ( for both UCS Central and Manager )
Regards,
Charles
10-12-2022 02:54 PM
Hi Charles! Thanks for submitting your question. UCSM has a feature that generates code in Python that is equivalent to actions taken in the UCSM user interface. This comes in handy when you would like to programmatically accomplish what you know how to do in the user interface. Here's what you can do to generate code to start a service profile in UCSM:
Covert the capture XML log file to Python:
from ucsmsdk.utils.converttopython import convert_to_ucs_python
convert_to_ucs_python(xml=True, literal_path="path_to_the_log_file_from_step_6_above")
convert_to_ucs_python returns the python code needed to perform the action recorded in the UI. The example below shows the outcome of the steps above and how code was generated to set a service profile's desired power state to on:
### Please review the generated cmdlets before deployment.
##### Start-Of-PythonScript #####
from ucsmsdk.mometa.ls.LsPower import LsPower
mo = LsPower(parent_mo_or_dn="org-root/org-da-compute/ls-HCI-1", state="admin-up")
handle.add_mo(mo, True)
handle.commit()
##### End-Of-PythonScript #####
### End of Convert-To-Python ###
Additional Resources:
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide