- Community Home
- >
- Software
- >
- HPE Morpheus Software
- >
- HPE Morpheus Enterprise Software
- >
- Re: Automation Python script to send an email to r...
Categories
Company
Local Language
Forums
Discussions
- Integrity Servers
- Server Clustering
- HPE NonStop Compute
- HPE Apollo Systems
- High Performance Computing
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp Software
Knowledge Base
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 12:46 AM
11-07-2023 12:46 AM
Automation Python script to send an email to receiver about new Approval Requests
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).
if any(approval.get(“status”) == “1 requested” for approval in approvals_data[“approvals”]):
You can go to my Github to pull code:
Don’t forget to change these lines:
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"
and
url = “https://csc-morpheus.anycloud.vn/api/approvals”
headers = {
“accept”: “application/json”,
“authorization”: “Bearer CHANGE_ME”
}
To run it on schedule on Morpheus, follow these steps:
- Package Python script into a task
- To create Execute Scheduling, access Library → Automation → Excute Scheduling → Add run minute
- To execute Execute Scheduling, access Provisioning → Jobs → Add → Select Job (Python Script)
The result:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 09:36 AM
11-07-2023 09:36 AM
Re: Automation Python script to send an email to receiver about new Approval Requests
That’s a great contribution @Cuong_Duong. Please keep them coming!
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 05:50 AM
11-09-2023 05:50 AM
Re: Automation Python script to send an email to receiver about new Approval Requests
Thats really nice script.
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).