<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to use Python SDK / API to acknowledge and reboot service prof in Unified Computing System (UCS)</title>
    <link>https://community.cisco.com/t5/unified-computing-system-ucs/how-to-use-python-sdk-api-to-acknowledge-and-reboot-service/m-p/4702271#M50</link>
    <description>&lt;P&gt;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:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Log into UCSM (you can also use the &lt;A href="https://community.cisco.com/t5/unified-computing-system-knowledge-base/ucs-platform-emulator-downloads-ucspe-4-2-2a-ucspe-4-1-2c/ta-p/3648177" target="_self"&gt;UCSM Platform Emulator&lt;/A&gt; if want to try it with an endpoint that is not in production).&lt;/LI&gt;
&lt;LI&gt;Simultaneously press the keys &amp;lt;cntrl&amp;gt;&amp;lt;alt&amp;gt;&amp;lt;q&amp;gt; (substitute the &amp;lt;alt&amp;gt; key with &amp;lt;option&amp;gt; on a mac)&lt;/LI&gt;
&lt;LI&gt;You'll see Record XML appear at the top of the UCSM UI. Click Record XML.&lt;/LI&gt;
&lt;LI&gt;Perform the action in the UCSM UI you wish to convert to generate code for.&lt;/LI&gt;
&lt;LI&gt;Click Stop XML Recording when you complete your tasks in the UCSM UI&lt;/LI&gt;
&lt;LI&gt;Save the newly generated XML log file.&lt;/LI&gt;
&lt;LI&gt;Execute the code below to convert the XML log file to Python code.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Covert the capture XML log file to Python:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;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")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;EM&gt;convert_to_ucs_python&lt;/EM&gt; 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:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;### 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 ###&lt;/LI-CODE&gt;
&lt;P&gt;Additional Resources:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;There's a learning lab named&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://developer.cisco.com/learning/tracks/ucs-compute-prog/ucs-python-sdk-introduction/" target="_self"&gt;UCS Python SDK Introduction&lt;/A&gt; that covers the code generator towards the end of the Introduction to UCS Python SDK Part III&lt;/SPAN&gt;&amp;nbsp;lab.&lt;/LI&gt;
&lt;LI&gt;dCloud has a &lt;A href="https://dcloud2-sjc.cisco.com/content/demo/4158" target="_self"&gt;Cisco UCS Programmability and Automation Lab v1&lt;/A&gt; covering similar steps.&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Wed, 12 Oct 2022 21:54:33 GMT</pubDate>
    <dc:creator>delgadm</dc:creator>
    <dc:date>2022-10-12T21:54:33Z</dc:date>
    <item>
      <title>How to use Python SDK / API to acknowledge and reboot service profile</title>
      <link>https://community.cisco.com/t5/unified-computing-system-ucs/how-to-use-python-sdk-api-to-acknowledge-and-reboot-service/m-p/4695161#M49</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have reviewed UCS programmability guide from DEVNET but no luck. Can you please help on the exact Python SDK / API to ' acknowledge &amp;amp; reboot a service profile ' after SP configuration change? ( for both UCS Central and Manager ) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Charles&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 04:50:23 GMT</pubDate>
      <guid>https://community.cisco.com/t5/unified-computing-system-ucs/how-to-use-python-sdk-api-to-acknowledge-and-reboot-service/m-p/4695161#M49</guid>
      <dc:creator>cshao</dc:creator>
      <dc:date>2022-09-28T04:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Python SDK / API to acknowledge and reboot service prof</title>
      <link>https://community.cisco.com/t5/unified-computing-system-ucs/how-to-use-python-sdk-api-to-acknowledge-and-reboot-service/m-p/4702271#M50</link>
      <description>&lt;P&gt;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:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Log into UCSM (you can also use the &lt;A href="https://community.cisco.com/t5/unified-computing-system-knowledge-base/ucs-platform-emulator-downloads-ucspe-4-2-2a-ucspe-4-1-2c/ta-p/3648177" target="_self"&gt;UCSM Platform Emulator&lt;/A&gt; if want to try it with an endpoint that is not in production).&lt;/LI&gt;
&lt;LI&gt;Simultaneously press the keys &amp;lt;cntrl&amp;gt;&amp;lt;alt&amp;gt;&amp;lt;q&amp;gt; (substitute the &amp;lt;alt&amp;gt; key with &amp;lt;option&amp;gt; on a mac)&lt;/LI&gt;
&lt;LI&gt;You'll see Record XML appear at the top of the UCSM UI. Click Record XML.&lt;/LI&gt;
&lt;LI&gt;Perform the action in the UCSM UI you wish to convert to generate code for.&lt;/LI&gt;
&lt;LI&gt;Click Stop XML Recording when you complete your tasks in the UCSM UI&lt;/LI&gt;
&lt;LI&gt;Save the newly generated XML log file.&lt;/LI&gt;
&lt;LI&gt;Execute the code below to convert the XML log file to Python code.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Covert the capture XML log file to Python:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;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")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;EM&gt;convert_to_ucs_python&lt;/EM&gt; 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:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;### 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 ###&lt;/LI-CODE&gt;
&lt;P&gt;Additional Resources:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;There's a learning lab named&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://developer.cisco.com/learning/tracks/ucs-compute-prog/ucs-python-sdk-introduction/" target="_self"&gt;UCS Python SDK Introduction&lt;/A&gt; that covers the code generator towards the end of the Introduction to UCS Python SDK Part III&lt;/SPAN&gt;&amp;nbsp;lab.&lt;/LI&gt;
&lt;LI&gt;dCloud has a &lt;A href="https://dcloud2-sjc.cisco.com/content/demo/4158" target="_self"&gt;Cisco UCS Programmability and Automation Lab v1&lt;/A&gt; covering similar steps.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 12 Oct 2022 21:54:33 GMT</pubDate>
      <guid>https://community.cisco.com/t5/unified-computing-system-ucs/how-to-use-python-sdk-api-to-acknowledge-and-reboot-service/m-p/4702271#M50</guid>
      <dc:creator>delgadm</dc:creator>
      <dc:date>2022-10-12T21:54:33Z</dc:date>
    </item>
  </channel>
</rss>

