Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
45f35f8
Adding notif email generation and sending to the iapi
jacob6838 Jan 6, 2026
c8cbeeb
Adding notification email examples
jacob6838 Jan 6, 2026
3d068d4
Adding iapi email controller
jacob6838 Jan 6, 2026
169105e
Fixing EmailServiceTest
jacob6838 Jan 9, 2026
6987b60
Update EmailController.java
jacob6838 Jan 9, 2026
4d4fce5
Update EmailServiceTest.java
jacob6838 Jan 9, 2026
1cb6ae9
Fixing broken config property refs
jacob6838 Jan 9, 2026
8361e8e
Updating email generator comments, colors, and content
jacob6838 Jan 14, 2026
d4deef4
Updating default iapi env vars to avoid localhost
jacob6838 Jan 14, 2026
b5411d8
Update EmailRecipient.java
jacob6838 Jan 14, 2026
9eebbe7
Adding email frequency to tables and queries
jacob6838 Jan 14, 2026
4b79219
Update launch.json
jacob6838 Jan 14, 2026
648b367
Improving getCombinedResponseEntity to handle partial failures
jacob6838 Jan 14, 2026
f748fb6
Removing secure env vars from application.yaml
jacob6838 Jan 15, 2026
06338b1
Renaming email template to email_template.html
jacob6838 Jan 15, 2026
9c89f37
Removing duplicate dependency
jacob6838 Jan 15, 2026
c7676b9
Update services/intersection-api/api/src/main/java/us/dot/its/jpo/ode…
jacob6838 Jan 15, 2026
0a3330b
Handling unsubscribe URL generation errors
jacob6838 Jan 15, 2026
84c8cbe
Merge branch 'intersection-api-email-generation-1' of https://github.…
jacob6838 Jan 15, 2026
f1e79bc
Removing unused methods
jacob6838 Jan 15, 2026
f00d7f2
Cleaning up email generation code
jacob6838 Jan 15, 2026
6825d8d
Writing email provider tests
jacob6838 Jan 15, 2026
791aa48
Merge branch 'develop' into intersection-api-email-generation-1
jacob6838 Jan 19, 2026
6462be9
Adding sql update script
jacob6838 Jan 19, 2026
4c75d2a
Update email_subscription_type_update.sql
jacob6838 Jan 19, 2026
249252e
Merge branch 'develop' into intersection-api-email-generation-1
jacob6838 Jan 22, 2026
7f116b1
SUpporting authenticated SMTP server
jacob6838 Jan 22, 2026
46f3a6d
Merge remote-tracking branch 'origin/develop' into intersection-api-e…
jacob6838 Feb 2, 2026
0ec11f6
Regenerating email postgres JPA objects
jacob6838 Feb 2, 2026
464672c
Working email sending with JPA repositories
jacob6838 Feb 2, 2026
ee3416a
Merge remote-tracking branch 'origin/develop' into intersection-api-e…
jacob6838 Feb 9, 2026
17151f1
Temporarily force enabling emailer
jacob6838 Feb 10, 2026
8c256e5
Renaming INTERSECTION_SMTP_SERVER_HOST
jacob6838 Feb 10, 2026
a3123dd
Merge remote-tracking branch 'origin/develop' into intersection-api-e…
jacob6838 Feb 11, 2026
1ee79f1
Adding spring mail ssl trust policy
jacob6838 Feb 11, 2026
4ac4f56
Adding python EmailApi
jacob6838 Feb 11, 2026
b66d519
Merge branch 'intersection-api-email-generation-1' into iapi-email-ge…
jacob6838 Feb 11, 2026
8c755d2
Adding IAPI endpoints for pyapi emails
jacob6838 Feb 11, 2026
80fc16b
Adding IAPI email generation to addons
jacob6838 Feb 11, 2026
8156bed
Removing unused environment variables
jacob6838 Feb 11, 2026
e20670d
Update docker-compose-addons.yml
jacob6838 Feb 11, 2026
c81a1e7
Reverting pyapi iapi email gen
jacob6838 Feb 11, 2026
9bb4f37
Revert "Reverting pyapi iapi email gen"
jacob6838 Feb 11, 2026
2270355
Removing unnecessary email endpoints
jacob6838 Feb 11, 2026
788c84b
Merge branch 'iapi-email-generation-extra-types' into iapi-email-gene…
jacob6838 Feb 11, 2026
9e88ee3
Merge branch 'iapi-email-generation-pyapi' into iapi-email-generation…
jacob6838 Feb 11, 2026
468063e
Revert "Removing unnecessary email endpoints"
jacob6838 Feb 11, 2026
88c3ee5
Writing tests for email generators
jacob6838 Feb 11, 2026
fe41dae
Adding snapshot tests for email generators
jacob6838 Feb 12, 2026
00c99c8
Updating intersectionNotificationSummary snapshot
jacob6838 Feb 12, 2026
8419ab6
Improving emailApi non-success handling
jacob6838 Feb 12, 2026
22fc718
Hardcoding gmail for testing
jacob6838 Feb 13, 2026
7a42278
Adding logging for email recipients
jacob6838 Feb 13, 2026
0c6f314
Adding additional iapi email logging
jacob6838 Feb 17, 2026
963b20e
Adding transport listener for email send debugging
jacob6838 Feb 17, 2026
7e19d46
Merge branch 'develop' into intersection-api-email-generation-1
jacob6838 Feb 17, 2026
da2e4bb
Merge branch 'develop' into intersection-api-email-generation-1
jacob6838 Mar 10, 2026
cb54e2c
Adding sentDate header
jacob6838 Mar 10, 2026
c807fae
Reverting add transport listener
jacob6838 Mar 10, 2026
8073ea1
Reverting email logging changes
jacob6838 Mar 10, 2026
b2ee5c5
Combining GlobalExceptionHandlers
jacob6838 Mar 10, 2026
037c27c
Update EmailService.java
jacob6838 Mar 11, 2026
0cb6d11
Merge branch 'develop' into intersection-api-email-generation-1
jacob6838 Mar 13, 2026
71d735b
Merge branch 'develop' into intersection-api-email-generation-1
jacob6838 Mar 17, 2026
d50e16d
Update launch.json
jacob6838 Mar 18, 2026
db94d0d
Merge branch 'intersection-api-email-generation-1' into iapi-email-ge…
jacob6838 Mar 18, 2026
9595bfe
Merge branch 'iapi-email-generation-extra-types' into iapi-email-gene…
jacob6838 Mar 18, 2026
180de8f
Merge branch 'iapi-email-generation-pyapi' into iapi-email-generation…
jacob6838 Mar 18, 2026
6ebfd85
Merge branch 'develop' into iapi-email-generation-extra-types
jacob6838 Mar 25, 2026
820af16
Merge branch 'develop' into iapi-email-generation-extra-types
jacob6838 Mar 25, 2026
a8930e8
Merge branch 'develop' into iapi-email-generation-extra-types
jacob6838 Apr 3, 2026
f7105e1
Merge branch 'develop' into iapi-email-generation-addons
jacob6838 Apr 3, 2026
c4c87f0
Merge branch 'develop' into iapi-email-generation-pyapi
jacob6838 Apr 3, 2026
0c148f8
Merge branch 'iapi-email-generation-pyapi' into iapi-email-generation…
jacob6838 Apr 3, 2026
ddec8b0
Revert "Merge branch 'iapi-email-generation-pyapi' into iapi-email-ge…
jacob6838 Apr 3, 2026
d353eef
Merge branch 'iapi-email-generation-extra-types' into iapi-email-gene…
jacob6838 Apr 3, 2026
a711189
Moving support-requests endpoint to EmailController
jacob6838 Apr 3, 2026
ddab28b
Reducing duplication in KeycloakApi
jacob6838 Apr 3, 2026
1efec30
Resolving unit tests comments
jacob6838 Apr 3, 2026
26245db
Update services/intersection-api/api/src/main/java/us/dot/its/jpo/ode…
jacob6838 Apr 3, 2026
63f91df
Update services/intersection-api/api/src/test/java/us/dot/its/jpo/ode…
jacob6838 Apr 3, 2026
8820a2d
Update services/intersection-api/api/src/main/java/us/dot/its/jpo/ode…
jacob6838 Apr 3, 2026
1cbe8da
Adding no unsubscribe email template
jacob6838 Apr 6, 2026
ae2bf0a
Update EmailServiceTest.java
jacob6838 Apr 7, 2026
214e780
Update SnapshotTestUtils.java
jacob6838 Apr 7, 2026
8a99b9c
Condensing shared keycloak api code
jacob6838 Apr 7, 2026
a5c4d17
Using EmailResponseException with email send APIs
jacob6838 Apr 7, 2026
43ed418
Removing Instant to/from Millis de/serializers
jacob6838 Apr 7, 2026
65f0f8a
Escaping HTML in email templating
jacob6838 Apr 7, 2026
c56eef2
Tweaking unit tests
jacob6838 Apr 7, 2026
44b2e59
Updating email test snapshot
jacob6838 Apr 7, 2026
51d213f
Merge branch 'iapi-email-generation-extra-types' into iapi-email-gene…
jacob6838 Apr 7, 2026
55dad0a
Update EmailServiceTest.java
jacob6838 Apr 7, 2026
76151aa
Updating unit tests
jacob6838 Apr 7, 2026
73c2072
Merge branch 'iapi-email-generation-extra-types' into iapi-email-gene…
jacob6838 Apr 7, 2026
0d0e5df
Creating python EmailApi
jacob6838 Apr 7, 2026
668e417
Removing contact-support and rsu-error-summary python code
jacob6838 Apr 7, 2026
cea3d2f
Adding email sending env vars to pyapi
jacob6838 Apr 7, 2026
1907ee8
Integrating support and rsu error iapi emails into webapp
jacob6838 Apr 7, 2026
7441893
Merge branch 'develop' into iapi-email-generation-extra-types
jacob6838 Apr 7, 2026
93a254b
Merge branch 'iapi-email-generation-python-email-sending' into iapi-e…
jacob6838 Apr 7, 2026
659a5a8
Reverting unnecessary changes
jacob6838 Apr 7, 2026
63cbb94
Merge branch 'iapi-email-generation-extra-types' into iapi-email-gene…
jacob6838 Apr 8, 2026
32bb3ed
Merge branch 'iapi-email-generation-python-email-sending' into iapi-e…
jacob6838 Apr 8, 2026
c698b97
Adding Schema annotations and removing unused code
jacob6838 Apr 13, 2026
c3eab4d
Improving mocking in email generator tests
jacob6838 Apr 13, 2026
5c51fff
Updating iapi email generator test url
jacob6838 Apr 13, 2026
04192fa
Updating email snapshot formatting
jacob6838 Apr 13, 2026
d14d23a
Update intersection_notification_summary_email_snapshot.html
jacob6838 Apr 13, 2026
8be1ec2
Revert update settings.json
jacob6838 Apr 13, 2026
4021318
Merge branch 'iapi-email-generation-extra-types' into iapi-email-gene…
jacob6838 Apr 13, 2026
befbef1
Reverting removal of emailSender
jacob6838 Apr 13, 2026
a106bd7
Updating unit tests
jacob6838 Apr 13, 2026
01df61a
Update AdminIntersectionTab.test.tsx.snap
jacob6838 Apr 13, 2026
6154468
Merge branch 'iapi-email-generation-python-email-sending' into iapi-e…
jacob6838 Apr 13, 2026
2f8d287
Update IntersectionNotificationSummaryEmailGeneratorTest.java
jacob6838 Apr 13, 2026
14ae834
Adding Schema annotations to Email contents objects
jacob6838 Apr 13, 2026
627d181
Update MessageCountEmailContents.java
jacob6838 Apr 13, 2026
950ed42
Working firmware and counts email sending
jacob6838 Apr 14, 2026
3b6353b
Converting smtp_error_handler to EmailApi
jacob6838 Apr 14, 2026
49459c9
Update test_smtp_error_handler.py
jacob6838 Apr 14, 2026
3f3dc7c
Handling serialization of datetimes in counts emailer
jacob6838 Apr 14, 2026
ecc7f4f
Updating addon email endpoint names
jacob6838 Apr 14, 2026
645d048
Update email_api.py
jacob6838 Apr 14, 2026
bf00491
Update email_api.py
jacob6838 Apr 14, 2026
4f70944
Updating message counts email recipients
jacob6838 Apr 14, 2026
b0fa05e
Updating email templates with no max-width
jacob6838 Apr 14, 2026
840ffc0
Merge branch 'iapi-email-generation-extra-types' into iapi-email-gene…
jacob6838 Apr 14, 2026
c033321
Merge branch 'iapi-email-generation-python-email-sending' into iapi-e…
jacob6838 Apr 14, 2026
fe98fe5
Adding ENABLE_ERROR_EMAILS to python api
jacob6838 Apr 14, 2026
cbbe949
Merge branch 'iapi-email-generation-python-email-sending' of https://…
jacob6838 Apr 14, 2026
82bce9a
Removing KeycloakApi
jacob6838 Apr 15, 2026
68a09ae
Adding keycloak_api direct to keycloak
jacob6838 Apr 15, 2026
6fd7e6d
Update rsu_error_summary_email_snapshot.html
jacob6838 Apr 15, 2026
d8b866d
Merge branch 'iapi-email-generation-extra-types' into iapi-email-gene…
jacob6838 Apr 15, 2026
1285606
Updating unit tests
jacob6838 Apr 15, 2026
ecacf66
Potential fix for pull request finding
jacob6838 Apr 15, 2026
588fa0b
Cleaning up email_api and keycloak_api
jacob6838 Apr 15, 2026
436a387
Merge branch 'iapi-email-generation-python-email-sending' of https://…
jacob6838 Apr 15, 2026
9857b52
Updating RsuErrorSummary email to only use requestors email
jacob6838 Apr 15, 2026
45aae34
Merge branch 'iapi-email-generation-extra-types' into iapi-email-gene…
jacob6838 Apr 15, 2026
010e14d
Removing RsuErrorSummary recipients
jacob6838 Apr 15, 2026
4826f27
Merge branch 'iapi-email-generation-python-email-sending' into iapi-e…
jacob6838 Apr 15, 2026
b7fc6f7
Update UserController.java
jacob6838 Apr 15, 2026
6553868
Update EmailServiceTest.java
jacob6838 Apr 15, 2026
71814b5
Fixing python api KC_SA_CLIENT_ID
jacob6838 Apr 15, 2026
85badce
Removing unused env vars from README
jacob6838 Apr 15, 2026
08914a7
Updating smtp error handler stack trace processing
jacob6838 Apr 15, 2026
901ee1b
Improving error handling in email_api
jacob6838 Apr 15, 2026
9a5d60b
Cleaning up email_api documentation
jacob6838 Apr 15, 2026
5047f73
Cleaning up email_api env vars and imports
jacob6838 Apr 15, 2026
454a159
Update test_smtp_error_handler.py
jacob6838 Apr 15, 2026
eeec5bf
Updating javadoc comments and handling null emails from token
jacob6838 Apr 15, 2026
5fb5b4c
Update EmailSendResponse.java
jacob6838 Apr 15, 2026
4389b82
Merge branch 'iapi-email-generation-extra-types' of https://github.co…
jacob6838 Apr 15, 2026
6d55d43
Removing RsuErrorSummary dialog
jacob6838 Apr 15, 2026
08ddb90
Updatin rsu error summary email text
jacob6838 Apr 15, 2026
c267190
Updating test snapshots
jacob6838 Apr 15, 2026
2884be1
Updating docstring comments throughout emailing code
jacob6838 Apr 15, 2026
03f9b4f
Update DisplayRsuErrors.tsx
jacob6838 Apr 15, 2026
8ed45b2
Merge branch 'iapi-email-generation-python-email-sending' of https://…
jacob6838 Apr 15, 2026
363b926
Update test_smtp_error_handler.py
jacob6838 Apr 15, 2026
3266419
Switching auth token getters to lombok
jacob6838 Apr 16, 2026
07a9dcc
Merge branch 'develop' into iapi-email-generation-extra-types
jacob6838 Apr 16, 2026
228bd2b
Updating EmailGeneratorTests with MockitoExtension
jacob6838 Apr 16, 2026
15f2bdd
Adding conditional unsubscribe url rendering
jacob6838 Apr 16, 2026
f926561
Update SupportRequestEmailGeneratorTest.java
jacob6838 Apr 17, 2026
baedc49
Adding email generator mocked tests
jacob6838 Apr 17, 2026
6f145e4
Tweaking logging in snapshot utils
jacob6838 Apr 17, 2026
e8264da
Tweaking logging in snapshot utils
jacob6838 Apr 17, 2026
c065a51
Parameterize shouldHandleEmailInVariousFormats test
jacob6838 Apr 20, 2026
2aaa5e3
Update CvManagerAuthTokenTest.java
jacob6838 Apr 20, 2026
761c761
Adding private methods to keycloak_api
jacob6838 Apr 21, 2026
24d059d
Cleaning up unused code
jacob6838 Apr 21, 2026
ba7ace4
Documenting keycloak_api test fixtures
jacob6838 Apr 21, 2026
4bf2820
Merge branch 'iapi-email-generation-extra-types' into iapi-email-gene…
jacob6838 Apr 21, 2026
c123bc9
Merge branch 'iapi-email-generation-python-email-sending' into iapi-e…
jacob6838 Apr 21, 2026
4939840
Adding python-keycloak to addons
jacob6838 Apr 22, 2026
947d19f
Adding missing KC_ENDPOINT and KC_REALM to addons
jacob6838 Apr 22, 2026
79e3bcd
Tweaking addon test environment variables
jacob6838 Apr 22, 2026
772d567
Updating addon email formatting
jacob6838 Apr 22, 2026
6967d0d
Reverting test exception in yunex_upgrader
jacob6838 Apr 22, 2026
80ddcf0
Adding deployment title to message counts email subject
jacob6838 Apr 22, 2026
640ccc0
Escaping html in email templating, fixing upgrade runner imports
jacob6838 Apr 22, 2026
e3562e9
Delete email_template_no_unsubscribe.png
jacob6838 Apr 22, 2026
e1e00d0
Updating diff_percent schema definition
jacob6838 Apr 22, 2026
e4704a0
Adding custom message counts email template
jacob6838 Apr 27, 2026
85303dc
Adding firmware upgrade failure email template
jacob6838 Apr 27, 2026
0e48e8c
Merge branch 'develop' into iapi-email-generation-python-email-sending
jacob6838 Apr 27, 2026
ed078d3
Merge branch 'iapi-email-generation-python-email-sending' into iapi-e…
jacob6838 Apr 27, 2026
e2b3b4f
Merge branch 'develop' into iapi-email-generation-addons
jacob6838 Apr 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions docker-compose-addons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ services:
ENABLE_EMAILER: ${ENABLE_EMAILER:-}
DEPLOYMENT_TITLE: ${DEPLOYMENT_TITLE:-}

SMTP_SERVER_IP: ${SMTP_SERVER_IP}
SMTP_USERNAME: ${SMTP_USERNAME}
SMTP_PASSWORD: ${SMTP_PASSWORD}
SMTP_EMAIL: ${SMTP_EMAIL}
IAPI_ENDPOINT: ${IAPI_ENDPOINT:-http://${DOCKER_HOST_IP}:8089}
KC_ENDPOINT: ${KEYCLOAK_ENDPOINT:-http://${DOCKER_HOST_IP:?error}:8084}
KC_REALM: ${KEYCLOAK_REALM:-cvmanager}
KC_SA_CLIENT_ID: ${KEYCLOAK_SA_COUNT_METRIC_CLIENT_ID:-sa_count_metric}
KC_SA_CLIENT_SECRET: ${KEYCLOAK_SA_COUNT_METRIC_CLIENT_SECRET_KEY:-sa-count-metric-secret-key}

PROJECT_ID: ${GCP_PROJECT_ID:-}

Expand Down Expand Up @@ -122,7 +123,7 @@ services:
restart: on-failure:3

ports:
- '8095:8080'
- '8091:8080'
environment:
PG_DB_HOST: ${PG_DB_HOST:-cvmanager_postgres:5432}
PG_DB_NAME: ${PG_DB_NAME:-postgres}
Expand Down Expand Up @@ -160,10 +161,11 @@ services:
GCP_PROJECT: ${GCP_PROJECT_ID:-}
GOOGLE_APPLICATION_CREDENTIALS: /home/gcp_key.json

SMTP_SERVER_IP: ${SMTP_SERVER_IP}
SMTP_EMAIL: ${SMTP_EMAIL}
SMTP_USERNAME: ${SMTP_USERNAME}
SMTP_PASSWORD: ${SMTP_PASSWORD}
IAPI_ENDPOINT: ${IAPI_ENDPOINT:-http://${DOCKER_HOST_IP}:8089}
KC_ENDPOINT: ${KEYCLOAK_ENDPOINT:-http://${DOCKER_HOST_IP:?error}:8084}
KC_REALM: ${KEYCLOAK_REALM:-cvmanager}
KC_SA_CLIENT_ID: ${KEYCLOAK_SA_FIRMWARE_UPGRADE_RUNNER_CLIENT_ID:-sa_firmware_upgrade_runner}
KC_SA_CLIENT_SECRET: ${KEYCLOAK_SA_FIRMWARE_UPGRADE_RUNNER_CLIENT_SECRET_KEY:-sa-firmware-upgrade-runner-secret-key}

UPGRADE_SCHEDULER_ENDPOINT: ${FIRMWARE_MANAGER_UPGRADE_SCHEDULER_ENDPOINT:-http://firmware_manager_upgrade_scheduler:8090}

Expand Down
2 changes: 1 addition & 1 deletion docker-compose-intersection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ services:
UNSUBSCRIBE_SECRET_KEY: ${UNSUBSCRIBE_SECRET_KEY:-b5f9070ca58d4576ea6a2d8d4c1b97caf8abc2554198f8f9acf86d0d31a52a52}
CV_MANAGER_FRONT_END_URI: ${CV_MANAGER_FRONT_END_URI:-http://localhost:${WEBAPP_PORT:-3000}}
INTERSECTION_SMTP_SERVER_HOST: ${INTERSECTION_SMTP_SERVER_HOST:-smtp4dev}
INTERSECTION_SMTP_SERVER_PORT: ${INTERSECTION_SMTP_SERVER_PORT:-1025}
INTERSECTION_SMTP_SERVER_PORT: ${INTERSECTION_SMTP_SERVER_PORT:-25}
INTERSECTION_SMTP_USERNAME: ${INTERSECTION_SMTP_USERNAME:-admin}
INTERSECTION_SMTP_PASSWORD: ${INTERSECTION_SMTP_PASSWORD:-password}
INTERSECTION_SMTP_AUTH: ${INTERSECTION_SMTP_AUTH_ENABLED:-true}
Expand Down
16 changes: 8 additions & 8 deletions services/addons/images/count_metric/count_metric_environment.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from common.common_environment import get_env_var

SMTP_SERVER_IP=get_env_var("SMTP_SERVER_IP", error=True)
SMTP_SERVER_PORT=int(get_env_var("SMTP_SERVER_PORT", "587", warn=False))
SMTP_EMAIL=get_env_var("SMTP_EMAIL", error=True)
DEPLOYMENT_TITLE=get_env_var("DEPLOYMENT_TITLE", "Example Deployment", warn=True)
SMTP_USERNAME=get_env_var("SMTP_USERNAME", error=True)
SMTP_PASSWORD=get_env_var("SMTP_PASSWORD", error=True)
MONGO_DB_URI=get_env_var("MONGO_DB_URI", "mongodb://localhost:27017")
MONGO_DB_NAME=get_env_var("MONGO_DB_NAME", "CV")
DEPLOYMENT_TITLE = get_env_var("DEPLOYMENT_TITLE", "Example Deployment", warn=True)
MONGO_DB_URI = get_env_var("MONGO_DB_URI", "mongodb://localhost:27017")
MONGO_DB_NAME = get_env_var("MONGO_DB_NAME", "CV")
IAPI_ENDPOINT = get_env_var("IAPI_ENDPOINT", error=True)
KC_ENDPOINT = get_env_var("KC_ENDPOINT", error=True)
KC_REALM = get_env_var("KC_REALM", error=True)
KC_SA_CLIENT_ID = get_env_var("KC_SA_CLIENT_ID", "sa_count_metric")
KC_SA_CLIENT_SECRET = get_env_var("KC_SA_CLIENT_SECRET", error=True, secret=True)
70 changes: 45 additions & 25 deletions services/addons/images/count_metric/daily_emailer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import logging
import gen_email
from common.emailSender import EmailSender
from common.email_api import EmailApi
import common.pgquery as pgquery
from common.email_util import get_email_list
from datetime import datetime, timedelta
from pymongo import MongoClient
import count_metric_environment
from common.keycloak_api import KeycloakServiceAccountApi

message_types = ["BSM", "TIM", "Map", "SPaT", "SRM", "SSM"]

Expand Down Expand Up @@ -122,26 +121,34 @@ def prepare_org_rsu_dict():
return rsu_dict


def email_daily_counts(org_name, email_body):
def email_daily_counts(
org_name: str,
deployment_title: str,
start_date: datetime,
end_date: datetime,
message_type_list: list[str],
counts: list[dict],
):
logging.info("Attempting to send the count emails...")
try:
email_addresses = get_email_list("Daily Message Counts", org_name)

for email_address in email_addresses:
emailSender = EmailSender(
count_metric_environment.SMTP_SERVER_IP,
count_metric_environment.SMTP_SERVER_PORT,
)
emailSender.send(
sender=count_metric_environment.SMTP_EMAIL,
recipient=email_address,
subject=f"{org_name} {count_metric_environment.DEPLOYMENT_TITLE} Counts",
message=email_body,
replyEmail="",
username=count_metric_environment.SMTP_USERNAME,
password=count_metric_environment.SMTP_PASSWORD,
pretty=True,
)
kc_api = KeycloakServiceAccountApi(
endpoint=count_metric_environment.KC_ENDPOINT,
realm=count_metric_environment.KC_REALM,
client_id=count_metric_environment.KC_SA_CLIENT_ID,
client_secret=count_metric_environment.KC_SA_CLIENT_SECRET,
)
email_api = EmailApi(
iapi_base_url=count_metric_environment.IAPI_ENDPOINT, kc_api=kc_api
)

email_api.send_message_counts(
org_name,
deployment_title,
start_date,
end_date,
message_type_list,
counts,
)
except Exception as e:
logging.error(e)

Expand All @@ -164,11 +171,24 @@ def run_daily_emailer():
query_mongo_in_counts(rsu_dict, start_dt, end_dt, mongo_db)
query_mongo_out_counts(rsu_dict, start_dt, end_dt, mongo_db)

# Generate the email content with the populated rsu_dict
email_body = gen_email.generate_email_body(
org_name, rsu_dict, start_dt, end_dt, message_types
rsu_counts = [
{
"rsu_ip": rsu_ip,
"counts": data["counts"],
"primary_route": data["primary_route"],
}
for rsu_ip, data in rsu_dict.items()
]

# Send emails through the Intersection API
email_daily_counts(
org_name=org_name,
deployment_title=count_metric_environment.DEPLOYMENT_TITLE,
start_date=start_dt,
end_date=end_dt,
message_type_list=message_types,
counts=rsu_counts,
)
email_daily_counts(org_name, email_body)


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions services/addons/images/count_metric/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pymongo==4.5.0
sqlalchemy==2.0.21
pg8000==1.30.2
python-dateutil==2.8.2
python-keycloak==5.8.1
9 changes: 4 additions & 5 deletions services/addons/images/count_metric/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ PG_DB_NAME =
MONGO_DB_URI = 'mongodb://:27017/'
MONGO_DB_NAME = ''

# SMTP REQUIRED VARIABLES
SMTP_SERVER_IP = ''
SMTP_USERNAME = ''
SMTP_PASSWORD = ''
SMTP_EMAIL = ''
# Error Email Configuration (proxied email sending through the intersection api)
IAPI_ENDPOINT=http://${DOCKER_HOST_IP}:8089
KC_SA_CLIENT_ID=sa_count_metric
KC_SA_CLIENT_SECRET=sa-count-metric-secret-key

# ---------------------------------------------------------------------
# If ENABLE_EMAILER is 'False', set the following environment variables
Expand Down
1 change: 1 addition & 0 deletions services/addons/images/firmware_manager/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ sqlalchemy==2.0.21
waitress==2.1.2
python-dateutil==2.8.2
pytz==2023.3.post1
python-keycloak==5.8.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
import traceback
from paramiko import SSHClient, WarningPolicy
from scp import SCPClient
import upgrader
Expand Down Expand Up @@ -74,7 +75,10 @@ def upgrade(self):
self.cleanup()
self.notify_firmware_manager(success=False)
# send email to support team with the rsu and error
self.send_error_email("Firmware Upgrader", err)
stack_trace = traceback.format_exc()
self.send_error_email(
str(err), stack_trace, "Commsignia Firmware Upgrade Error"
)

def post_upgrade(self):
if self.wait_until_online() == -1:
Expand Down Expand Up @@ -122,7 +126,10 @@ def post_upgrade(self):
f"Failed to execute post upgrade script for rsu {self.rsu_ip}: {err}"
)
# send email to support team with the rsu and error
self.send_error_email("Post-Upgrade Script", err)
stack_trace = traceback.format_exc()
self.send_error_email(
str(err), stack_trace, "Commsignia Post-Upgrade Script Error"
)


# sys.argv[1] - JSON string with the following key-values:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ FW_UPGRADE_MAX_RETRY_LIMIT=3
GCP_PROJECT=""
GOOGLE_APPLICATION_CREDENTIALS=""

# For sending failure emails
SMTP_SERVER_IP=
SMTP_EMAIL=
SMTP_USERNAME=
SMTP_PASSWORD=
# Error Email Configuration (proxied email sending through the intersection api)
IAPI_ENDPOINT=http://${DOCKER_HOST_IP}:8089
KC_SA_CLIENT_ID=sa_firmware_upgrade_runner
KC_SA_CLIENT_SECRET=sa-firmware-upgrade-runner-secret-key

# Must specify this endpoint to wherever the Upgrade Scheduler is hosted
# Must include 'http://' or 'https://' along with specified port if non-standard
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from common.common_environment import get_env_var

BLOB_STORAGE_PROVIDER=get_env_var("BLOB_STORAGE_PROVIDER", "DOCKER", warn=False)
UPGRADE_SCHEDULER_ENDPOINT=get_env_var("UPGRADE_SCHEDULER_ENDPOINT", "127.0.0.1")
BLOB_STORAGE_PROVIDER = get_env_var("BLOB_STORAGE_PROVIDER", "DOCKER", warn=False)
UPGRADE_SCHEDULER_ENDPOINT = get_env_var("UPGRADE_SCHEDULER_ENDPOINT", "127.0.0.1")

SMTP_SERVER_IP=get_env_var("SMTP_SERVER_IP", error=True)
SMTP_SERVER_PORT=int(get_env_var("SMTP_SERVER_PORT", "587", warn=False))
SMTP_EMAIL=get_env_var("SMTP_EMAIL", error=True)
DEPLOYMENT_TITLE=get_env_var("DEPLOYMENT_TITLE", "Example Deployment", warn=True)
SMTP_USERNAME=get_env_var("SMTP_USERNAME", error=True)
SMTP_PASSWORD=get_env_var("SMTP_PASSWORD", error=True)
IAPI_ENDPOINT = get_env_var("IAPI_ENDPOINT", error=True)
KC_ENDPOINT = get_env_var("KC_ENDPOINT", error=True)
KC_REALM = get_env_var("KC_REALM", error=True)
KC_SA_CLIENT_ID = get_env_var("KC_SA_CLIENT_ID", "sa_firmware_upgrade_runner")
KC_SA_CLIENT_SECRET = get_env_var("KC_SA_CLIENT_SECRET", error=True, secret=True)
41 changes: 16 additions & 25 deletions services/addons/images/firmware_manager/upgrade_runner/upgrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import logging
import requests
import shutil
from common.emailSender import EmailSender
from common.email_util import get_email_list_from_rsu
from common.email_api import EmailApi
from common.keycloak_api import KeycloakServiceAccountApi
from addons.images.firmware_manager.upgrade_runner import download_blob
import upgrade_runner_environment

Expand Down Expand Up @@ -116,33 +116,24 @@ def check_online(self):
# 5 seconds pass with no response
return False

def send_error_email(self, type="Firmware Upgrader", err=""):
def send_error_email(self, err: Exception, stack_trace: str, type: str):
try:
email_addresses = get_email_list_from_rsu(
"Firmware Upgrade Failures", self.rsu_ip
kc_api = KeycloakServiceAccountApi(
endpoint=upgrade_runner_environment.KC_ENDPOINT,
realm=upgrade_runner_environment.KC_REALM,
client_id=upgrade_runner_environment.KC_SA_CLIENT_ID,
client_secret=upgrade_runner_environment.KC_SA_CLIENT_SECRET,
)

subject = (
f"{self.rsu_ip} Firmware Upgrader Failure"
if type == "Firmware Upgrader"
else f"{self.rsu_ip} Firmware Upgrader Post Upgrade Script Failure"
email_api = EmailApi(
iapi_base_url=upgrade_runner_environment.IAPI_ENDPOINT, kc_api=kc_api
)

for email_address in email_addresses:
emailSender = EmailSender(
upgrade_runner_environment.SMTP_SERVER_IP,
upgrade_runner_environment.SMTP_SERVER_PORT,
)
emailSender.send(
sender=upgrade_runner_environment.SMTP_EMAIL,
recipient=email_address,
subject=subject,
message=f"{type}: Failed to perform update on RSU {self.rsu_ip} due to the following error: {err}",
replyEmail="",
username=upgrade_runner_environment.SMTP_USERNAME,
password=upgrade_runner_environment.SMTP_PASSWORD,
pretty=True,
)
email_api.send_firmware_upgrade_failure(
rsu_ip=self.rsu_ip,
error_message=f"{type}: Failed to perform update on RSU {self.rsu_ip} due to the following error: {err}",
failure_type=type,
stack_trace=stack_trace,
)
except Exception as e:
logging.error(e)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import tarfile
import time
import traceback
from common import common_environment


Expand Down Expand Up @@ -111,7 +112,8 @@ def upgrade(self):
self.cleanup()
self.notify_firmware_manager(success=False)
# send email to support team with the rsu and error
self.send_error_email("Firmware Upgrader", err)
stack_trace = traceback.format_exc()
self.send_error_email(str(err), stack_trace, "Yunex Firmware Upgrade Error")


# sys.argv[1] - JSON string with the following key-values:
Expand Down
9 changes: 5 additions & 4 deletions services/addons/tests/count_metric/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

os.environ['SMTP_SERVER_IP'] = 'smtp-server-ip'
os.environ['SMTP_EMAIL'] = 'smtp-email'
os.environ['SMTP_USERNAME'] = 'smtp-username'
os.environ['SMTP_PASSWORD'] = 'smtp-password'
os.environ["IAPI_ENDPOINT"] = "localhost:8089"
os.environ["KC_ENDPOINT"] = "http://localhost:8084"
os.environ["KC_REALM"] = "cvmanager"
os.environ["KC_SA_CLIENT_ID"] = "sa_count_metric"
os.environ["KC_SA_CLIENT_SECRET"] = "sa_count_metric_secret"
Loading
Loading