forked from stfc/st2-cloud-pack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
671b76b
commit 486b96f
Showing
2 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from openstack_query import ServerQuery | ||
from email_api.emailer import Emailer | ||
from structs.email.email_params import EmailParams | ||
from structs.email.email_template_details import EmailTemplateDetails | ||
from structs.email.smtp_account import SMTPAccount | ||
|
||
sq = ServerQuery() | ||
sq.select(["name", "id", "status", "updated_at"]) | ||
sq.where(preset="younger_than", prop="updated_at", days=60) | ||
sq.where(preset="equal_to", prop="status", value="ACTIVE") | ||
sq.sort_by([("server_name", "ascending")]) | ||
sq.run("prod-vgc59244", as_admin=False, all_projects=False) | ||
sq.append_from("projects", cloud_account="prod", props=["project_id", "project_name"]) | ||
|
||
uq = sq.then("users") | ||
uq.group_by("user_email") | ||
uq.run("prod") | ||
|
||
print(uq.to_string()) | ||
# uq.to_csv("./") | ||
|
||
Emailer( | ||
SMTPAccount( | ||
username="", | ||
password="", | ||
smtp_auth=False, | ||
server="mail.gridpp.rl.ac.uk", | ||
port=465, | ||
secure=False, | ||
) | ||
).send_emails( | ||
[ | ||
EmailParams( | ||
subject="test email", | ||
email_to=["[email protected]"], | ||
email_from="[email protected]", | ||
email_templates=[ | ||
EmailTemplateDetails( | ||
template_name="test", | ||
template_params={ | ||
"username": "anish", | ||
"test_message": "test that email works", | ||
}, | ||
), | ||
EmailTemplateDetails(template_name="footer"), | ||
], | ||
) | ||
] | ||
) |