From 02bf4da839ec267c558bf04f6b21c832334ea3bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Je=C5=BEek?= <252651@mail.muni.cz>
Date: Mon, 5 Aug 2024 09:58:30 +0200
Subject: [PATCH] Data for communication have now migration-date specified by
 parameter

---
 .gitlab-ci.yml                        |  2 +-
 CHANGELOG.md                          |  5 +++++
 ci/generate-data-for-communication.py | 11 +++++++----
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 14efb63..22338d7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -67,7 +67,7 @@ ostack-einfra_cz-trigger-communication-generation:
     TEMPLATE_PATH: "howtos/email_tool/g1-g2-migration/templates/mail-final_project-migrated"
     TRIGGER_URL: "https://gitlab.ics.muni.cz/api/v4/projects/2804/trigger/pipeline"
   script:
-  - ci/generate-data-for-communication.py --source-openrc="${SRC_CLOUD_OSTACK_RC_FILE}" --destination-openrc="${DST_CLOUD_OSTACK_RC_FILE}" --project-name="${PROJECT_NAME}" --signature="${GITLAB_USER_NAME}" --expiration="${PROJECT_EXPIRATION}"
+  - ci/generate-data-for-communication.py --source-openrc="${SRC_CLOUD_OSTACK_RC_FILE}" --destination-openrc="${DST_CLOUD_OSTACK_RC_FILE}" --project-name="${PROJECT_NAME}" --signature="${GITLAB_USER_NAME}" --expiration="${PROJECT_EXPIRATION}" --migration-date="${MIGRATION_DATE}"
   - zip -P ${ZIP_DATA_ENCRYTPION_PASSWORD} data.zip data.csv servers.csv
   - BASE64_ZIP_FILE=$(base64 -w 0 data.zip)
   - RESPONSE=$(curl -X POST -F token=${TRIGGER_TOKEN_KB} -F ref=master -F "variables[TEMPLATE]=${TEMPLATE_PATH}" -F "variables[BASE64_DATA]=${BASE64_ZIP_FILE}"  ${TRIGGER_URL})
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 894a2fc..ac2780e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+## [1.5.3] - 2024-08-05
+### Changed
+- Changed generate-data-for-cummunication script - added possibility to specify migration date.
+- This change is reflected in .gitlab-ci.yml 
+
 ## [1.5.2] - 2024-07-25
 ### Fixed
 - temporarily disable compute quotas check
diff --git a/ci/generate-data-for-communication.py b/ci/generate-data-for-communication.py
index 3c4d59e..2c6a629 100755
--- a/ci/generate-data-for-communication.py
+++ b/ci/generate-data-for-communication.py
@@ -15,8 +15,9 @@ Usage example:
    --source-openrc                 ~/c/prod-einfra_cz_migrator.sh.inc
    --destination-openrc            ~/c/g2-prod-brno-einfra_cz_migrator.sh.inc
    --project-name                  meta-cloud-new-openstack
-   --signature                     John Doe
-   --expiration                    1.1.2025 
+   --signature                     'John Doe'
+   --expiration                    1.1.2025
+   --migration-date                2.2.2025
 """
 
 import argparse
@@ -65,7 +66,7 @@ def main(args):
     lib.assert_entity_ownership(destination_project_servers, destination_project)
 
     # prepare project data
-    today = date.today()
+    migration_date = args.migration_date
     vm_count = len(destination_project_servers)
     signature = args.signature
     project_expiration = args.expiration
@@ -73,7 +74,7 @@ def main(args):
     project_data = [
         {
             "project_name": source_project_name,
-            "migration_date": today,
+            "migration_date": migration_date,
             "project_expiration": project_expiration,
             "vm_count": vm_count,
             "signature": signature,
@@ -147,6 +148,8 @@ if __name__ == "__main__":
                     help='Signature of person who will be sending the mail.')
     AP.add_argument('--expiration', default=None, required=True,
                     help='Date of expiration of project.')
+    AP.add_argument('--migration-date', default=date.today().strftime("%-d.%-m.%Y"), required=False,
+                    help='Date of migration of project.')
 
     AP.add_argument('--exception-trace-file', default="project-migrator.dump",
                     required=False,
-- 
GitLab