<?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: Automation Python script to send an email to receiver about new Approval Requests in HPE Morpheus Enterprise Software</title>
    <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/automation-python-script-to-send-an-email-to-receiver-about-new/m-p/7249642#M2816</link>
    <description>&lt;P&gt;That’s a great contribution &lt;A class="mention" href="https://community.hpe.com/u/cuong_duong"&gt;@Cuong_Duong&lt;/A&gt;. Please keep them coming!&lt;/P&gt;</description>
    <pubDate>Tue, 07 Nov 2023 17:36:23 GMT</pubDate>
    <dc:creator>Ollie-Phillips</dc:creator>
    <dc:date>2023-11-07T17:36:23Z</dc:date>
    <item>
      <title>Automation Python script to send an email to receiver about new Approval Requests</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/automation-python-script-to-send-an-email-to-receiver-about-new/m-p/7249641#M2815</link>
      <description>&lt;P&gt;Hi everyone, I want to share with you guys a Python script to send an email notification for the new approval requests by packaging this script into a task and scheduling it to run every minute (the condition to send email is when Status = “request” in Python code from API JSON result).&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;if any(approval.get(“status”) == “1 requested” for approval in approvals_data[“approvals”]):&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;/P&gt;&lt;DIV class="lightbox-wrapper"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="2"&gt;&lt;img src="https://community.hpe.com/t5/image/serverpage/image-id/150462iFCD11BEF1E66DD00/image-size/large?v=v2&amp;amp;px=2000" role="button" title="3ed8309061b9fda94225c75e9987183ff8c519f1.png" alt="3ed8309061b9fda94225c75e9987183ff8c519f1.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;You can go to my Github to pull code:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://github.com/tzquocuong918/Morpheus-Alert-Mail/tree/main/Morpheus-API-Code/Approval-Email" rel="noopener nofollow ugc"&gt;Python Approval List Alert&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Don’t forget to change these lines:&lt;/P&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE style="background : #f0f1f2;"&gt;smtp_server = "smtp.elasticemail.com"  #SMTP Server
smtp_port = 2525  #SMTP Server Port
smtp_username = "cuong.dq@csc-jsc.com"   #SMTP Username
smtp_password = "REPLACE_ME"   #SMTP Password
sender_email = "REPLACE_ME"
recipient_email = "REPLACE_ME"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;url = “&lt;A href="https://csc-morpheus.anycloud.vn/api/approvals" rel="noopener nofollow ugc"&gt;https://csc-morpheus.anycloud.vn/api/approvals&lt;/A&gt;”&lt;/P&gt;
&lt;P&gt;headers = {&lt;BR /&gt;
“accept”: “application/json”,&lt;BR /&gt;
“authorization”: “Bearer CHANGE_ME”&lt;BR /&gt;
}&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;To run it on schedule on Morpheus, follow these steps:&lt;/STRONG&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Package Python script into a task&lt;/LI&gt;
&lt;LI&gt;To create Execute Scheduling, access Library → Automation → Excute Scheduling → Add run minute&lt;/LI&gt;
&lt;LI&gt;To execute  Execute Scheduling, access Provisioning → Jobs → Add → Select Job (Python Script)&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;STRONG&gt;The result:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;DIV class="lightbox-wrapper"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Screenshot 2023-11-08 at 11.11.48"&gt;&lt;img src="https://community.hpe.com/t5/image/serverpage/image-id/150003i0C9AA9B46F7B0E08/image-size/large?v=v2&amp;amp;px=2000" role="button" title="d4057c35ce9468ed8b4702be7aa11371e9ae6bc3.png" alt="d4057c35ce9468ed8b4702be7aa11371e9ae6bc3.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 08:46:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/automation-python-script-to-send-an-email-to-receiver-about-new/m-p/7249641#M2815</guid>
      <dc:creator>CuongDuong</dc:creator>
      <dc:date>2023-11-07T08:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Automation Python script to send an email to receiver about new Approval Requests</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/automation-python-script-to-send-an-email-to-receiver-about-new/m-p/7249642#M2816</link>
      <description>&lt;P&gt;That’s a great contribution &lt;A class="mention" href="https://community.hpe.com/u/cuong_duong"&gt;@Cuong_Duong&lt;/A&gt;. Please keep them coming!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 17:36:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/automation-python-script-to-send-an-email-to-receiver-about-new/m-p/7249642#M2816</guid>
      <dc:creator>Ollie-Phillips</dc:creator>
      <dc:date>2023-11-07T17:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Automation Python script to send an email to receiver about new Approval Requests</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/automation-python-script-to-send-an-email-to-receiver-about-new/m-p/7249643#M2817</link>
      <description>&lt;P&gt;Thats really nice script.&lt;/P&gt;
&lt;P&gt;Personally I really think that should be incorporated into product rather then scheduling script to run on schedule basis (this is real gap on Morpheus side).&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 13:50:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/automation-python-script-to-send-an-email-to-receiver-about-new/m-p/7249643#M2817</guid>
      <dc:creator />
      <dc:date>2023-11-09T13:50:55Z</dc:date>
    </item>
  </channel>
</rss>

